You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Nam Nguyen Duc via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/08/28 08:38:29 UTC

[Apache TVM Discuss] [Questions] How to save model compile 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)`
<br>My code:
```python
    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 !?
<br>I tried to read documents but not found the solutions





---
[Visit Topic](https://discuss.tvm.apache.org/t/how-to-save-model-compile-by-virtualmachine/10902/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/2555e195c482d6adcaeb24031d66394bdde2a617a252a410f76af94656002227).

[Apache TVM Discuss] [Questions] How to save model compiled by VirtualMachine

Posted by Nam Nguyen Duc via Apache TVM Discuss <no...@discuss.tvm.ai>.

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





---
[Visit Topic](https://discuss.tvm.apache.org/t/how-to-save-model-compiled-by-virtualmachine/10902/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/a127fe88001f2dd1b0c72bd666bbf36c2b8d501c2c4ab956f62a87399d36003c).

[Apache TVM Discuss] [Questions] How to save model compiled by VirtualMachine

Posted by Yuchen Jin via Apache TVM Discuss <no...@discuss.tvm.ai>.

Hi @namduc, you can use `vm_exec.save()` to save the executable. Checkout the code example here: https://github.com/apache/tvm/blob/main/python/tvm/runtime/vm.py#L123.





---
[Visit Topic](https://discuss.tvm.apache.org/t/how-to-save-model-compiled-by-virtualmachine/10902/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/1e2c3e4ed40da0936f445375193c1782e240ff20d4be94e47e2a72da87f18e09).