JiaoPaner opened a new issue #20727:
URL: https://github.com/apache/incubator-mxnet/issues/20727


   # Ask a Question
   I success convert mxnet model to onnx  but it failed when inference .The 
model 's shape is (1,1,100,100)
   **convert code**
   ```
   sym = 'single-symbol.json'
   params = '/single-0090.params'
   input_shape = (1, 1, 100, 100)
   onnx_file = './model.onnx'
   converted_model_path = onnx_mxnet.export_model(sym, params, [input_shape], 
np.float32, onnx_file,verbose=True)
   model= onnx.load_model(converted_model_path)
   checker.check_graph(model.graph)
   checker.check_model(model)
   ```
   **output**
   ```
   INFO:root:Input shape of the model [(1, 1, 100, 100)] 
   INFO:root:Exported ONNX file ./model.onnx saved to disk
   ```
   
   **inference code**
   ```
   sess = ort.InferenceSession("./model.onnx") 
   ```
   **output**
   ```
   onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException:
    [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : 
   Exception during initialization: 
   /onnxruntime/core/providers/cpu/nn/pool_attributes.h:77 
   onnxruntime::PoolAttributes::PoolAttributes(const 
OpNodeProtoHelper<onnxruntime::ProtoHelperNodeContext> &,
                                                     const std::string &, int) 
pads[dim] < kernel_shape[dim] &&
                                                     pads[dim + 
kernel_shape.size()] < kernel_shape[dim] was false. 
   Pad should be smaller than kernel.
   ```
   ### Question
   **mxnet pooling node json**
   ```
   {
     "op": "Pooling", 
     "name": "pool1_fwd", 
     "attrs": {
       "count_include_pad": "True", 
       "global_pool": "False", 
       "kernel": "(4, 4)", 
       "layout": "NCHW", 
       "pad": "(4, 4)", 
       "pool_type": "avg", 
       "pooling_convention": "valid", 
       "stride": "(4, 4)"
     }, 
     "inputs": [[46, 0, 0]]
   }
   ```
   I change the "pad": "(4, 4)" to "pad": "(3, 3)" smaller than "kernel": "(4, 
4), then try convert again.
   ```
   sess = ort.InferenceSession("./model.onnx")
   output = sess.run(None, {"data": data.astype(np.float32)})
   ``` 
   it worked,but the output value is not right.
   how to fix it ?
   BTW:convert the mxnet model to ncnn all is right(not change 
anything,pad=(4,4),kernel=(4,4))
   
   ### Further information
   python:3.8
   onnx:1.10.2
   mxnet:1.8.0
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@mxnet.apache.org
For additional commands, e-mail: issues-h...@mxnet.apache.org

Reply via email to