I am running a model with external codegen. After calling relay.build
, I call update_lib
. However, when I call lib.export_library()
or lib.save()
on the library returned from the function, I get an error: Module[library] does not support SaveToFile
.
What is the recommended way to save this to a single file? Or is it recommended to save the original lib separately, and call update_lib
every time we load it?
I would like to do this in C++ as well, and am currently working on Windows.
Here is the update_lib code:
def update_lib(lib):
cur_dir = os.path.dirname(os.path.realpath(os.path.expanduser(__file__)))
tvm_home = os.getenv("TVM_HOME", None)
contrib_path = os.path.join(tvm_home, "src", "runtime", "contrib")
kwargs = {}
kwargs["options"] = ["-O3", "-std=c++11", "-I" + contrib_path]
tmp_path = util.tempdir()
lib_name = 'lib.so'
lib_path = tmp_path.relpath(lib_name)
lib.export_library(lib_path, fcompile=False, **kwargs)
lib = tvm.runtime.load_module(lib_path)
lib.export_library("test.dll") # this causes the error
return lib