diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -946,7 +946,8 @@ let dependentDialects = [ "AffineDialect", "memref::MemRefDialect", - "scf::SCFDialect" + "scf::SCFDialect", + "tensor::TensorDialect" ]; let options = [ Option<"fullUnroll", "full-unroll", "bool", /*default=*/"false", diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -19,6 +19,7 @@ #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/IR/SCF.h" +#include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Vector/Transforms/VectorTransforms.h" #include "mlir/IR/Builders.h" #include "mlir/IR/ImplicitLocOpBuilder.h" diff --git a/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir b/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir --- a/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir +++ b/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir @@ -498,3 +498,16 @@ } return %token : !async.token } + +// ----- + +// CHECK-LABEL: transfer_read_with_tensor +func.func @transfer_read_with_tensor(%arg: tensor) -> vector<1xf32> { + // CHECK: %[[EXTRACTED:.*]] = tensor.extract %{{.*}}[] : tensor + // CHECK-NEXT: %[[RESULT:.*]] = vector.broadcast %[[EXTRACTED]] : f32 to vector<1xf32> + // CHECK-NEXT: return %[[RESULT]] : vector<1xf32> + %f0 = arith.constant 0.0 : f32 + %0 = vector.transfer_read %arg[], %f0 {permutation_map = affine_map<()->(0)>} : + tensor, vector<1xf32> + return %0: vector<1xf32> +}