TracerWarning: Converting a tensor to a Python index 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!
See original GitHub issueI convert a pytorch model to onnx.
example = torch.rand(10, 3, 224, 224)
torch.onnx.export(net, # model being run
example, # model input (or a tuple for multiple inputs)
"./infer/tsm_resnet50.onnx", # where to save the model (can be a file or file-like object)
export_params=True, # store the trained parameter weights inside the model file
opset_version=10, # the ONNX version to export the model to
do_constant_folding=True, # whether to execute constant folding for optimization
input_names = ['input'], # the model's input names
output_names = ['output'], # the model's output names
# operator_export_type=torch.onnx.OperatorExportTypes.ONNX_ATEN_FALLBACK,
dynamic_axes={'input' : {0 : 'batch_size'}, # variable lenght axes
'output' : {0 : 'batch_size'}})
And then it show me that: this is my log file log.txt the problem snippet:
out = torch.zeros_like(x)
out[:, :-1, :fold] = x[:, 1:, :fold] # shift left
out[:, 1:, fold: 2 * fold] = x[:, :-1, fold: 2 * fold] # shift right
out[:, :, 2 * fold:] = x[:, :, 2 * fold:] # not shift
how can replace it ? thanks my version: python3.6 torch 1.2.0 torchvison 0.4.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:20
- Comments:18 (3 by maintainers)
Top Results From Across the Web
Converting a tensor to a Python boolean might cause the trace ...
TracerWarning : Converting a tensor to a Python boolean might cause the trace to be incorrect. We cant record the data flow of...
Read more >Converting a tensor to a Python index might cause the trace to ...
TracerWarning : Converting a tensor to a Python index might cause the trace to be incorrect...This means that the trace might not generalize...
Read more >CompVis/stable-diffusion-v1-4 · Help with an error
We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means...
Read more >TracerWarning: Converting a tensor to a Python index might ...
TracerWarning : Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of...
Read more >8. Basic MERA Manipulations & Optimization - quimb
We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Anyone explain it, please? it´s an issue for prediction ? how to solve it?
I´m facing the same warning with Python=3.7.9, pytorch=1.6.0, onnxruntime=1.4.0, onxruntime-tools=1.4.2 when converting a bert model.
TracerWarning: Converting a tensor to a Python index 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! position_ids = self.position_ids[:, :seq_length]
TracerWarning: Converting a tensor to a Python boolean 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! input_tensor.shape == tensor_shape for input_tensor in input_tensors