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 @@ -91,21 +91,6 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> { let cppNamespace = "::mlir::linalg"; let methods = [ - //===------------------------------------------------------------------===// - // Loop types handling. - //===------------------------------------------------------------------===// - InterfaceMethod< - /*desc=*/[{ - Return the number of induction variables in the basic block. This should - always be 0 for index-free linalg ops. For IndexedGeneric, this must be - equal to numLoops - }], - /*retTy=*/"unsigned", - /*methodName=*/"getNumPayloadInductionVariables", - /*args=*/(ins), - /*methodBody=*/"", - /*defaultImplementation=*/"" - >, //===------------------------------------------------------------------===// // Loop types handling. //===------------------------------------------------------------------===// @@ -491,8 +476,7 @@ /*args=*/(ins "OpOperand *":$opOperand), /*methodBody=*/"", /*defaultImplementation=*/[{ - unsigned bbArgNumber = - $_op.getNumPayloadInductionVariables() + opOperand->getOperandNumber(); + unsigned bbArgNumber = opOperand->getOperandNumber(); // Safeguard against the named linalg ops that are manually defined and // that only support buffer semantics: we should not be there. // Such ops have an empty regionBuilder and are not constructed with a diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -28,13 +28,6 @@ : Op { code structuredOpsBaseDecls = [{ - // Return the number of induction variables in the basic block. This should - // always be 0 for index-free linalg ops. For IndexedGeneric, this must be - // equal to numLoops. - unsigned getNumPayloadInductionVariables() { - return 0; - } - // Return whether the op accesses the iteration indices. bool hasIndexSemantics() { Operation *op = this->getOperation(); 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 @@ -440,25 +440,17 @@ // consistency discussions (i.e. what to do with output tensors whose bbarg is // not used). Block &block = linalgOp->getRegion(0).front(); - unsigned numBBIvs = linalgOp.getNumPayloadInductionVariables(); - if (linalgOp.getNumInputsAndOutputs() + numBBIvs != block.getNumArguments()) + if (linalgOp.getNumInputsAndOutputs() != block.getNumArguments()) return op->emitOpError("expected as many non-induction variable region " "arguments as the number of input/output operands"); - // Note: the number and type of yield values are checked in the YieldOp. - for (unsigned i = 0; i < numBBIvs; ++i) - if (!block.getArgument(i).getType().isIndex()) - return op->emitOpError("expected index block argument #") << i; - for (OpOperand *opOperand : linalgOp.getInputAndOutputOperands()) { Type elementType = getElementTypeOrSelf(opOperand->get()); - Type argType = - block.getArgument(numBBIvs + opOperand->getOperandNumber()).getType(); + Type argType = block.getArgument(opOperand->getOperandNumber()).getType(); if (elementType != argType) return op->emitOpError("expected type of bb argument #") - << numBBIvs + opOperand->getOperandNumber() << " (" << argType - << ")" + << opOperand->getOperandNumber() << " (" << argType << ")" << " to match element or self type of the corresponding operand (" << elementType << ")"; } diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -3229,16 +3229,13 @@ // Get the argument number of the returned values. That is the operand // number to use for replacing uses of this operation. - unsigned numIndexArgs = op.getNumPayloadInductionVariables(); SmallVector returnedArgs; for (Value yieldVal : yieldOp.values()) { auto yieldArg = yieldVal.dyn_cast(); if (!yieldArg || yieldArg.getOwner() != &body) return failure(); unsigned argumentNumber = yieldArg.getArgNumber(); - if (argumentNumber < numIndexArgs) - return failure(); - returnedArgs.push_back(op->getOperand(argumentNumber - numIndexArgs)); + returnedArgs.push_back(op->getOperand(argumentNumber)); } if (returnedArgs.size() != op.getOperation()->getNumResults()) return failure();