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.

Custom Implementation for ScatterND op

Sharma__Divyanshu
New Contributor I
4,842 Views

Hi!

I am trying to convert an ONNX model to an OpenVino IR model. However, the ONNX model contains an unsupported op 'ScatterND'. Since ScatterND is quite similar to Scatter_Add, I was seeing if I could find the implementation for the Scatter_Add extension (the file with the execute() function). I can't seem to find it. Is it proprietary? 

Also, I can't seem to understand what to do after I've written the custom implementation code. I've already added the op to the Model Optimizer extensions but I don't know how to proceed with building the Inference Engine implementation. Where do I place the file, and how do I build it?

Thanks!

Labels (3)
0 Kudos
1 Solution
Max_L_Intel
Moderator
4,772 Views

Hi @Sharma__Divyanshu 

ScatterND support for MO has been implemented using ScatterNDUpdate. The PR provided includes changes for 11 files in total, not only scatternd.py. So please have a chance to test it out.

View solution in original post

0 Kudos
7 Replies
Munesh_Intel
Moderator
4,829 Views

Hi Divyanshu,


I suggest you try using ScatterND extension implementation that is available in GitHub, at the following link:

https://github.com/openvinotoolkit/openvino/blob/master/model-optimizer/extensions/ops/scatternd.py


For Inference Engine implementation, please refer to the following links for the necessary steps:

  • Common Workflow for Using the Inference Engine API

https://docs.openvinotoolkit.org/2020.4/openvino_docs_IE_DG_inference_engine_intro.html#common_workflow_for_using_the_inference_engine_api


  • Integrate the Inference Engine with Your Application

https://docs.openvinotoolkit.org/2020.4/openvino_docs_IE_DG_Integrate_with_customer_application_new_API.html


Regards,

Munesh


0 Kudos
Sharma__Divyanshu
New Contributor I
4,814 Views

Hi @Munesh_Intel . Thank you so much for replying. I tried using the scatternd.py extension already present.

Since I needed the ScatterND function, I just inherited the ScatterND base class and used its infer function:

 

class ScatterND(ScatterNDBase):
    op = op_type = "ScatterND"
    version = None

    @staticmethod
    def infer(node: Node):
        ScatterNDBase.infer(node)

 

but it still gives the error:

[ ERROR ]  Cannot infer shapes or values for node "ScatterND_748".
[ ERROR ]  There is no registered "infer" function for node "ScatterND_748" with op = "ScatterND". Please implement this function in the extensions.
 For more information please refer to Model Optimizer FAQ (https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html), question #37.
[ ERROR ]
[ ERROR ]  It can happen due to bug in custom shape infer function <UNKNOWN>.
[ 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).
[ ERROR ]  Run Model Optimizer with --log_level=DEBUG for more information.
[ ERROR ]  Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "ScatterND_748" 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.

I don't get what the issue is. The infer function seems to be defined.

Could you help me with this? I've attached the scatternd.py (in txt form because .py are not allowed) and the debug log.

Thanks!

0 Kudos
Max_L_Intel
Moderator
4,790 Views

Hi @Sharma__Divyanshu 

Please try the complete fix from this Github pull request https://github.com/openvinotoolkit/openvino/pull/584

As I see this PR was already merged into the master branch. As for Intel Distribution of OpenVINO toolkit, it is going to be included into next public release.

Hope this helps.
Best regards, Max.

0 Kudos
Sharma__Divyanshu
New Contributor I
4,785 Views

Hi @Max_L_Intel. Thanks for Replying!

I think I do have the changes made by that PR since I have the scatternd.py. However, it seems that the op it introduces has been registered by the name of ScatterNDUpdate. I still can't find ScatterND as a registered op, or the model would have been optimized successfully. Can you please help me with this?

 

Would you like me to send you the ONNX model?

Thanks a lot!

0 Kudos
Max_L_Intel
Moderator
4,773 Views

Hi @Sharma__Divyanshu 

ScatterND support for MO has been implemented using ScatterNDUpdate. The PR provided includes changes for 11 files in total, not only scatternd.py. So please have a chance to test it out.

0 Kudos
Max_L_Intel
Moderator
4,750 Views

This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question.

0 Kudos
Sharma__Divyanshu
New Contributor I
4,741 Views

I get the same error despite building the latest version of the model_optimizer from GitHub 

Reply