-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[microTVM] Add support for host-driven AoT Executor #11044
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 17 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
1f076ad
Generate AOT Metadata when targeting C runtime and packed API.
areusch 92aad23
Also copy metadata.h and metadata_base.h to standalone_crt.
areusch 8d5b266
add support for get_input_index as well as setting up get_input_info …
alanmacd 5425e46
add support for tvm.aot_executor.create in C runtime
alanmacd 6ddb5c2
changes in-progress to unit tests
alanmacd a7e05a5
Include get_c_metadata in emitted function list
areusch fd8fc0d
make CRT error codes generic for graph or AoT executor, fix AoT lib l…
alanmacd 3bad0f9
add AoT executor creation and initializaion, as well as support for g…
alanmacd db82d35
add allocation of inputs, outputs, and pools; add get_input(), but sh…
alanmacd 9786e6b
add support to test_aot_executor for get_input()
alanmacd 75a2e28
fix numpy array shape so that get_input() works properly
alanmacd 90f3152
implement run(), get_output(), get_num_inputs(), and get_num_outputs(…
alanmacd c8e9964
fix up some issues from rebase with main
alanmacd 6f389bb
clean up logging and test_graph_executor()
alanmacd ae73fa6
Merge branch 'main' into host-driven-aot-executor-merge-main
alanmacd 2c16c63
lint clean-up
alanmacd 2f54090
more lint clean-up
alanmacd 94294d3
fix i386 build errors
alanmacd 4e2978f
Merge branch 'main' into host-driven-aot-executor
alanmacd f11400e
first set of changes addressing PR feedback
alanmacd 0723196
more PR feedback: device pass-by-value, docstring entries, return var…
alanmacd a7c07e4
add mangling of get_c_metadata() name to avoid function name collisions
alanmacd 797f9a0
only mangle get_c_metadata() when using C runtime
alanmacd 57ad55c
add static specifier to all kTvmgenMetadata variables to avoid namesp…
alanmacd 31014d0
Merge branch 'main' into host-driven-aot-executor
alanmacd ae79dc6
use TVM_IS_CPP_RUNTIME preprocessor define to deteremine whether or n…
alanmacd c40e6ad
add TVM_IS_CPP_RUNTIME define for cpptest
alanmacd 2290e55
add TVM_IS_CPP_RUNTIME to apps/bundle_deploy
alanmacd fcdbb6d
add TVM_IS_CPP_RUNTIME web/Makefile
alanmacd 1d9545b
update number of expected generated C files for AoT source files
alanmacd 9b152f1
break out metadata data structures into separate metadata_types.h hea…
alanmacd 8185074
remove TVM_IS_CPP_RUNTIME from web makefile
alanmacd 8ff68f3
fix metadata.h include-order lint issue
alanmacd b68bd3a
correct error mask bits
alanmacd 370c272
address PR feedback
alanmacd ab30758
Merge branch 'main' into host-driven-aot-executor
alanmacd d3dae0f
Merge branch 'main' into host-driven-aot-executor
alanmacd 778ec49
Merge branch 'main' into host-driven-aot-executor
alanmacd 49b4f15
trigger build
alanmacd f22f274
trigger build
alanmacd bdc02d1
trigger build
alanmacd 7b744a4
trigger build
alanmacd e7f5080
add alternate name for test_graph_executor() too see if it runs in CI
alanmacd d566feb
fix lint
alanmacd 98eed70
revert alternate test code
alanmacd 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /*! | ||
| * \file aot_executor.h | ||
| * \brief AoT Executor | ||
| */ | ||
| #ifndef TVM_RUNTIME_CRT_AOT_EXECUTOR_H_ | ||
| #define TVM_RUNTIME_CRT_AOT_EXECUTOR_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #include <dlpack/dlpack.h> | ||
| #include <tvm/runtime/crt/internal/common/ndarray.h> | ||
| #include <tvm/runtime/metadata.h> | ||
|
|
||
| typedef struct TVMMetadata TVMMetadata; | ||
|
|
||
| typedef struct TVMAotExecutor { | ||
| /*! \brief The top-level metadata structure */ | ||
alanmacd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| TVMMetadata* metadata; | ||
alanmacd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /*! \brief The code module that contains both host and device code */ | ||
alanmacd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| TVMModuleHandle module_handle; | ||
| /*! \brief The device type */ | ||
| DLDevice device; | ||
| /*! \brief List of allocated arguments, input(s), output(s), and pool(s)*/ | ||
| TVMNDArray* args; | ||
| int64_t num_args; | ||
| } TVMAotExecutor; | ||
|
|
||
| /*! | ||
| * \brief Allocate a new AotExecutor with TVMPlatformMemoryAllocate and initialize it. | ||
| * | ||
| * \param module_handle TVM Module that exposes the functions to call. | ||
| * \param devices runtime execution device. | ||
alanmacd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * \param executor Pointer which receives a pointer to the newly-created instance. | ||
| * \return 0 if successful. | ||
| */ | ||
| int TVMAotExecutor_Create(TVMModuleHandle module_handle, const DLDevice* devices, | ||
| TVMAotExecutor** executor); | ||
|
|
||
| int TVMAotExecutor_Release(TVMAotExecutor* executor, const DLDevice device); | ||
alanmacd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| int TVMAotExecutor_GetNumInputs(TVMAotExecutor* executor); | ||
|
|
||
| int TVMAotExecutor_GetNumOutputs(TVMAotExecutor* executor); | ||
|
|
||
| int TVMAotExecutor_GetInputIndex(TVMAotExecutor* executor, const char* name); | ||
|
|
||
| int TVMAotExecutor_Run(TVMAotExecutor* executor); | ||
|
|
||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif | ||
|
|
||
| #endif // TVM_RUNTIME_CRT_AOT_EXECUTOR_H_ | ||
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,42 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /*! | ||
| * \file graph_executor.h | ||
| * \brief Tiny AoT executor | ||
| */ | ||
| #ifndef TVM_RUNTIME_CRT_AOT_EXECUTOR_MODULE_H_ | ||
| #define TVM_RUNTIME_CRT_AOT_EXECUTOR_MODULE_H_ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #include <tvm/runtime/crt/error_codes.h> | ||
|
|
||
| /*! | ||
| * \brief Register the "tvm.aot_executor.create" constructor PackedFunc. | ||
| */ | ||
| tvm_crt_error_t TVMAotExecutorModule_Register(); | ||
|
|
||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif | ||
|
|
||
| #endif // TVM_RUNTIME_CRT_AOT_EXECUTOR_MODULE_H_ |
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
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.
Uh oh!
There was an error while loading. Please reload this page.