9 #ifndef MLIR_IR_BUILTINTYPES_H 10 #define MLIR_IR_BUILTINTYPES_H 24 #include "mlir/IR/BuiltinTypeInterfaces.h.inc" 52 static bool classof(
Type type);
58 unsigned getFPMantissaWidth();
62 FloatType scaleElementBitwidth(
unsigned scale);
65 const llvm::fltSemantics &getFloatSemantics();
93 Type elementType)
const;
96 static bool isValidElementType(
Type type);
99 static bool classof(
Type type);
102 operator ShapedType()
const {
return cast<ShapedType>(); }
121 bool hasRank()
const;
129 Type elementType)
const;
132 static bool isValidElementType(
Type type);
135 static bool classof(
Type type);
145 operator ShapedType()
const {
return cast<ShapedType>(); }
154 #define GET_TYPEDEF_CLASSES 155 #include "mlir/IR/BuiltinTypes.h.inc" 170 layout(other.getLayout()), memorySpace(other.getMemorySpace()) {}
174 : shape(shape), elementType(elementType) {}
182 elementType = newElementType;
192 memorySpace = newMemorySpace;
197 Builder &setMemorySpace(
unsigned newMemorySpace);
199 operator MemRefType() {
200 return MemRefType::get(shape, elementType, layout, memorySpace);
206 MemRefLayoutAttrInterface layout;
221 encoding(other.getEncoding()) {}
225 : shape(shape), elementType(elementType), encoding(encoding) {}
233 elementType = newElementType;
238 encoding = newEncoding;
244 assert(pos < shape.size() &&
"overflow");
246 storage.append(shape.begin(), shape.end());
247 storage.erase(storage.begin() + pos);
248 shape = {storage.data(), storage.size()};
254 assert(pos <= shape.size() &&
"overflow");
256 storage.append(shape.begin(), shape.end());
257 storage.insert(storage.begin() + pos, val);
258 shape = {storage.data(), storage.size()};
262 operator RankedTensorType() {
263 return RankedTensorType::get(shape, elementType, encoding);
285 numScalableDims(other.getNumScalableDims()) {}
289 unsigned numScalableDims = 0)
290 : shape(shape), elementType(elementType),
291 numScalableDims(numScalableDims) {}
294 unsigned newNumScalableDims = 0) {
295 numScalableDims = newNumScalableDims;
301 elementType = newElementType;
307 assert(pos < shape.size() &&
"overflow");
308 if (pos >= shape.size() - numScalableDims)
311 storage.append(shape.begin(), shape.end());
312 storage.erase(storage.begin() + pos);
313 shape = {storage.data(), storage.size()};
323 return VectorType::get(shape, elementType, numScalableDims);
331 unsigned numScalableDims;
363 ShapedType candidateReducedType);
369 inline bool BaseMemRefType::classof(
Type type) {
373 inline bool BaseMemRefType::isValidElementType(
Type type) {
376 type.
isa<MemRefElementTypeInterface>();
379 inline bool FloatType::classof(
Type type) {
380 return type.
isa<BFloat16Type, Float16Type, Float32Type, Float64Type,
381 Float80Type, Float128Type>();
385 return BFloat16Type::get(ctx);
389 return Float16Type::get(ctx);
393 return Float32Type::get(ctx);
397 return Float64Type::get(ctx);
401 return Float80Type::get(ctx);
405 return Float128Type::get(ctx);
408 inline bool TensorType::classof(
Type type) {
409 return type.
isa<RankedTensorType, UnrankedTensorType>();
510 #endif // MLIR_IR_BUILTINTYPES_H TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
The OpAsmOpInterface, see OpAsmInterface.td for more details.
MemRefType eraseStridedLayout(MemRefType t)
Return a version of t with a layout that has all dynamic offset and strides.
Builder(ArrayRef< int64_t > shape, Type elementType, unsigned numScalableDims=0)
Build from scratch.
AffineMap getStridedLinearLayoutMap(MemRefType t)
Return the layout map in strided linear layout AffineMap form.
llvm::Optional< llvm::SmallDenseSet< unsigned > > computeRankReductionMask(ArrayRef< int64_t > originalShape, ArrayRef< int64_t > reducedShape)
Given an originalShape and a reducedShape assumed to be a subset of originalShape with some 1 entries...
bool isIntOrIndexOrFloat() const
Return true if this is an integer (of any signedness), index, or float type.
AffineExpr makeCanonicalStridedLayoutExpr(ArrayRef< int64_t > sizes, MLIRContext *context)
Return the result of makeCanonicalStrudedLayoutExpr for the common case where exprs is {d0...
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity...
Builder & setEncoding(Attribute newEncoding)
SliceVerificationResult isRankReducedType(ShapedType originalType, ShapedType candidateReducedType)
Check if originalType can be rank reduced to candidateReducedType type by dropping some dimensions wi...
Builder & insertDim(int64_t val, unsigned pos)
Insert a val into shape .
static ArrayRef< int64_t > getShape(Type type)
Returns the shape of the given type.
Builder & dropDim(unsigned pos)
Erase a dim from shape .
Builder(MemRefType other)
Builder(RankedTensorType other)
Build from another RankedTensorType.
This class represents an efficient way to signal success or failure.
bool isStrided(MemRefType t)
Return true if the layout for t is compatible with strided semantics.
Attributes are known-constant values of operations.
SliceVerificationResult
Enum that captures information related to verifier error conditions on slice insert/extract type of o...
Base type for affine expression.
Builder & dropDim(unsigned pos)
Erase a dim from shape .
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued...
Tensor types represent multi-dimensional arrays, and have two variants: RankedTensorType and Unranked...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
LogicalResult getStridesAndOffset(MemRefType t, SmallVectorImpl< AffineExpr > &strides, AffineExpr &offset)
This is a builder type that keeps local references to arguments.
This is a builder type that keeps local references to arguments.
Builder(VectorType other)
Build from another VectorType.
This class provides a shared interface for ranked and unranked memref types.
Builder & setElementType(Type newElementType)
This is a builder type that keeps local references to arguments.
MLIRContext is the top-level object for a collection of MLIR operations.
AffineMap makeStridedLinearLayoutMap(ArrayRef< int64_t > strides, int64_t offset, MLIRContext *context)
Given a list of strides (in which MemRefType::getDynamicStrideOrOffset() represents a dynamic value)...
MemRefType canonicalizeStridedLayout(MemRefType t)
Return a version of t with identity layout if it can be determined statically that the layout is the ...
Builder(ArrayRef< int64_t > shape, Type elementType, Attribute encoding)
Build from scratch.
Builder & setMemorySpace(Attribute newMemorySpace)
Builder(ArrayRef< int64_t > shape, Type elementType)
Builder & setLayout(MemRefLayoutAttrInterface newLayout)
Builder & setElementType(Type newElementType)
Builder & setShape(ArrayRef< int64_t > newShape, unsigned newNumScalableDims=0)
Builder & setShape(ArrayRef< int64_t > newShape)
Builder & setShape(ArrayRef< int64_t > newShape)
Builder & setElementType(Type newElementType)
unsigned getMemorySpaceAsInt(Attribute memorySpace)
[deprecated] Returns the memory space in old raw integer representation.
bool isStaticShapeAndContiguousRowMajor(MemRefType memrefType)
Helper determining if a memref is static-shape and contiguous-row-major layout, while still allowing ...