-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for integer division to TCP #97
Add support for integer division to TCP #97
Conversation
Tcp_SignednessAttr:$signedness, | ||
Tcp_RoundingModeAttr:$rounding_mode |
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.
Why do we need a "Ceil" rounding mode here? Are they any cases where that is necessary?
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.
I don't think there's a good use-case for the tcp.diviop
itself to support a ceil rounding mode, given that such a thing does not exist for the torch.div
op. I added it because there is a natural mapping to the arith.ceildiviop
. I can remove it.
However, I think the RoundingMode type itself should have ceil in it for completion though.
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.
LGTM. Some comments inline.
@@ -32,4 +32,22 @@ def Tcp_Signedness : I32EnumAttr<"Signedness", | |||
|
|||
def Tcp_SignednessAttr : EnumAttr<Tcp_Dialect, Tcp_Signedness, "signedness">; | |||
|
|||
// TCP rounding mode | |||
def Tcp_RoundingMode_Trunc : I32EnumAttrCase<"Trunc", 0>; | |||
def Tcp_RoundingMode_Floor : I32EnumAttrCase<"Floor", 1>; |
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.
minor nit: fix spacing here and below
return {b.create<arith::DivSIOp>(loc, payloadArgs[0], payloadArgs[1])}; | ||
else if (divOp.getRoundingMode() == RoundingMode::Ceil) | ||
return { | ||
b.create<arith::CeilDivUIOp>(loc, payloadArgs[0], payloadArgs[1])}; |
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.
Shouldn't this be arith::CeilDivSIOp
instead?
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.
yikes :( thanks for the typo fix.
let arguments = (ins | ||
Tcp_IntTensor:$in1, | ||
Tcp_IntTensor:$in2, | ||
Tcp_RoundingModeAttr:$rounding_mode |
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.
Do we need the rounding mode here? Should we just stick to using trunc
mode for divui
?
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.
Given that the arith dialect has straightforward mapping to ceildiv, why not just have it for the sake of expressibility? I do not have a strong opinion on this though. We could just leave it out now and introduce it later if we find a need for it.
As titled, add support for integer division in TCP. This closely mimics the existing capabilities in pytorch and arith.