-
Notifications
You must be signed in to change notification settings - Fork 605
Add onnx GridSample support for border padding mode #3819
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
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.
Thanks for adding this support!
I have a couple of changes to request, and I'd also like you to sync your branch with head of main to avoid the failing CI.
Value zeroInt = | ||
b.create<arith::ConstantOp>(loc, b.getIntegerAttr(int64type, 0)); |
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 might be better to keep this constant outside the lambda function, and just get it from the capture (otherwise you will re-write the constant multiple times in the IR).
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.
Since paddingMode is checked at compile time, I have removed zeroInt completely.
Thanks for the feedback! I'll work on the requested changes. |
Evaluate paddingMode at compile time
@@ -2587,10 +2587,30 @@ class ConvertAtenGridSamplerOp : public OpConversionPattern<AtenGridSamplerOp> { | |||
return res; | |||
}; | |||
|
|||
auto lambdaBorder = [&](OpBuilder &b, Location loc, Value x, | |||
Value SizeSubOne) -> Value { |
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.
SizeSubOne -> sizeSubOne
auto resultType = cast<RankedTensorType>( | ||
getTypeConverter()->convertType(op.getResult().getType())); | ||
Value alignCorners = adaptor.getAlignCorners(); | ||
Value interMode = adaptor.getInterpolationMode(); | ||
|
||
int64_t paddingModeInt; | ||
matchPattern(op.getPaddingMode(), m_TorchConstantInt(&paddingModeInt)); |
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 not put this inside an if and return failure?
I completely agree with you, but I accidentally removed the branch and the PR was automatically closed, and I can't seem to open it again, even though the branch is restored.... Is it due to the new one being open? |
I think that's happening probably because the link between your past and the restored one is lost. Anyway, you should open any of the PR which you are able to. |
Hey, I reopened the other one. Sorry for the inconvenience. |
Adds support for padding_mode="border"
Clamps the grid coordinates between 0 and size - 1 like this when using this padding mode: