@@ -44,30 +44,27 @@ struct LinalgCopyOpInterface
4444 linalg::CopyOp> {
4545 OpOperand &getSourceOperand (Operation *op) const {
4646 auto copyOp = cast<CopyOp>(op);
47- assert (copyOp.getInputs ().size () == 1 && " expected single input" );
48- return copyOp.getInputsMutable ()[0 ];
47+ return llvm::getSingleElement (copyOp.getInputsMutable ());
4948 }
5049
5150 bool
5251 isEquivalentSubset (Operation *op, Value candidate,
5352 function_ref<bool (Value, Value)> equivalenceFn) const {
5453 auto copyOp = cast<CopyOp>(op);
55- assert (copyOp. getOutputs (). size () == 1 && " expected single output " );
56- return equivalenceFn (candidate, copyOp.getOutputs ()[ 0 ] );
54+ return equivalenceFn (candidate,
55+ llvm::getSingleElement ( copyOp.getOutputs ()) );
5756 }
5857
5958 Value buildSubsetExtraction (Operation *op, OpBuilder &builder,
6059 Location loc) const {
6160 auto copyOp = cast<CopyOp>(op);
62- assert (copyOp.getOutputs ().size () == 1 && " expected single output" );
63- return copyOp.getOutputs ()[0 ];
61+ return llvm::getSingleElement (copyOp.getOutputs ());
6462 }
6563
6664 SmallVector<Value>
6765 getValuesNeededToBuildSubsetExtraction (Operation *op) const {
6866 auto copyOp = cast<CopyOp>(op);
69- assert (copyOp.getOutputs ().size () == 1 && " expected single output" );
70- return {copyOp.getOutputs ()[0 ]};
67+ return {llvm::getSingleElement (copyOp.getOutputs ())};
7168 }
7269};
7370} // namespace
0 commit comments