@@ -388,33 +388,6 @@ expandTargetSpecification(Location loc, bool isAll, bool isInverted,
388
388
return DiagnosedSilenceableFailure::success ();
389
389
}
390
390
391
- // / Checks if the positional specification defined is valid and reports errors
392
- // / otherwise.
393
- LogicalResult verifyStructuredTransformDimsOp (Operation *op,
394
- ArrayRef<int64_t > raw,
395
- bool inverted, bool all) {
396
- if (all) {
397
- if (inverted) {
398
- return op->emitOpError ()
399
- << " cannot request both 'all' and 'inverted' values in the list" ;
400
- }
401
- if (!raw.empty ()) {
402
- return op->emitOpError ()
403
- << " cannot both request 'all' and specific values in the list" ;
404
- }
405
- }
406
- if (!all && raw.empty ()) {
407
- return op->emitOpError () << " must request specific values in the list if "
408
- " 'all' is not specified" ;
409
- }
410
- SmallVector<int64_t > rawVector = llvm::to_vector (raw);
411
- auto *it = std::unique (rawVector.begin (), rawVector.end ());
412
- if (it != rawVector.end ())
413
- return op->emitOpError () << " expected the listed values to be unique" ;
414
-
415
- return success ();
416
- }
417
-
418
391
// ===----------------------------------------------------------------------===//
419
392
// MatchStructuredDimOp
420
393
// ===----------------------------------------------------------------------===//
@@ -475,8 +448,8 @@ LogicalResult transform::MatchStructuredDimOp::verify() {
475
448
return emitOpError () << " cannot request the same dimension to be both "
476
449
" parallel and reduction" ;
477
450
}
478
- return verifyStructuredTransformDimsOp (getOperation (), getRawDimList (),
479
- getIsInverted (), getIsAll ());
451
+ return verifyTransformMatchDimsOp (getOperation (), getRawDimList (),
452
+ getIsInverted (), getIsAll ());
480
453
}
481
454
482
455
// ===----------------------------------------------------------------------===//
@@ -592,8 +565,8 @@ LogicalResult verifyStructuredOperandOp(OpTy op) {
592
565
LogicalResult transform::MatchStructuredInputOp::verify () {
593
566
if (failed (verifyStructuredOperandOp (*this )))
594
567
return failure ();
595
- return verifyStructuredTransformDimsOp (getOperation (), getRawPositionList (),
596
- getIsInverted (), getIsAll ());
568
+ return verifyTransformMatchDimsOp (getOperation (), getRawPositionList (),
569
+ getIsInverted (), getIsAll ());
597
570
}
598
571
599
572
// ===----------------------------------------------------------------------===//
@@ -665,8 +638,8 @@ DiagnosedSilenceableFailure transform::MatchStructuredInitOp::getPositionsFor(
665
638
LogicalResult transform::MatchStructuredInitOp::verify () {
666
639
if (failed (verifyStructuredOperandOp (*this )))
667
640
return failure ();
668
- return verifyStructuredTransformDimsOp (getOperation (), getRawPositionList (),
669
- getIsInverted (), getIsAll ());
641
+ return verifyTransformMatchDimsOp (getOperation (), getRawPositionList (),
642
+ getIsInverted (), getIsAll ());
670
643
}
671
644
672
645
// ===----------------------------------------------------------------------===//
@@ -793,78 +766,5 @@ void transform::MatchStructuredYieldOp::build(OpBuilder &builder,
793
766
build (builder, state, ValueRange ());
794
767
}
795
768
796
- // ===----------------------------------------------------------------------===//
797
- // Printing and parsing for structured match ops.
798
- // ===----------------------------------------------------------------------===//
799
-
800
- // / Keyword syntax for positional specification inversion.
801
- constexpr const static llvm::StringLiteral kDimExceptKeyword = " except" ;
802
-
803
- // / Keyword syntax for full inclusion in positional specification.
804
- constexpr const static llvm::StringLiteral kDimAllKeyword = " all" ;
805
-
806
- // / Parses a positional specification for structured transform operations. The
807
- // / following forms are accepted:
808
- // /
809
- // / - `all`: sets `isAll` and returns;
810
- // / - comma-separated-integer-list: populates `rawDimList` with the values;
811
- // / - `except` `(` comma-separated-integer-list `)`: populates `rawDimList`
812
- // / with the values and sets `isInverted`.
813
- static ParseResult parseStructuredTransformDims (OpAsmParser &parser,
814
- DenseI64ArrayAttr &rawDimList,
815
- UnitAttr &isInverted,
816
- UnitAttr &isAll) {
817
- Builder &builder = parser.getBuilder ();
818
- if (parser.parseOptionalKeyword (kDimAllKeyword ).succeeded ()) {
819
- rawDimList = builder.getDenseI64ArrayAttr ({});
820
- isInverted = nullptr ;
821
- isAll = builder.getUnitAttr ();
822
- return success ();
823
- }
824
-
825
- isAll = nullptr ;
826
- isInverted = nullptr ;
827
- if (parser.parseOptionalKeyword (kDimExceptKeyword ).succeeded ()) {
828
- isInverted = builder.getUnitAttr ();
829
- }
830
-
831
- if (isInverted) {
832
- if (parser.parseLParen ().failed ())
833
- return failure ();
834
- }
835
-
836
- SmallVector<int64_t > values;
837
- ParseResult listResult = parser.parseCommaSeparatedList (
838
- [&]() { return parser.parseInteger (values.emplace_back ()); });
839
- if (listResult.failed ())
840
- return failure ();
841
-
842
- rawDimList = builder.getDenseI64ArrayAttr (values);
843
-
844
- if (isInverted) {
845
- if (parser.parseRParen ().failed ())
846
- return failure ();
847
- }
848
- return success ();
849
- }
850
-
851
- // / Prints a positional specification for structured transform operations.
852
- static void printStructuredTransformDims (OpAsmPrinter &printer, Operation *op,
853
- DenseI64ArrayAttr rawDimList,
854
- UnitAttr isInverted, UnitAttr isAll) {
855
- if (isAll) {
856
- printer << kDimAllKeyword ;
857
- return ;
858
- }
859
- if (isInverted) {
860
- printer << kDimExceptKeyword << " (" ;
861
- }
862
- llvm::interleaveComma (rawDimList.asArrayRef (), printer.getStream (),
863
- [&](int64_t value) { printer << value; });
864
- if (isInverted) {
865
- printer << " )" ;
866
- }
867
- }
868
-
869
769
#define GET_OP_CLASSES
870
770
#include " mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp.inc"
0 commit comments