-
Notifications
You must be signed in to change notification settings - Fork 593
Add lowering of aten.Int.Tensor
op.
#387
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
Conversation
Hi @ALL, I have tried to come up with the lowering seeing pytorch/TensorRT#513. I was not able to find the respective torch python function that can emit |
fb046bd
to
16f543e
Compare
The python function that generates the def forward(self, x):
return int(x) where func private @__torch__.MyModule.forward(%arg0: !torch.nn.Module<"__torch__.MyModule">, %arg1: !torch.tensor {torch.type_bound = !torch.vtensor<[],f32>}) -> !torch.int {
%1 = torch.operator "aten.Int.Tensor"(%arg1) : (!torch.tensor) -> !torch.int
return %1 : !torch.int
} Although, I don't know if the |
Hey, thanks for this. Sure, let me check. |
16f543e
to
e65aa17
Compare
Yes, this seems to be an issue. The return type should be Memref type.
I can rewrap the integer into a tensor and return, but there is another op that pops up |
be47b7c
to
1d6b97b
Compare
The lowering of `aten.Int.Tensor` op has been added. The changes has been made as a part of `convert-torch-to-linalg` pass. Signed-off-by: Prashant Kumar <[email protected]>
1d6b97b
to
96abfca
Compare
def forward(self, x, y): | ||
# This is a workaround for not returning scalar value. | ||
a = int(x) | ||
return y.add(y, alpha=a) |
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.
this is pretty clever :)
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.
@ramiro050 All thanks to @cathyzhyi.
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.
It was originally @silvasean 's idea!
Co-authored-by: Tian Jin <[email protected]>
The lowering of
aten.Int.Tensor
op has been added.The changes has been made as a part of
convert-torch-to-linalg
pass.