AOT with tmvc driver

Hi,

I have small onnx file (say add.onnx) that I can pass to driver and get the desired json etc in microtvm.

python3 -m tvm.driver.tvmc compile --target="c -device=micro_dev" add.onnx

However, when I try to getnerate C code for AOT, I am not able to do so.

python3 -m tvm.driver.tvmc compile --target="c --executor=aot" add.onnx

Is the driver support for AOT not complete yet? Or am I missing something on the command line?

Btw,

I see following error:

/tmp/tmph45cnco6/lib0.c: In function ‘int32_t fused_add(void*, void*, int32_t, void*, void*, void*)’:
/tmp/tmph45cnco6/lib0.c:35:7: error: ‘float5’ was not declared in this scope
     ((float5*)((float*)T_add + ((ax0_ax1_fused * 5))))[0] = (((float5*)((float*)placeholder + ((ax0_ax1_fused * 5))))[0] + ((float5*)((float*)placeholder1 + ((ax0_ax1_fused * 5))))[0]);
       ^
/tmp/tmph45cnco6/lib0.c:35:14: error: expected primary-expression before ‘)’ token
     ((float5*)((float*)T_add + ((ax0_ax1_fused * 5))))[0] = (((float5*)((float*)placeholder + ((ax0_ax1_fused * 5))))[0] + ((float5*)((float*)placeholder1 + ((ax0_ax1_fused * 5))))[0]);
              ^
/tmp/tmph45cnco6/lib0.c:35:71: error: expected primary-expression before ‘)’ token
     ((float5*)((float*)T_add + ((ax0_ax1_fused * 5))))[0] = (((float5*)((float*)placeholder + ((ax0_ax1_fused * 5))))[0] + ((float5*)((float*)placeholder1 + ((ax0_ax1_fused * 5))))[0]);
                                                                       ^
/tmp/tmph45cnco6/lib0.c:35:133: error: expected primary-expression before ‘)’ token
     ((float5*)((float*)T_add + ((ax0_ax1_fused * 5))))[0] = (((float5*)((float*)placeholder + ((ax0_ax1_fused * 5))))[0] + ((float5*)((float*)placeholder1 + ((ax0_ax1_fused * 5))))[0]);
                                                                                                                                     ^

Command line: g++ -shared -fPIC -o /tmp/tmp1gzo8bvq/mod.so /tmp/tmph45cnco6/lib0.c -I/../tvm/include -I/../tvm/3rdparty/dlpack/include -I/../tvm/3rdparty/dmlc-core/include

Hi @sirish,

There are few things to note.

The error is derived from the fact the codegen’d artifact (.c) files contain float5 that is an invalid c type. From my experience, this is resulted from running the tir.vectorizer which we generally disable for micro compilation flows.

I think why you dont see this in the first command line is it has an additional argument -device=micro_dev (though Im not sure where in the codebase that utilizes this to disable the vectorizer, @areusch might know better). Would you be able to see if you drop -device=micro_dev from the first CL or maybe adding -device=micro_dev to the second raises/resolves the error ?

For your last question, short anwser is the TVMC support for micro is still pending. The current AoT deployment flow is aimed at using Model Library Format ([RFC] [µTVM] Model Library Format), which is the support we need to add for TVMC.

Maybe I should ask, are you looking to use AoT for micro or non-micro environement (with dlsym and .so s) ?

cc : @leandron @gromero @giuseros

i think for generating C code, you need:

with tvm.transform.PassContext(
    opt_level=3, config={"tir.disable_vectorize": True}
):
    mod = tvm.relay.build(...)

I’m not sure if tvmc does this properly yet?

Thanks @manupa-arm @areusch.

Don’t see there is support for tvmc driver yet. That’s ok for now. I followed an example from tvm/tests/python/relay/aot/test_crt_aot.py and related utils. As per @manupa-arm 's question - In the longer term, I am looking to use AoT for both micro and non-micro environment. However, I am starting without any dlsym. I am very interseted in how DMA is handled in AOT, and what kind of flexibility is allowed for target to do its own DMA optimizations.

