This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferization] Add `init` region to bufferization.alloc_tensor
AbandonedPublic

Authored by springerm on Feb 20 2023, 2:09 AM.

Details

Summary

The op no longer has a copy operand. It now has a region instead. Furthermore, dynamic dims can no longer be omitted when copying a tensor.

%0 = bufferization.alloc_tensor(%sz) init {
^bb0(%arg0: tensor<?xf32>):
  bufferization.yield %tensor_to_copy : tensor<?xf32>
} : tensor<?xf32>

This op can be used to force an allocation for arbitrary tensor values. The region makes it compatible with DPS ops.

In case the op should just allocate and not copy, the block argument can be yielded directly.

%0 = bufferization.alloc_tensor(%sz) init {
^bb0(%arg0: tensor<?xf32>):
  bufferization.yield %arg0 : tensor<?xf32>
} : tensor<?xf32>

This op is heavily utilized during bufferization and we rely on readable IR dumps for debugging bufferization issues. Therefore, the parser/printer support a shorter syntax in case the region consists only of the terminator.

%0 = bufferization.alloc_tensor(%sz) copy(%tensor_to_copy) : tensor<?xf32>

This syntax is identical to the previous syntax (before adding the region).

Depends On: D144389

Diff Detail