-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
NormalizeL2 transformation #1892
NormalizeL2 transformation #1892
Conversation
inference-engine/src/transformations/src/transformations/normalize_l2_fusion.cpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/src/transformations/normalize_l2_fusion.cpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/src/transformations/normalize_l2_fusion.cpp
Show resolved
Hide resolved
inference-engine/src/transformations/src/transformations/normalize_l2_fusion.cpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/include/transformations/utils/utils.hpp
Outdated
Show resolved
Hide resolved
inference-engine/src/transformations/include/transformations/utils/utils.hpp
Outdated
Show resolved
Hide resolved
return false; | ||
} | ||
|
||
if (shape_size(constant->get_shape()) > 1) { |
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.
What if the constant is empty? I mean if the size is equal to 0.
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.
@lazarevevgeny As I understand shape_size(constant->get_shape()) == 0
means that it is scalar
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.
Scalar is only if shapes are empty.
But if one dimension is equal to 0, shape_size
also returns 0, if I remember right.
But in any way it is a really strange case.
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.
I think this check is not only for a scalar but constant with any shape like {1, 1, 1} that we can also cast to a single value.
So shape_size
returns "Number of elements in spanned by a 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.
added self-explanatory variable (is_scalar_or_single_elem
) + used is_scalar
helper
return false; | ||
} | ||
|
||
if (shape_size(constant->get_shape()) > 1) { |
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.
Scalar is only if shapes are empty.
But if one dimension is equal to 0, shape_size
also returns 0, if I remember right.
But in any way it is a really strange case.
inference-engine/src/transformations/src/transformations/normalize_l2_fusion.cpp
Show resolved
Hide resolved
auto reduce_sum = std::make_shared<ngraph::opset4::ReduceSum>(pow, axes); | ||
auto sqrt = std::make_shared<ngraph::opset4::Sqrt>(reduce_sum); | ||
auto eps_const = ngraph::pattern::wrap_type<ngraph::opset4::Constant>(); | ||
auto sqrt_add_eps = std::make_shared<ngraph::opset4::Add>(sqrt, eps_const); |
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.
Maybe we can join these two passes if check sqrt_max_eps
or sqrt_add_eps
types in the callback.
@GlebKazantaev what do you think about it?
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.
@GlebKazantaev ping
@ilyachur , @GlebKazantaev , please, take a look. |
I asked @GlebKazantaev to look at this PR. I think we can join two passes from this PR. |
LGTM |
* first version of implementation * added unit tests * changed multiply to pow * doc + unit tests * more unit tests * code review remarks * missing new line * remarks * review remarks * Build fix - update constant check function in HSwishFusionWithClamp Co-authored-by: mitruska <[email protected]>
* first version of implementation * added unit tests * changed multiply to pow * doc + unit tests * more unit tests * code review remarks * missing new line * remarks * review remarks * Build fix - update constant check function in HSwishFusionWithClamp Co-authored-by: mitruska <[email protected]>
No description provided.