-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ONNX] Extend ONNX Frontend with com.microsoft.Pad
#22000
Conversation
This PR will be closed in a week because of 2 weeks of no activity. |
This PR will be closed in a week because of 2 weeks of no activity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @siddhant-0707, thank you for your contribution!
MS ONNX Pad and ONNX standard Pad-11 seem to be compatible. The only difference I can see is that MS Pad allows pads input to be 2D
, then the first dim is required to be 1
, so it could be simply resolved by Squeeze. My suggestion is to reuse set_11::pad
code within a common function to avoid duplication of the main logic. Squeeze can be applied to the MS pads input if needed, before the common part.
Also this PR doesn't have any tests for the provided changes, please add them including the mentioned 2D pads scenario.
Registration of the correct pad function should be ensured.
@@ -585,6 +585,7 @@ OperatorsBridge::OperatorsBridge() { | |||
REGISTER_OPERATOR_WITH_DOMAIN(MICROSOFT_DOMAIN, "FusedConv", 1, fused_conv); | |||
REGISTER_OPERATOR_WITH_DOMAIN(MICROSOFT_DOMAIN, "FusedGemm", 1, fusedgemm); | |||
REGISTER_OPERATOR_WITH_DOMAIN(MICROSOFT_DOMAIN, "EmbedLayerNormalization", 1, embed_layer_normalization); | |||
REGISTER_OPERATOR_WITH_DOMAIN(MICROSOFT_DOMAIN, "Pad", 1, pad); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new file src/frontends/onnx/frontend/src/op/com.microsoft/pad.hpp
is not included here, so the created function is not visible.
It means that set_1::pad
from /onnx/frontend/src/op/pad.hpp
has been registered instead.
openvino/src/frontends/onnx/frontend/src/op/pad.cpp
Lines 39 to 40 in ea3601e
namespace set_1 { | |
ov::OutputVector pad(const ov::frontend::onnx::Node& node) { |
To distinguish the pad function dedicated for conversion of MS Op, my suggestion is to put it in a different namespace or change name of the function, and register like:
REGISTER_OPERATOR_WITH_DOMAIN(MICROSOFT_DOMAIN, "Pad", 1, pad); | |
register_operator_in_custom_domain("Pad", VersionRange::single_version_for_all_opsets(), op::custom::set_1::pad, MICROSOFT_DOMAIN); |
throw ngraph_error("Unsupported pad_mode in ONNX com.microsoft.Pad operator"); | ||
} | ||
|
||
auto pads_shape = pads.get_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .get_shape()
will throw for dynamic shape, it should be used only if static shape is ensured,
.get_partial_shape()
can be used instead.
For partial shape .is_static()
or .is_dynamic()
can be used and .size()
is safe only for shapes with static rank.
To check whether the rank is static: partial_shape.rank().is_static()
.
This PR will be closed in a week because of 2 weeks of no activity. |
This PR was closed because it has been stalled for 2 week with no activity. |
hey @siddhant-0707 :) |
Apologies for the delay @mlukasze, I was a little occupied with other tasks. Please reopen the PR. |
Also added 2d and 1d tests |
Hello @siddhant-0707, great to see some updates! Reopened the PR as you asked. |
build_jenkins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My previous concern (#22000 (comment)) about get_shape()
call has been not applied.
Please add suggested change to avoid further issues.
About creating the common pad function, it could be a helper taking ov::OutputVector
as argument, and called from the onnx standard pad and custom pad (after get_ov_inputs()).
But such code unification can be considered as follow up improvement within a separate PR.
Let's focus on the last necessary change:)
Co-authored-by: Katarzyna Mitrus <katarzyna.mitrus@intel.com>
build_jenkins |
build_jenkins |
…#22000) ### Details: - created implementation for `com.microsoft.Pad` - creating test ### Tickets: - Closes openvinotoolkit#17576 --------- Co-authored-by: Georgy Krivoruchko <georgy.krivoruchko@intel.com> Co-authored-by: Katarzyna Mitrus <katarzyna.mitrus@intel.com>
…#22000) ### Details: - created implementation for `com.microsoft.Pad` - creating test ### Tickets: - Closes openvinotoolkit#17576 --------- Co-authored-by: Georgy Krivoruchko <georgy.krivoruchko@intel.com> Co-authored-by: Katarzyna Mitrus <katarzyna.mitrus@intel.com>
Details:
com.microsoft.Pad
Tickets:
com.microsoft.Pad
operator #17576