Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Why Model Optimizer Gave Shape Conflict When Customized ONNX Model Converted to OpenVINO IR Model?

Ben__Hsu
Beginner
660 Views

I converted the Pytorch model (CIResNet22_RPN.pth) from SiamDW Project to ONNX model successfully and got the artifact (siamdw.onnx as attached).

Then, i kept converting ONNX model (siamdw.onnx) to OpenVINO IR model with the bellowed command.

$ cd dldt/model-optimizer
$ python3 mo_onnx.py --input_model '~/SiamDW/models/siamdw.onnx' --log_level DEBUG

 

I get the following errors.

[ ERROR ]  Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.DecomposeBias.DecomposeBias'>): After partial shape inference were found shape collision for node 475 (old shape: [  1 256  -2  -2], new shape: [  1 256  -1  -1])
[ 2020-04-27 17:48:03,119 ] [ DEBUG ] [ main:317 ]  Traceback (most recent call last):
  File "~/dldt/model-optimizer/mo/utils/class_registration.py", line 291, in apply_transform
    for_graph_and_each_sub_graph_recursively(graph, lambda G: G.clean_up())
  File "~/dldt/model-optimizer/mo/middle/pattern_match.py", line 58, in for_graph_and_each_sub_graph_recursively
    func(graph)
  File "~/dldt/model-optimizer/mo/utils/class_registration.py", line 291, in <lambda>
    for_graph_and_each_sub_graph_recursively(graph, lambda G: G.clean_up())
  File "~/dldt/model-optimizer/mo/graph/graph.py", line 972, in clean_up
    shape_inference(self)
  File "~/dldt/model-optimizer/mo/middle/passes/eliminate.py", line 176, in shape_inference
    "{}, new shape: {})".format(node.name, shape1, shape2))
mo.utils.error.Error: After partial shape inference were found shape collision for node 475 (old shape: [  1 256  -2  -2], new shape: [  1 256  -1  -1])

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "~/dldt/model-optimizer/mo/main.py", line 307, in main
    return driver(argv)
  File "~/dldt/model-optimizer/mo/main.py", line 272, in driver
    ret_res = emit_ir(prepare_ir(argv), argv)
  File "~/dldt/model-optimizer/mo/main.py", line 237, in prepare_ir
    graph = unified_pipeline(argv)
  File "~/dldt/model-optimizer/mo/pipeline/unified.py", line 29, in unified_pipeline
    class_registration.ClassType.BACK_REPLACER
  File "~/dldt/model-optimizer/mo/utils/class_registration.py", line 334, in apply_replacements
    apply_replacements_list(graph, replacers_order)
  File "~/dldt/model-optimizer/mo/utils/class_registration.py", line 324, in apply_replacements_list
    num_transforms=len(replacers_order))
  File "~/dldt/model-optimizer/mo/utils/logger.py", line 124, in wrapper
    function(*args, **kwargs)
  File "~/dldt/model-optimizer/mo/utils/class_registration.py", line 304, in apply_transform
    )) from err
mo.utils.error.Error: Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.DecomposeBias.DecomposeBias'>): After partial shape inference were found shape collision for node 475 (old shape: [  1 256  -2  -2], new shape: [  1 256  -1  -1])

 

I check the node name 475 via Netron model viewer viewing siamdw.onnx and it shows the edge propagated conv operator to shape operator.

To identify the operator, i dump the node at ~/dldt/model-optimizer/mo/middle/passes/eliminate.py line 176.

But It shows Add operator that confused me?

{'kind': 'op', 'op': 'Add', 'type': 'Add', 'infer': <function Elementwise.__init__.<locals>.<lambda> at 0x7fc67ac83840>, 'type_infer': <function Elementwise.type_infer at 0x7fc67fb59598>, 'can_be_bias': True, 'can_be_fused': True, 'in_ports_count': 2, 'out_ports_count': 1, 'is_eltwise': True, 'stop_value_propagation': False, 'name': '475', 'dim_attrs': ['channel_dims', 'batch_dims', 'axis', 'spatial_dims'], 'shape_attrs': ['pad', 'output_shape', 'window', 'shape', 'stride'], 'IE': [('layer', [('id', <function Op.substitute_ie_attrs.<locals>.<lambda> at 0x7fc67a9ea620>), 'name', 'type', 'version'], [('data', [], []), '@ports', '@consts'])], '_in_ports': {0: {}, 1: {}}, '_out_ports': {0: {}}, 'need_shape_inference': True, 'is_output_reachable': True}

 

So my questions are: 

1. Which node is the root cause of shape conflict?

2. Why the old shape has partial negative values [ 1 256 -2 -2] and how OpenVINO Model Optimizer infers the new shape [ 1 256 -1 -1]?

 

PS: The toolkits i have tried are OpenVINO 2020.1, 2020.2 and dldt master and 2020 latest branches and all of them gave the same result.

 

Any idea in appreciation.

Ben.

0 Kudos
1 Reply
SIRIGIRI_V_Intel
Employee
660 Views

The reason for this issue was mentioned in this thread. Kindly check the thread and let us know in case of any questions.

Regards,

Ram prasad

0 Kudos
Reply