[Mlir-commits] [mlir] [mlir][Affine] Let affine.[de]linearize_index omit outer bounds (PR #116103)
Krzysztof Drewniak
llvmlistbot at llvm.org
Thu Nov 14 09:21:00 PST 2024
================
@@ -1096,17 +1114,37 @@ def AffineDelinearizeIndexOp : Affine_Op<"delinearize_index",
}];
let builders = [
- OpBuilder<(ins "Value":$linear_index, "ValueRange":$basis)>,
- OpBuilder<(ins "Value":$linear_index, "ArrayRef<OpFoldResult>":$basis)>,
- OpBuilder<(ins "Value":$linear_index, "ArrayRef<int64_t>":$basis)>
+ OpBuilder<(ins "Value":$linear_index, "ValueRange":$dynamic_basis, "ArrayRef<int64_t>":$static_asis, CArg<"bool", "true">:$hasOuterBound)>,
+ OpBuilder<(ins "Value":$linear_index, "ValueRange":$basis, CArg<"bool", "true">:$hasOuterBound)>,
+ OpBuilder<(ins "Value":$linear_index, "ArrayRef<OpFoldResult>":$basis, CArg<"bool", "true">:$hasOuterBound)>,
+ OpBuilder<(ins "Value":$linear_index, "ArrayRef<int64_t>":$basis, CArg<"bool", "true">:$hasOuterBound)>
];
let extraClassDeclaration = [{
+ /// Return true if the basis includes a bound on the first index input.
+ bool hasOuterBound() {
+ return getMultiIndex().size() == getStaticBasis().size();
+ }
+
/// Returns a vector with all the static and dynamic basis values.
SmallVector<OpFoldResult> getMixedBasis() {
OpBuilder builder(getContext());
return ::mlir::getMixedValues(getStaticBasis(), getDynamicBasis(), builder);
}
+
+ /// Return a vector that contains the basis of the operation, removing
+ /// the outer bound if one is present.
+ SmallVector<OpFoldResult> getEffectiveBasis() {
+ OpBuilder builder(getContext());
+ if (hasOuterBound()) {
+ if (getStaticBasis().front() == ::mlir::ShapedType::kDynamic)
----------------
krzysz00 wrote:
There's existing code in this file, but I can move it, no problem.
ANd this check is so that I don't pass a spurious input to `getMixedValues()`
https://github.com/llvm/llvm-project/pull/116103
More information about the Mlir-commits
mailing list