Let’s say I have compiled a function (from python with jit) as;
@script
def process_sequence(sequence):
for t in range(sequence.size(0)):
process_timestep_traced(sequence[t])
save(process_sequence, ‘process_seq.torchjit’)
// until here everything in python, works perfect.
// main part for my question ; in my cpp file (where libtorch is configured & built perfect) I have ;
std::vectortorch::jit::IValue sequence_in; // just creating a sequence for testing
sequence_in.push_back(torch::randn({1, 2}));
sequence_in.push_back(torch::randn({1, 2}));
// These lines below are the cause of my confusion…
torch::jit::script::Module process_seq = torch::jit::load(“process_seq.torchjit”);
torch::Tensor sequence_out = process_seq.forward(sequence_in).toTensor();
My question is:
How do I call a single jit function (not a module) into cpp, and how can I execute that function?
ps: I’m definitely not a user of cpp… I know of namespaces, but the problem is which import from torch::jit::script:: I use as my variable type for the imported function…
Thank you in advance
Edit: The error msg I get is ;
libc++abi.dylib: terminating with uncaught exception of type c10::Error: Expected at most 2 argument(s) for operator ‘forward’, but received 3 argument(s). Declaration: forward(ClassType<process_seq> self, Tensor sequence) -> (None) (checkAndNormalizeInputs at …/aten/src/ATen/core/function_schema_inl.h:134)
Abort trap: 6