Hello Folks,
I am trying to trace my custom model using torch.jit.trace
for getting mobile runnable model. I am following the step-by-step procedure mentioned in the Pytorch Mobile documentation page.
However, for my model, it fails during the tracing process with the following error: Error: :List trace inputs must have elements
. I find that there are certain variables which are empty in my case.
File "mobile_model.py", line 135, in profile_sample
traced_script_module = torch.jit.trace(model, sample)
File "/home/us000146/anaconda3/envs/selfsupervised/lib/python3.6/site-packages/torch/jit/_trace.py", line 742, in trace
_module_class,
File "/home/us000146/anaconda3/envs/selfsupervised/lib/python3.6/site-packages/torch/jit/_trace.py", line 940, in trace_module
_force_outplace,
RuntimeError: Tracer cannot infer type of ({'label_target': [], 'occ_target': [], 'coords_': [tensor([[ 0, 4, 13, 2],
My understanding is because there are certain data holders (label_target
and occ_target
) which are empty during the tracing stage which causes this issue. If that is indeed the case, How do I handle this scenario, considering that I can not do away with these variables and still want the tracing part to complete successfully.
PS: I am doing training of the model in stages where in some stage these variable are used but on another where I need to trace the model, they are not.
Regards,
Nitin