Skip to content

Ngraph reference implementation: OneHot specifications review.#4243

Merged
lazarevevgeny merged 7 commits intoopenvinotoolkit:masterfrom
IvanNovoselov:NgRefRev_OneHot_spec
Feb 15, 2021
Merged

Ngraph reference implementation: OneHot specifications review.#4243
lazarevevgeny merged 7 commits intoopenvinotoolkit:masterfrom
IvanNovoselov:NgRefRev_OneHot_spec

Conversation

@IvanNovoselov
Copy link
Copy Markdown
Contributor

@IvanNovoselov IvanNovoselov commented Feb 9, 2021

Updated specifications for the OneHot operation. The most notable changes are:

  • Input indices must be non-negative, since it is assumed in the ref and CPU plugin implementations.
  • The depth must be positive (explicit check in the ngraph class).

@openvino-pushbot openvino-pushbot added the ExternalIntelPR External contributor from Intel label Feb 9, 2021
@IvanNovoselov IvanNovoselov marked this pull request as ready for review February 9, 2021 11:32
@IvanNovoselov IvanNovoselov requested a review from a team as a code owner February 9, 2021 11:32
@IvanNovoselov IvanNovoselov requested a review from iefode February 9, 2021 11:33
@openvino-pushbot openvino-pushbot added the category: docs OpenVINO documentation label Feb 9, 2021
@IvanNovoselov IvanNovoselov removed the ExternalIntelPR External contributor from Intel label Feb 9, 2021
@iefode
Copy link
Copy Markdown
Contributor

iefode commented Feb 10, 2021

@lazarevevgeny Could you please take a look?

Copy link
Copy Markdown
Contributor

@lazarevevgeny lazarevevgeny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes looks good, but miss section about supported data types.

Comment thread docs/ops/sequence/OneHot_1.md
Comment thread docs/ops/sequence/OneHot_1.md
@IvanNovoselov
Copy link
Copy Markdown
Contributor Author

Just noticed that some constant_folding tests do pass negative indices to OneHot. This seems a little bit strange, since all negative indices will be statically casted to huge size_t numbers, and almost certainly ignored (at least for reasonable depth values, not smth like 2^30). I’m not sure if this negative-indices feature is needed, but if it does, I suggest to add smth like “When some elements from the indices are negative, or greater or equal to the depth it is a well-formed operation…”.
@lazarevevgeny, what do you think?

@IvanNovoselov IvanNovoselov requested review from a team and lazarevevgeny February 12, 2021 07:30
@lazarevevgeny
Copy link
Copy Markdown
Contributor

Just noticed that some constant_folding tests do pass negative indices to OneHot. This seems a little bit strange, since all negative indices will be statically casted to huge size_t numbers, and almost certainly ignored (at least for reasonable depth values, not smth like 2^30). I’m not sure if this negative-indices feature is needed, but if it does, I suggest to add smth like “When some elements from the indices are negative, or greater or equal to the depth it is a well-formed operation…”.
@lazarevevgeny, what do you think?

CC @dmitry-gorokhov, @nshchego, @andrei-kochin One more example with negative indices like with Gather operation.

@IvanNovoselov We preliminary agreed to that the behaviour with negative indices is undefined, because different plugins may work differently since we don't support negative indices.

@IvanNovoselov
Copy link
Copy Markdown
Contributor Author

IvanNovoselov commented Feb 12, 2021

@lazarevevgeny could you please clarify what this undefined behavior means from the implementation point of view? Specifically, I would suggest:

  1. The ref. implementation should not throw on negative indices, but have to ignore them silently (since they are not supported).
  2. Negative indices should be eliminated from the constant folding tests for one_hot, because undefined behavior should not be tested.
  3. This behavior should be explicitly stated in the specs, smth like "Behavior for negative indices is undefined."

Please, correct me if I'm getting smth wrong.

@lazarevevgeny
Copy link
Copy Markdown
Contributor

@lazarevevgeny could you please clarify what this undefined behavior means from the implementation point of view? Specifically, I would suggest:

  1. The ref. implementation should not throw on negative indices, but have to ignore them silently (since they are not supported).
  2. Negative indices should be eliminated from the constant folding tests for one_hot, because undefined behavior should not be tested.
  3. This behavior should be explicitly stated in the specs, smth like "Behavior for negative indices is undefined."

Please, correct me if I'm getting smth wrong.

Agree. Let's write 0 value to elements corresponding to negative elements.

Copy link
Copy Markdown
Contributor Author

@IvanNovoselov IvanNovoselov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the suggested corrections were addressed.

@IvanNovoselov
Copy link
Copy Markdown
Contributor Author

@lazarevevgeny, please take a look at the corrected version, and approve the changes if everything is Ok.

@lazarevevgeny
Copy link
Copy Markdown
Contributor

Please, revert commit of the mkl-dnn.

Copy link
Copy Markdown
Contributor

@lazarevevgeny lazarevevgeny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor comments to the spec + major comment for the mkl-dnn. But approve in advance.

Comment thread docs/ops/sequence/OneHot_1.md Outdated
Comment thread docs/ops/sequence/OneHot_1.md Outdated
@ilyachur
Copy link
Copy Markdown
Contributor

Looks like you changed the mkl-dnn submodule by mistake.

@IvanNovoselov
Copy link
Copy Markdown
Contributor Author

@ilyachur, you are right. Fixed.

@lazarevevgeny lazarevevgeny merged commit 9e87ddf into openvinotoolkit:master Feb 15, 2021
@IvanNovoselov IvanNovoselov deleted the NgRefRev_OneHot_spec branch March 25, 2021 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: docs OpenVINO documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants