分享到微信

打开微信,使用扫一扫进入页面后,点击右上角菜单,

点击“发送给朋友”或“分享到朋友圈”完成分享

pytorch移植问题 yu2020-08-22 17:07:43 回复 3 查看 PyTorch 思元270
pytorch移植问题
分享到:

模型在cpu上跑没问题,量化后跑在线模式,前向传播时,在 nn.MaxPool2d(2stride=2) 这一层会报错,错误信息如下所示。

尝试在forward函数里打印这一层的输入Tensor的shape,量化前输入shape是 torch.Size([1, 3, 208, 976]), 输出shape是torch.Size([1, 3, 104, 488]),量化后输入依然是torch.Size([1, 3, 208, 976]),然后就报下面这个错了


2020-08-22 08:55:38.023472: [cnmlError] MLU::pool dimension mismatch,output shape is wrong, the given shape is:(n=1, c=3,h=104,w=488, d=0, t=0, data in array:{1, 104, 488, 3, } , but the expected shape is:(n=1, c=4,h=104,w=488, d=0, t=0, data in array:{1, 104, 488, 4, } 

2020-08-22 08:55:38.023615: [cnmlError] MLU::pool Op update tensor shape failed

Traceback (most recent call last):

  File "quantize_check.py", line 84, in <module>

    test(quantized_net, , s)

  File "quantize_check.py", line 65, in test

    output, output_exist = model(input_var)

  File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 541, in __call__

    result = self.forward(*input, **kwargs)

  File "/workspace/LaneDetection2/models/erfnet.py", line 277, in forward

    output = self.encoder(input)  # predict=False by default

  File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 541, in __call__

    result = self.forward(*input, **kwargs)

  File "/workspace/LaneDetection2/models/erfnet.py", line 90, in forward

    output = self.initial_block(input)

  File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 541, in __call__

    result = self.forward(*input, **kwargs)

  File "/workspace/LaneDetection2/models/erfnet.py", line 22, in forward

    print('pool: ' + str(self.pool(input).shape))

  File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 541, in __call__

    result = self.forward(*input, **kwargs)

  File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/modules/pooling.py", line 141, in forward

    self.return_indices)

  File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/_jit_internal.py", line 138, in fn

    return if_false(*args, **kwargs)

  File "/opt/cambricon/pytorch/src/catch/venv/pytorch/lib/python3.5/site-packages/torch/nn/functional.py", line 488, in _max_pool2d

    input, kernel_size, stride, padding, dilation, ceil_mode)

RuntimeError: CNML error: CNML_STATUS_INVALIDPARAM

版权所有 © 2019 寒武纪 Cambricon 备案/许可证号:京ICP备17003415
关闭