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

[Torch Dialect] Emit torch.aten.mul.float_int, add folder and conversion to Arith. #3750

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

giacs-epic
Copy link
Contributor

Folder is required to simplify the shape calculation of torch.aten.__interpolate.size_list_scale_list:

" %13 = torch.operator \"aten.mul.float_int\"(%11, %12) : (!torch.float, !torch.int) -> !torch.float \n"
" %14 = torch.aten.Int.float %13 : !torch.float -> !torch.int\n"
" %15 = torch.aten.append.t %3, %14 : !torch.list<int>, !torch.int -> !torch.list<int>\n"
" %16 = torch.aten.__getitem__.t %9, %int1 : !torch.list<float>, !torch.int -> !torch.float\n"
" %17 = torch.aten.__getitem__.t %arg0, %int3 : !torch.list<int>, !torch.int -> !torch.int\n"
" %18 = torch.operator \"aten.mul.float_int\"(%16, %17) : (!torch.float, !torch.int) -> !torch.float \n"
" %19 = torch.aten.Int.float %18 : !torch.float -> !torch.int\n"
" %20 = torch.aten.append.t %3, %19 : !torch.list<int>, !torch.int -> !torch.list<int>\n"

(I've re-run build_tools/update_abstract_interp_lib.sh)

Copy link
Collaborator

@zjgarvey zjgarvey left a comment

Choose a reason for hiding this comment

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

Thanks! Similar comments as on the other PR.

// CHECK-SAME: %[[RHS:.*]]: !torch.int) -> !torch.float {
// CHECK-DAG: %[[LHS_F64:.*]] = torch_c.to_f64 %[[LHS]]
// CHECK-DAG: %[[RHS_I64:.*]] = torch_c.to_i64 %[[RHS]]
// CHECK: %[[MUL:.*]] = arith.mulf %[[LHS_F64:.*]], [[RHS_I64:.*]] : f64
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to the other PR, I'm certain there is an additional arith.sitofp op, and the arguments for arith.mulf shouldn't be assignments of variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correcting here as well.

return nullptr;
}
return atenBinaryFloatOperatorFoldHelper(
adaptor.getOperands(), [](double a, double b) { return a * b; });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to my comment in your other PR, one of the two arguments should be an int64_t, and it would be beneficial to have additional folding options for whenever one of the two operands is 1 or 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See other PR.

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.

2 participants