summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mlir/include/mlir/Dialect/Utils/StaticValueUtils.h8
-rw-r--r--mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp5
-rw-r--r--mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp3
-rw-r--r--mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp36
-rw-r--r--mlir/lib/Dialect/Tensor/IR/TensorOps.cpp62
-rw-r--r--mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp2
-rw-r--r--mlir/lib/Dialect/Utils/StaticValueUtils.cpp10
7 files changed, 44 insertions, 82 deletions
diff --git a/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h b/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
index e72f7095b6da..0454137d4005 100644
--- a/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
+++ b/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
@@ -39,20 +39,18 @@ getOffsetsSizesAndStrides(ArrayRef<Range> ranges);
/// Helper function to dispatch an OpFoldResult into `staticVec` if:
/// a) it is an IntegerAttr
/// In other cases, the OpFoldResult is dispached to the `dynamicVec`.
-/// In such dynamic cases, a copy of the `sentinel` value is also pushed to
+/// In such dynamic cases, ShapedType::kDynamic is also pushed to
/// `staticVec`. This is useful to extract mixed static and dynamic entries that
/// come from an AttrSizedOperandSegments trait.
void dispatchIndexOpFoldResult(OpFoldResult ofr,
SmallVectorImpl<Value> &dynamicVec,
- SmallVectorImpl<int64_t> &staticVec,
- int64_t sentinel);
+ SmallVectorImpl<int64_t> &staticVec);
/// Helper function to dispatch multiple OpFoldResults according to the behavior
/// of `dispatchIndexOpFoldResult(OpFoldResult ofr` for a single OpFoldResult.
void dispatchIndexOpFoldResults(ArrayRef<OpFoldResult> ofrs,
SmallVectorImpl<Value> &dynamicVec,
- SmallVectorImpl<int64_t> &staticVec,
- int64_t sentinel);
+ SmallVectorImpl<int64_t> &staticVec);
/// Extract int64_t values from the assumed ArrayAttr of IntegerAttr.
SmallVector<int64_t, 4> extractFromI64ArrayAttr(Attribute attr);
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 79738d1737a1..853321f22dba 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -1457,8 +1457,7 @@ void transform::TileToForeachThreadOp::build(
ArrayAttr mapping) {
SmallVector<int64_t> staticTileSizes;
SmallVector<Value> dynamicTileSizes;
- dispatchIndexOpFoldResults(mixedTileSizes, dynamicTileSizes, staticTileSizes,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(mixedTileSizes, dynamicTileSizes, staticTileSizes);
// Call the default builder which sets up the proper operands segment sizes
// attributes for multiple variadic operands. In the absence of this, horrible
// bugs ensue.
@@ -1493,7 +1492,7 @@ void transform::TileToForeachThreadOp::build(
SmallVector<int64_t> staticNumThreads;
SmallVector<Value> dynamicNumThreads;
dispatchIndexOpFoldResults(mixedNumThreads, dynamicNumThreads,
- staticNumThreads, ShapedType::kDynamic);
+ staticNumThreads);
// Call the default builder which sets up the proper operands segment sizes
// attributes for multiple variadic operands. In the absence of this, horrible
// bugs ensue.
diff --git a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
index beeba58f1785..cf8f56fcce06 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
@@ -278,8 +278,7 @@ struct LinalgOpPartialReductionInterface
SmallVector<Value> dynamicDims;
for (int64_t idx : llvm::seq<int64_t>(0, oldShape.size() + 1)) {
if (idx == insertSplitDimension) {
- dispatchIndexOpFoldResults(sizes[idx], dynamicDims, newOutputShape,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(sizes[idx], dynamicDims, newOutputShape);
continue;
}
int64_t oldIdx = idx < insertSplitDimension ? idx : idx - 1;
diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
index 028cc53b18f9..4b60eb9c7987 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
@@ -1769,12 +1769,9 @@ void ReinterpretCastOp::build(OpBuilder &b, OperationState &result,
ArrayRef<NamedAttribute> attrs) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offset, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offset, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
build(b, result, resultType, source, dynamicOffsets, dynamicSizes,
dynamicStrides, b.getDenseI64ArrayAttr(staticOffsets),
b.getDenseI64ArrayAttr(staticSizes),
@@ -2577,12 +2574,9 @@ Type SubViewOp::inferResultType(MemRefType sourceMemRefType,
ArrayRef<OpFoldResult> strides) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
return SubViewOp::inferResultType(sourceMemRefType, staticOffsets,
staticSizes, staticStrides);
}
@@ -2627,12 +2621,9 @@ Type SubViewOp::inferRankReducedResultType(ArrayRef<int64_t> resultShape,
ArrayRef<OpFoldResult> strides) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
return SubViewOp::inferRankReducedResultType(
resultShape, sourceRankedTensorType, staticOffsets, staticSizes,
staticStrides);
@@ -2648,12 +2639,9 @@ void SubViewOp::build(OpBuilder &b, OperationState &result,
ArrayRef<NamedAttribute> attrs) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
auto sourceMemRefType = source.getType().cast<MemRefType>();
// Structuring implementation this way avoids duplication between builders.
if (!resultType) {
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index 3578db643c98..57c0495f25d4 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -519,8 +519,7 @@ void EmptyOp::build(OpBuilder &builder, OperationState &result,
Attribute encoding) {
SmallVector<int64_t> staticShape;
SmallVector<Value> dynamicSizes;
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticShape,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticShape);
build(builder, result, staticShape, elementType, dynamicSizes, encoding);
}
@@ -1575,12 +1574,9 @@ RankedTensorType ExtractSliceOp::inferResultType(
ArrayRef<OpFoldResult> sizes, ArrayRef<OpFoldResult> strides) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
return ExtractSliceOp::inferResultType(sourceShapedTensorType, staticOffsets,
staticSizes, staticStrides);
}
@@ -1623,12 +1619,9 @@ RankedTensorType ExtractSliceOp::inferCanonicalRankReducedResultType(
ArrayRef<OpFoldResult> strides) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
return ExtractSliceOp::inferCanonicalRankReducedResultType(
desiredResultRank, sourceRankedTensorType, staticOffsets, staticSizes,
staticStrides);
@@ -1644,12 +1637,9 @@ void ExtractSliceOp::build(OpBuilder &b, OperationState &result,
ArrayRef<NamedAttribute> attrs) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
auto sourceRankedTensorType = source.getType().cast<RankedTensorType>();
// Structuring implementation this way avoids duplication between builders.
if (!resultType) {
@@ -2081,12 +2071,9 @@ void InsertSliceOp::build(OpBuilder &b, OperationState &result, Value source,
ArrayRef<NamedAttribute> attrs) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
build(b, result, dest.getType(), source, dest, dynamicOffsets, dynamicSizes,
dynamicStrides, b.getDenseI64ArrayAttr(staticOffsets),
b.getDenseI64ArrayAttr(staticSizes),
@@ -2542,9 +2529,8 @@ void PadOp::build(OpBuilder &b, OperationState &result, Type resultType,
// This will grow staticLow and staticHigh with 1 value. If the config is
// dynamic (ie not a constant), dynamicLow and dynamicHigh will grow with 1
// value as well.
- dispatchIndexOpFoldResults(low, dynamicLow, staticLow, ShapedType::kDynamic);
- dispatchIndexOpFoldResults(high, dynamicHigh, staticHigh,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(low, dynamicLow, staticLow);
+ dispatchIndexOpFoldResults(high, dynamicHigh, staticHigh);
if (!resultType) {
resultType = PadOp::inferResultType(sourceType, staticLow, staticHigh);
}
@@ -2891,12 +2877,9 @@ void ParallelInsertSliceOp::build(OpBuilder &b, OperationState &result,
ArrayRef<NamedAttribute> attrs) {
SmallVector<int64_t> staticOffsets, staticSizes, staticStrides;
SmallVector<Value> dynamicOffsets, dynamicSizes, dynamicStrides;
- dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes,
- ShapedType::kDynamic);
- dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
+ dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
+ dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
build(b, result, {}, source, dest, dynamicOffsets, dynamicSizes,
dynamicStrides, b.getDenseI64ArrayAttr(staticOffsets),
b.getDenseI64ArrayAttr(staticSizes),
@@ -3063,8 +3046,7 @@ static SmallVector<int64_t> getStaticTilesImpl(OpTy op) {
"applies to only pack or unpack operations");
SmallVector<Value> dynamicTiles;
SmallVector<int64_t> staticTiles;
- dispatchIndexOpFoldResults(op.getMixedTiles(), dynamicTiles, staticTiles,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(op.getMixedTiles(), dynamicTiles, staticTiles);
return staticTiles;
}
@@ -3211,8 +3193,7 @@ void PackOp::build(OpBuilder &builder, OperationState &state, Value source,
"original dimensions to be tiled");
SmallVector<int64_t> staticTileSizes;
SmallVector<Value> dynamicTileSizes;
- dispatchIndexOpFoldResults(innerTiles, dynamicTileSizes, staticTileSizes,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(innerTiles, dynamicTileSizes, staticTileSizes);
build(builder, state, dest.getType(), source, dest,
paddingValue ? paddingValue.value() : nullptr,
outerDimsPerm.empty() ? nullptr
@@ -3420,8 +3401,7 @@ void UnPackOp::build(OpBuilder &builder, OperationState &state, Value source,
"original dimensions to be tiled");
SmallVector<int64_t> staticTileSizes;
SmallVector<Value> dynamicTileSizes;
- dispatchIndexOpFoldResults(innerTiles, dynamicTileSizes, staticTileSizes,
- ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(innerTiles, dynamicTileSizes, staticTileSizes);
build(builder, state, dest.getType(), source, dest,
outerDimsPerm.empty() ? nullptr
: builder.getDenseI64ArrayAttr(outerDimsPerm),
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
index b8210aabd782..837ecb17736b 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
@@ -358,7 +358,7 @@ Operation *tensor::bubbleUpPadSlice(OpBuilder &b, tensor::PadOp padOp,
// The shape of the result can be obtained from the sizes passed in.
SmallVector<Value> dynDims;
SmallVector<int64_t> shape;
- dispatchIndexOpFoldResults(sizes, dynDims, shape, ShapedType::kDynamic);
+ dispatchIndexOpFoldResults(sizes, dynDims, shape);
RankedTensorType resultType =
RankedTensorType::get(shape, padOp.getResultType().getElementType());
diff --git a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp
index 601e85b0248b..092dbae9beb0 100644
--- a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp
+++ b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp
@@ -37,8 +37,7 @@ getOffsetsSizesAndStrides(ArrayRef<Range> ranges) {
/// come from an AttrSizedOperandSegments trait.
void dispatchIndexOpFoldResult(OpFoldResult ofr,
SmallVectorImpl<Value> &dynamicVec,
- SmallVectorImpl<int64_t> &staticVec,
- int64_t sentinel) {
+ SmallVectorImpl<int64_t> &staticVec) {
auto v = ofr.dyn_cast<Value>();
if (!v) {
APInt apInt = ofr.get<Attribute>().cast<IntegerAttr>().getValue();
@@ -46,15 +45,14 @@ void dispatchIndexOpFoldResult(OpFoldResult ofr,
return;
}
dynamicVec.push_back(v);
- staticVec.push_back(sentinel);
+ staticVec.push_back(ShapedType::kDynamic);
}
void dispatchIndexOpFoldResults(ArrayRef<OpFoldResult> ofrs,
SmallVectorImpl<Value> &dynamicVec,
- SmallVectorImpl<int64_t> &staticVec,
- int64_t sentinel) {
+ SmallVectorImpl<int64_t> &staticVec) {
for (OpFoldResult ofr : ofrs)
- dispatchIndexOpFoldResult(ofr, dynamicVec, staticVec, sentinel);
+ dispatchIndexOpFoldResult(ofr, dynamicVec, staticVec);
}
/// Extract int64_t values from the assumed ArrayAttr of IntegerAttr.