Hello all,
When trying to convert pretrained MobileNetV2 using tensorrt I get this error when trying to call the export_library method. i share below the code:
import numpy as np
import tvm
from tvm import te
import tvm.relay as relay
import tensorflow as tf
import os
model = tf.keras.applications.MobileNetV2(alpha = .35, pooling = 'max', include_top=False, input_shape=(220,220,3))
target = "cuda"
shape_dict = {"input_0":(1,3,220,220)}
mod, params = relay.frontend.from_keras(model, shape_dict)
from tvm.relay.op.contrib.tensorrt import partition_for_tensorrt
mod, config = partition_for_tensorrt(mod, params)
with tvm.transform.PassContext(opt_level=3, config={'relay.ext.tensorrt.options': config}):
lib = relay.build(mod, target=target, params=params)
lib.export_library(os.path.join("model_lib.so"))
I’d love to get some help with this the traceback I get is : in ----> 1 lib.export_library(“merda”)
~/tvm/python/tvm/runtime/module.py in export_library(self, file_name, fcompile, addons, workspace_dir, **kwargs)
467 path_cc = os.path.join(workspace_dir, "devc.c")
468 with open(path_cc, "w") as f:
--> 469 f.write(_ffi_api.ModulePackImportsToC(self, is_system_lib))
470 files.append(path_cc)
471
~/tvm/python/tvm/_ffi/_ctypes/packed_func.py in __call__(self, *args)
235 != 0
236 ):
--> 237 raise get_last_ffi_error()
238 _ = temp_args
239 _ = args
TVMError: Traceback (most recent call last):
4: TVMFuncCall
3: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (tvm::runtime::Module const&, bool)>::AssignTypedLambda<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (*)(tvm::runtime::Module const&, bool)>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > (*)(tvm::runtime::Module const&, bool), std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
2: tvm::codegen::PackImportsToC[abi:cxx11](tvm::runtime::Module const&, bool)
1: tvm::codegen::(anonymous namespace)::SerializeModule(tvm::runtime::Module const&)
0: tvm::runtime::ModuleNode::SaveToBinary(dmlc::Stream*)
File "/home/pfernandes/tvm/src/runtime/module.cc", line 100
TVMError: Module[stackvm] does not support SaveToBinary