How to check whether model loading is successful and how to release model in version 1.2 or 1.3

According to the release note, there are same different between nightly version and old version to load a model.

In the old version, the code is like this:

and now it change into :

  • torch::jit::script::Module model = torch::jit::load(“model.py”);

and in the old version, i can use nullptr to check whether loading is successful:

  • if (model == nullptr) std::cout << “failed to load model” << std::endl;

but how can i do this in the version after 1.2?

there have same problem when to release loaded model to load another one.

Can someone tell me how to do these, thanks.

related issue