[Mlir-commits] [mlir] [mlir][transform] Add support for transform.param pad multiples in `PadOp` (PR #90755)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu May 2 07:40:17 PDT 2024
================
@@ -1677,18 +1723,126 @@ void transform::PadOp::build(OpBuilder &b, OperationState &result, Value target,
/*target=*/target,
/*paddingValues=*/ArrayAttr(), // let inference handle this
/*paddingDimensions=*/b.getI64ArrayAttr(paddingDimensions),
+ /*padToMultipleOf=*/ValueRange{},
/*padToMultipleOf=*/
- (padToMultipleOf.empty() ? ArrayAttr()
- : b.getI64ArrayAttr(padToMultipleOf)),
+ (padToMultipleOf.empty()
+ ? DenseI64ArrayAttr()
+ : b.getDenseI64ArrayAttr(padToMultipleOf)),
/*packPaddings=*/b.getI64ArrayAttr(packPaddings),
/*transposePaddings=*/b.getArrayAttr(transposePaddings),
/*copyBackOp=*/b.getStringAttr(copyBackOp));
}
+void transform::PadOp::build(OpBuilder &b, OperationState &result, Value target,
+ ArrayRef<int64_t> paddingDimensions,
+ ArrayRef<OpFoldResult> mixedPadToMultipleOf,
+ ArrayRef<int64_t> packPaddings,
+ ArrayRef<Attribute> transposePaddings,
+ StringRef copyBackOp) {
+ auto resultType = transform::AnyOpType::get(b.getContext());
+ SmallVector<int64_t> staticPadToMultipleOf;
+ SmallVector<Value> dynamicPadToMultipleOf;
+ dispatchIndexOpFoldResults(mixedPadToMultipleOf, dynamicPadToMultipleOf,
+ staticPadToMultipleOf);
+ return build(/*builder=*/b,
+ /*result=*/result,
+ /*types=*/TypeRange{resultType, resultType},
+ /*target=*/target,
+ /*paddingValues=*/ArrayAttr(), // let inference handle this
+ /*paddingDimensions=*/b.getI64ArrayAttr(paddingDimensions),
+ /*padToMultipleOf=*/dynamicPadToMultipleOf,
+ /*padToMultipleOf=*/staticPadToMultipleOf,
+ /*packPaddings=*/b.getI64ArrayAttr(packPaddings),
+ /*transposePaddings=*/b.getArrayAttr(transposePaddings),
+ /*copyBackOp=*/b.getStringAttr(copyBackOp));
+}
+
+void PadOp::getEffects(
+ SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
+ consumesHandle(getTarget(), effects);
+ onlyReadsHandle(getPadToMultipleOf(), effects);
+ producesHandle(getPadded(), effects);
+ producesHandle(getPad(), effects);
+ producesHandle(getCopy(), effects);
+ modifiesPayload(effects);
+}
+
+SmallVector<OpFoldResult> PadOp::getMixedPadToMultipleOf() {
+ OpBuilder b(getContext());
----------------
srcarroll wrote:
i see. i was just going with the same signature i've seen in similar functions. i'll switch to `Builder`
https://github.com/llvm/llvm-project/pull/90755
More information about the Mlir-commits
mailing list