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/core] Fix ShapeValidator of RmsNorm #14217

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions runtime/onert/core/src/compiler/ShapeValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,15 @@ void ShapeValidator::visit(const ir::operation::RmsNorm &node)
const auto ifm_index{node.getInputs().at(ir::operation::RmsNorm::Input::INPUT)};
const auto gamma_index{node.getInputs().at(ir::operation::RmsNorm::Input::GAMMA)};

OP_REQUIRES(operands.at(ifm_index).shape().rank() == 4);
OP_REQUIRES(operands.at(ifm_index).shape() == operands.at(ofm_index).shape());
OP_REQUIRES(operands.at(gamma_index).shape().rank() == 1);
auto ifm_shape = operands.at(ifm_index).shape();
auto ofm_shape = operands.at(ofm_index).shape();
auto gamma_shape = operands.at(gamma_index).shape();
Copy link
Contributor

Choose a reason for hiding this comment

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

(optional) How about adding const reference?

Suggested change
auto ifm_shape = operands.at(ifm_index).shape();
auto ofm_shape = operands.at(ofm_index).shape();
auto gamma_shape = operands.at(gamma_index).shape();
const auto& ifm_shape = operands.at(ifm_index).shape();
const auto& ofm_shape = operands.at(ofm_index).shape();
const auto& gamma_shape = operands.at(gamma_index).shape();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(optional) How about adding const reference?

Okay, I'll update it :)


OP_REQUIRES(ifm_shape.rank() == 3 || ifm_shape.rank() == 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

IDK the background, Is there a reason to support input with rank==3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IDK the background, Is there a reason to support input with rank==3?

Current testing model has "rank = 3" inputs, like A x B x C.

OP_REQUIRES(ifm_shape == ofm_shape);
OP_REQUIRES(gamma_shape.rank() == 1);
OP_REQUIRES((gamma_shape.dim(0) == 1) ||
(gamma_shape.dim(0) == ifm_shape.dim(ifm_shape.rank() - 1)));
}

} // namespace compiler
Expand Down