This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tensor] Fix one-shot bufferization of tensor.reshape.
ClosedPublic

Authored by ingomueller-net on May 26 2023, 1:52 AM.

Details

Summary

I believe that the previous implementation did not work on any input. It
called getMemRefType with layout = {}, presumably with the intention
to create a MemrefType with identity layout. However, the implementation
of that function returns a MemrefType with *unknown* layout if it is
provided with a default-constructed layout attribute. This patch uses
getMemRefTypeWithStaticIdentityLayout instead, with has identical
behavior except for the case of a default-constructed layout, which it
passes on as-is to the MemrefType.

This problem did not surface in the test because tensor.reshape was not
tested with -one-shot-bufferize. This patch introduces a test copied
from the tests for -tesnor-bufferize adapted in as follows: since the
test is run with "bufferize-function-boundaries", a tensor that is
passed into the function is bufferized into a memref with unknown
layout, which wouldn't be a valid intput for memref.reshape, so the
tests now uses a tensor constructed with arith.constant inside of the
function.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2023, 1:52 AM
ingomueller-net requested review of this revision.May 26 2023, 1:52 AM
springerm accepted this revision.May 26 2023, 1:58 AM

A few typos in the commit message, otherwise looks good. Thx!

This revision is now accepted and ready to land.May 26 2023, 1:58 AM