[all-commits] [llvm/llvm-project] a9205c: [mlir][tensor] Implement constant folder for tenso...

Spenser Bauman via All-commits all-commits at lists.llvm.org
Thu Jun 6 07:22:38 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a9205c5c9d5aeadbb97ed7283a35515df4ba49da
      https://github.com/llvm/llvm-project/commit/a9205c5c9d5aeadbb97ed7283a35515df4ba49da
  Author: Spenser Bauman <sbauman at mathworks.com>
  Date:   2024-06-06 (Thu, 06 Jun 2024)

  Changed paths:
    M mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td
    M mlir/include/mlir/Dialect/Tensor/Transforms/Transforms.h
    M mlir/lib/Dialect/Tensor/TransformOps/TensorTransformOps.cpp
    M mlir/lib/Dialect/Tensor/Transforms/RewriteAsConstant.cpp
    M mlir/lib/Dialect/Utils/IndexingUtils.cpp
    M mlir/test/Dialect/Tensor/rewrite-as-constant.mlir

  Log Message:
  -----------
  [mlir][tensor] Implement constant folder for tensor.pad (#92691)

Extend the folding ability of the RewriteAsConstant patterns to include
tensor.pad operations on constants. The new pattern with constant fold
tensor.pad operations which operate on tensor constants and have
statically resolvable padding sizes/values.

    %init = arith.constant dense<[[6, 7], [8, 9]]> : tensor<2x2xi32>
    %pad_value = arith.constant 0 : i32

    %0 = tensor.pad %init low[1, 1] high[1, 1] {
      ^bb0(%arg1: index, %arg2: index):
        tensor.yield %pad_value : i32
    } : tensor<2x2xi32> to tensor<4x4xi32>

becomes

    %cst = arith.constant dense<[[0, 0, 0, 0],
                                 [0, 6, 7, 0],
                                 [0, 8, 9, 0],
                                 [0, 0, 0, 0]]> : tensor<4x4xi32>

Co-authored-by: Spenser Bauman <sabauma at fastmail>



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