未验证 提交 94a56cc1 编写于 作者: A Aurelius84 提交者: GitHub

[IR]Add BFloat16 in IrContextImpl (#54281)

上级 c71198f8
......@@ -42,6 +42,8 @@ class BFloat16Type : public Type {
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(BFloat16Type, TypeStorage);
static BFloat16Type get(IrContext *context);
};
class Int8Type : public Type {
......
......@@ -22,9 +22,8 @@ Dialect::~Dialect() = default;
void Dialect::RegisterInterface(std::unique_ptr<DialectInterface> interface) {
VLOG(4) << "Register interface into dialect" << std::endl;
auto it = registered_interfaces_.emplace(interface->interface_id(),
std::move(interface));
(void)it;
registered_interfaces_.emplace(interface->interface_id(),
std::move(interface));
}
DialectInterface::~DialectInterface() = default;
......
......@@ -151,6 +151,7 @@ class IrContextImpl {
// TypeStorage uniquer and cache instances.
StorageManager registed_type_storage_manager_;
// Cache some built-in type objects.
BFloat16Type bfp16_type;
Float16Type fp16_type;
Float32Type fp32_type;
Float64Type fp64_type;
......@@ -185,6 +186,7 @@ IrContext::IrContext() : impl_(new IrContextImpl()) {
GetOrRegisterDialect<BuiltinDialect>();
VLOG(4) << "==============================================";
impl_->bfp16_type = TypeManager::get<BFloat16Type>(this);
impl_->fp16_type = TypeManager::get<Float16Type>(this);
impl_->fp32_type = TypeManager::get<Float32Type>(this);
impl_->fp64_type = TypeManager::get<Float64Type>(this);
......@@ -319,6 +321,10 @@ const AbstractAttribute &AbstractAttribute::lookup(TypeId type_id,
}
}
BFloat16Type BFloat16Type::get(IrContext *ctx) {
return ctx->impl().bfp16_type;
}
Float16Type Float16Type::get(IrContext *ctx) { return ctx->impl().fp16_type; }
Float32Type Float32Type::get(IrContext *ctx) { return ctx->impl().fp32_type; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册