Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1d2a91c6
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
1d2a91c6
编写于
7月 17, 2023
作者:
W
winter-wang
提交者:
GitHub
7月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[IR] optimize the error log. (#55465)
上级
74206917
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
30 addition
and
27 deletion
+30
-27
paddle/fluid/ir/dialect/op_generator/op_member_func_gen.py
paddle/fluid/ir/dialect/op_generator/op_member_func_gen.py
+0
-13
paddle/ir/core/builtin_attribute_storage.h
paddle/ir/core/builtin_attribute_storage.h
+4
-1
paddle/ir/core/op_base.h
paddle/ir/core/op_base.h
+23
-10
paddle/ir/core/operation.h
paddle/ir/core/operation.h
+3
-3
未找到文件。
paddle/fluid/ir/dialect/op_generator/op_member_func_gen.py
浏览文件 @
1d2a91c6
...
...
@@ -18,18 +18,6 @@ OP_GET_INPUT_TEMPLATE = """ ir::Value {input_name}() {{ return operand({input_i
"""
OP_GET_OUTPUT_TEMPLATE
=
""" ir::OpResult {output_name}() {{ return result({output_index}); }}
"""
OP_GET_ATTRIBUTE_TEMPLATE
=
""" ir::Attribute attribute(const std::string &name) {
PADDLE_ENFORCE(attributes().count(name) > 0,
phi::errors::PreconditionNotMet("Attribute is not exist."));
return attributes().at(name);
}
template <typename T>
T attribute(const std::string &name) {
PADDLE_ENFORCE(attributes().count(name) > 0 && attributes().at(name).isa<T>(),
phi::errors::PreconditionNotMet("Attribute is not right."));
return attributes().at(name).dyn_cast<T>();
}
"""
def
gen_op_get_inputs_outputs_str
(
...
...
@@ -51,5 +39,4 @@ def gen_op_get_inputs_outputs_str(
output_name
=
op_output_name_list
[
idx
],
output_index
=
idx
,
)
op_get_inputs_outputs_str
+=
OP_GET_ATTRIBUTE_TEMPLATE
return
op_get_inputs_outputs_str
paddle/ir/core/builtin_attribute_storage.h
浏览文件 @
1d2a91c6
...
...
@@ -135,7 +135,10 @@ struct ArrayAttributeStorage : public AttributeStorage {
bool
empty
()
const
{
return
size_
==
0u
;
}
Attribute
at
(
size_t
index
)
const
{
IR_ENFORCE
(
index
<
size_
,
"Invalid index"
);
IR_ENFORCE
(
index
<
size_
,
"The index (%d) must be less than size (%d)."
,
index
,
size_
);
return
data_
[
index
];
}
...
...
paddle/ir/core/op_base.h
浏览文件 @
1d2a91c6
...
...
@@ -15,6 +15,7 @@
#pragma once
#include <type_traits>
#include "paddle/ir/core/enforce.h"
#include "paddle/ir/core/operation.h"
#include "paddle/ir/core/utils.h"
...
...
@@ -68,25 +69,37 @@ class IR_API OpBase {
public:
explicit
OpBase
(
Operation
*
operation
=
nullptr
)
:
operation_
(
operation
)
{}
Operation
*
operation
()
const
{
return
operation_
;
}
Operation
*
operation
()
const
{
IR_ENFORCE
(
operation_
,
"Can't use operation() in a null op."
);
return
operation_
;
}
explicit
operator
bool
()
const
{
return
operation_
!=
nullptr
;
}
operator
Operation
*
()
const
{
return
operation
();
}
explicit
operator
bool
()
const
{
return
operation
()
!=
nullptr
;
}
Operation
*
operator
->
()
const
{
return
operation
()
;
}
operator
Operation
*
()
const
{
return
operation_
;
}
IrContext
*
ir_context
()
const
{
return
operation
()
->
ir_context
()
;
}
Operation
*
operator
->
()
const
{
return
operation_
;
}
uint32_t
num_results
()
const
{
return
operation
()
->
num_results
()
;
}
IrContext
*
ir_context
()
const
{
return
operation_
->
ir_context
();
}
uint32_t
num_operands
()
const
{
return
operation
()
->
num_operands
();
}
uint32_t
num_results
()
const
{
return
operation_
->
num_result
s
();
}
const
AttributeMap
&
attributes
()
const
{
return
operation
()
->
attribute
s
();
}
uint32_t
num_operands
()
const
{
return
operation_
->
num_operands
(
);
}
Value
operand
(
uint32_t
index
)
const
{
return
operation
()
->
operand
(
index
);
}
const
AttributeMap
&
attributes
()
const
{
return
operation_
->
attributes
(
);
}
OpResult
result
(
uint32_t
index
)
const
{
return
operation
()
->
result
(
index
);
}
Value
operand
(
uint32_t
index
)
const
{
return
operation_
->
operand
(
index
);
}
ir
::
Attribute
attribute
(
const
std
::
string
&
name
)
{
return
operation
()
->
attribute
(
name
);
}
OpResult
result
(
uint32_t
index
)
const
{
return
operation_
->
result
(
index
);
}
template
<
typename
T
>
T
attribute
(
const
std
::
string
&
name
)
{
return
operation
()
->
attribute
<
T
>
(
name
);
}
private:
Operation
*
operation_
;
// Not owned
...
...
paddle/ir/core/operation.h
浏览文件 @
1d2a91c6
...
...
@@ -69,9 +69,9 @@ class IR_API alignas(8) Operation final {
template
<
typename
T
>
T
attribute
(
const
std
::
string
&
name
)
{
IR_ENFORCE
(
attributes
().
count
(
name
)
>
0
&&
attributes
().
at
(
name
).
isa
<
T
>
(),
"Attribute is not right."
);
return
attr
ibutes
().
at
(
name
)
.
dyn_cast
<
T
>
();
Attribute
attr
=
attribute
(
name
);
IR_ENFORCE
(
attr
.
isa
<
T
>
(),
"Attribute (%s) type is not right."
,
name
);
return
attr
.
dyn_cast
<
T
>
();
}
void
set_attribute
(
const
std
::
string
&
key
,
Attribute
value
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录