ncnn icon indicating copy to clipboard operation
ncnn copied to clipboard

NCNN GPU / CPU produces different result in MediaPipe HandLandmark model

Open qwertypower opened this issue 2 years ago • 3 comments

error log | 日志或报错信息 | ログ

context | 编译/运行环境 | バックグラウンド

how to reproduce | 复现步骤 | 再現方法

  1. Code and models avaible from https://github.com/FeiGeChuanShu/ncnn-Android-mediapipe_hand and converted to windows project
  2. Use latest library
  3. Older version of NCNN works correctly on CPU, new version working only in GPU mode

more | 其他 | その他

GPU correct result: image CPU incorrect result: image

Both models (hand full & lite) works perfect with NCNN release [20221128] and older.

If use_packing_layout=false then latest version works.

PS: I`m find that Gemm produces wrong result if i turn off packing sse for gemm, then latest library works fine!!!!!!

Gemm_x86::Gemm_x86() { #if SSE2 support_packing = false; #endif // SSE2

nT = 0;

}

qwertypower avatar Sep 06 '23 08:09 qwertypower

My model was supposed to output 1x2 through the GEMM operator, but it turned out to be 1x2x8. Then I optimized my onnx model again, and when exporting ncnn again, GEMM was replaced with InnerProduct. Please try using onnx-sim to simplify your model again, but do not use '--overwrite-input-shape'.

hhxdestiny avatar Nov 22 '23 03:11 hhxdestiny

My model was supposed to output 1x2 through the GEMM operator, but it turned out to be 1x2x8. Then I optimized my onnx model again, and when exporting ncnn again, GEMM was replaced with InnerProduct. Please try using onnx-sim to simplify your model again, but do not use '--overwrite-input-shape'.

This is not a solution, this must work well with CPU, because GPU works well with all models.

qwertypower avatar Nov 28 '23 15:11 qwertypower

针对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 avatar Aug 05 '24 09:08 nihui