|
47 | 47 | #include "llvm/ADT/StringSet.h" |
48 | 48 | #include "llvm/ADT/TypeSwitch.h" |
49 | 49 | #include "llvm/Support/FormatVariadic.h" |
| 50 | +#include "llvm/Support/InterleavedRange.h" |
50 | 51 | #include "llvm/Support/LogicalResult.h" |
51 | 52 | #include "llvm/Support/MathExtras.h" |
52 | 53 | #include "llvm/Support/raw_ostream.h" |
@@ -3660,17 +3661,13 @@ ParseResult MatmulOp::parse(OpAsmParser &parser, OperationState &result) { |
3660 | 3661 | } |
3661 | 3662 |
|
3662 | 3663 | void MatmulOp::print(OpAsmPrinter &p) { |
3663 | | - SmallVector<Attribute, 3> indexingMaps = llvm::map_to_vector( |
| 3664 | + SmallVector<Attribute, 3> indexingMaps = llvm::map_to_vector<3>( |
3664 | 3665 | MatmulOp::getDefaultIndexingMaps(getContext()), |
3665 | 3666 | [](AffineMap map) -> Attribute { return AffineMapAttr::get(map); }); |
3666 | | - if (!llvm::equal(getIndexingMaps(), indexingMaps)) { |
3667 | | - p << " indexing_maps = ["; |
3668 | | - llvm::interleaveComma(getIndexingMaps(), p, |
3669 | | - [&](Attribute attr) { p.printAttribute(attr); }); |
3670 | | - p << "]"; |
3671 | | - } |
| 3667 | + if (!llvm::equal(getIndexingMaps(), indexingMaps)) |
| 3668 | + p << " indexing_maps = " << llvm::interleaved_array(getIndexingMaps()); |
3672 | 3669 |
|
3673 | | - SmallVector<StringRef, 3> elidedAttrs = { |
| 3670 | + std::array<StringRef, 3> elidedAttrs = { |
3674 | 3671 | "operandSegmentSizes", "linalg.memoized_indexing_maps", "indexing_maps"}; |
3675 | 3672 | printNamedStructuredOp(p, getOperation(), getInputs(), getOutputs(), |
3676 | 3673 | elidedAttrs); |
@@ -3777,10 +3774,7 @@ ParseResult ContractOp::parse(OpAsmParser &parser, OperationState &result) { |
3777 | 3774 | } |
3778 | 3775 |
|
3779 | 3776 | void ContractOp::print(OpAsmPrinter &p) { |
3780 | | - p << " indexing_maps = ["; |
3781 | | - llvm::interleaveComma(getIndexingMaps(), p, |
3782 | | - [&](Attribute attr) { p.printAttribute(attr); }); |
3783 | | - p << "]"; |
| 3777 | + p << " indexing_maps = " << llvm::interleaved_array(getIndexingMaps()); |
3784 | 3778 | printNamedStructuredOp( |
3785 | 3779 | p, getOperation(), getInputs(), getOutputs(), |
3786 | 3780 | /*elidedAttrs=*/{"indexing_maps", "operandSegmentSizes"}); |
@@ -4013,17 +4007,13 @@ ParseResult BatchMatmulOp::parse(OpAsmParser &parser, OperationState &result) { |
4013 | 4007 | } |
4014 | 4008 |
|
4015 | 4009 | void BatchMatmulOp::print(OpAsmPrinter &p) { |
4016 | | - SmallVector<Attribute, 3> indexingMaps = llvm::map_to_vector( |
| 4010 | + SmallVector<Attribute, 3> indexingMaps = llvm::map_to_vector<3>( |
4017 | 4011 | BatchMatmulOp::getDefaultIndexingMaps(getContext()), |
4018 | 4012 | [](AffineMap map) -> Attribute { return AffineMapAttr::get(map); }); |
4019 | | - if (!llvm::equal(getIndexingMaps(), indexingMaps)) { |
4020 | | - p << " indexing_maps = ["; |
4021 | | - llvm::interleaveComma(getIndexingMaps(), p, |
4022 | | - [&](Attribute attr) { p.printAttribute(attr); }); |
4023 | | - p << "]"; |
4024 | | - } |
| 4013 | + if (!llvm::equal(getIndexingMaps(), indexingMaps)) |
| 4014 | + p << " indexing_maps = " << llvm::interleaved_array(getIndexingMaps()); |
4025 | 4015 |
|
4026 | | - SmallVector<StringRef, 3> elidedAttrs = { |
| 4016 | + std::array<StringRef, 3> elidedAttrs = { |
4027 | 4017 | "operandSegmentSizes", "linalg.memoized_indexing_maps", "indexing_maps"}; |
4028 | 4018 | ::printNamedStructuredOp(p, getOperation(), getInputs(), getOutputs(), |
4029 | 4019 | elidedAttrs); |
@@ -4204,17 +4194,13 @@ void ElementwiseOp::print(OpAsmPrinter &p) { |
4204 | 4194 | getArityGroupAsUInt(getArityGroupAndKind(getKind()).arityGroup); |
4205 | 4195 | unsigned numDims = getResultRank(); |
4206 | 4196 |
|
4207 | | - SmallVector<Attribute, 3> indexingMaps = llvm::map_to_vector( |
| 4197 | + SmallVector<Attribute, 3> indexingMaps = llvm::map_to_vector<3>( |
4208 | 4198 | ElementwiseOp::getDefaultIndexingMaps(arity + 1 /*output*/, numDims, |
4209 | 4199 | getContext()), |
4210 | 4200 | [](AffineMap map) -> Attribute { return AffineMapAttr::get(map); }); |
4211 | 4201 |
|
4212 | | - if (!llvm::equal(getIndexingMaps(), indexingMaps)) { |
4213 | | - p << " indexing_maps = ["; |
4214 | | - llvm::interleaveComma(getIndexingMaps(), p, |
4215 | | - [&](Attribute attr) { p.printAttribute(attr); }); |
4216 | | - p << "]"; |
4217 | | - } |
| 4202 | + if (!llvm::equal(getIndexingMaps(), indexingMaps)) |
| 4203 | + p << " indexing_maps = " << llvm::interleaved_array(getIndexingMaps()); |
4218 | 4204 |
|
4219 | 4205 | printNamedStructuredOp(p, getOperation(), getInputs(), getOutputs(), |
4220 | 4206 | elidedAttrs); |
|
0 commit comments