[all-commits] [llvm/llvm-project] 2443d9: [mlir] Use RankedTensorType when rank is required

Matthias Springer via All-commits all-commits at lists.llvm.org
Wed Apr 5 21:27:38 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2443d946f9156dcc1352a6c9abffdc05f0b52d69
      https://github.com/llvm/llvm-project/commit/2443d946f9156dcc1352a6c9abffdc05f0b52d69
  Author: Matthias Springer <springerm at google.com>
  Date:   2023-04-06 (Thu, 06 Apr 2023)

  Changed paths:
    M mlir/examples/toy/Ch2/mlir/Dialect.cpp
    M mlir/examples/toy/Ch3/mlir/Dialect.cpp
    M mlir/examples/toy/Ch4/mlir/Dialect.cpp
    M mlir/examples/toy/Ch5/mlir/Dialect.cpp
    M mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
    M mlir/examples/toy/Ch6/mlir/Dialect.cpp
    M mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
    M mlir/examples/toy/Ch7/mlir/Dialect.cpp
    M mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
    M mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td
    M mlir/include/mlir/IR/OpBase.td
    M mlir/lib/Conversion/TensorToSPIRV/TensorToSPIRV.cpp
    M mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
    M mlir/test/Dialect/Tensor/invalid.mlir

  Log Message:
  -----------
  [mlir] Use RankedTensorType when rank is required

`RankedTensorOf` and `TensorRankOf` (in Tablegen files) now generate code that uses `RankedTensorType` instead of `TensorType`. This gives us more accurate type information (e.g., when calling `op.getType()`).

Also use restrict tensor.expand_shape/tensor.collapse_shape/tensor.pad to ranked tensors. Only cast ops should deal with unranked tensors.

Also improves a few places in the code base (e.g., Toy tutorial) where a ranked tensor is assumed (e.g., because `getRank` is called) but a `TensorType` is currently used: cast to `RankedTensorType` directly, so that the assertion is triggered directly at the cast.

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




More information about the All-commits mailing list