[Mlir-commits] [mlir] [mlir][transform] Add transform.get_operand op (PR #78397)
Quinn Dawkins
llvmlistbot at llvm.org
Wed Jan 17 08:42:34 PST 2024
================
@@ -1464,6 +1464,35 @@ transform::GetProducerOfOperand::apply(transform::TransformRewriter &rewriter,
return DiagnosedSilenceableFailure::success();
}
+//===----------------------------------------------------------------------===//
+// GetOperandOp
+//===----------------------------------------------------------------------===//
+
+DiagnosedSilenceableFailure
+transform::GetOperandOp::apply(transform::TransformRewriter &rewriter,
+ transform::TransformResults &results,
+ transform::TransformState &state) {
+ std::optional<int64_t> maybeOperandNumber = getOperandNumber();
+ SmallVector<Value> operands;
+ for (Operation *target : state.getPayloadOps(getTarget())) {
+ if (!maybeOperandNumber) {
+ for (Value operand : target->getOperands())
+ operands.push_back(operand);
+ continue;
+ }
+ int64_t operandNumber = *maybeOperandNumber;
+ if (operandNumber >= target->getNumOperands()) {
+ DiagnosedSilenceableFailure diag =
+ emitSilenceableError() << "targeted op does not have enough operands";
----------------
qedawkins wrote:
This is resolved by switching to the `StructuredTransformDims` approach.
https://github.com/llvm/llvm-project/pull/78397
More information about the Mlir-commits
mailing list