|
15 | 15 | # specific language governing permissions and limitations |
16 | 16 | # under the License. |
17 | 17 | """ |
18 | | -.. _tutorial-micro-AoT: |
| 18 | +.. _tutorial-micro-aot: |
19 | 19 |
|
20 | | -microTVM Host-Driven AoT |
21 | | -=========================== |
| 20 | +3. microTVM Ahead-of-Time (AOT) Compilation |
| 21 | +=========================================== |
22 | 22 | **Authors**: |
23 | 23 | `Mehrdad Hessar <https://github.com/mehrdadh>`_, |
24 | 24 | `Alan MacDonald <https://github.com/alanmacd>`_ |
|
59 | 59 |
|
60 | 60 | import tvm |
61 | 61 | from tvm import relay |
| 62 | +import tvm.micro.testing |
62 | 63 | from tvm.relay.backend import Executor, Runtime |
63 | 64 | from tvm.contrib.download import download_testdata |
64 | 65 |
|
|
102 | 103 | # using AOT host driven executor. We use the host micro target which is for running a model |
103 | 104 | # on x86 CPU using CRT runtime or running a model with Zephyr platform on qemu_x86 simulator |
104 | 105 | # board. In the case of a physical microcontroller, we get the target model for the physical |
105 | | -# board (E.g. nucleo_l4r5zi) and pass it to `tvm.target.target.micro` to create a full |
106 | | -# micro target. |
| 106 | +# board (E.g. nucleo_l4r5zi) and change `BOARD` to supported Zephyr board. |
107 | 107 | # |
108 | 108 |
|
109 | 109 | # Use the C runtime (crt) and enable static linking by setting system-lib to True |
110 | 110 | RUNTIME = Runtime("crt", {"system-lib": True}) |
111 | 111 |
|
112 | 112 | # Simulate a microcontroller on the host machine. Uses the main() from `src/runtime/crt/host/main.cc`. |
113 | 113 | # To use physical hardware, replace "host" with something matching your hardware. |
114 | | -TARGET = tvm.target.target.micro("host") |
| 114 | +TARGET = tvm.micro.testing.get_target("crt") |
115 | 115 |
|
116 | 116 | # Use the AOT executor rather than graph or vm executors. Don't use unpacked API or C calling style. |
117 | 117 | EXECUTOR = Executor("aot") |
118 | 118 |
|
119 | 119 | if use_physical_hw: |
120 | | - boards_file = pathlib.Path(tvm.micro.get_microtvm_template_projects("zephyr")) / "boards.json" |
121 | | - with open(boards_file) as f: |
122 | | - boards = json.load(f) |
123 | 120 | BOARD = os.getenv("TVM_MICRO_BOARD", default="nucleo_l4r5zi") |
124 | 121 | SERIAL = os.getenv("TVM_MICRO_SERIAL", default=None) |
125 | | - TARGET = tvm.target.target.micro(boards[BOARD]["model"]) |
| 122 | + TARGET = tvm.micro.testing.get_target("zephyr", BOARD) |
126 | 123 |
|
127 | 124 | ###################################################################### |
128 | 125 | # Compile the model |
|
0 commit comments