Hello, I just saw that TVMC now has a --pass-config flag for the compile command (See: [tvmc] Add a --config option to `tvmc compile` by leandron · Pull Request #8253 · apache/tvm · GitHub). This would allow to set tir.disable_vectorize=True without using the tvm.transform.PassContext and fix the compiler errors mentioned in the first post when using --target=c. However an alternative would be to just use the Model Library Format (without compiling anything) by setting --output-format=mlf.

@PhilippvK just a note–tir.disable_vectorize and --output-format=mlf are independent things. disable_vectorize controls how the C code is generated, and stops TVM from creating invalid C types such as uint3_t.

1 Like

Yes, @PhilippvK I forgot to report it back here, which was one of the places that would benefit from the new --pass-config.

As @areusch mentioned, this is orthogonal to Model Library Format, which was also implemented in the meantime.

Have you tried it out, and it works for you? Happy to help in case there is anything else causing trouble.

Hi @manupa-arm, @areusch,

I was trying to generate build (AOT enabled) as follows:

    def _make_session(temp_dir, zephyr_board, west_cmd, mod):
        config_main_stack_size = None

        project_options = {
            "project_type": "host_driven",
            "west_cmd": west_cmd,
            "verbose": False,
            "zephyr_board": zephyr_board,
        }
        if config_main_stack_size is not None:
            project_options["config_main_stack_size"] = config_main_stack_size

        project = tvm.micro.generate_project(
            temp_dir,
            mod,
            temp_dir + "/project",
            project_options,
        )
        project.build()
        project.flash()
        return tvm.micro.Session(project.transport())

    TARGET = tvm.target.target.micro("stm32f746xx") # Specifying target hardware architecture
    BOARD = "nucleo_f746zg" # Specifying exact board name, used by zephyr later to create binary

    repo_root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], encoding='utf-8').strip()
    project_dir = os.path.join(repo_root, "apps", "microtvm", "zephyr", "template_project")
    temp_file_directory = repo_root

    def build_flash(mod,TARGET,params,input_mcu,node,iteration):
         RUNTIME = Runtime(“crt”, {“system-lib”: True})
         EXECUTOR = Executor("aot")
         with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
             c_mod = relay.build(mod, target=TARGET, executor=EXECUTOR, runtime=RUNTIME, params=params)
         with _make_session(project_dir, BOARD, "west", c_mod) as session:
            graph_mod = tvm.micro.create_local_debug_executor(graph, session.get_system_lib(), session.device, dump_root= temp_file_directory)
            graph_mod.set_input(**c_mod.get_params())    
            graph_mod.run() 
            tvm_output = graph_mod.get_output(0).asnumpy()

But the build throws following error:

warning: TEST_RANDOM_GENERATOR (defined at subsys/random/Kconfig:8) was assigned the value 'y' but
got the value 'n'. Check these unsatisfied dependencies: (!ENTROPY_HAS_DRIVER) (=n). See
http://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_TEST_RANDOM_GENERATOR.html and/or look
up TEST_RANDOM_GENERATOR in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.

