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

[PT FE] Add aten::rot90 #28224

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Po-V
Copy link

@Po-V Po-V commented Dec 29, 2024

Details:

  • Add aten::rot90 operator

Tickets:

@Po-V Po-V requested a review from a team as a code owner December 29, 2024 03:49
@Po-V Po-V requested review from mvafin and PiotrKrzem December 29, 2024 03:49
@github-actions github-actions bot added the category: PyTorch FE OpenVINO PyTorch Frontend label Dec 29, 2024
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Dec 29, 2024
Copy link
Contributor

@mvafin mvafin left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, please fix the comments

} else if (k == 2) {
size_t dims_size = dims.size();
auto flip_dims = context.mark_node(v0::Constant::create(element::i32, Shape{dims_size}, dims));
rotated = create_flip(input, flip_dims);
Copy link
Contributor

Choose a reason for hiding this comment

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

This fails to build with error:

/__w/openvino/openvino/openvino/src/frontends/pytorch/src/op/rot90.cpp: In function 'ov::OutputVector ov::frontend::pytorch::op::translate_rot90(const ov::frontend::pytorch::NodeContext&)':
/__w/openvino/openvino/openvino/src/frontends/pytorch/src/op/rot90.cpp:46:24: error: 'create_flip' was not declared in this scope
   46 |         auto flipped = create_flip(input, flip_dims);
      |                        ^~~~~~~~~~~
/__w/openvino/openvino/openvino/src/frontends/pytorch/src/op/rot90.cpp:56:19: error: 'create_flip' was not declared in this scope
   56 |         rotated = create_flip(input, flip_dims);
      |                   ^~~~~~~~~~~

There is no such function as create_flip

num_inputs_check(context, 1, 3);
auto input = context.get_input(0);
int k = context.input_is_none(1) ? 1 : context.const_input<int64_t>(1);
std::vector<int64_t> dims = context.input_is_none(2) ? std::vector<int64_t>{0, 1}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of const_input get dims as Node using get_input and use as is. To avoid requirement for it to be const and to avoid creating a Constant with dims later.

Comment on lines +36 to +38
for (auto& dim : dims) {
dim = (dim + ndims) % ndims;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use normalize_axis function for this after you change dims to be a Node rather then constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: PyTorch FE OpenVINO PyTorch Frontend ExternalPR External contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Good First Issue]: Support aten::rot90 for pytorch models
3 participants