Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
e73ddd6c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
e73ddd6c
编写于
6月 12, 2023
作者:
Z
zhangbo9674
提交者:
GitHub
6月 12, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine attribute name (#54516)
上级
b04689e9
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
48 addition
and
50 deletion
+48
-50
paddle/fluid/ir/dialect/op_gen.py
paddle/fluid/ir/dialect/op_gen.py
+9
-9
paddle/fluid/ir/dialect/pd_attribute.cc
paddle/fluid/ir/dialect/pd_attribute.cc
+4
-4
paddle/fluid/ir/dialect/pd_attribute.h
paddle/fluid/ir/dialect/pd_attribute.h
+2
-2
paddle/fluid/ir/dialect/utils.h
paddle/fluid/ir/dialect/utils.h
+2
-2
paddle/fluid/ir_adaptor/translator/attribute_translator.cc
paddle/fluid/ir_adaptor/translator/attribute_translator.cc
+3
-3
paddle/fluid/ir_adaptor/translator/op_translator.cc
paddle/fluid/ir_adaptor/translator/op_translator.cc
+5
-5
paddle/ir/core/builtin_attribute.cc
paddle/ir/core/builtin_attribute.cc
+2
-2
paddle/ir/core/builtin_attribute.h
paddle/ir/core/builtin_attribute.h
+4
-4
paddle/ir/core/builtin_attribute_storage.h
paddle/ir/core/builtin_attribute_storage.h
+2
-2
paddle/ir/core/builtin_dialect.cc
paddle/ir/core/builtin_dialect.cc
+2
-2
paddle/ir/core/builtin_op.cc
paddle/ir/core/builtin_op.cc
+2
-2
paddle/ir/core/ir_printer.cc
paddle/ir/core/ir_printer.cc
+2
-2
test/cpp/ir/core/ir_op_test.cc
test/cpp/ir/core/ir_op_test.cc
+1
-1
test/cpp/ir/core/ir_program_test.cc
test/cpp/ir/core/ir_program_test.cc
+3
-4
test/cpp/ir/core/op_info_test.cc
test/cpp/ir/core/op_info_test.cc
+1
-1
test/cpp/ir/core/phi_kernel_adaptor.h
test/cpp/ir/core/phi_kernel_adaptor.h
+2
-3
test/cpp/ir/core/scalar_attribute_test.cc
test/cpp/ir/core/scalar_attribute_test.cc
+2
-2
未找到文件。
paddle/fluid/ir/dialect/op_gen.py
浏览文件 @
e73ddd6c
...
@@ -251,8 +251,8 @@ def to_phi_and_fluid_op_name(op_item):
...
@@ -251,8 +251,8 @@ def to_phi_and_fluid_op_name(op_item):
scalar_type_maps
=
{
scalar_type_maps
=
{
'int'
:
'ir::Int32
_t
Attribute'
,
'int'
:
'ir::Int32Attribute'
,
'int64_t'
:
'ir::Int64
_t
Attribute'
,
'int64_t'
:
'ir::Int64Attribute'
,
'float'
:
'ir::FloatAttribute'
,
'float'
:
'ir::FloatAttribute'
,
'dobule'
:
'ir::DoubleAttribute'
,
'dobule'
:
'ir::DoubleAttribute'
,
'bool'
:
'ir::BoolAttribute'
,
'bool'
:
'ir::BoolAttribute'
,
...
@@ -309,17 +309,17 @@ class OpInfoParser:
...
@@ -309,17 +309,17 @@ class OpInfoParser:
self
.
attr_types_map
=
{
self
.
attr_types_map
=
{
'IntArray'
:
[
'paddle::dialect::IntArrayAttribute'
,
'IntArray'
],
'IntArray'
:
[
'paddle::dialect::IntArrayAttribute'
,
'IntArray'
],
'Scalar'
:
[
'paddle::dialect::ScalarAttribute'
,
'Scalar'
],
'Scalar'
:
[
'paddle::dialect::ScalarAttribute'
,
'Scalar'
],
'Scalar(int)'
:
[
'ir::Int32
_t
Attribute'
,
'int'
],
'Scalar(int)'
:
[
'ir::Int32Attribute'
,
'int'
],
'Scalar(int64_t)'
:
[
'ir::Int64
_t
Attribute'
,
'int64_t'
],
'Scalar(int64_t)'
:
[
'ir::Int64Attribute'
,
'int64_t'
],
'Scalar(float)'
:
[
'ir::FloatAttribute'
,
'float'
],
'Scalar(float)'
:
[
'ir::FloatAttribute'
,
'float'
],
'Scalar(dobule)'
:
[
'ir::DoubleAttribute'
,
'dobule'
],
'Scalar(dobule)'
:
[
'ir::DoubleAttribute'
,
'dobule'
],
'Scalar[]'
:
[
'Scalar[]'
:
[
'ir::ArrayAttribute<paddle::dialect::ScalarAttribute>'
,
'ir::ArrayAttribute<paddle::dialect::ScalarAttribute>'
,
'const std::vector<Scalar>&'
,
'const std::vector<Scalar>&'
,
],
],
'int'
:
[
'ir::Int32
_t
Attribute'
,
'int'
],
'int'
:
[
'ir::Int32Attribute'
,
'int'
],
'int32_t'
:
[
'ir::Int32
_t
Attribute'
,
'int32_t'
],
'int32_t'
:
[
'ir::Int32Attribute'
,
'int32_t'
],
'int64_t'
:
[
'ir::Int64
_t
Attribute'
,
'int64_t'
],
'int64_t'
:
[
'ir::Int64Attribute'
,
'int64_t'
],
'long'
:
[
'ir::LongAttribute'
,
'long'
],
'long'
:
[
'ir::LongAttribute'
,
'long'
],
'size_t'
:
[
'ir::Size_tAttribute'
,
'size_t'
],
'size_t'
:
[
'ir::Size_tAttribute'
,
'size_t'
],
'float'
:
[
'ir::FloatAttribute'
,
'float'
],
'float'
:
[
'ir::FloatAttribute'
,
'float'
],
...
@@ -345,11 +345,11 @@ class OpInfoParser:
...
@@ -345,11 +345,11 @@ class OpInfoParser:
],
],
'DataType'
:
[
'paddle::dialect::DataTypeAttribute'
,
'DataType'
],
'DataType'
:
[
'paddle::dialect::DataTypeAttribute'
,
'DataType'
],
'int64_t[]'
:
[
'int64_t[]'
:
[
'ir::ArrayAttribute<ir::Int64
_t
Attribute>'
,
'ir::ArrayAttribute<ir::Int64Attribute>'
,
'const std::vector<int64_t>&'
,
'const std::vector<int64_t>&'
,
],
],
'int[]'
:
[
'int[]'
:
[
'ir::ArrayAttribute<ir::Int32
_t
Attribute>'
,
'ir::ArrayAttribute<ir::Int32Attribute>'
,
'const std::vector<int>&'
,
'const std::vector<int>&'
,
],
],
}
}
...
...
paddle/fluid/ir/dialect/pd_attribute.cc
浏览文件 @
e73ddd6c
...
@@ -31,10 +31,10 @@ phi::Scalar ScalarAttribute::data() {
...
@@ -31,10 +31,10 @@ phi::Scalar ScalarAttribute::data() {
return
phi
::
Scalar
(
dyn_cast
<
ir
::
FloatAttribute
>
().
data
());
return
phi
::
Scalar
(
dyn_cast
<
ir
::
FloatAttribute
>
().
data
());
}
else
if
(
isa
<
ir
::
DoubleAttribute
>
())
{
}
else
if
(
isa
<
ir
::
DoubleAttribute
>
())
{
return
phi
::
Scalar
(
dyn_cast
<
ir
::
DoubleAttribute
>
().
data
());
return
phi
::
Scalar
(
dyn_cast
<
ir
::
DoubleAttribute
>
().
data
());
}
else
if
(
isa
<
ir
::
Int32
_t
Attribute
>
())
{
}
else
if
(
isa
<
ir
::
Int32Attribute
>
())
{
return
phi
::
Scalar
(
dyn_cast
<
ir
::
Int32
_t
Attribute
>
().
data
());
return
phi
::
Scalar
(
dyn_cast
<
ir
::
Int32Attribute
>
().
data
());
}
else
if
(
isa
<
ir
::
Int64
_t
Attribute
>
())
{
}
else
if
(
isa
<
ir
::
Int64Attribute
>
())
{
return
phi
::
Scalar
(
dyn_cast
<
ir
::
Int64
_t
Attribute
>
().
data
());
return
phi
::
Scalar
(
dyn_cast
<
ir
::
Int64Attribute
>
().
data
());
}
else
if
(
isa
<
ir
::
BoolAttribute
>
())
{
}
else
if
(
isa
<
ir
::
BoolAttribute
>
())
{
return
phi
::
Scalar
(
dyn_cast
<
ir
::
BoolAttribute
>
().
data
());
return
phi
::
Scalar
(
dyn_cast
<
ir
::
BoolAttribute
>
().
data
());
}
else
{
}
else
{
...
...
paddle/fluid/ir/dialect/pd_attribute.h
浏览文件 @
e73ddd6c
...
@@ -44,8 +44,8 @@ class ScalarAttribute : public ir::Attribute {
...
@@ -44,8 +44,8 @@ class ScalarAttribute : public ir::Attribute {
return
(
val
.
type_id
()
==
ir
::
BoolAttribute
::
type_id
())
||
return
(
val
.
type_id
()
==
ir
::
BoolAttribute
::
type_id
())
||
(
val
.
type_id
()
==
ir
::
FloatAttribute
::
type_id
())
||
(
val
.
type_id
()
==
ir
::
FloatAttribute
::
type_id
())
||
(
val
.
type_id
()
==
ir
::
DoubleAttribute
::
type_id
())
||
(
val
.
type_id
()
==
ir
::
DoubleAttribute
::
type_id
())
||
(
val
.
type_id
()
==
ir
::
Int32
_t
Attribute
::
type_id
())
||
(
val
.
type_id
()
==
ir
::
Int32Attribute
::
type_id
())
||
(
val
.
type_id
()
==
ir
::
Int64
_t
Attribute
::
type_id
());
(
val
.
type_id
()
==
ir
::
Int64Attribute
::
type_id
());
}
}
phi
::
Scalar
data
();
phi
::
Scalar
data
();
...
...
paddle/fluid/ir/dialect/utils.h
浏览文件 @
e73ddd6c
...
@@ -83,9 +83,9 @@ static inline ir::Attribute TransToIrAttribute(phi::Scalar scalar,
...
@@ -83,9 +83,9 @@ static inline ir::Attribute TransToIrAttribute(phi::Scalar scalar,
case
phi
::
DataType
::
FLOAT64
:
case
phi
::
DataType
::
FLOAT64
:
return
ir
::
DoubleAttribute
::
get
(
ctx
,
scalar
.
to
<
double
>
());
return
ir
::
DoubleAttribute
::
get
(
ctx
,
scalar
.
to
<
double
>
());
case
phi
::
DataType
::
INT32
:
case
phi
::
DataType
::
INT32
:
return
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
scalar
.
to
<
int32_t
>
());
return
ir
::
Int32Attribute
::
get
(
ctx
,
scalar
.
to
<
int32_t
>
());
case
phi
::
DataType
::
INT64
:
case
phi
::
DataType
::
INT64
:
return
ir
::
Int64
_t
Attribute
::
get
(
ctx
,
scalar
.
to
<
int64_t
>
());
return
ir
::
Int64Attribute
::
get
(
ctx
,
scalar
.
to
<
int64_t
>
());
case
phi
::
DataType
::
BOOL
:
case
phi
::
DataType
::
BOOL
:
return
ir
::
BoolAttribute
::
get
(
ctx
,
scalar
.
to
<
bool
>
());
return
ir
::
BoolAttribute
::
get
(
ctx
,
scalar
.
to
<
bool
>
());
default:
default:
...
...
paddle/fluid/ir_adaptor/translator/attribute_translator.cc
浏览文件 @
e73ddd6c
...
@@ -38,7 +38,7 @@ class AttributeVisitor {
...
@@ -38,7 +38,7 @@ class AttributeVisitor {
public:
public:
virtual
ir
::
Attribute
operator
()(
int
i
)
{
virtual
ir
::
Attribute
operator
()(
int
i
)
{
VLOG
(
10
)
<<
"translating int"
;
VLOG
(
10
)
<<
"translating int"
;
return
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
i
);
return
ir
::
Int32Attribute
::
get
(
ctx
,
i
);
}
}
virtual
ir
::
Attribute
operator
()(
float
f
)
{
virtual
ir
::
Attribute
operator
()(
float
f
)
{
...
@@ -91,7 +91,7 @@ class AttributeVisitor {
...
@@ -91,7 +91,7 @@ class AttributeVisitor {
std
::
vector
<
ir
::
Attribute
>
attrs
;
std
::
vector
<
ir
::
Attribute
>
attrs
;
attrs
.
reserve
(
is
.
size
());
attrs
.
reserve
(
is
.
size
());
for
(
const
auto
&
v
:
is
)
{
for
(
const
auto
&
v
:
is
)
{
attrs
.
push_back
(
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
v
));
attrs
.
push_back
(
ir
::
Int32Attribute
::
get
(
ctx
,
v
));
}
}
return
ir
::
ArrayAttribute
::
get
(
ctx
,
attrs
);
return
ir
::
ArrayAttribute
::
get
(
ctx
,
attrs
);
}
}
...
@@ -111,7 +111,7 @@ class AttributeVisitor {
...
@@ -111,7 +111,7 @@ class AttributeVisitor {
std
::
vector
<
ir
::
Attribute
>
attrs
;
std
::
vector
<
ir
::
Attribute
>
attrs
;
attrs
.
reserve
(
i64s
.
size
());
attrs
.
reserve
(
i64s
.
size
());
for
(
const
auto
&
v
:
i64s
)
{
for
(
const
auto
&
v
:
i64s
)
{
attrs
.
push_back
(
ir
::
Int64
_t
Attribute
::
get
(
ctx
,
v
));
attrs
.
push_back
(
ir
::
Int64Attribute
::
get
(
ctx
,
v
));
}
}
return
ir
::
ArrayAttribute
::
get
(
ctx
,
attrs
);
return
ir
::
ArrayAttribute
::
get
(
ctx
,
attrs
);
}
}
...
...
paddle/fluid/ir_adaptor/translator/op_translator.cc
浏览文件 @
e73ddd6c
...
@@ -131,7 +131,7 @@ inline ir::Operation* InsertSliceOperationForTarget(
...
@@ -131,7 +131,7 @@ inline ir::Operation* InsertSliceOperationForTarget(
std
::
string
slice_op_name
(
ir
::
SliceOp
::
name
());
std
::
string
slice_op_name
(
ir
::
SliceOp
::
name
());
ir
::
OpInfo
op_info
=
ctx
->
GetRegisteredOpInfo
(
slice_op_name
);
ir
::
OpInfo
op_info
=
ctx
->
GetRegisteredOpInfo
(
slice_op_name
);
std
::
unordered_map
<
std
::
string
,
ir
::
Attribute
>
op_attribute_map
=
{
std
::
unordered_map
<
std
::
string
,
ir
::
Attribute
>
op_attribute_map
=
{
{
"index"
,
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
defining_info
.
idx_in_vector
)},
{
"index"
,
ir
::
Int32Attribute
::
get
(
ctx
,
defining_info
.
idx_in_vector
)},
};
};
ir
::
VectorType
src_vec_type
=
ir
::
VectorType
src_vec_type
=
defining_info
.
value
.
type
().
dyn_cast
<
ir
::
VectorType
>
();
defining_info
.
value
.
type
().
dyn_cast
<
ir
::
VectorType
>
();
...
@@ -179,11 +179,11 @@ inline ir::Operation* InsertFullOperationForAttributeInput(ir::IrContext* ctx,
...
@@ -179,11 +179,11 @@ inline ir::Operation* InsertFullOperationForAttributeInput(ir::IrContext* ctx,
}
else
if
(
attr
.
isa
<
ir
::
DoubleAttribute
>
())
{
}
else
if
(
attr
.
isa
<
ir
::
DoubleAttribute
>
())
{
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
DoubleAttribute
>
().
data
());
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
DoubleAttribute
>
().
data
());
dtype
=
phi
::
DataType
::
FLOAT64
;
dtype
=
phi
::
DataType
::
FLOAT64
;
}
else
if
(
attr
.
isa
<
ir
::
Int32
_t
Attribute
>
())
{
}
else
if
(
attr
.
isa
<
ir
::
Int32Attribute
>
())
{
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
Int32
_t
Attribute
>
().
data
());
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
Int32Attribute
>
().
data
());
dtype
=
phi
::
DataType
::
INT32
;
dtype
=
phi
::
DataType
::
INT32
;
}
else
if
(
attr
.
isa
<
ir
::
Int64
_t
Attribute
>
())
{
}
else
if
(
attr
.
isa
<
ir
::
Int64Attribute
>
())
{
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
Int64
_t
Attribute
>
().
data
());
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
Int64Attribute
>
().
data
());
dtype
=
phi
::
DataType
::
INT64
;
dtype
=
phi
::
DataType
::
INT64
;
}
else
if
(
attr
.
isa
<
ir
::
BoolAttribute
>
())
{
}
else
if
(
attr
.
isa
<
ir
::
BoolAttribute
>
())
{
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
BoolAttribute
>
().
data
());
data
=
static_cast
<
float
>
(
attr
.
dyn_cast
<
ir
::
BoolAttribute
>
().
data
());
...
...
paddle/ir/core/builtin_attribute.cc
浏览文件 @
e73ddd6c
...
@@ -25,9 +25,9 @@ float FloatAttribute::data() const { return storage()->GetAsKey(); }
...
@@ -25,9 +25,9 @@ float FloatAttribute::data() const { return storage()->GetAsKey(); }
double
DoubleAttribute
::
data
()
const
{
return
storage
()
->
GetAsKey
();
}
double
DoubleAttribute
::
data
()
const
{
return
storage
()
->
GetAsKey
();
}
int32_t
Int32
_t
Attribute
::
data
()
const
{
return
storage
()
->
GetAsKey
();
}
int32_t
Int32Attribute
::
data
()
const
{
return
storage
()
->
GetAsKey
();
}
int64_t
Int64
_t
Attribute
::
data
()
const
{
return
storage
()
->
GetAsKey
();
}
int64_t
Int64Attribute
::
data
()
const
{
return
storage
()
->
GetAsKey
();
}
std
::
vector
<
Attribute
>
ArrayAttribute
::
data
()
const
{
std
::
vector
<
Attribute
>
ArrayAttribute
::
data
()
const
{
return
storage
()
->
GetAsKey
();
return
storage
()
->
GetAsKey
();
...
...
paddle/ir/core/builtin_attribute.h
浏览文件 @
e73ddd6c
...
@@ -61,20 +61,20 @@ class DoubleAttribute : public Attribute {
...
@@ -61,20 +61,20 @@ class DoubleAttribute : public Attribute {
double
data
()
const
;
double
data
()
const
;
};
};
class
Int32
_t
Attribute
:
public
Attribute
{
class
Int32Attribute
:
public
Attribute
{
public:
public:
using
Attribute
::
Attribute
;
using
Attribute
::
Attribute
;
DECLARE_ATTRIBUTE_UTILITY_FUNCTOR
(
Int32
_tAttribute
,
Int32_t
AttributeStorage
);
DECLARE_ATTRIBUTE_UTILITY_FUNCTOR
(
Int32
Attribute
,
Int32
AttributeStorage
);
int32_t
data
()
const
;
int32_t
data
()
const
;
};
};
class
Int64
_t
Attribute
:
public
Attribute
{
class
Int64Attribute
:
public
Attribute
{
public:
public:
using
Attribute
::
Attribute
;
using
Attribute
::
Attribute
;
DECLARE_ATTRIBUTE_UTILITY_FUNCTOR
(
Int64
_tAttribute
,
Int64_t
AttributeStorage
);
DECLARE_ATTRIBUTE_UTILITY_FUNCTOR
(
Int64
Attribute
,
Int64
AttributeStorage
);
int64_t
data
()
const
;
int64_t
data
()
const
;
};
};
...
...
paddle/ir/core/builtin_attribute_storage.h
浏览文件 @
e73ddd6c
...
@@ -81,8 +81,8 @@ struct StrAttributeStorage : public AttributeStorage {
...
@@ -81,8 +81,8 @@ struct StrAttributeStorage : public AttributeStorage {
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
BoolAttributeStorage
,
bool
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
BoolAttributeStorage
,
bool
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
FloatAttributeStorage
,
float
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
FloatAttributeStorage
,
float
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
DoubleAttributeStorage
,
double
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
DoubleAttributeStorage
,
double
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
Int32
_t
AttributeStorage
,
int32_t
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
Int32AttributeStorage
,
int32_t
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
Int64
_t
AttributeStorage
,
int64_t
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
Int64AttributeStorage
,
int64_t
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
PointerAttributeStorage
,
void
*
);
DECLARE_BASE_TYPE_ATTRIBUTE_STORAGE
(
PointerAttributeStorage
,
void
*
);
struct
ArrayAttributeStorage
:
public
AttributeStorage
{
struct
ArrayAttributeStorage
:
public
AttributeStorage
{
...
...
paddle/ir/core/builtin_dialect.cc
浏览文件 @
e73ddd6c
...
@@ -41,8 +41,8 @@ void BuiltinDialect::initialize() {
...
@@ -41,8 +41,8 @@ void BuiltinDialect::initialize() {
FloatAttribute
,
FloatAttribute
,
DoubleAttribute
,
DoubleAttribute
,
PointerAttribute
,
PointerAttribute
,
Int32
_t
Attribute
,
Int32Attribute
,
Int64
_t
Attribute
,
Int64Attribute
,
ArrayAttribute
>
();
ArrayAttribute
>
();
RegisterOps
<
ModuleOp
,
RegisterOps
<
ModuleOp
,
...
...
paddle/ir/core/builtin_op.cc
浏览文件 @
e73ddd6c
...
@@ -161,9 +161,9 @@ void SliceOp::Verify(const std::vector<ir::OpResult> &inputs,
...
@@ -161,9 +161,9 @@ void SliceOp::Verify(const std::vector<ir::OpResult> &inputs,
IR_ENFORCE
(
attributes
.
count
(
"index"
)
!=
0
,
IR_ENFORCE
(
attributes
.
count
(
"index"
)
!=
0
,
"The attributes must contains index."
);
"The attributes must contains index."
);
const
ir
::
Attribute
&
attr
=
attributes
.
at
(
"index"
);
const
ir
::
Attribute
&
attr
=
attributes
.
at
(
"index"
);
IR_ENFORCE
(
attr
.
isa
<
ir
::
Int32
_t
Attribute
>
(),
IR_ENFORCE
(
attr
.
isa
<
ir
::
Int32Attribute
>
(),
"The attribute index must be INT32."
);
"The attribute index must be INT32."
);
auto
index
=
attr
.
dyn_cast
<
ir
::
Int32
_t
Attribute
>
().
data
();
auto
index
=
attr
.
dyn_cast
<
ir
::
Int32Attribute
>
().
data
();
// index >= 0 and < inputs[0].size()
// index >= 0 and < inputs[0].size()
IR_ENFORCE
(
IR_ENFORCE
(
...
...
paddle/ir/core/ir_printer.cc
浏览文件 @
e73ddd6c
...
@@ -83,9 +83,9 @@ class BasicIRPrinter {
...
@@ -83,9 +83,9 @@ class BasicIRPrinter {
os
<<
f
.
data
();
os
<<
f
.
data
();
}
else
if
(
auto
d
=
attr
.
dyn_cast
<
DoubleAttribute
>
())
{
}
else
if
(
auto
d
=
attr
.
dyn_cast
<
DoubleAttribute
>
())
{
os
<<
d
.
data
();
os
<<
d
.
data
();
}
else
if
(
auto
i
=
attr
.
dyn_cast
<
Int32
_t
Attribute
>
())
{
}
else
if
(
auto
i
=
attr
.
dyn_cast
<
Int32Attribute
>
())
{
os
<<
i
.
data
();
os
<<
i
.
data
();
}
else
if
(
auto
i
=
attr
.
dyn_cast
<
Int64
_t
Attribute
>
())
{
}
else
if
(
auto
i
=
attr
.
dyn_cast
<
Int64Attribute
>
())
{
os
<<
i
.
data
();
os
<<
i
.
data
();
}
else
if
(
auto
arr
=
attr
.
dyn_cast
<
ArrayAttribute
>
())
{
}
else
if
(
auto
arr
=
attr
.
dyn_cast
<
ArrayAttribute
>
())
{
const
auto
&
vec
=
arr
.
data
();
const
auto
&
vec
=
arr
.
data
();
...
...
test/cpp/ir/core/ir_op_test.cc
浏览文件 @
e73ddd6c
...
@@ -238,7 +238,7 @@ TEST(op_test, module_op_death) {
...
@@ -238,7 +238,7 @@ TEST(op_test, module_op_death) {
// (3) Test uses for op.
// (3) Test uses for op.
std
::
vector
<
ir
::
OpResult
>
inputs
{
ir
::
OpResult
()};
std
::
vector
<
ir
::
OpResult
>
inputs
{
ir
::
OpResult
()};
ir
::
AttributeMap
attrs
{{
"program"
,
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
1
)}};
ir
::
AttributeMap
attrs
{{
"program"
,
ir
::
Int32Attribute
::
get
(
ctx
,
1
)}};
std
::
vector
<
ir
::
Type
>
output_types
=
{
ir
::
Float32Type
::
get
(
ctx
)};
std
::
vector
<
ir
::
Type
>
output_types
=
{
ir
::
Float32Type
::
get
(
ctx
)};
EXPECT_THROW
(
ir
::
Operation
::
Create
(
inputs
,
{},
{},
op_info
),
EXPECT_THROW
(
ir
::
Operation
::
Create
(
inputs
,
{},
{},
op_info
),
...
...
test/cpp/ir/core/ir_program_test.cc
浏览文件 @
e73ddd6c
...
@@ -283,7 +283,7 @@ TEST(program_test, slice_combine_test) {
...
@@ -283,7 +283,7 @@ TEST(program_test, slice_combine_test) {
// (7) Def slice_op = SliceOp(combine_op, 0)
// (7) Def slice_op = SliceOp(combine_op, 0)
std
::
string
slice_op_name
=
std
::
string
(
ir
::
SliceOp
::
name
());
std
::
string
slice_op_name
=
std
::
string
(
ir
::
SliceOp
::
name
());
ir
::
OpInfo
slice_op_info
=
ctx
->
GetRegisteredOpInfo
(
slice_op_name
);
ir
::
OpInfo
slice_op_info
=
ctx
->
GetRegisteredOpInfo
(
slice_op_name
);
ir
::
Attribute
index_attr
=
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
0
);
ir
::
Attribute
index_attr
=
ir
::
Int32Attribute
::
get
(
ctx
,
0
);
ir
::
Operation
*
slice_op
=
ir
::
Operation
*
slice_op
=
ir
::
Operation
::
Create
({
combine_op
->
GetResultByIndex
(
0
)},
ir
::
Operation
::
Create
({
combine_op
->
GetResultByIndex
(
0
)},
{{
"index"
,
index_attr
}},
{{
"index"
,
index_attr
}},
...
@@ -319,8 +319,7 @@ TEST(program_test, builder) {
...
@@ -319,8 +319,7 @@ TEST(program_test, builder) {
}
}
ir
::
ConstantOp
constant
=
builder
.
Build
<
ir
::
ConstantOp
>
(
ir
::
ConstantOp
constant
=
builder
.
Build
<
ir
::
ConstantOp
>
(
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
2
),
ir
::
Int32Type
::
get
(
ctx
));
ir
::
Int32Attribute
::
get
(
ctx
,
2
),
ir
::
Int32Type
::
get
(
ctx
));
EXPECT_EQ
(
program
.
block
()
->
size
()
==
2
,
true
);
EXPECT_EQ
(
program
.
block
()
->
size
()
==
2
,
true
);
EXPECT_EQ
(
constant
.
value
().
dyn_cast
<
ir
::
Int32_tAttribute
>
().
data
()
==
2
,
EXPECT_EQ
(
constant
.
value
().
dyn_cast
<
ir
::
Int32Attribute
>
().
data
()
==
2
,
true
);
true
);
}
}
test/cpp/ir/core/op_info_test.cc
浏览文件 @
e73ddd6c
...
@@ -28,7 +28,7 @@ TEST(ir_op_info_test, op_op_info_test) {
...
@@ -28,7 +28,7 @@ TEST(ir_op_info_test, op_op_info_test) {
ir
::
Block
*
block
=
program
.
block
();
ir
::
Block
*
block
=
program
.
block
();
ir
::
Builder
builder
(
context
,
block
);
ir
::
Builder
builder
(
context
,
block
);
builder
.
Build
<
ir
::
ConstantOp
>
(
ir
::
Int32
_t
Attribute
::
get
(
context
,
5
),
builder
.
Build
<
ir
::
ConstantOp
>
(
ir
::
Int32Attribute
::
get
(
context
,
5
),
ir
::
Int32Type
::
get
(
context
));
ir
::
Int32Type
::
get
(
context
));
ir
::
Operation
*
op
=
block
->
back
();
ir
::
Operation
*
op
=
block
->
back
();
...
...
test/cpp/ir/core/phi_kernel_adaptor.h
浏览文件 @
e73ddd6c
...
@@ -164,9 +164,8 @@ void build_context(ir::Operation* op,
...
@@ -164,9 +164,8 @@ void build_context(ir::Operation* op,
}
else
if
(
type_name
==
"paddle::dialect::DataTypeAttribute"
)
{
}
else
if
(
type_name
==
"paddle::dialect::DataTypeAttribute"
)
{
ctx
->
EmplaceBackAttr
(
ctx
->
EmplaceBackAttr
(
attr_map
[
t
].
dyn_cast
<
paddle
::
dialect
::
DataTypeAttribute
>
().
data
());
attr_map
[
t
].
dyn_cast
<
paddle
::
dialect
::
DataTypeAttribute
>
().
data
());
}
else
if
(
type_name
==
"ir::Int32_tAttribute"
)
{
}
else
if
(
type_name
==
"ir::Int32Attribute"
)
{
ctx
->
EmplaceBackAttr
(
ctx
->
EmplaceBackAttr
(
attr_map
[
t
].
dyn_cast
<
ir
::
Int32Attribute
>
().
data
());
attr_map
[
t
].
dyn_cast
<
ir
::
Int32_tAttribute
>
().
data
());
}
else
if
(
type_name
==
"paddle::dialect::PlaceAttribute"
)
{
}
else
if
(
type_name
==
"paddle::dialect::PlaceAttribute"
)
{
ctx
->
EmplaceBackAttr
(
ctx
->
EmplaceBackAttr
(
attr_map
[
t
].
dyn_cast
<
paddle
::
dialect
::
PlaceAttribute
>
().
data
());
attr_map
[
t
].
dyn_cast
<
paddle
::
dialect
::
PlaceAttribute
>
().
data
());
...
...
test/cpp/ir/core/scalar_attribute_test.cc
浏览文件 @
e73ddd6c
...
@@ -47,9 +47,9 @@ TEST(ScalarTest, test_classof) {
...
@@ -47,9 +47,9 @@ TEST(ScalarTest, test_classof) {
ir
::
Attribute
double_scalar
=
ir
::
DoubleAttribute
::
get
(
ctx
,
1.0
);
ir
::
Attribute
double_scalar
=
ir
::
DoubleAttribute
::
get
(
ctx
,
1.0
);
EXPECT_TRUE
(
double_scalar
.
isa
<
ScalarAttribute
>
());
EXPECT_TRUE
(
double_scalar
.
isa
<
ScalarAttribute
>
());
ir
::
Attribute
int32_scalar
=
ir
::
Int32
_t
Attribute
::
get
(
ctx
,
1
);
ir
::
Attribute
int32_scalar
=
ir
::
Int32Attribute
::
get
(
ctx
,
1
);
EXPECT_TRUE
(
int32_scalar
.
isa
<
ScalarAttribute
>
());
EXPECT_TRUE
(
int32_scalar
.
isa
<
ScalarAttribute
>
());
ir
::
Attribute
int64_scalar
=
ir
::
Int64
_t
Attribute
::
get
(
ctx
,
1l
);
ir
::
Attribute
int64_scalar
=
ir
::
Int64Attribute
::
get
(
ctx
,
1l
);
EXPECT_TRUE
(
int64_scalar
.
isa
<
ScalarAttribute
>
());
EXPECT_TRUE
(
int64_scalar
.
isa
<
ScalarAttribute
>
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录