Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Target not available while compiling ONNX model to MIPS #17578

Open
RajS999 opened this issue Dec 30, 2024 · 0 comments
Open

[Bug] Target not available while compiling ONNX model to MIPS #17578

RajS999 opened this issue Dec 30, 2024 · 0 comments
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug

Comments

@RajS999
Copy link

RajS999 commented Dec 30, 2024

I am trying to compile ONNX model using Apache TVM to target MIPS platform. Here is how my code looks like:

import tvm
from tvm import relay
from tvm.contrib import graph_executor
import torch
import onnx

input_shape = (1, 200, 10)  
onnx_model = onnx.load("model.onnx")

# Convert to Relay
input_name = "input0"
shape_dict = {input_name: input_shape}

mod, params = relay.frontend.from_onnx(onnx_model, shape_dict)

# Target MIPS
target = "llvm -mtriple=mips-linux-gcc"

# Compile the model
with tvm.transform.PassContext(opt_level=3):
    lib = relay.build(mod, target=target, params=params)

# Save the model artifacts
lib.export_library("deployable_model.so")
with open("deploy_graph.json", "w") as f:
    f.write(lib.get_graph_json())
with open("deploy_params.params", "wb") as f:
    f.write(relay.save_param_dict(lib.get_params()))

However, it gives me following exception:

$ python onnx2tvm.py 
[00:33:25] /workspace/tvm/src/runtime/threading_backend.cc:338: Warning: more than two frequencies detected!
One or more operators have not been tuned. Please tune your model for better performance. Use DEBUG logging level to see more details.
Traceback (most recent call last):
  File "/home//workspace/my-project/onnx2tvm.py", line 28, in <module>
    lib = relay.build(mod, target=target, params=params)
  File "/home//.local/lib/python3.10/site-packages/tvm/relay/build_module.py", line 364, in build
    graph_json, runtime_mod, params = bld_mod.build(
  File "/home//.local/lib/python3.10/site-packages/tvm/relay/build_module.py", line 161, in build
    self._build(
  File "tvm/_ffi/_cython/./packed_func.pxi", line 331, in tvm._ffi._cy3.core.PackedFuncBase.__call__
  File "tvm/_ffi/_cython/./packed_func.pxi", line 276, in tvm._ffi._cy3.core.FuncCall
  File "tvm/_ffi/_cython/./base.pxi", line 181, in tvm._ffi._cy3.core.CHECK_CALL
tvm._ffi.base.TVMError: Traceback (most recent call last):
  7: TVMFuncCall
  6: tvm::relay::backend::RelayBuildModule::GetFunction(std::string const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#3}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const
  5: tvm::relay::backend::RelayBuildModule::BuildRelay(tvm::IRModule, tvm::runtime::String const&)
  4: tvm::TIRToRuntime(tvm::runtime::Map<tvm::Target, tvm::IRModule, void, void> const&, tvm::Target const&)
  3: tvm::codegen::Build(tvm::IRModule, tvm::Target)
  2: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::runtime::Module (tvm::IRModule, tvm::Target)>::AssignTypedLambda<tvm::codegen::{lambda(tvm::IRModule, tvm::Target)#1}>(tvm::codegen::{lambda(tvm::IRModule, tvm::Target)#1}, std::string)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
  1: tvm::codegen::LLVMModuleNode::Init(tvm::IRModule const&, tvm::Target const&)
  0: tvm::codegen::LLVMTargetInfo::GetOrCreateTargetMachine(bool)
  File "/workspace/tvm/src/target/llvm/llvm_instance.cc", line 302
TVMError: 
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
  Check failed: (target_machine_ != nullptr) is false: No available targets are compatible with triple "mips-linux-gcc"

It seems that mips-linux-gcc target is not supported. I also tried mips-linux-gnu, which also did not work.
What is target string for mips target?

@RajS999 RajS999 added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it type: bug
Projects
None yet
Development

No branches or pull requests

1 participant