Tencent / ncnn

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

ex.extract return -100 #4321

Open niwch opened 2 years ago

niwch commented 2 years ago

detail | 详细描述 | 詳細な説明

像是模型刚开始就错误了,请问是模型还是代码加载的问题?

int ret = ex.input("input1", in); // 返回值0 正确

int ret = ex.extract("output1", out); // 返回值-100

code执行到Reshape_vulkan::forward函数返回-100 Reshape_vulkan::forward w = -233 , h = -233 , d = -233, c = -233 , ndim = 0 permute = 0

模型param 如下: 7767517 213 237 Input input1 0 1 input1 MemoryData onnx::Add_952 0 1 onnx::Add_952 0=1024 1=1025 MemoryData onnx::Concat_124 0 1 onnx::Concat_124 0=1024 1=1 MemoryData vit.to_patch_embedding.1.bias 0 1 vit.to_patch_embedding.1.bias 0=1024 MemoryData vit.transformer.layers.0.0.fn.to_out.0.bias 0 1 vit.transformer.layers.0.0.fn.to_out.0.bias 0=1024 MemoryData vit.transformer.layers.0.1.fn.net.0.bias 0 1 vit.transformer.layers.0.1.fn.net.0.bias 0=1024 MemoryData vit.transformer.layers.0.1.fn.net.3.bias 0 1 vit.transformer.layers.0.1.fn.net.3.bias 0=1024 MemoryData vit.transformer.layers.1.0.fn.to_out.0.bias 0 1 vit.transformer.layers.1.0.fn.to_out.0.bias 0=1024 MemoryData vit.transformer.layers.1.1.fn.net.0.bias 0 1 vit.transformer.layers.1.1.fn.net.0.bias 0=1024 MemoryData vit.transformer.layers.1.1.fn.net.3.bias 0 1 vit.transformer.layers.1.1.fn.net.3.bias 0=1024 MemoryData vit.transformer.layers.2.0.fn.to_out.0.bias 0 1 vit.transformer.layers.2.0.fn.to_out.0.bias 0=1024 MemoryData vit.transformer.layers.2.1.fn.net.0.bias 0 1 vit.transformer.layers.2.1.fn.net.0.bias 0=1024 MemoryData vit.transformer.layers.2.1.fn.net.3.bias 0 1 vit.transformer.layers.2.1.fn.net.3.bias 0=1024 MemoryData vit.transformer.layers.3.0.fn.to_out.0.bias 0 1 vit.transformer.layers.3.0.fn.to_out.0.bias 0=1024 MemoryData vit.transformer.layers.3.1.fn.net.0.bias 0 1 vit.transformer.layers.3.1.fn.net.0.bias 0=1024 MemoryData vit.transformer.layers.3.1.fn.net.3.bias 0 1 vit.transformer.layers.3.1.fn.net.3.bias 0=1024 MemoryData vit.transformer.layers.4.0.fn.to_out.0.bias 0 1 vit.transformer.layers.4.0.fn.to_out.0.bias 0=1024 MemoryData vit.transformer.layers.4.1.fn.net.0.bias 0 1 vit.transformer.layers.4.1.fn.net.0.bias 0=1024 MemoryData vit.transformer.layers.4.1.fn.net.3.bias 0 1 vit.transformer.layers.4.1.fn.net.3.bias 0=1024 MemoryData vit.transformer.layers.5.0.fn.to_out.0.bias 0 1 vit.transformer.layers.5.0.fn.to_out.0.bias 0=1024 MemoryData vit.transformer.layers.5.1.fn.net.0.bias 0 1 vit.transformer.layers.5.1.fn.net.0.bias 0=1024 MemoryData vit.transformer.layers.5.1.fn.net.3.bias 0 1 vit.transformer.layers.5.1.fn.net.3.bias 0=1024

执行到Reshape错误

Reshape Reshape_45 1 1 input1 tensor
Permute Transpose_46 1 1 tensor tensor.4 Reshape Reshape_47 1 1 tensor.4 onnx::MatMul_96 0=768 1=1024 InnerProduct MatMul_48 1 1 onnx::MatMul_96 onnx::Add_98 0=1024 1=0 2=786432

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