[Mlir-commits] [mlir] 51c8af2 - Adopt Properties to store operations inherent Attributes in the Vector dialect

Mehdi Amini llvmlistbot at llvm.org
Mon May 15 15:36:43 PDT 2023


Author: Mehdi Amini
Date: 2023-05-15T15:36:16-07:00
New Revision: 51c8af2763dd7820bea5abf28728b400a86d1ba3

URL: https://github.com/llvm/llvm-project/commit/51c8af2763dd7820bea5abf28728b400a86d1ba3
DIFF: https://github.com/llvm/llvm-project/commit/51c8af2763dd7820bea5abf28728b400a86d1ba3.diff

LOG: Adopt Properties to store operations inherent Attributes in the Vector dialect

This is part of an on-going migration to adopt Properties inside MLIR.

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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
    mlir/lib/Dialect/Vector/IR/VectorOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index e4909a24dbeea..b9bcd2bb5f126 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -29,6 +29,7 @@ def Vector_Dialect : Dialect {
 
   let useDefaultAttributePrinterParser = 1;
   let hasConstantMaterializer = 1;
+  let usePropertiesForAttributes = 1;
   let dependentDialects = ["arith::ArithDialect"];
 }
 

diff  --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index 2d3b27f1af58f..5c139b5897d73 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -1153,8 +1153,9 @@ ExtractOp::inferReturnTypes(MLIRContext *, std::optional<Location>,
                             ValueRange operands, DictionaryAttr attributes,
                             OpaqueProperties properties, RegionRange,
                             SmallVectorImpl<Type> &inferredReturnTypes) {
-  ExtractOp::Adaptor op(operands, attributes);
-  auto vectorType = llvm::cast<VectorType>(op.getVector().getType());
+  ExtractOp::Adaptor op(operands, attributes
+                        *properties.as<ExtractOp::Properties *>());
+  auto vectorType = op.getVector().getType().cast<VectorType>();
   if (static_cast<int64_t>(op.getPosition().size()) == vectorType.getRank()) {
     inferredReturnTypes.push_back(vectorType.getElementType());
   } else {
@@ -2089,8 +2090,9 @@ ShuffleOp::inferReturnTypes(MLIRContext *, std::optional<Location>,
                             ValueRange operands, DictionaryAttr attributes,
                             OpaqueProperties properties, RegionRange,
                             SmallVectorImpl<Type> &inferredReturnTypes) {
-  ShuffleOp::Adaptor op(operands, attributes);
-  auto v1Type = llvm::cast<VectorType>(op.getV1().getType());
+  ShuffleOp::Adaptor op(operands, attributes
+                        *properties.as<ShuffleOp::Properties *>());
+    auto v1Type = op.getV1().getType().cast<VectorType>();
   auto v1Rank = v1Type.getRank();
   // Construct resulting type: leading dimension matches mask
   // length, all trailing dimensions match the operands.


        


More information about the Mlir-commits mailing list