36 OpAsmPrinter &printer, Operation *op, OperandRange mapOperands,
size_t numDims
46 OpAsmParser &parser, SmallVectorImpl<OpAsmParser::UnresolvedOperand> &mapOperands,
49 int32_t numDimsRes = -1;
50 ParseResult res = parseDimAndSymbolListImpl(parser, mapOperands, numDimsRes);
51 numDims = parser.getBuilder().getIndexAttr(numDimsRes);
63 SmallVectorImpl<SmallVector<OpAsmParser::UnresolvedOperand>> &multiMapOperands,
64 DenseI32ArrayAttr &numDimsPerMap
66 SmallVector<int32_t> numDimsPerMapRes;
67 auto parseEach = [&]() -> ParseResult {
68 SmallVector<OpAsmParser::UnresolvedOperand> nextMapOps;
69 int32_t nextMapDims = -1;
70 ParseResult res = parseDimAndSymbolListImpl(parser, nextMapOps, nextMapDims);
71 numDimsPerMapRes.push_back(nextMapDims);
72 multiMapOperands.push_back(nextMapOps);
75 ParseResult res = parser.parseCommaSeparatedList(AsmParser::Delimiter::None, parseEach);
77 numDimsPerMap = parser.getBuilder().getDenseI32ArrayAttr(numDimsPerMapRes);
82 OpAsmPrinter &printer, Operation *op, OperandRangeRange multiMapOperands,
83 DenseI32ArrayAttr numDimsPerMap
85 size_t count = numDimsPerMap.size();
86 assert(multiMapOperands.size() == count);
87 llvm::interleaveComma(llvm::seq<size_t>(0, count), printer.getStream(), [&](
size_t i) {
88 printDimAndSymbolListImpl(printer, op, multiMapOperands[i], numDimsPerMap[i]);
95 llvm::SMLoc loc = parser.getCurrentLocation();
96 if (parser.parseOptionalAttrDict(extraAttrs)) {
99 if (failed(state.name.verifyInherentAttrs(extraAttrs, [&]() {
100 return parser.emitError(loc) <<
"'" << state.name.getStringRef() <<
"' op ";
105 for (StringAttr skipName : state.name.getAttributeNames()) {
106 if (extraAttrs.erase(skipName)) {
108 "Ignoring attribute '" + Twine(skipName) +
"' because it must be computed automatically.";
109 mlir::emitWarning(parser.getEncodedSourceLoc(loc), msg).report();
128 Operation *op, int32_t segmentSize, ArrayRef<int32_t> mapOpGroupSizes,
129 OperandRangeRange mapOperands, ArrayRef<int32_t> numDimsPerMap
135 int32_t totalMapOpGroupSizes = std::reduce(mapOpGroupSizes.begin(), mapOpGroupSizes.end());
136 if (totalMapOpGroupSizes != segmentSize && segmentSize >= 0) {
138 return op->emitOpError().append(
139 "number of operands for affine map instantiation (", totalMapOpGroupSizes,
140 ") does not match with the total size (", segmentSize,
141 ") specified in attribute 'operandSegmentSizes'"
148 size_t count = mapOpGroupSizes.size();
149 if (mapOperands.size() != count) {
150 return msgInstantiationGroupAttrMismatch(op, count, mapOperands.size());
152 if (numDimsPerMap.size() != count) {
154 return op->emitOpError().append(
155 "length of 'numDimsPerMap' attribute (", numDimsPerMap.size(),
156 ") does not match with length of 'mapOpGroupSizes' attribute (", count,
")"
163 LogicalResult aggregateResult = success();
164 for (
size_t i = 0; i < count; ++i) {
165 auto currMapOpGroupSize = mapOpGroupSizes[i];
166 if (std::cmp_not_equal(mapOperands[i].size(), currMapOpGroupSize)) {
168 aggregateResult = op->emitOpError().append(
169 "map instantiation group ", i,
" operand count (", mapOperands[i].size(),
170 ") does not match group ", i,
" size in 'mapOpGroupSizes' attribute (",
171 currMapOpGroupSize,
")"
173 }
else if (std::cmp_greater(numDimsPerMap[i], currMapOpGroupSize)) {
175 aggregateResult = op->emitOpError().append(
176 "map instantiation group ", i,
" dimension count (", numDimsPerMap[i],
") exceeds group ",
177 i,
" size in 'mapOpGroupSizes' attribute (", currMapOpGroupSize,
")"
181 return aggregateResult;
185 OperandRangeRange mapOps, ArrayRef<int32_t> numDimsPerMap, ArrayRef<AffineMapAttr> mapAttrs,
188 size_t count = numDimsPerMap.size();
189 if (mapOps.size() != count) {
190 return msgInstantiationGroupAttrMismatch(origin, count, mapOps.size());
194 if (mapAttrs.size() != count) {
197 return origin->emitOpError().append(
198 "map instantiation group count (", count,
199 ") does not match the number of affine map instantiations (", mapAttrs.size(),
200 ") required by the type"
207 LogicalResult aggregateResult = success();
208 for (
size_t i = 0; i < count; ++i) {
209 AffineMap map = mapAttrs[i].getAffineMap();
210 if (std::cmp_not_equal(map.getNumDims(), numDimsPerMap[i])) {
212 aggregateResult = origin->emitOpError().append(
213 "instantiation of map ", i,
" expected ", map.getNumDims(),
" but found ",
214 numDimsPerMap[i],
" dimension values in ()"
216 }
else if (std::cmp_not_equal(map.getNumInputs(), mapOps[i].size())) {
218 aggregateResult = origin->emitOpError().append(
219 "instantiation of map ", i,
" expected ", map.getNumSymbols(),
" but found ",
220 (mapOps[i].size() - numDimsPerMap[i]),
" symbol values in []"
224 return aggregateResult;