Hello,
I would like to know how can I call other methods of ScriptModule?
For example, I have a python module which has 2 scripting methods.
class MyScriptModule(torch.jit.ScriptModule):
def init(self):
super(MyScriptModule, self).init()
# torch.jit.trace produces a ScriptModule’s conv1 and conv2
self.conv1 = torch.jit.trace(nn.Conv2d(1, 20, 5), torch.rand(1, 1, 16, 16))
self.conv2 = torch.jit.trace(nn.Conv2d(20, 20, 5), torch.rand(1, 20, 16, 16))@torch.jit.script_method def regressor(self, input): input = F.relu(self.conv1(input)) return input @torch.jit.script_method def forward(self, input): input = self.regressor(input) input = F.relu(self.conv2(input)) return input
my_script_module = MyScriptModule()
torch.jit.save(my_script_module, ‘test_cpp.pt’)
How could I call ‘regressor’ in c++ ?
Best,