Skip to content

Conversation

@ljfitz
Copy link
Collaborator

@ljfitz ljfitz commented Dec 27, 2021

In RefineTypes.cpp, the return dtype was being determined for conv2d and maxpool2d, but the shape was not. This code adds static shape computation then the operator arguments provide the required static details.

This may relate to/clash with other possible approaches to #415, where @silvasean talks about revamping shape inference to be more precise, but I don't know what @silvasean had in mind.

Copy link
Collaborator

@ramiro050 ramiro050 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 this! Everything looks good to me, I just have a small style comment below

}

// dim_out =
// floor((dim_in + 2 * padding - dilation * (kernelSize - 1) - 1) / stride) + 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I don't think this is necessary since this information can very easily be determined from the body of the function

Copy link
Collaborator

@ramiro050 ramiro050 left a comment

Choose a reason for hiding this comment

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

Oh also, given that the size calculations are really complicated, it would be nice to have an e2e test with static shapes to make sure our code agrees with PyTorch

https://github.com/llvm/torch-mlir/blob/main/e2e_testing/torchscript/conv.py

@ljfitz
Copy link
Collaborator Author

ljfitz commented Dec 29, 2021

e2e test with static shapes

Thanks @ramiro050 for the review and the suggestion. I've added an e2e test and manually verified that the output of torchscript-module-to-torch-backend-pipeline has information being propagated as expected.

@ljfitz ljfitz requested a review from ramiro050 December 29, 2021 09:43
Copy link
Collaborator

@ramiro050 ramiro050 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for adding this!

@ljfitz
Copy link
Collaborator Author

ljfitz commented Jan 3, 2022

LGTM! Thanks for adding this!

And thanks for the supportive review. I see that I haven't permission to merge the the pull request. Do you know if merging will happen automatically or if I need to take some additional action?

@ramiro050 ramiro050 merged commit ccfdfd1 into llvm:main Jan 3, 2022
@ramiro050
Copy link
Collaborator

And thanks for the supportive review. I see that I haven't permission to merge the the pull request. Do you know if merging will happen automatically or if I need to take some additional action?

Merged!

@ljfitz ljfitz deleted the static_shapes branch January 4, 2022 09:49
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