[all-commits] [llvm/llvm-project] ced2fc: [mlir][bufferization] Fix OneShotBufferize when `d...

Christopher Bate via All-commits all-commits at lists.llvm.org
Tue Nov 26 08:46:18 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ced2fc7819d5ddea616ec330f18e08ff284c1868
      https://github.com/llvm/llvm-project/commit/ced2fc7819d5ddea616ec330f18e08ff284c1868
  Author: Christopher Bate <cbate at nvidia.com>
  Date:   2024-11-26 (Tue, 26 Nov 2024)

  Changed paths:
    M mlir/docs/Bufferization.md
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
    M mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
    M mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/test/Dialect/Affine/loop-fusion-4.mlir
    M mlir/test/Dialect/Arith/bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation/dealloc-other.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-analysis.mlir
    A mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-encodings.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-partial.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-analysis.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-force-copy-before-write.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
    M mlir/test/Dialect/Bufferization/canonicalize.mlir
    M mlir/test/Dialect/Bufferization/ops.mlir
    M mlir/test/Dialect/ControlFlow/one-shot-bufferize.mlir
    M mlir/test/Dialect/Linalg/bufferize.mlir
    M mlir/test/Dialect/Linalg/canonicalize.mlir
    M mlir/test/Dialect/MemRef/normalize-memrefs.mlir
    M mlir/test/Dialect/SCF/bufferize.mlir
    A mlir/test/Dialect/SCF/one-shot-bufferize-encodings.mlir
    M mlir/test/Dialect/Shape/bufferize.mlir
    M mlir/test/Dialect/SparseTensor/GPU/gpu_matmul24_lib.mlir
    M mlir/test/Dialect/SparseTensor/GPU/gpu_matmul_lib.mlir
    M mlir/test/Dialect/SparseTensor/GPU/gpu_matvec_lib.mlir
    M mlir/test/Dialect/SparseTensor/GPU/gpu_sampled_matmul_lib.mlir
    M mlir/test/Dialect/SparseTensor/GPU/gpu_sddmm_lib.mlir
    M mlir/test/Dialect/SparseTensor/constant_index_map.mlir
    M mlir/test/Dialect/SparseTensor/dense.mlir
    M mlir/test/Dialect/SparseTensor/fuse_sparse_pad_with_consumer.mlir
    M mlir/test/Dialect/SparseTensor/sorted_coo.mlir
    M mlir/test/Dialect/SparseTensor/sparse_1d.mlir
    M mlir/test/Dialect/SparseTensor/sparse_2d.mlir
    M mlir/test/Dialect/SparseTensor/sparse_3d.mlir
    M mlir/test/Dialect/SparseTensor/sparse_affine.mlir
    M mlir/test/Dialect/SparseTensor/sparse_batch.mlir
    M mlir/test/Dialect/SparseTensor/sparse_fp_ops.mlir
    M mlir/test/Dialect/SparseTensor/sparse_fusion.mlir
    M mlir/test/Dialect/SparseTensor/sparse_int_ops.mlir
    M mlir/test/Dialect/SparseTensor/sparse_kernels.mlir
    M mlir/test/Dialect/SparseTensor/sparse_kernels_to_iterator.mlir
    M mlir/test/Dialect/SparseTensor/sparse_lower.mlir
    M mlir/test/Dialect/SparseTensor/sparse_lower_col.mlir
    M mlir/test/Dialect/SparseTensor/sparse_lower_inplace.mlir
    M mlir/test/Dialect/SparseTensor/sparse_nd.mlir
    M mlir/test/Dialect/SparseTensor/sparse_outbuf.mlir
    M mlir/test/Dialect/SparseTensor/sparse_pack.mlir
    M mlir/test/Dialect/SparseTensor/sparse_parallel_reduce.mlir
    M mlir/test/Dialect/SparseTensor/sparse_perm.mlir
    M mlir/test/Dialect/SparseTensor/sparse_perm_lower.mlir
    M mlir/test/Dialect/SparseTensor/sparse_scalars.mlir
    M mlir/test/Dialect/SparseTensor/sparse_sddmm.mlir
    M mlir/test/Dialect/SparseTensor/sparse_sddmm_org.mlir
    M mlir/test/Dialect/SparseTensor/sparse_vector_chain.mlir
    M mlir/test/Dialect/SparseTensor/sparse_vector_index.mlir
    M mlir/test/Dialect/SparseTensor/spy_sddmm.mlir
    M mlir/test/Dialect/SparseTensor/spy_sddmm_bsr.mlir
    M mlir/test/Dialect/SparseTensor/unused-tensor.mlir
    M mlir/test/Dialect/SparseTensor/vectorize_reduction.mlir
    M mlir/test/Dialect/Tensor/bufferize.mlir
    A mlir/test/Dialect/Tensor/one-shot-bufferize-encodings.mlir
    M mlir/test/Dialect/Tensor/one-shot-bufferize.mlir
    M mlir/test/Dialect/Vector/bufferize.mlir
    M mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/sparse-matvec-const.mlir
    M mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/sparse-mma-2-4-f16.mlir
    M mlir/test/Integration/Dialect/Tosa/CPU/test-maxpool-dynamic.mlir
    M mlir/test/Integration/Dialect/Vector/CPU/AMX/mulf-full.mlir
    M mlir/test/Integration/Dialect/Vector/CPU/AMX/muli-full.mlir

  Log Message:
  -----------
  [mlir][bufferization] Fix OneShotBufferize when `defaultMemorySpaceFn` is used (#91524)

As described in issue llvm/llvm-project#91518, a previous PR
llvm/llvm-project#78484 introduced the `defaultMemorySpaceFn` into
bufferization options, allowing one to inform OneShotBufferize that it
should use a specified function to derive the memory space attribute
from the encoding attribute attached to tensor types.

However, introducing this feature exposed unhandled edge cases,
examples of which are introduced by this change in the new test under

`test/Dialect/Bufferization/Transforms/one-shot-bufferize-encodings.mlir`.

Fixing the inconsistencies introduced by `defaultMemorySpaceFn` is
pretty simple. This change:

- Updates the `bufferization.to_memref` and `bufferization.to_tensor`
  operations to explicitly include operand and destination types,
  whereas previously they relied on type inference to deduce the
  tensor types. Since the type inference cannot recover the correct
  tensor encoding/memory space, the operand and result types must be
  explicitly included. This is a small assembly format change, but it
  touches a large number of test files.

- Makes minor updates to other bufferization functions to handle the
  changes in building the above ops.

- Updates bufferization of `tensor.from_elements` to handle memory
  space.


Integration/upgrade guide:

In downstream projects, if you have tests or MLIR files that explicitly
use
`bufferization.to_tensor` or `bufferization.to_memref`, then update
them to the new assembly format as follows:

```
%1 = bufferization.to_memref %0 : memref<10xf32>
%2 = bufferization.to_tensor %1 : memref<10xf32>
```

becomes

```
%1 = bufferization.to_memref %0 : tensor<10xf32> to memref<10xf32>
%2 = bufferization.to_tensor %0 : memref<10xf32> to tensor<10xf32> 
```



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list