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

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.

You could use pickle

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

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

:ok_man:Thanks for your suggestion.

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.

1 Like

Thanks for your suggestion.

Use relay.load_param_dict in python

Saving your graph, lib and params is something covered by our ongoing PR around tvmc compile CLI driver: https://github.com/apache/incubator-tvm/pull/6302.