eljiwo
eljiwo

Reputation: 856

Torchscript call other function rather than forward

When I compile my torch model to torchscript I can make use of the function forward by just calling the torchscript model object model().

But when I want to use another function created on the model I cant call the function. I try to do model.functionName() expecting to call the function functionName but nothing happens.

Any idea on how could I call subfunctions from the model object that are not forward?

Thanks

Upvotes: 5

Views: 2703

Answers (1)

teplandr
teplandr

Reputation: 316

I suppose you should add decorator @torch.jit.export above the method you want to call and convert torchscript model again. After that you can call method by module.run_method(name, args) docs.

Upvotes: 2

Related Questions