Skip to content
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

[onert/backend] Fix checking indices tensor shape in GatherLayer #14284

Merged

Conversation

seockho-kim
Copy link
Contributor

This fixes checking indices tensor shape in GatherLayer.
If dimension count is 4 and dim(0) != 0, it should throw exception, but it didn't.

ONE-DCO-1.0-Signed-off-by: Seockho Kim [email protected]

This fixes checking indices tensor shape in GatherLayer.
If dimension count is 4 and dim(0) != 0, it should throw exception, but it didn't.

ONE-DCO-1.0-Signed-off-by: Seockho Kim [email protected]
@seockho-kim seockho-kim requested a review from a team October 29, 2024 10:46
@@ -83,7 +83,7 @@ void GatherLayer::runByGGMLQuantInputType()
if (getShape(_input).DimensionsCount() != 2)
throw std::runtime_error("Gather: block quantized input tensor must be rank 2");

if (getShape(_indices).DimensionsCount() > 4 &&
if (getShape(_indices).DimensionsCount() >= 4 &&
Copy link
Contributor

@glistening glistening Oct 31, 2024

Choose a reason for hiding this comment

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

A few days ago, I also thought it was wrong at a glance. However, I think it is true.

It is the negation of the condition in comment.

// Indice: rank < 4 or rank 4 with dim(0) = 1, INT32

not (A or B) = (not A) and (not B)

That is,

not (rank < 4) and not (rank == 4 && dim(0) == 1)
⇔ rank >= 4 && (rank != 4 || dim(0) != 1)

You're right!

(ADD) It would be more readable to use

not ((rank < 4) or (rank == 4 && dim(0) == 1))

Copy link
Contributor

@glistening glistening left a comment

Choose a reason for hiding this comment

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

LGTM

@glistening glistening merged commit cf45dcc into Samsung:master Nov 1, 2024
9 checks passed
@seockho-kim seockho-kim deleted the onert_backend_gatherlayer_fix branch November 1, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants