forked from neo-ai/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AOT] Introducing AOT in TVM (apache#7785)
* [AOT] Introducing AOT in TVM This change adds the code generation and minimal runtime API to use the Ahead Of Time (AOT) compilation flow. The main logic is contained in: - src/relay/backend/aot_codegen.cc Which produces a TIR PrimFunc traversing the Relay graph The runtime interface (authored by @Mousius) leaves a gap for future iterations using platform-specific features from RTOS. Currently AOT runs successfully on x86 in a host OS, running these tests on micro is coming soon. This PR is based on the RFC described here: https://discuss.tvm.apache.org/t/implementing-aot-in-tvm/9206 Co-authored-by: Christopher Sidebottom <Christopher.Sidebottom@arm.com> Change-Id: I9f731c953231f129e1472298915dddc01788efd7 * Rebasing 2 Change-Id: Ia0a533a49960f1cb4bf3c3833511e539cf7c459f * Applying comments/refactoring Change-Id: Iea1832355f8b1d4c921d02c6b4ceec7db3a681c1 * Fixing comments + refactoring - 2 Change-Id: I7200cc17b297e42bf67dcdef6f643e86991ca0a8 * fix linting Change-Id: Iba6544ac7101595696b352b8702345cf916625f6 * fix linting - 2 Change-Id: I7f80d16005f2c621d37a9aae2cbbd61df0277cbe * fix linting - 3 Change-Id: I7a1ba40afeea46d5f122563a20cd4b2f08751a1e * fix tests Change-Id: I1297ccc54dd6d93647f421e0beb226f410bf73f5 * Addressing comments - 3 Change-Id: Id25d1382c30d6d0a0013b5e8986fb8cd886666dc * Addressing comments - 4 Change-Id: Ibe29676abe3b75161b5a0903e007118a8318d862 * fix tests - 2 Change-Id: I2117f9d4392bfd87102ecbef0993c8b320f479a0 * fix tests - 3 Change-Id: Ic0373543b0f9a54dbd4dc32d428272f7293200ba * fix tests - 4 Change-Id: I8a6f229c9a3a9e169779c8d49cbfa3f473348b1f * Addressing comments - 5 Change-Id: Ib9ccd07c87392034a21b2eb70955d0b091b780f1 * fix tests - 5 Change-Id: I4b13c3b548ced414991e83072e9e6fc99b64f939 * fix tests - 6 Change-Id: Id5af1f778ae25bc60849cc054a605181c1b7a765 * addressing comments - 6 Change-Id: Id94a2bbcaae891f9498d41be538f13a952f55b81 * fix linting - 4 Change-Id: I371a0aa5b81824b5a3a1278fac22ace57832027a * add missing file Change-Id: If359bef96dd0773ead4f75f0d9f5234276347e2d * fix build Change-Id: I73fc1feb6f7b5d454a528e3289228484dc2b07d5 * addressing comments - 7 Change-Id: I7f908f3908ffc77e408391f62edcc06f2600c6c2 * addressing comments - 8 Change-Id: I90bced4e18259a6d42e6a406d93958e204f3859e * rebasing Change-Id: Id28751b069bd046f00faee301b2b446b2ea4fab8 * Addressing comments - 9 Change-Id: I06c9f280de0a9bf0ca5545bbbbfcc70cb66831b3 * fix tests - 7 Change-Id: I739f29779862f05def36e5f3e0722019596d17f8 * Addressing comments - 9 Change-Id: Ie736f40a5225f4e56e79006753d7732127da5408 * Applying comments + fixing tests Change-Id: I83e16068b93aaccc7a86b79d42f13328bc76b53d * Applying comments - 10 Change-Id: I443d72f53913849f3c28fd6e416162d1ca99e647 * Addressing comments - 11 Change-Id: I7fefbd0076949b9c38d0abbf2759ebf1502de330 * Addressing comments - 11 Change-Id: Iad028144d7b394b2dd2fce41a35ca689d1680200 * fix tests - 7 Change-Id: I14286e665dcdba1e9bc10bb5a27dd6ced50372b0 * fixing tests -8 Change-Id: I7b4c966da9680870ceda1704c749ee3bdc751926 * fixing tests - 9 Change-Id: Icf62128a604998ed1b7d5af4cbeadf7d39196d0b Co-authored-by: Christopher Sidebottom <Christopher.Sidebottom@arm.com>
- Loading branch information
1 parent
f9c56b7
commit b3d8e88
Showing
64 changed files
with
2,491 additions
and
204 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,60 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// LINT_C_FILE | ||
#ifndef TVM_RUNTIME_CRT_STACK_ALLOCATOR_H_ | ||
#define TVM_RUNTIME_CRT_STACK_ALLOCATOR_H_ | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include "crt_config.h" | ||
#include "error_codes.h" | ||
|
||
#define STACK_ALLOCATOR_TAG 0xabcd1234 | ||
#define STACK_ALLOCATOR_TAG_SIZE_BYTES 4 | ||
|
||
/*! Memory alignment for allocator */ | ||
|
||
#ifndef TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES | ||
#define TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES 16 | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct { | ||
uint8_t* next_alloc; // Pointer to the next block of TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES | ||
uint8_t* workspace; // Pointer to start of the workspace | ||
size_t workspace_size; // Total number of bytes in the workspace | ||
} tvm_workspace_t; | ||
|
||
tvm_crt_error_t StackMemoryManager_Init(tvm_workspace_t* tvm_runtime_workspace, | ||
uint8_t* g_aot_memory, size_t workspace_size); | ||
|
||
tvm_crt_error_t StackMemoryManager_Allocate(tvm_workspace_t* tvm_runtime_workspace, int32_t nbytes, | ||
void**); | ||
|
||
tvm_crt_error_t StackMemoryManager_Free(tvm_workspace_t* tvm_runtime_workspace, void* ptr); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // TVM_RUNTIME_CRT_STACK_ALLOCATOR_H_ |
This file contains 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,39 @@ | ||
/* | ||
* 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 executor_info.h | ||
* \brief Executor information | ||
*/ | ||
#ifndef TVM_RUNTIME_EXECUTOR_INFO_H_ | ||
#define TVM_RUNTIME_EXECUTOR_INFO_H_ | ||
|
||
namespace tvm { | ||
namespace runtime { | ||
|
||
/*! \brief Value used to indicate the graph executor. */ | ||
static constexpr const char* kTvmExecutorGraph = "graph"; | ||
|
||
/*! \brief Value used to indicate the aot executor. */ | ||
static constexpr const char* kTvmExecutorAot = "aot"; | ||
|
||
} // namespace runtime | ||
} // namespace tvm | ||
|
||
#endif // TVM_RUNTIME_EXECUTOR_INFO_H_ |
This file contains 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 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 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 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.