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.
6403 Discussions

Question about converting slice operator from onnx to Open Vino

Chen__Xiwu
Beginner
1,078 Views

Hi,

I'm converting a pytorch model containing slice operator. I convert it to onnx firstly. But it seems that Open Vino doesn't support slice operator from onnx. Is this my misunderstanding about Open Vino? Or is there any alternative way to do?

Thanks

Xiwu

Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      ...
        - Path for generated IR:        ...
        - IR output name:       model_best
        - Log level:    DEBUG
        - Batch:        Not specified, inherited from the model
        - Input layers:         Not specified, inherited from the model
        - Output layers:        Not specified, inherited from the model
        - Input shapes:         [1,3,1024,768]
        - Mean values:  Not specified
        - Scale values:         Not specified
        - Scale factor:         Not specified
        - Precision of IR:      FP32
        - Enable fusing:        True
        - Enable grouped convolutions fusing:   True
        - Move mean values to preprocess section:       False
        - Reverse input channels:       False
ONNX specific parameters:
Model Optimizer version:        2019.2.0-436-gf5827d4
[ 2019-09-19 14:32:01,489 ] [ DEBUG ] [ infer:32 ]  input[2]: shape = [1], value = [2.382705e-05]
[ 2019-09-19 14:32:01,489 ] [ DEBUG ] [ infer:144 ]  Outputs:
[ 2019-09-19 14:32:01,489 ] [ DEBUG ] [ infer:32 ]  output[0]: shape = [  1   1 130  98], value = <UNKNOWN>
[ 2019-09-19 14:32:01,489 ] [ DEBUG ] [ infer:129 ]  --------------------
[ 2019-09-19 14:32:01,489 ] [ DEBUG ] [ infer:130 ]  Partial infer for 128
[ 2019-09-19 14:32:01,489 ] [ DEBUG ] [ infer:131 ]  Op: ShapeOf
[ 2019-09-19 14:32:01,490 ] [ DEBUG ] [ infer:142 ]  Inputs:
[ 2019-09-19 14:32:01,490 ] [ DEBUG ] [ infer:32 ]  input[0]: shape = [  1   1 130  98], value = <UNKNOWN>
[ 2019-09-19 14:32:01,490 ] [ DEBUG ] [ infer:144 ]  Outputs:
[ 2019-09-19 14:32:01,490 ] [ DEBUG ] [ infer:32 ]  output[0]: shape = [4], value = [  1   1 130  98]
[ 2019-09-19 14:32:01,490 ] [ DEBUG ] [ infer:129 ]  --------------------
[ 2019-09-19 14:32:01,490 ] [ DEBUG ] [ infer:130 ]  Partial infer for 132
[ 2019-09-19 14:32:01,490 ] [ DEBUG ] [ infer:131 ]  Op: Slice
[ WARNING ]  Incorrect number of input nodes in slice operation
[ 2019-09-19 14:32:01,491 ] [ DEBUG ] [ infer:142 ]  Inputs:
[ 2019-09-19 14:32:01,491 ] [ DEBUG ] [ infer:32 ]  input[0]: shape = [4], value = [  1   1 130  98]
[ 2019-09-19 14:32:01,491 ] [ DEBUG ] [ infer:32 ]  input[1]: shape = [1], value = [2]
[ 2019-09-19 14:32:01,491 ] [ DEBUG ] [ infer:32 ]  input[2]: shape = [1], value = [4]
[ 2019-09-19 14:32:01,491 ] [ DEBUG ] [ infer:32 ]  input[3]: shape = [1], value = [0]
[ 2019-09-19 14:32:01,491 ] [ DEBUG ] [ infer:144 ]  Outputs:
[ 2019-09-19 14:32:01,492 ] [ DEBUG ] [ infer:32 ]  output[0]: shape = <UNKNOWN>, value = <UNKNOWN>
[ ERROR ]  Shape is not defined for output 0 of "132".
[ ERROR ]  Cannot infer shapes or values for node "132".
[ ERROR ]  Not all output shapes were inferred or fully defined for node "132".
 For more information please refer to Model Optimizer FAQ (https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html), question #40.
[ ERROR ]  It can happen due to bug in custom shape infer function <function Slice.infer at 0x7f8e3f36aa60>.
[ ERROR ]  Or because the node inputs have incorrect values/shapes.
[ ERROR ]  Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ 2019-09-19 14:32:01,492 ] [ DEBUG ] [ infer:196 ]  Node "132" attributes: {'_out_ports': {0: {'control_flow': False}}, 'start': None, 'out_ports_count': 1, 'precision': 'FP32', 'shape_attrs': ['pad', 'window', 'output_shape', 'stride',
'shape'], 'op': 'Slice', 'is_const_producer': False, 'IE': [('layer', [('id', <function Op.substitute_ie_attrs.<locals>.<lambda> at 0x7f8e3b0d5e18>), 'name', 'precision', 'type'], [('data', ['start', 'end', 'axis'], []), '@ports', '@const
s'])], 'axis': None, 'is_undead': False, 'name': '132', 'is_partial_inferred': False, 'in_ports_count': 3, '_in_ports': {0: {'control_flow': False}, 1: {'control_flow': False}, 2: {'control_flow': False}, 3: {'control_flow': False}}, 'end
': None, 'dim_attrs': ['axis', 'spatial_dims', 'batch_dims', 'channel_dims'], 'is_output_reachable': True, 'type': 'Slice', 'kind': 'op', 'infer': <function Slice.infer at 0x7f8e3f36aa60>, 'pb': input: "128"
input: "130"
input: "131"
input: "129"
output: "132"
op_type: "Slice"
}
[ ERROR ]  Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "132" node.
 For more information please refer to Model Optimizer FAQ (https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html), question #38.
[ 2019-09-19 14:32:01,493 ] [ DEBUG ] [ main:308 ]  Traceback (most recent call last):
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/mo/middle/passes/infer.py", line 168, in partial_infer
    node_name)
mo.utils.error.Error: Not all output shapes were inferred or fully defined for node "132".
 For more information please refer to Model Optimizer FAQ (https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html), question #40.

The above exception was the direct cause of the following exception:
0 Kudos
1 Reply
Shubha_R_Intel
Employee
1,078 Views

Dear Chen, Xiwu

Supported Framework Layers Model Optimizer verifies that Slice is not a supported ONNX layer. However you can still make it work by creating a custom layer.

Here are some resources on how to do that:

https://github.com/david-drew/OpenVINO-Custom-Layers/blob/master/2019.r1.0/README.md

Also I have helped many customers with this slightly dated post:

https://software.intel.com/en-us/forums/computer-vision/topic/805980

The dldt github links are 2018 and we are on 2019 R2.01 now, but it won't be difficult for you to redirect and find the 2019 version of the URLs.

Hope it helps,

Thanks,

Shubha

0 Kudos
Reply