How to save relay module?

Is it possible to save relay module into a file? And meanwhile, we can restore the relay module from the file… For example, if i get the relay module by: mod, params = relay.frontend.from_tensorflow(…) When i dump the mod into file by pickle lib, it raise errors. So, could anyone help me?

is the export_library you want? We could support mod.export_library(""), then you could load it back using mod = tvm.module.load("")

In fact, i just want to save relay module that is not built, which means that not execute ‘’. and ‘mod’ is the instance of tvm.relay.module. So, i gusss that there is no any interface like export_library.

Hmm… relay.astext() and relay.fromtext()?

:joy: I know how strange the demand is! If using relay.astext() to save relay.module into eg. mod.txt, are there some mothods that i can restore the module from mod.txt?

I think I have pointed it. You could call astext to save the file. Then you could open the file and pass the content to fromtext. Maybe we have another good way to handle it better.

besides the astext and fromtext, all the tvm AST nodes can be saved to json and load back via save json and load json . Or simply pickle them in python

Thank you very much!!! It works!:blush:

Thanks. I just tried to pickle params, but it raises some errors: ValueError: ctypes objects containing pointers cannot be pickled