[all-commits] [llvm/llvm-project] 519847: [mlir] materialize strided memref layout as attribute

ftynse via All-commits all-commits at lists.llvm.org
Tue Aug 30 08:20:17 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 519847fefc6da1f82cffb44d31cb923f512557fe
      https://github.com/llvm/llvm-project/commit/519847fefc6da1f82cffb44d31cb923f512557fe
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2022-08-30 (Tue, 30 Aug 2022)

  Changed paths:
    M mlir/docs/Dialects/Linalg/_index.md
    M mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
    M mlir/include/mlir/IR/BuiltinAttributes.h
    M mlir/include/mlir/IR/BuiltinAttributes.td
    M mlir/include/mlir/IR/BuiltinTypes.h
    M mlir/include/mlir/IR/BuiltinTypes.td
    M mlir/lib/AsmParser/AttributeParser.cpp
    M mlir/lib/AsmParser/Parser.h
    M mlir/lib/AsmParser/TokenKinds.def
    M mlir/lib/AsmParser/TypeParser.cpp
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/BuiltinAttributes.cpp
    M mlir/lib/IR/BuiltinTypes.cpp
    M mlir/test/Conversion/FuncToLLVM/func-memref-return.mlir
    M mlir/test/Conversion/FuncToSPIRV/types-to-spirv.mlir
    M mlir/test/Conversion/MemRefToLLVM/convert-dynamic-memref-ops.mlir
    M mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir
    M mlir/test/Dialect/Affine/memref-stride-calculation.mlir
    M mlir/test/Dialect/Affine/ops.mlir
    M mlir/test/Dialect/Bufferization/Transforms/buffer-deallocation.mlir
    M mlir/test/Dialect/Bufferization/canonicalize.mlir
    A mlir/test/Dialect/Builtin/types.mlir
    M mlir/test/Dialect/Linalg/fusion-2-level.mlir
    M mlir/test/Dialect/Linalg/fusion.mlir
    M mlir/test/Dialect/Linalg/loops.mlir
    M mlir/test/Dialect/Linalg/promote.mlir
    M mlir/test/Dialect/Linalg/roundtrip.mlir
    M mlir/test/Dialect/Linalg/standard.mlir
    M mlir/test/Dialect/Linalg/tile-parallel.mlir
    M mlir/test/Dialect/Linalg/tile.mlir
    M mlir/test/Dialect/Linalg/transform-patterns.mlir
    M mlir/test/Dialect/Linalg/transform-promotion.mlir
    M mlir/test/Dialect/MemRef/canonicalize.mlir
    M mlir/test/Dialect/MemRef/fold-memref-alias-ops.mlir
    M mlir/test/Dialect/MemRef/invalid.mlir
    M mlir/test/Dialect/MemRef/ops.mlir
    M mlir/test/Dialect/MemRef/subview.mlir
    M mlir/test/Dialect/SCF/parallel-loop-fusion.mlir
    M mlir/test/Dialect/Vector/vector-transfer-drop-unit-dims-patterns.mlir
    M mlir/test/Dialect/Vector/vector-transfer-flatten.mlir
    M mlir/test/Dialect/Vector/vector-transfer-full-partial-split.mlir
    M mlir/test/IR/core-ops.mlir
    M mlir/test/IR/invalid-builtin-types.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/matmul-vs-matvec.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/rank-reducing-subview.mlir
    M mlir/test/Integration/Dialect/Standard/CPU/test_subview.mlir
    M mlir/test/Integration/Dialect/Vector/CPU/test-transfer-read-1d.mlir
    M mlir/test/Transforms/canonicalize.mlir
    M mlir/test/mlir-cpu-runner/copy.mlir
    M mlir/test/mlir-cpu-runner/memref-reinterpret-cast.mlir
    M mlir/test/python/dialects/memref.py

  Log Message:
  -----------
  [mlir] materialize strided memref layout as attribute

Introduce a new attribute to represent the strided memref layout. Strided
layouts are omnipresent in code generation flows and are the only kind of
layouts produced and supported by a half of operation in the memref dialect
(view-related, shape-related). However, they are internally represented as
affine maps that require a somewhat fragile extraction of the strides from the
linear form that also comes with an overhead. Furthermore, textual
representation of strided layouts as affine maps is difficult to read: compare
`affine_map<(d0, d1, d2)[s0, s1] -> (d0*32 + d1*s0 + s1 + d2)>` with
`strides: [32, ?, 1], offset: ?`. While a rudimentary support for parsing a
syntactically sugared version of the strided layout has existed in the codebase
for a long time, it does not go as far as this commit to make the strided
layout a first-class attribute in the IR.

This introduces the attribute and updates the tests that using the pre-existing
sugared form to use the new attribute instead. Most memref created
programmatically, e.g., in passes, still use the affine form with further
extraction of strides and will be updated separately.

Update and clean-up the memref type documentation that has gotten stale and has
been referring to the details of affine map composition that are long gone.

See https://discourse.llvm.org/t/rfc-materialize-strided-memref-layout-as-an-attribute/64211.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D132864




More information about the All-commits mailing list