Page MenuHomePhabricator

[mlir] Add translation from tensor.reshape to memref.reshape
ClosedPublic

Authored by ashay-github on May 5 2022, 11:50 AM.

Details

Summary

This patch augments the tensor-bufferize pass by adding a conversion
rule to translate ReshapeOp from the tensor dialect to the memref
dialect, in addition to adding a unit test to validate the translation.

Diff Detail

Event Timeline

ashay-github created this revision.May 5 2022, 11:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2022, 11:50 AM
ashay-github requested review of this revision.May 5 2022, 11:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2022, 11:50 AM
springerm added inline comments.May 6 2022, 1:17 AM
mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
752

If opOperand is shape, we should return true here. For the source, we can return false.

774

nit: We should return failure() if state.getBuffer fails.

I will update the remaining implementations in this file at some point....

776

same as above

fix bufferizesToMemoryRead() and bufferize()

This patch changes the bufferizesToMemoryRead() method so that it returns true
for the shape operand. It also makes bufferize() return false if
BufferizationState::getBuffer() returns a failure.

ashay-github marked 3 inline comments as done.May 6 2022, 9:31 AM

Thanks! Fixed the code as per the suggestions. PTAL.

springerm accepted this revision.May 7 2022, 3:50 AM

thanks!

This revision is now accepted and ready to land.May 7 2022, 3:50 AM

Thanks @springerm! Could you commit the change please? I don't yet have write access to the repo.

This revision was automatically updated to reflect the committed changes.

Thanks @springerm! Could you commit the change please? I don't yet have write access to the repo.

done!