Tencent / ncnn

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

Is ncnn support nn.embedding in pytorch? #2457

Closed Songyima closed 2 years ago

Songyima commented 3 years ago

I have converted my pytorch model to onnx and simplified it by onnx-simplifier. However, there still a GATHER op which refers to nn.embedding in pytorch. Hence, I failed to run onnx2ncnn.

In fact, my model is used in an NLP task, I wonder if ncnn doesn't support NLP well.

Songyima commented 3 years ago

dwcnn.zip This is my onnx file converted from pytorch

jxt1234 commented 3 years ago

Use mnn you can get correct result: https://github.com/alibaba/MNN

nihui commented 2 years ago

embedding is supported via pnnx, see https://github.com/Tencent/ncnn/tree/master/tools/pnnx

nihui commented 3 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