Tencent / ncnn

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

PNNX转化后模型使用错误 #3951

Closed ChaoII closed 2 years ago

ChaoII commented 2 years ago

1、PNNX模型转化过程中未报错转化信息如下:

./pnnx ch_ptocr_v2_rec_infer.pt inputshape=1,3,32,320 optlevel=2
pnnxparam = ch_ptocr_v2_rec_infer.pnnx.param
pnnxbin = ch_ptocr_v2_rec_infer.pnnx.bin
pnnxpy = ch_ptocr_v2_rec_infer_pnnx.py
ncnnparam = ch_ptocr_v2_rec_infer.ncnn.param
ncnnbin = ch_ptocr_v2_rec_infer.ncnn.bin
ncnnpy = ch_ptocr_v2_rec_infer_ncnn.py
optlevel = 2
device = cpu
inputshape = [1,3,32,320]f32
inputshape2 = 
customop = 
moduleop = 
############# pass_level0
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.ConvBNLayer
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.DepthwiseSeparable
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.MobileNetV1Enhance
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.SEModule
inline module = pytorchocr.modeling.common.Activation
inline module = pytorchocr.modeling.common.Hswish
inline module = pytorchocr.modeling.heads.rec_ctc_head.CTCHead
inline module = pytorchocr.modeling.necks.rnn.EncoderWithRNN
inline module = pytorchocr.modeling.necks.rnn.Im2Seq
inline module = pytorchocr.modeling.necks.rnn.SequenceEncoder
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.ConvBNLayer
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.DepthwiseSeparable
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.MobileNetV1Enhance
inline module = pytorchocr.modeling.backbones.rec_mv1_enhance.SEModule
inline module = pytorchocr.modeling.common.Activation
inline module = pytorchocr.modeling.common.Hswish
inline module = pytorchocr.modeling.heads.rec_ctc_head.CTCHead
inline module = pytorchocr.modeling.necks.rnn.EncoderWithRNN
inline module = pytorchocr.modeling.necks.rnn.Im2Seq
inline module = pytorchocr.modeling.necks.rnn.SequenceEncoder
31  32  34  36  input.6  38  39  40  59  60  62  64  input.3  66  67  68  72  73  75  77  input.5  79  80  81  87  88  90  92  input.7  94  95  96  100  101  103  105  input.9  107  108  109  115  116  118  120  input.11  122  123  124  128  129  131  133  input.13  135  136  137  143  144  146  148  input.15  150  151  152  156  157  159  161  input.17  163  164  165  171  172  174  176  input.19  178  179  180  184  185  187  189  input.21  191  192  193  199  200  202  204  input.23  206  207  208  212  213  215  217  input.25  219  220  221  227  228  230  232  input.27  234  235  236  240  241  243  245  input.29  247  248  249  255  256  258  260  input.31  262  263  264  268  269  271  273  input.33  275  276  277  283  284  286  288  input.35  290  291  292  296  297  299  301  input.37  303  304  305  311  312  314  316  input.39  318  319  320  324  325  327  329  input.41  331  332  333  339  340  342  344  input.43  346  347  348  352  353  355  357  input.45  359  360  361  368  369  371  373  input.47  375  376  377  378  380  384  385  input.49  387  input0.2  389  outputs.2  391  395  396  398  400  input.51  402  403  404  411  412  414  416  input.2  418  419  420  421  423  427  428  input.4  430  input0.1  432  outputs.1  434  438  439  441  443  input.1  445  446  447  448  x.1  456  458  463  464  465  
----------------

############# pass_level1
no attribute value
############# pass_level2
############# pass_level3
############# pass_level4
############# pass_level5
############# pass_ncnn
insert_reshape_pooling 4

但是在转化完成后生成了aten::Relu6,导致ncnn推理报错aten:Relu6不存在或未注册,模型结构如下图:

77

请问一下这是咋回事?该怎么处理额?

nihui commented 2 years ago

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

ChaoII commented 2 years ago

3952

感谢up,这效率直接起飞了

ChaoII commented 2 years ago

3952

fetch pr#3952 pnnx转是转成了,但是模型推理结果不对,和pytorch推理结果差异较大。

ChaoII commented 2 years ago

3952

fetch pr#3952 pnnx转是转成了,但是模型推理结果不对,和pytorch推理结果差异较大。

对不起,UP,后面验证过前后处理去掉推理结果相同。