Considerations for converting to onnx

Notes for converting to onnx:

1) For any use of shape and size return numbers, avoid using the return value of tensor.size() directly, but add int conversion, such as tensor.view(-1,int(tensor.size(1)) );
2) For the nn.upsample or nn,functional.interpolate function, use scale_factor to specify the multiple, instead of using the size parameter to specify the size (for those that cannot use multiples, use size to specify the size); 3) For reshape and view
operations , the batch dimension is specified by -1, and other dimensions can be obtained by calculation (convenient for dynamic batch);
4) After torch.cat changes the dimension, it performs softmax on its data; otherwise, the error in the following example will occur (specific reasons hope Someone can explain it).

References:
TensorRT High Performance Deployment

Guess you like

Origin blog.csdn.net/qq_42178122/article/details/128236981