Get torch::jit::Graph from torch::jit::script::Module

Is there a way to get std::shared_ptr<torch::jit::Graph>& graph
from torch::jit::script::Module

I exported a module in python using:

torchscript_trace = torch.jit.trace(my_module, example_inputs)
torchscript_trace = torch.jit.freeze(torchscript_trace.eval())
torchscript_trace.save('model.pt')

and wanted to get the graph object in C++ using:

torch::jit::script::Module module;
module = torch::jit::load('./model.pt');
1 Like

found solution here

1 Like