44 OpAsmParser &parser, SmallVectorImpl<OpAsmParser::UnresolvedOperand> &mapOperands,
47 int32_t numDimsRes = -1;
48 ParseResult res = parseDimAndSymbolListImpl(parser, mapOperands, numDimsRes);
49 numDims = parser.getBuilder().getIndexAttr(numDimsRes);
61 SmallVectorImpl<SmallVector<OpAsmParser::UnresolvedOperand>> &multiMapOperands,
62 DenseI32ArrayAttr &numDimsPerMap
64 SmallVector<int32_t> numDimsPerMapRes;
65 auto parseEach = [&]() -> ParseResult {
66 SmallVector<OpAsmParser::UnresolvedOperand> nextMapOps;
67 int32_t nextMapDims = -1;
68 ParseResult res = parseDimAndSymbolListImpl(parser, nextMapOps, nextMapDims);
69 numDimsPerMapRes.push_back(nextMapDims);
70 multiMapOperands.push_back(nextMapOps);
73 ParseResult res = parser.parseCommaSeparatedList(AsmParser::Delimiter::None, parseEach);
75 numDimsPerMap = parser.getBuilder().getDenseI32ArrayAttr(numDimsPerMapRes);
80 OpAsmPrinter &printer, Operation *, OperandRangeRange multiMapOperands,
81 DenseI32ArrayAttr numDimsPerMap
83 size_t count = numDimsPerMap.size();
84 assert(multiMapOperands.size() == count);
85 llvm::interleaveComma(llvm::seq<size_t>(0, count), printer.getStream(), [&](
size_t i) {
86 printDimAndSymbolListImpl(printer, multiMapOperands[i], numDimsPerMap[i]);
93 llvm::SMLoc loc = parser.getCurrentLocation();
94 if (parser.parseOptionalAttrDict(extraAttrs)) {
97 if (failed(state.name.verifyInherentAttrs(extraAttrs, [&]() {
98 return parser.emitError(loc) <<
'\'' << state.name.getStringRef() <<
"' op ";
103 for (StringAttr skipName : state.name.getAttributeNames()) {
104 if (extraAttrs.erase(skipName)) {
106 "Ignoring attribute '" + Twine(skipName) +
"' because it must be computed automatically.";
107 mlir::emitWarning(parser.getEncodedSourceLoc(loc), msg).report();
126 Operation *op, int32_t segmentSize, ArrayRef<int32_t> mapOpGroupSizes,
127 OperandRangeRange mapOperands, ArrayRef<int32_t> numDimsPerMap
133 int32_t totalMapOpGroupSizes = std::reduce(mapOpGroupSizes.begin(), mapOpGroupSizes.end());
134 if (totalMapOpGroupSizes != segmentSize && segmentSize >= 0) {
136 return op->emitOpError().append(
137 "number of operands for affine map instantiation (", totalMapOpGroupSizes,
138 ") does not match with the total size (", segmentSize,
139 ") specified in attribute 'operandSegmentSizes'"
146 size_t count = mapOpGroupSizes.size();
147 if (mapOperands.size() != count) {
148 return msgInstantiationGroupAttrMismatch(op, count, mapOperands.size());
150 if (numDimsPerMap.size() != count) {
152 return op->emitOpError().append(
153 "length of 'numDimsPerMap' attribute (", numDimsPerMap.size(),
154 ") does not match with length of 'mapOpGroupSizes' attribute (", count,
")"
161 LogicalResult aggregateResult = success();
162 for (
size_t i = 0; i < count; ++i) {
163 auto currMapOpGroupSize = mapOpGroupSizes[i];
164 if (std::cmp_not_equal(mapOperands[i].size(), currMapOpGroupSize)) {
166 aggregateResult = op->emitOpError().append(
167 "map instantiation group ", i,
" operand count (", mapOperands[i].size(),
168 ") does not match group ", i,
" size in 'mapOpGroupSizes' attribute (",
169 currMapOpGroupSize,
")"
171 }
else if (std::cmp_greater(numDimsPerMap[i], currMapOpGroupSize)) {
173 aggregateResult = op->emitOpError().append(
174 "map instantiation group ", i,
" dimension count (", numDimsPerMap[i],
") exceeds group ",
175 i,
" size in 'mapOpGroupSizes' attribute (", currMapOpGroupSize,
")"
179 return aggregateResult;
183 OperandRangeRange mapOps, ArrayRef<int32_t> numDimsPerMap, ArrayRef<AffineMapAttr> mapAttrs,
186 size_t count = numDimsPerMap.size();
187 if (mapOps.size() != count) {
188 return msgInstantiationGroupAttrMismatch(origin, count, mapOps.size());
192 if (mapAttrs.size() != count) {
195 return origin->emitOpError().append(
196 "map instantiation group count (", count,
197 ") does not match the number of affine map instantiations (", mapAttrs.size(),
198 ") required by the type"
205 LogicalResult aggregateResult = success();
206 for (
size_t i = 0; i < count; ++i) {
207 AffineMap map = mapAttrs[i].getAffineMap();
208 if (std::cmp_not_equal(map.getNumDims(), numDimsPerMap[i])) {
210 aggregateResult = origin->emitOpError().append(
211 "instantiation of map ", i,
" expected ", map.getNumDims(),
" but found ",
212 numDimsPerMap[i],
" dimension values in ()"
214 }
else if (std::cmp_not_equal(map.getNumInputs(), mapOps[i].size())) {
216 aggregateResult = origin->emitOpError().append(
217 "instantiation of map ", i,
" expected ", map.getNumSymbols(),
" but found ",
218 (mapOps[i].size() - numDimsPerMap[i]),
" symbol values in []"
222 return aggregateResult;