How to save model compiled by VirtualMachine

I want to save and load the model compiled by relay.vm.compile, how can I be !? Because my model is not able to build with relay.build thus I was unable to save the model like this lib.export_library(path_lib)
My code:

    with tvm.transform.PassContext(opt_level=3, disabled_pass=["FoldScaleAxis"]):
        vm_exec = relay.vm.compile(mod, target=TARGET, params=params)
# I want to save model here
    dev = tvm.cpu()
    vm = VirtualMachine(vm_exec, dev)
# Or save here
    vm.set_input("main", **{"input0": sample.cpu().numpy()})
    tvm_res = vm.run()

Any ideas !?
I tried to read documents but not found the solutions

Hi @namduc, you can use vm_exec.save() to save the executable. Checkout the code example here: tvm/vm.py at main · apache/tvm · GitHub.

1 Like

@yuchenj Thanks you very much, it is exactly what I looking for

1 Like