I am compiling a test model with the following TVMC command:
```
python -m tv…m.driver.tvmc compile test.onnx --verbose --target='c -keys=cpu' --runtime=crt --runtime-crt-system-lib=1 --executor=aot --executor-aot-interface-api=c --executor-aot-unpacked-api=1 --pass-config tir.disable_vectorize=1 --output-format=mlf --output=model_tvm.tar
```
Inside the generated `lib0.c` I get two definitions of both `tvmgen_default_run` and `tvmgen_default__tvm_main__`. This causes the following errors :
- `Conflicting types for 'tvmgen_default_run'`
- `Conflicting types for 'tvmgen_default___tvm_main__'`
By simply removing the conflicting definition I am able to compile a working binary.
In this forum post it was resolved with unpacked-api=true, this did not work for me from tvmc.
https://discuss.tvm.apache.org/t/problem-with-tvmexecute-on-arduino-in-standalone-execution/15420
This bug report also experiences the issue https://github.com/apache/tvm/issues/14871 but it has gone unaddressed
This bug report also mentions it but they are on tvm 0.13 https://github.com/apache/tvm/issues/17136
I also personally know colleagues who have experienced this too.
### Expected behavior
Valid C code to be generated with no conflicts
### Actual behavior
The following is generated:
```C
....
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);
...
#ifdef __cplusplus
extern "C"
#endif
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);
static TVMBackendPackedCFunc _tvm_func_array[] = {
(TVMBackendPackedCFunc)tvmgen_default_run,
(TVMBackendPackedCFunc)tvmgen_default_fused_nn_contrib_dense_pack,
(TVMBackendPackedCFunc)tvmgen_default_fused_reshape,
(TVMBackendPackedCFunc)tvmgen_default_fused_reshape_add_nn_relu,
(TVMBackendPackedCFunc)tvmgen_default___tvm_main__,
};
static const TVMFuncRegistry _tvm_func_registry = {
"\005\000tvmgen_default_run\000tvmgen_default_fused_nn_contrib_dense_"
"pack\000tvmgen_default_fused_reshape\000tvmgen_default_fused_reshape_add_"
"nn_relu\000tvmgen_default___tvm_main__\000",
_tvm_func_array,
};
static const TVMModule _tvm_system_lib = {
&_tvm_func_registry,
};
const TVMModule *TVMSystemLibEntryPoint(void) { return &_tvm_system_lib; }
#include "tvm/runtime/c_runtime_api.h"
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((
section(".rodata.tvm"), )) static const struct global_const_workspace {
float fused_constant_let[10]
__attribute__((aligned(16))); // 40 bytes, aligned offset: 0
float fused_constant_1_let[1]
__attribute__((packed, aligned(16))); // 4 bytes, aligned offset: 48
} global_const_workspace = {
.fused_constant_let = {-0x1.23b7a4p-2, 0x1.08fb6cp-2, 0x1.4128e2p-4,
-0x1.03f552p-2, -0x1.09157ep-2, 0x1.8a4daep-4,
-0x1.ffa53ep-3, -0x1.2849ep-3, -0x1.c1e5cp-3,
-0x1.1a14aap-6},
.fused_constant_1_let = {-0x1.25dc64p-3},
}; // of total size 52 bytes
__attribute__((section(".bss.noinit.tvm"),
aligned(16))) static uint8_t global_workspace[68];
#include <tvmgen_default.h>
TVM_DLL int32_t tvmgen_default___tvm_main__(
void *onnx__MatMul_0, void *output0, uint8_t *global_const_workspace_0_var,
uint8_t *global_workspace_1_var);
int32_t tvmgen_default_run(struct tvmgen_default_inputs *inputs,
struct tvmgen_default_outputs *outputs) {
return tvmgen_default___tvm_main__(inputs->onnx__MatMul_0, outputs->output,
((uint8_t *)&global_const_workspace),
((uint8_t *)&global_workspace));
}
#ifdef __cplusplus
}
#endif
;
```
### Environment
Any environment details, such as: Operating System, TVM version, etc
OS: RHEL8
```
$ python -m tvm.driver.tvmc --version
[15:48:26] /home/dev/tvm/src/runtime/logging.cc:390: TVM_LOG_DEBUG enables VLOG statements in 'ir/transform.cc' up to level 1
[15:48:26] /home/dev/tvm/src/runtime/logging.cc:390: TVM_LOG_DEBUG enables VLOG statements in 'relay/ir/transform.cc' up to level 1
0.17.dev0
```
### Steps to reproduce
```
python -m tvm.driver.tvmc compile test.onnx --verbose --target='c -keys=cpu' --runtime=crt --runtime-crt-system-lib=1 --executor=aot --executor-aot-interface-api=c --executor-aot-unpacked-api=1 --pass-config tir.disable_vectorize=1 --output-format=mlf --output=model_tvm.tar
```
where test.onnx is simply a torch.Linear followed by a relu.
### Triage
* backend:c