apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.6k stars 3.44k forks source link

[Bug] Error compiling a reference model in STM32CubeIDE #14871

Open georgesterpu opened 1 year ago

georgesterpu commented 1 year ago

Hi. I am compiling a reference model downloaded from the mlcommons tiny benchmark following the microTVM tutorial here: https://tvm.apache.org/docs/how_to/work_with_microtvm/micro_custom_ide.html

Both the .tflite model and the Model Library File are attached below files.zip

When I'm building the project in STM32CubeIDE I am seeing the following errors:

Description Resource    Path  Location    Type
conflicting types for 'tvmgen_default___tvm_main__'   default_lib0.c    /tvmapp/kws_model/codegen/host/src  line 98     C/C++ Problem
conflicting types for 'tvmgen_default_run'      default_lib0.c    /tvmapp/kws_model/codegen/host/src  line 99     C/C++ Problem
conflicting types for 'tvmgen_default_run'      tvmgen_default.h  /tvmapp/kws_model/codegen/host/include    line 36     C/C++ Problem
make: *** [kws_model/codegen/host/src/subdir.mk:22: kws_model/codegen/host/src/default_lib0.o] Error 1      tvmapp                  C/C++ Problem
make: *** Waiting for unfinished jobs.... tvmapp                  C/C++ Problem

Expected behavior

Compile the example app successfully

Actual behavior

Compiler error above

Environment

Ubuntu 20.04 apache-tvm from pypi, version 0.13.dev133, also tried version 0.11.1 with the same outcome STM32CubeIDE 1.12.1

The Python script for TVM uses the following flags: runtime: crt, system-lib: True target: stm32h7xx executor: aot, unpacked-api: True, interface-api: c, workspace-byte-alignment: 8 opt_level=3

Steps to reproduce

Set up a new app in CubeIDE as in the tutorial, and build the project

Triage

Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).

georgesterpu commented 1 year ago

Digging deeper into this issue, I could see the following. In default_lib0.c on lines 5 and 65 respectively:

TVM_DLL int32_t tvmgen_default_run(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle);
TVM_DLL int32_t tvmgen_default___tvm_main__(TVMValue* args, int* type_code, int num_args, TVMValue* out_value, int* out_type_code, void* resource_handle);

but the same two functions are re-declared in the same file and in tvmgen_default.h with different signatures:

TVM_DLL int32_t tvmgen_default___tvm_main__(void* input_1,void* output0);
int32_t tvmgen_default_run(
  struct tvmgen_default_inputs* inputs,
  struct tvmgen_default_outputs* outputs
);

Could you please verify this?