Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.6k stars 4.18k forks source link

torch.roll、torch.lgamma are not suportted? #2807

Open ciwei123 opened 3 years ago

ciwei123 commented 3 years ago

@nihui Thanks for your sharing. I want to convert https://github.com/photosynthesis-team/piq/blob/master/piq/brisque.py to ncnn ,and I get some errors: 1.ONNX export failed on ATen operator group_norm because torch.onnx.symbolic.roll does not exist 2.ONNX export failed on ATen operator group_norm because torch.onnx.symbolic.lgamma does not exist To solve these errors, I add two functions to symbolic_opset9.py:

@parse_args( 'v')
def lgamma (g,input):
    return g.op("lgamma ",input)

@parse_args( 'v', 'v','v')
def roll (g,input,shift,dim):
    return g.op("roll",shift,dim)

And then I get another error: RuntimeError: ONNX export failed: Couldn't export operator aten::sum Could you help me? Thank you very much!

nihui commented 4 months ago

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx

nihui commented 3 months ago

https://github.com/Tencent/ncnn/pull/5623