-
Notifications
You must be signed in to change notification settings - Fork 506
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] : Implement lowering of torch.frac op #3847
base: main
Are you sure you want to change the base?
Conversation
Could you please review this pull request? @vivekkhandelwal1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@milinkovicandrea Please rebase your PR.
class ElementwiseFracModule(torch.nn.Module): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
@export | ||
@annotate_args( | ||
[ | ||
None, | ||
([1, 6], torch.float32, True), | ||
] | ||
) | ||
def forward(self, a): | ||
return torch.frac(a) | ||
|
||
|
||
@register_test_case(module_factory=lambda: ElementwiseFracModule()) | ||
def ElementwiseFracModule_basic(module, tu: TestUtils): | ||
module.forward(torch.tensor([[-torch.inf, torch.inf, torch.nan, -2.3, 0.0, 1.5]])) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it take f64 input? If yes, can you please add a test for the same?
@@ -8012,6 +8012,34 @@ class DecomposeAtenTruncOp : public OpRewritePattern<AtenTruncOp> { | |||
}; | |||
} // namespace | |||
|
|||
namespace { | |||
// decompose `frac(x)` to `x - sign(x) * floor(abs(x))` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decomposition written below follows a different implementation. Better to either remove this comment or change it as per the decomposition.
Implement lowering of torch.frac op.
Decompose op inside DecomposeComplexOps.cpp.
Add tests into elementwise.py.