-
Notifications
You must be signed in to change notification settings - Fork 696
[aoti-et] Add cuda delegate runtime code #14827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
13d005f
[aoti-et] Add cuda delegate runtime code
larryliu0820 6e58d47
Add CI
larryliu0820 2b10d8a
Cleanup
larryliu0820 480a76a
Fix CI jobs
larryliu0820 d58e941
Add cxx standard
larryliu0820 12460c2
Fix broken CI
larryliu0820 253f2ee
Fix mimi
larryliu0820 bb32d9b
Remove CoreML
larryliu0820 a9bb409
Fix CI
larryliu0820 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ using executorch::runtime::etensor::Tensor; | |
| extern "C" { | ||
|
|
||
| // Type definitions | ||
| using AOTITensorHandle = Tensor*; | ||
| using AOTIRuntimeError = Error; | ||
|
|
||
| // Forward declarations for AOT Inductor model container | ||
|
|
@@ -74,6 +75,7 @@ extern AOTInductorModelContainerRunFunc AOTInductorModelContainerRun; | |
| // AOTI Delegate Handle structure | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit if this backend can't be instantiated directly then perhaps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you say more? |
||
| struct AOTIDelegateHandle { | ||
| void* so_handle; | ||
| std::string so_path; | ||
| AOTInductorModelContainerHandle container_handle; | ||
| }; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| # | ||
| # Build AOTI CUDA backend for runtime. | ||
| # | ||
| # ### Editing this file ### | ||
| # | ||
| # This file should be formatted with | ||
| # ~~~ | ||
| # cmake-format -i CMakeLists.txt | ||
| # ~~~ | ||
| # It should also be cmake-lint clean. | ||
| # | ||
|
|
||
larryliu0820 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
|
||
larryliu0820 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Source root directory for executorch. | ||
| if(NOT EXECUTORCH_ROOT) | ||
| set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
| endif() | ||
|
|
||
| find_package(CUDAToolkit REQUIRED) | ||
|
|
||
| # Use ExecutorTorch's standard way to find PyTorch libraries for AOTI | ||
| include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) | ||
| find_package_torch() | ||
|
|
||
| # CUDA-specific AOTI functionality | ||
| set(_aoti_cuda_sources runtime/cuda_backend.cpp runtime/shims/memory.cpp | ||
| runtime/shims/tensor_attribute.cpp | ||
| ) | ||
| add_library(aoti_cuda STATIC ${_aoti_cuda_sources}) | ||
| target_include_directories( | ||
| aoti_cuda | ||
| PUBLIC ${CUDAToolkit_INCLUDE_DIRS} | ||
| $<BUILD_INTERFACE:${EXECUTORCH_ROOT}> | ||
| $<INSTALL_INTERFACE:include> | ||
| # PyTorch AOTI headers from ExecutorTorch's torch detection | ||
| ${TORCH_INCLUDE_DIRS} | ||
| ) | ||
| target_compile_options(aoti_cuda PUBLIC -fexceptions -frtti -fPIC) | ||
| # Ensure symbols are exported properly | ||
| target_link_options(aoti_cuda PUBLIC -Wl,--export-dynamic) | ||
|
|
||
| # Link against CUDA::cudart, common AOTI library, and PyTorch CUDA libraries | ||
| target_link_libraries( | ||
| aoti_cuda | ||
| PUBLIC aoti_common CUDA::cudart ${CMAKE_DL_LIBS} | ||
| # Link PyTorch libraries for AOTI CUDA functions | ||
| ${TORCH_LIBRARIES} | ||
| ) | ||
| # If you need other CUDA libraries, link them similarly: | ||
| # target_link_libraries(aoti_cuda PUBLIC CUDA::cublas CUDA::cufft ...) | ||
| executorch_target_link_options_shared_lib(aoti_cuda) | ||
|
|
||
| install( | ||
| TARGETS aoti_cuda | ||
| EXPORT ExecuTorchTargets | ||
| DESTINATION lib | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can directly using Tensor*; in the other places we've removed the alias.