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] Add torch.aten.mul.int_float (required to simplify shape calculation of upsample_nearest2d) #3764

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

Conversation

giacs-epic
Copy link
Contributor

As per title. See also PR for torch.aten.mul.float_int.

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 for the PR! I have a few comments, so please take a look and ping me when you'd like to have me re-review.

}
return atenBinaryFloatOperatorFoldHelper(
adaptor.getOperands(),
[](double a, double b) -> double { 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.

I think a is supposed to be an int64_t, so you might need to do something like:

Suggested change
[](double a, double b) -> double { return a * b; });
[](int64_t a, double b) -> double { return static_cast<double>(a) * b; });

Other helpful options for folding:

you can return the right operand if the left operand is statically 1, or if either operand is zero, the result should be zero even if we don't have all constant operands.

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

Choose a reason for hiding this comment

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

This is a bit strange, shouldn't there be a cast on LHS_I64 before passing to arith.mulf ?

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