Tensorrt: Unsupported method torch.arange/repeat/from_numpy/tensor?

Created on 11 Nov 2019  路  5Comments  路  Source: NVIDIA/TensorRT

Hi,
I try to convert my model to tensorrt, but meet the problem like this:

Warning: Encountered known unsupported method torch.arange
Warning: Encountered known unsupported method torch.Tensor.repeat

My Code:

grid_x = torch.arange(nGw).repeat((nGh, 1)).view((1, 1, nGh, nGw)).float()
grid_y = torch.arange(nGh).repeat((nGw, 1)).transpose(0,1).view((1, 1, nGh, nGw)).float()

So I changed it to:

grid_x = torch.from_numpy(np.tile(np.arange(nGw), nGh).reshape((nGh, -1))).view((1, 1, nGh, nGw)).float()
grid_y = torch.from_numpy(np.tile(np.arange(nGh), nGw).reshape((nGw, -1))).transpose(0, 1).view((1, 1, nGh, nGw)).float()

and meet the problem:

Warning: Encountered known unsupported method torch.from_numpy

So I changed to torch.tensor(), and meet this

Warning: Encountered known unsupported method torch.tensor

It neally drive me crazy...Do you have any ideas?

Thank you for your any reply!!!

PyTorch needs-info question

Most helpful comment

Did you figure out a solution @Xianqi-Zhang ?

Hi
Sorry, I'm not.
I use another NVIDIA toolkit torch2trt and meet the above problem. The problem seems related to that toolkit.(https://github.com/NVIDIA-AI-IOT/torch2trt). I raise the same issue and their reply (https://github.com/NVIDIA-AI-IOT/torch2trt/issues/151)
So I use the ONNX to convert and meet the problem
UserWarning: ONNX export failed on dim because ONNX and PyTorch use different strategies to split the input. not supported
warnings.warn("ONNX export failed on " + op + " because " + msg + " not supported")
I really have no idea about this ,maybe need to raise issue under ONNX?
ENVIRONMENT
TensorRT Version:6.0.1.5
GPU Type:GTX 1080ti
NVRM version: NVIDIA UNIX x86_64 Kernel Module 390.25 Wed Jan 24 20:02:43 PST 2018
CUDA Version:9.0
CUDNN Version:7.6.4
Operating System + Version: Centos7.4
Python Version (if applicable):3.7
TensorFlow Version (if applicable):1.14
PyTorch Version (if applicable):1.1.0

All 5 comments

Hi @Xianqi-Zhang,

  1. How are you trying to convert your model? PyTorch -> ONNX -> TensorRT?

  2. Please provide the template info below:

Environment

TensorRT Version:
GPU Type:
Nvidia Driver Version:
CUDA Version:
CUDNN Version:
Operating System + Version:
Python Version (if applicable):
TensorFlow Version (if applicable):
PyTorch Version (if applicable):
Baremetal or Container (if container which image + tag):

Did you figure out a solution @Xianqi-Zhang ?

Did you figure out a solution @Xianqi-Zhang ?

Hi
Sorry, I'm not.
I use another NVIDIA toolkit torch2trt and meet the above problem. The problem seems related to that toolkit.(https://github.com/NVIDIA-AI-IOT/torch2trt). I raise the same issue and their reply (https://github.com/NVIDIA-AI-IOT/torch2trt/issues/151)
So I use the ONNX to convert and meet the problem
UserWarning: ONNX export failed on dim because ONNX and PyTorch use different strategies to split the input. not supported
warnings.warn("ONNX export failed on " + op + " because " + msg + " not supported")
I really have no idea about this ,maybe need to raise issue under ONNX?
ENVIRONMENT
TensorRT Version:6.0.1.5
GPU Type:GTX 1080ti
NVRM version: NVIDIA UNIX x86_64 Kernel Module 390.25 Wed Jan 24 20:02:43 PST 2018
CUDA Version:9.0
CUDNN Version:7.6.4
Operating System + Version: Centos7.4
Python Version (if applicable):3.7
TensorFlow Version (if applicable):1.14
PyTorch Version (if applicable):1.1.0

The underlying data structure does not need to be converted, try try this
self.grid_x = torch.cuda.FloatTensor([list(range(nGw))]*nGh).view([1, 1, nGh, nGw])
self.grid_y = torch.cuda.FloatTensor([[x] * nGw for x in range(nGh)]).view([1, 1, nGh, nGw])

Try torch.cat, good luck

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sbbug picture sbbug  路  5Comments

anmol039w picture anmol039w  路  5Comments

lapolonio picture lapolonio  路  5Comments

Stephenfang51 picture Stephenfang51  路  3Comments

MachineJeff picture MachineJeff  路  5Comments