How could I save the "graph", "lib", and "params"


#1

Through the following codes, we can get the “graph”, “lib”, and “params”:

graph, lib, params = relay.build_module.build(
net, target, params=params)

I want to save these at the local PC, and then copy to the remote machine to run the model for inferrence.


#2

You could use pickle


#3

pickle only saves the “graph” file, but the “lib” and “params” can not be saved?


#4

TVM Module class has a save function . check here (https://docs.tvm.ai/api/python/module.html), so your lib can be saved in this way

Params is a dictionary and can still be saved as pickle file


#5

:ok_man:Thanks for your suggestion.


#6

Pickle is good to save and reload again in python. But TVM has it’s own format for params.

Refer below to save params in a format accepted by TVM runtime while deployment.


#7

Thanks for your suggestion.