Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d73db135
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d73db135
编写于
5月 24, 2023
作者:
王
王明冬
提交者:
GitHub
5月 24, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IR] fine-tune the interface of ir-context class. (#54031)
上级
e862753c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
18 addition
and
12 deletion
+18
-12
paddle/ir/ir_context.cc
paddle/ir/ir_context.cc
+17
-11
paddle/ir/ir_context.h
paddle/ir/ir_context.h
+1
-1
未找到文件。
paddle/ir/ir_context.cc
浏览文件 @
d73db135
...
@@ -99,6 +99,10 @@ class IrContextImpl {
...
@@ -99,6 +99,10 @@ class IrContextImpl {
return
nullptr
;
return
nullptr
;
}
}
bool
IsOpInfoRegistered
(
const
std
::
string
&
name
)
{
return
registed_op_infos_
.
find
(
name
)
!=
registed_op_infos_
.
end
();
}
void
RegisterOpInfo
(
const
std
::
string
&
name
,
OpInfoImpl
*
opinfo
)
{
void
RegisterOpInfo
(
const
std
::
string
&
name
,
OpInfoImpl
*
opinfo
)
{
std
::
lock_guard
<
ir
::
SpinLock
>
guard
(
registed_op_infos_lock_
);
std
::
lock_guard
<
ir
::
SpinLock
>
guard
(
registed_op_infos_lock_
);
VLOG
(
4
)
<<
"Register an operation of: [Name="
<<
name
VLOG
(
4
)
<<
"Register an operation of: [Name="
<<
name
...
@@ -125,7 +129,11 @@ class IrContextImpl {
...
@@ -125,7 +129,11 @@ class IrContextImpl {
registed_dialect_
.
emplace
(
name
,
dialect
);
registed_dialect_
.
emplace
(
name
,
dialect
);
}
}
Dialect
*
GetDialect
(
std
::
string
name
)
{
bool
IsDialectRegistered
(
const
std
::
string
&
name
)
{
return
registed_dialect_
.
find
(
name
)
!=
registed_dialect_
.
end
();
}
Dialect
*
GetDialect
(
const
std
::
string
&
name
)
{
std
::
lock_guard
<
ir
::
SpinLock
>
guard
(
registed_dialect_lock_
);
std
::
lock_guard
<
ir
::
SpinLock
>
guard
(
registed_dialect_lock_
);
auto
iter
=
registed_dialect_
.
find
(
name
);
auto
iter
=
registed_dialect_
.
find
(
name
);
if
(
iter
!=
registed_dialect_
.
end
())
{
if
(
iter
!=
registed_dialect_
.
end
())
{
...
@@ -221,17 +229,15 @@ AbstractAttribute *IrContext::GetRegisteredAbstractAttribute(TypeId id) {
...
@@ -221,17 +229,15 @@ AbstractAttribute *IrContext::GetRegisteredAbstractAttribute(TypeId id) {
}
}
Dialect
*
IrContext
::
GetOrRegisterDialect
(
Dialect
*
IrContext
::
GetOrRegisterDialect
(
std
::
string
dialect_name
,
std
::
function
<
Dialect
*
()
>
constructor
)
{
const
std
::
string
&
dialect_name
,
std
::
function
<
Dialect
*
()
>
constructor
)
{
VLOG
(
4
)
<<
"Try to get or register a Dialect of: [name="
<<
dialect_name
VLOG
(
4
)
<<
"Try to get or register a Dialect of: [name="
<<
dialect_name
<<
"]."
;
<<
"]."
;
Dialect
*
dialect
=
impl
().
GetDialect
(
dialect_name
);
if
(
!
impl
().
IsDialectRegistered
(
dialect_name
))
{
if
(
dialect
==
nullptr
)
{
VLOG
(
4
)
<<
"Create and register a new Dialect of: [name="
<<
dialect_name
VLOG
(
4
)
<<
"Create and register a new Dialect of: [name="
<<
dialect_name
<<
"]."
;
<<
"]."
;
dialect
=
constructor
();
impl
().
RegisterDialect
(
dialect_name
,
constructor
());
impl
().
RegisterDialect
(
dialect_name
,
dialect
);
}
}
return
dialect
;
return
impl
().
GetDialect
(
dialect_name
)
;
}
}
std
::
vector
<
Dialect
*>
IrContext
::
GetRegisteredDialects
()
{
std
::
vector
<
Dialect
*>
IrContext
::
GetRegisteredDialects
()
{
...
@@ -271,7 +277,9 @@ void IrContext::RegisterOpInfo(Dialect *dialect,
...
@@ -271,7 +277,9 @@ void IrContext::RegisterOpInfo(Dialect *dialect,
size_t
attributes_num
,
size_t
attributes_num
,
const
char
**
attributes_name
,
const
char
**
attributes_name
,
VerifyPtr
verify
)
{
VerifyPtr
verify
)
{
if
(
GetRegisteredOpInfo
(
name
)
==
nullptr
)
{
if
(
impl
().
IsOpInfoRegistered
(
name
))
{
LOG
(
WARNING
)
<<
name
<<
" op already registered."
;
}
else
{
OpInfoImpl
*
opinfo
=
OpInfoImpl
::
create
(
dialect
,
OpInfoImpl
*
opinfo
=
OpInfoImpl
::
create
(
dialect
,
op_id
,
op_id
,
name
,
name
,
...
@@ -281,9 +289,7 @@ void IrContext::RegisterOpInfo(Dialect *dialect,
...
@@ -281,9 +289,7 @@ void IrContext::RegisterOpInfo(Dialect *dialect,
attributes_name
,
attributes_name
,
verify
);
verify
);
impl
().
RegisterOpInfo
(
name
,
opinfo
);
impl
().
RegisterOpInfo
(
name
,
opinfo
);
VLOG
(
4
)
<<
"Op "
<<
name
<<
" registered into IrContext. --->"
;
VLOG
(
4
)
<<
name
<<
" op registered into IrContext. --->"
;
}
else
{
LOG
(
WARNING
)
<<
name
<<
" op already registered."
;
}
}
}
}
...
...
paddle/ir/ir_context.h
浏览文件 @
d73db135
...
@@ -143,7 +143,7 @@ class IrContext {
...
@@ -143,7 +143,7 @@ class IrContext {
///
///
/// \return The dialect named "dialect_name" in the context.
/// \return The dialect named "dialect_name" in the context.
///
///
Dialect
*
GetOrRegisterDialect
(
std
::
string
dialect_name
,
Dialect
*
GetOrRegisterDialect
(
const
std
::
string
&
dialect_name
,
std
::
function
<
Dialect
*
()
>
constructor
);
std
::
function
<
Dialect
*
()
>
constructor
);
///
///
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录