-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/vagrant/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Deprecation Warning at /home/vagrant/zephyr/modules/lib/civetweb/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/build
INFO:__main__:run (in cwd: /home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/build): make -j2
[  1%] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
[  2%] Built target parse_syscalls_target
[  2%] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h
[  3%] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
[  3%] Built target syscall_list_h_target
[  3%] Built target kobj_types_h_target
[  4%] Generating include/generated/driver-validation.h
[  4%] Built target driver_validation_h_target
[  5%] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
[  5%] Building CXX object CMakeFiles/microtvm_rpc_server.dir/crt/src/runtime/crt/microtvm_rpc_server/rpc_server.cc.obj
[  6%] Linking CXX static library libmicrotvm_rpc_server.a
[  6%] Built target microtvm_rpc_server
[  7%] Building C object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/crcccitt.c.obj
[  7%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/frame_buffer.cc.obj
[  8%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/framing.cc.obj
[  9%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/session.cc.obj
[  9%] Building CXX object CMakeFiles/microtvm_rpc_common.dir/crt/src/runtime/crt/microtvm_rpc_common/write_stream.cc.obj
[ 10%] Linking CXX static library libmicrotvm_rpc_common.a
[ 10%] Built target microtvm_rpc_common
[ 11%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_backend_api.c.obj
[ 11%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/crt_runtime_api.c.obj
[ 12%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/func_registry.c.obj
[ 12%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/ndarray.c.obj
[ 13%] Building C object CMakeFiles/common.dir/crt/src/runtime/crt/common/packed_func.c.obj
[ 14%] Linking C static library libcommon.a
[ 14%] Built target offsets
[ 14%] Building C object CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib0.c.obj
[ 14%] Built target common
[ 15%] Building C object CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib1.c.obj
CMakeFiles/tvm_model.dir/build.make:75: recipe for target 'CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib0.c.obj' failed
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib0.c:87:17: error: conflicting types for 'tvmgen_default_run_model'
   87 | TVM_DLL int32_t tvmgen_default_run_model(void* args, void* type_code, int num_args, void* out_value, void* out_type_code, void* resource_handle);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib0.c:57:17: note: previous declaration of 'tvmgen_default_run_model' was here
   57 | TVM_DLL int32_t tvmgen_default_run_model(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/tvm_model.dir/model/codegen/host/src/default_lib0.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 15%] Generating include/generated/offsets.h
[ 15%] Built target offsets_h
[ 15%] Built target zephyr_generated_headers
[ 15%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
[ 16%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
[ 17%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc16_sw.c.obj
[ 17%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc8_sw.c.obj
[ 18%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc7_sw.c.obj
[ 18%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/dec.c.obj
[ 19%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
[ 20%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/hex.c.obj
[ 20%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
[ 21%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
[ 22%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c: In function 'tvmgen_default_run_model':
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:1999:42: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1999 |   (((DLTensor*)tvm_value_8)[0].data) = (*(void* *)(&(_1)));
      |                                          ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2053:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2053 |   (((DLTensor*)tvm_value_17)[0].data) = __tvm_param__p0;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2056:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2056 |   (((DLTensor*)tvm_value_19)[0].data) = (*(void* *)(&(_2)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2093:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2093 |   (((DLTensor*)tvm_value_21)[0].data) = __tvm_param__p1;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2094:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2094 |   (((DLTensor*)tvm_value_22)[0].data) = __tvm_param__p2;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2097:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2097 |   (((DLTensor*)tvm_value_24)[0].data) = (*(void* *)(&(_3)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2129:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2129 |   (((DLTensor*)tvm_value_30)[0].data) = (*(void* *)(&(_4)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2163:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2163 |   (((DLTensor*)tvm_value_35)[0].data) = __tvm_param__p3;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2166:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2166 |   (((DLTensor*)tvm_value_37)[0].data) = (*(void* *)(&(_5)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2229:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2229 |   (((DLTensor*)tvm_value_52)[0].data) = (*(void* *)(&(_6)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2274:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2274 |   (((DLTensor*)tvm_value_54)[0].data) = __tvm_param__p4;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2275:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2275 |   (((DLTensor*)tvm_value_55)[0].data) = __tvm_param__p5;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2278:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2278 |   (((DLTensor*)tvm_value_57)[0].data) = (*(void* *)(&(_7)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2310:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2310 |   (((DLTensor*)tvm_value_63)[0].data) = (*(void* *)(&(_8)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2347:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2347 |   (((DLTensor*)tvm_value_70)[0].data) = (*(void* *)(&(_9)));
      |                                           ^~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2410:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2410 |   (((DLTensor*)tvm_value_85)[0].data) = (*(void* *)(&(_10)));
      |                                           ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2455:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2455 |   (((DLTensor*)tvm_value_87)[0].data) = __tvm_param__p6;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2456:39: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2456 |   (((DLTensor*)tvm_value_88)[0].data) = __tvm_param__p7;
      |                                       ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2459:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2459 |   (((DLTensor*)tvm_value_90)[0].data) = (*(void* *)(&(_11)));
      |                                           ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2491:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2491 |   (((DLTensor*)tvm_value_96)[0].data) = (*(void* *)(&(_12)));
      |                                           ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2528:44: warning: dereferencing type-punned pointer will break striCMakeFiles/Makefile2:2239: recipe for target 'CMakeFiles/tvm_model.dir/all' failed
ct-aliasing rules [-Wstrict-aliasing]
 2528 |   (((DLTensor*)tvm_value_103)[0].data) = (*(void* *)(&(_13)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2591:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2591 |   (((DLTensor*)tvm_value_118)[0].data) = (*(void* *)(&(_14)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2636:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2636 |   (((DLTensor*)tvm_value_120)[0].data) = __tvm_param__p8;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2637:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2637 |   (((DLTensor*)tvm_value_121)[0].data) = __tvm_param__p9;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2640:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2640 |   (((DLTensor*)tvm_value_123)[0].data) = (*(void* *)(&(_15)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2672:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2672 |   (((DLTensor*)tvm_value_129)[0].data) = (*(void* *)(&(_16)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2709:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2709 |   (((DLTensor*)tvm_value_136)[0].data) = (*(void* *)(&(_17)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2772:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2772 |   (((DLTensor*)tvm_value_151)[0].data) = (*(void* *)(&(_18)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2817:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2817 |   (((DLTensor*)tvm_value_153)[0].data) = __tvm_param__p10;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2818:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2818 |   (((DLTensor*)tvm_value_154)[0].data) = __tvm_param__p11;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2821:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2821 |   (((DLTensor*)tvm_value_156)[0].data) = (*(void* *)(&(_19)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2853:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2853 |   (((DLTensor*)tvm_value_162)[0].data) = (*(void* *)(&(_20)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2890:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2890 |   (((DLTensor*)tvm_value_169)[0].data) = (*(void* *)(&(_21)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2953:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 2953 |   (((DLTensor*)tvm_value_184)[0].data) = (*(void* *)(&(_22)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2998:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2998 |   (((DLTensor*)tvm_value_186)[0].data) = __tvm_param__p12;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:2999:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2999 |   (((DLTensor*)tvm_value_187)[0].data) = __tvm_param__p13;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3002:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3002 |   (((DLTensor*)tvm_value_189)[0].data) = (*(void* *)(&(_23)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3034:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3034 |   (((DLTensor*)tvm_value_195)[0].data) = (*(void* *)(&(_24)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3071:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3071 |   (((DLTensor*)tvm_value_202)[0].data) = (*(void* *)(&(_25)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3134:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3134 |   (((DLTensor*)tvm_value_217)[0].data) = (*(void* *)(&(_26)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3179:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3179 |   (((DLTensor*)tvm_value_219)[0].data) = __tvm_param__p14;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3180:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3180 |   (((DLTensor*)tvm_value_220)[0].data) = __tvm_param__p15;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3183:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3183 |   (((DLTensor*)tvm_value_222)[0].data) = (*(void* *)(&(_27)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3215:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3215 |   (((DLTensor*)tvm_value_228)[0].data) = (*(void* *)(&(_28)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3252:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3252 |   (((DLTensor*)tvm_value_235)[0].data) = (*(void* *)(&(_29)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3315:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3315 |   (((DLTensor*)tvm_value_250)[0].data) = (*(void* *)(&(_30)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3360:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3360 |   (((DLTensor*)tvm_value_252)[0].data) = __tvm_param__p16;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3361:40: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3361 |   (((DLTensor*)tvm_value_253)[0].data) = __tvm_param__p17;
      |                                        ^
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3364:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3364 |   (((DLTensor*)tvm_value_255)[0].data) = (*(void* *)(&(_31)));
      |                                            ^~~~~~~~~~~~~~~~~
/home/vagrant/tvm/apps/microtvm/zephyr/template_project/project/model/codegen/host/src/default_lib1.c:3387:44: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3387 |   (((DLTensor*)tvm_value_258)[0].data) = (*(void* *)(&(_32)));
      |                                            ^~~~~~~~~~~~~~~~~
make[1]: *** [CMakeFiles/tvm_model.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 22%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
[ 23%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
[ 24%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.obj
[ 24%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
[ 25%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/work_q.c.obj
[ 26%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
[ 26%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
[ 27%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_complete.c.obj
[ 28%] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/ring_buffer.c.obj
[ 28%] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
[ 29%] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/st_stm32/stm32f7/soc.c.obj
[ 30%] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/st_stm32/common/stm32cube_hal.c.obj
[ 30%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_init_array.c.obj
[ 31%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_ctors.c.obj
[ 31%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_dtors.c.obj
[ 32%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_virtual.c.obj
[ 33%] Building CXX object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_vtable.cpp.obj
[ 33%] Building CXX object zephyr/CMakeFiles/zephyr.dir/subsys/cpp/cpp_new.cpp.obj
[ 34%] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/power/reboot.c.obj
[ 35%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/interrupt_controller/intc_exti_stm32.c.obj
[ 35%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/clock_control/clock_stm32_ll_common.c.obj
[ 36%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/clock_control/clock_stm32f2_f4_f7.c.obj
[ 37%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/pinmux/stm32/pinmux_stm32.c.obj
[ 37%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/sys_clock_init.c.obj
[ 38%] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/cortex_m_systick.c.obj
[ 39%] Linking CXX static library libzephyr.a
[     39%] Built target zephyr
    > make: *** [all] Error 2
    > Makefile:90: recipe for target 'all' failed

Do you know what might be the issue?

There is no build and flashing error when AOT compilation is not enabled:

c_mod = relay.build(mod, target=TARGET, runtime=RUNTIME, params=params)

we’re discussing this on Error in build using AOT