ncnn
ncnn copied to clipboard
layer `torch.roll` not exists or registered, with pnnx to ncnn
error log | 日志或报错信息 | ログ
❯ python ./pnnx/cpu_demo/scunet_demo_ncnn.py
layer torch.roll not exists or registered
[1] 80513 segmentation fault (core dumped) python ./pnnx/cpu_demo/scunet_demo_ncnn.py
model | 模型 | モデル
- original model https://github.com/cszn/SCUNet
how to reproduce | 复现步骤 | 再現方法
- pnnx version:
pnnx-20240603os: fedora 40 convert script:
import torch
import pnnx
from pathlib import Path
import torch
from models.network_scunet import SCUNet as net
device = "cpu"
n_channels = 3
model = net(in_nc=n_channels, config=[4, 4, 4, 4, 4, 4, 4], dim=64)
model.load_state_dict(torch.load("./model_zoo/scunet_color_real_psnr.pth"), strict=True)
for k, v in model.named_parameters():
v.requires_grad = False
model = model.to(device)
folder_path = Path("pnnx/cpu_demo/")
folder_path.mkdir(exist_ok=True, parents=True)
_input = torch.rand(1, 3, 480, 640).to(device)
opt_model = pnnx.export(
model, str((folder_path / "scunet_demo.pt").absolute()), _input, device="cpu"
)
# result = opt_model(img_L)
# print(result)
3.infer with ncnn
❯ python ./pnnx/cpu_demo/scunet_demo_ncnn.py
layer torch.roll not exists or registered
[1] 80513 segmentation fault (core dumped) python ./pnnx/cpu_demo/scunet_demo_ncnn.py
4.some fragments in scunet_demo.pnnx.param
Tensor.reshape Tensor.reshape_380 1 1 154 155 shape=(1,512,640,32) $input=154 #154=(1,64,8,80,8,32)f32 #155=(1,512,640,32)f32
torch.roll torch.roll_1406 1 1 155 156 dims=(1,2) shifts=(4,4) $input=155 #155=(1,512,640,32)f32 #156=(1,512,640,32)f32
pnnx.Expression pnnx_expr_7583 2 1 131 156 157 expr=add(@0,@1) #131=(1,512,640,32)f32 #156=(1,512,640,32)f32 #157=(1,512,640,32)f32
nn.LayerNorm m_down2.1.trans_block.ln1 1 1 214 215 elementwise_affine=True eps=1.000000e-05 normalized_shape=(64) @bias=(64)f32 @weight=(64)f32 #214=(1,256,320,64)f32 #215=(1,256,320,64)f32
torch.roll torch.roll_1407 1 1 215 216 dims=(1,2) shifts=(-4,-4) $input=215 #215=(1,256,320,64)f32 #216=(1,256,320,64)f32
Tensor.reshape Tensor.reshape_388 1 1 216 217 shape=(1,32,8,40,8,64) $input=216 #216=(1,256,320,64)f32 #217=(1,32,8,40,8,64)f32
5.some fragments in scunet_demo.ncnn.param
Reshape reshape_564 1 1 99 100 0=32 1=640 2=512
torch.roll torch.roll_1404 1 1 100 101
BinaryOp add_9 2 1 70 101 102 0=0
Reshape reshape_592 1 1 213 214 0=32 1=640 2=512
torch.roll torch.roll_1406 1 1 214 215
BinaryOp add_21 2 1 184 215 216 0=0
https://github.com/Tencent/ncnn/pull/5623
fixed, please update your pnnx package
fixed, please update your pnnx package
Sorry for the late reply; thanks for your contribution!