14#include "mlir/Interfaces/IndexingMapOpInterface.cpp.inc"
18 unsigned operandNumber) {
24 if (isa<VectorType>(t))
28 if (isa<UnrankedMemRefType>(t)) {
30 << operandNumber <<
" must be a ranked memref, but got " << t;
32 if (isa<MemRefType>(t))
36 if (isa<UnrankedTensorType>(t)) {
38 << operandNumber <<
" must be a ranked tensor, but got " << t;
40 if (isa<RankedTensorType>(t))
46 <<
" must be ranked tensor/memref, vector, or scalar, but got " << t;
49LogicalResult mlir::IndexingMapOpInterface::verifyImpl() {
51 if (
static_cast<int64_t>(getIndexingMapsArray().size()) !=
52 getOperation()->getNumOperands())
53 return this->
emitOpError(
"expected the number of indexing_map (")
54 << getIndexingMapsArray().size()
55 <<
") to be equal to the number of input/output operands ("
56 << getOperation()->getNumOperands() <<
")";
60 for (
OpOperand &opOperand : getOperation()->getOpOperands()) {
61 Type ty = opOperand.get().getType();
63 opOperand.getOperandNumber())))
65 AffineMap indexingMap = getMatchingIndexingMap(&opOperand);
68 return this->
emitOpError(
"unexpected symbols in indexing_map #")
69 << opOperand.getOperandNumber();
75 << opOperand.getOperandNumber() <<
" rank (" << rank
76 <<
") to match the result rank of indexing_map ("
86 << opOperand.getOperandNumber() <<
" rank (" << rank
87 <<
") to match the result rank of indexing_map ("
90 llvm::append_range(allShapesSizes,
shape);
93 AffineMap invertedMap = getShapesToLoopsMap();
96 llvm::raw_string_ostream os(str);
97 getLoopsToShapesMap().print(os);
98 return this->
emitOpError(
"invalid indexing maps are non-invertible: ")
108 if (llvm::none_of(endLoopRangeValues, ShapedType::isDynamic)) {
110 for (
int64_t &range : endLoopRangeValues)
112 for (
OpOperand &opOperand : getOperation()->getOpOperands()) {
113 AffineMap indexingMap = getMatchingIndexingMap(&opOperand);
115 indexingMap.
compose(startLoopRangeValues);
118 for (
auto dim : llvm::seq<int64_t>(0,
shape.size())) {
120 if (ShapedType::isDynamic(
shape[dim]) ||
shape[dim] == 0)
134 std::max(startIndices[dim], endIndices[dim]) + 1;
135 if (std::min(startIndices[dim], endIndices[dim]) < 0) {
138 llvm::raw_string_ostream os(mapStr);
142 "unexpected result less than 0 at expression #")
143 << dim <<
" in " << mapStr;
145 if (isa<AffineDimExpr>(indexingMap.
getResult(dim))) {
146 if (inferredDimSize !=
shape[dim]) {
147 return this->
emitOpError(
"inferred input/output operand #")
148 << opOperand.getOperandNumber() <<
" has shape's dimension #"
149 << dim <<
" to be " << inferredDimSize <<
", but found "
153 if (inferredDimSize >
shape[dim]) {
154 return this->
emitOpError(
"inferred input/output operand #")
155 << opOperand.getOperandNumber() <<
" has shape's dimension #"
156 << dim <<
" to be greater than or equal to "
157 << inferredDimSize <<
", but found " <<
shape[dim];
p<< " : "<< getMemRefType()<< ", "<< getType();}static LogicalResult verifyVectorMemoryOp(Operation *op, MemRefType memrefType, VectorType vectorType) { if(memrefType.getElementType() !=vectorType.getElementType()) return op-> emitOpError("requires memref and vector types of the same elemental type")
Given a list of lists of parsed operands, populates uniqueOperands with unique operands.
static LogicalResult verifyIndexingMapOperandType(Operation *op, Type t, unsigned operandNumber)
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
unsigned getNumSymbols() const
unsigned getNumResults() const
AffineExpr getResult(unsigned idx) const
AffineMap compose(AffineMap map) const
Returns the AffineMap resulting from composing this with map.
This class represents an operand of an operation.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
bool isIntOrIndexOrFloat() const
Return true if this is an integer (of any signedness), index, or float type.
Include the generated interface declarations.