However, I have no clue on how to trace models that take 2 inputs. I tried the following which produces error as given below:
z = torch.rand(1,3,127,127)
x = torch.rand(1,3,256,256)
traced_module_rpn = torch.jit.trace(model, { 'zf':z, 'xf':x } )
and the output is
Traceback (most recent call last):
File "export_to_cpp.py", line 57, in <module>
main()
File "export_to_cpp.py", line 52, in main
traced_module_rpn = torch.jit.trace(model.rpn_model, { 'zf':z, 'xf':x } )
File "/home/tlm/anaconda3/envs/svt2_pyth1/lib/python3.7/site-packages/torch/jit/__init__.py", line 565, in trace
module._create_method_from_trace('forward', func, example_inputs)
RuntimeError: Only tensors and (possibly nested) tuples of tensors are supported as inputs or outputs of traced functions (toIValue at /opt/conda/conda-bld/pytorch-nightly_1538562647654/work/torch/csrc/jit/pybind_utils.h:74)
frame #0: <unknown function> + 0x3fe53f (0x7f98c5fb353f in /home/tlm/anaconda3/envs/svt2_pyth1/lib/python3.7/site-packages/torch/_C.cpython-37m-x86_64-linux-gnu.so)
frame #1: <unknown function> + 0x463a2b (0x7f98c6018a2b in /home/tlm/anaconda3/envs/svt2_pyth1/lib/python3.7/site-packages/torch/_C.cpython-37m-x86_64-linux-gnu.so)
frame #2: <unknown function> + 0x1a665d (0x7f98c5d5b65d in /home/tlm/anaconda3/envs/svt2_pyth1/lib/python3.7/site-packages/torch/_C.cpython-37m-x86_64-linux-gnu.so)
<omitting python frames>
frame #19: __libc_start_main + 0xf0 (0x7f98da43b830 in /lib/x86_64-linux-gnu/libc.so.6)
I am using pytorch-1.0-rc1 with cuda-9.0 and python 3.7.
I am trying to trace UPChannelRPN(). This network does not include any conditionals (to the best of my knowledge) and therefore I think it should be possible to trace this network using torch.jit.trace
rpn.py:18: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
po = F.conv2d(px, pk, groups=batch)
where line 18: of rpn.py is
po = F.conv2d(px, pk, groups=batch)
Any help in understanding this warning message is highly appreciated.
Hello, i would like to see the trace graphically through
torch.jit.trace:
traced_net = torch.jit.trace(net,inputs, optimize=True, check_trace=True, check_inputs=None, check_tolerance=1e-05)
print(traced_net)
make_dot_from_trace(traced_net) <—
—>AttributeError: ‘TopLevelTracedModule’ object has no attribute ‘set_graph’
If there is not graph then what ?