Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/IR/StandardTypes.h
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | public: | ||||
/// Integer representation maximal bitwidth. | /// Integer representation maximal bitwidth. | ||||
static constexpr unsigned kMaxWidth = 4096; | static constexpr unsigned kMaxWidth = 4096; | ||||
}; | }; | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// FloatType | // FloatType | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
class FloatType : public Type::TypeBase<FloatType, Type, TypeStorage> { | class FloatType : public Type { | ||||
public: | public: | ||||
using Base::Base; | using Type::Type; | ||||
static FloatType get(StandardTypes::Kind kind, MLIRContext *context); | |||||
// Convenience factories. | // Convenience factories. | ||||
static FloatType getBF16(MLIRContext *ctx) { | static FloatType getBF16(MLIRContext *ctx); | ||||
return get(StandardTypes::BF16, ctx); | static FloatType getF16(MLIRContext *ctx); | ||||
} | static FloatType getF32(MLIRContext *ctx); | ||||
static FloatType getF16(MLIRContext *ctx) { | static FloatType getF64(MLIRContext *ctx); | ||||
return get(StandardTypes::F16, ctx); | |||||
} | /// Methods for support type inquiry through isa, cast, and dyn_cast. | ||||
static FloatType getF32(MLIRContext *ctx) { | static bool classof(Type type); | ||||
return get(StandardTypes::F32, ctx); | |||||
} | |||||
static FloatType getF64(MLIRContext *ctx) { | |||||
return get(StandardTypes::F64, ctx); | |||||
} | |||||
/// Return the bitwidth of this float type. | /// Return the bitwidth of this float type. | ||||
unsigned getWidth(); | unsigned getWidth(); | ||||
/// Return the floating semantics of this float type. | /// Return the floating semantics of this float type. | ||||
const llvm::fltSemantics &getFloatSemantics(); | const llvm::fltSemantics &getFloatSemantics(); | ||||
}; | }; | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// BFloat16Type | |||||
class BFloat16Type | |||||
: public Type::TypeBase<BFloat16Type, FloatType, TypeStorage> { | |||||
public: | |||||
using Base::Base; | |||||
/// Return an instance of the bfloat16 type. | |||||
static BFloat16Type get(MLIRContext *context); | |||||
}; | |||||
inline FloatType FloatType::getBF16(MLIRContext *ctx) { | |||||
return BFloat16Type::get(ctx); | |||||
} | |||||
//===----------------------------------------------------------------------===// | |||||
// Float16Type | |||||
class Float16Type : public Type::TypeBase<Float16Type, FloatType, TypeStorage> { | |||||
public: | |||||
using Base::Base; | |||||
/// Return an instance of the float16 type. | |||||
static Float16Type get(MLIRContext *context); | |||||
}; | |||||
inline FloatType FloatType::getF16(MLIRContext *ctx) { | |||||
return Float16Type::get(ctx); | |||||
} | |||||
//===----------------------------------------------------------------------===// | |||||
// Float32Type | |||||
class Float32Type : public Type::TypeBase<Float32Type, FloatType, TypeStorage> { | |||||
public: | |||||
using Base::Base; | |||||
/// Return an instance of the float32 type. | |||||
static Float32Type get(MLIRContext *context); | |||||
}; | |||||
inline FloatType FloatType::getF32(MLIRContext *ctx) { | |||||
return Float32Type::get(ctx); | |||||
} | |||||
//===----------------------------------------------------------------------===// | |||||
// Float64Type | |||||
class Float64Type : public Type::TypeBase<Float64Type, FloatType, TypeStorage> { | |||||
public: | |||||
using Base::Base; | |||||
/// Return an instance of the float64 type. | |||||
static Float64Type get(MLIRContext *context); | |||||
}; | |||||
inline FloatType FloatType::getF64(MLIRContext *ctx) { | |||||
return Float64Type::get(ctx); | |||||
} | |||||
//===----------------------------------------------------------------------===// | |||||
// NoneType | // NoneType | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
/// NoneType is a unit type, i.e. a type with exactly one possible value, where | /// NoneType is a unit type, i.e. a type with exactly one possible value, where | ||||
/// its value does not have a defined dynamic representation. | /// its value does not have a defined dynamic representation. | ||||
class NoneType : public Type::TypeBase<NoneType, Type, TypeStorage> { | class NoneType : public Type::TypeBase<NoneType, Type, TypeStorage> { | ||||
public: | public: | ||||
using Base::Base; | using Base::Base; | ||||
▲ Show 20 Lines • Show All 399 Lines • ▼ Show 20 Lines | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// Deferred Method Definitions | // Deferred Method Definitions | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
inline bool BaseMemRefType::classof(Type type) { | inline bool BaseMemRefType::classof(Type type) { | ||||
return type.isa<MemRefType, UnrankedMemRefType>(); | return type.isa<MemRefType, UnrankedMemRefType>(); | ||||
} | } | ||||
inline bool FloatType::classof(Type type) { | |||||
return type.isa<BFloat16Type, Float16Type, Float32Type, Float64Type>(); | |||||
} | |||||
inline bool ShapedType::classof(Type type) { | inline bool ShapedType::classof(Type type) { | ||||
return type.isa<RankedTensorType, VectorType, UnrankedTensorType, | return type.isa<RankedTensorType, VectorType, UnrankedTensorType, | ||||
UnrankedMemRefType, MemRefType>(); | UnrankedMemRefType, MemRefType>(); | ||||
} | } | ||||
inline bool TensorType::classof(Type type) { | inline bool TensorType::classof(Type type) { | ||||
return type.isa<RankedTensorType, UnrankedTensorType>(); | return type.isa<RankedTensorType, UnrankedTensorType>(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |