diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td @@ -491,6 +491,19 @@ return $_op.iterator_types(); }] >, + InterfaceMethod< + /*desc=*/[{ + Return iterator types in the current operation. + }], + /*retTy=*/"SmallVector", + /*methodName=*/"getIteratorTypesArray", + /*args=*/(ins), + /*methodBody=*/"", + /*defaultImplementation=*/[{ + auto range = $_op.iterator_types().template getAsValueRange(); + return {range.begin(), range.end()}; + }] + >, InterfaceMethod< /*desc=*/[{ Return true if the indexing map is depending on the current op instance. diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp @@ -297,8 +297,7 @@ !indexingMaps.back().isProjectedPermutation()) return MatchConvolutionResult::NotProjectedPermutations; - auto iteratorTypesRange = - linalgOp.iterator_types().getAsValueRange(); + auto iteratorTypesRange = linalgOp.getIteratorTypesArray(); llvm::SmallDenseSet outputDims = getPreservedDims(indexingMaps.back()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp @@ -438,8 +438,7 @@ resultTypes.push_back(newInputOutputTypes[i + genericOp.getNumInputs()]); GenericOp replacementOp = rewriter.create( loc, resultTypes, newInputs, newOutputs, newIndexingMaps, - llvm::to_vector<4>(genericOp.getIteratorTypes() - .template getAsValueRange())); + genericOp.getIteratorTypesArray()); rewriter.inlineRegionBefore(genericOp.getRegion(), replacementOp.getRegion(), replacementOp.getRegion().begin()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @@ -467,9 +467,8 @@ .isProjectedPermutation(); }) && genericOp.getTiedIndexingMap(fusableOpOperand).getNumResults() > 0 && - llvm::all_of(genericOp.getIteratorTypes(), [](Attribute attr) { - return attr.cast().getValue() == - getParallelIteratorTypeName(); + llvm::all_of(genericOp.getIteratorTypesArray(), [](StringRef it) { + return it == getParallelIteratorTypeName(); }); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp @@ -53,8 +53,7 @@ SmallVector inputOperands = linalgOp.getInputOperands(); SmallVector outputOperands = linalgOp.getOutputOperands(); SmallVector indexingMaps = linalgOp.getIndexingMapsArray(); - SmallVector iterators = llvm::to_vector<4>( - linalgOp.iterator_types().getAsValueRange()); + SmallVector iterators = linalgOp.getIteratorTypesArray(); SmallVector resultTypes = linalgOp.getOutputTensorTypes(); SmallVector types(resultTypes.begin(), resultTypes.end()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp b/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp @@ -61,9 +61,7 @@ SmallVector outputOperands = genericOp.getOutputOperands(); auto newOp = rewriter.create( loc, genericOp->getResultTypes(), newOperands, outputOperands, - newIndexingMaps, - llvm::to_vector<4>(genericOp.getIteratorTypes() - .template getAsValueRange())); + newIndexingMaps, genericOp.getIteratorTypesArray()); rewriter.cloneRegionBefore(genericOp.getRegion(), newOp.getRegion(), newOp.getRegion().begin());