Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b927e72f
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看板
提交
b927e72f
编写于
4月 22, 2019
作者:
S
superjomn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add type compatible check
上级
12db9f3c
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
37 addition
and
5 deletion
+37
-5
paddle/fluid/lite/core/mir/io_complement_pass.cc
paddle/fluid/lite/core/mir/io_complement_pass.cc
+3
-1
paddle/fluid/lite/core/mir/node.h
paddle/fluid/lite/core/mir/node.h
+1
-0
paddle/fluid/lite/core/mir/variable_place_inference_pass.h
paddle/fluid/lite/core/mir/variable_place_inference_pass.h
+2
-0
paddle/fluid/lite/core/type_system.h
paddle/fluid/lite/core/type_system.h
+31
-4
未找到文件。
paddle/fluid/lite/core/mir/io_complement_pass.cc
浏览文件 @
b927e72f
...
@@ -36,7 +36,9 @@ void IoComplementPass::Apply(std::unique_ptr<mir::SSAGraph>& graph) {
...
@@ -36,7 +36,9 @@ void IoComplementPass::Apply(std::unique_ptr<mir::SSAGraph>& graph) {
inst
.
place
,
inst
.
op_type
,
tmp
);
inst
.
place
,
inst
.
op_type
,
tmp
);
CHECK
(
type
)
<<
"no param type found for "
<<
inst
.
op_type
<<
":"
<<
name
CHECK
(
type
)
<<
"no param type found for "
<<
inst
.
op_type
<<
":"
<<
name
<<
" "
<<
inst
.
place
;
<<
" "
<<
inst
.
place
;
if
(
type
->
tensor_place
!=
in
->
AsArgument
().
place
)
{
CHECK
(
type
->
type
);
CHECK
(
in
->
AsArgument
().
type
);
if
(
!
TypeCompatible
(
*
type
->
type
,
*
in
->
AsArgument
().
type
))
{
LOG
(
INFO
)
<<
"found IO unmatched tensor: "
<<
in
->
AsArgument
().
name
;
LOG
(
INFO
)
<<
"found IO unmatched tensor: "
<<
in
->
AsArgument
().
name
;
}
}
}
}
...
...
paddle/fluid/lite/core/mir/node.h
浏览文件 @
b927e72f
...
@@ -58,6 +58,7 @@ class Node {
...
@@ -58,6 +58,7 @@ class Node {
struct
Argument
{
struct
Argument
{
std
::
string
name
;
std
::
string
name
;
Place
place
;
Place
place
;
const
Type
*
type
;
// Weight is a special kind of argument, it is marked as weight explicitly
// Weight is a special kind of argument, it is marked as weight explicitly
// so that some weight related optimization can take place.
// so that some weight related optimization can take place.
bool
is_weight
{
false
};
bool
is_weight
{
false
};
...
...
paddle/fluid/lite/core/mir/variable_place_inference_pass.h
浏览文件 @
b927e72f
...
@@ -68,6 +68,7 @@ class VariablePlaceInferencePass : public DebugPass {
...
@@ -68,6 +68,7 @@ class VariablePlaceInferencePass : public DebugPass {
auto
&
arg_node
=
node
->
AsArgument
();
auto
&
arg_node
=
node
->
AsArgument
();
if
(
arg_node
.
place
.
is_valid
())
continue
;
if
(
arg_node
.
place
.
is_valid
())
continue
;
UpdatePlace
(
&
arg_node
.
place
,
type
->
tensor_place
);
UpdatePlace
(
&
arg_node
.
place
,
type
->
tensor_place
);
arg_node
.
type
=
type
->
type
;
}
}
}
}
...
@@ -86,6 +87,7 @@ class VariablePlaceInferencePass : public DebugPass {
...
@@ -86,6 +87,7 @@ class VariablePlaceInferencePass : public DebugPass {
CHECK
(
node
)
<<
"argument "
<<
arg_name
<<
" not exists in the graph"
;
CHECK
(
node
)
<<
"argument "
<<
arg_name
<<
" not exists in the graph"
;
auto
&
arg_node
=
node
->
AsArgument
();
auto
&
arg_node
=
node
->
AsArgument
();
if
(
arg_node
.
place
.
is_valid
())
continue
;
if
(
arg_node
.
place
.
is_valid
())
continue
;
node
->
AsArgument
().
type
=
type
->
type
;
UpdatePlace
(
&
arg_node
.
place
,
type
->
tensor_place
);
UpdatePlace
(
&
arg_node
.
place
,
type
->
tensor_place
);
}
}
}
}
...
...
paddle/fluid/lite/core/type_system.h
浏览文件 @
b927e72f
...
@@ -94,6 +94,7 @@ class Type : public DataTypeBase {
...
@@ -94,6 +94,7 @@ class Type : public DataTypeBase {
TargetType
target
()
const
{
return
place_
.
target
;
}
TargetType
target
()
const
{
return
place_
.
target
;
}
PrecisionType
precision
()
const
{
return
place_
.
precision
;
}
PrecisionType
precision
()
const
{
return
place_
.
precision
;
}
DataLayoutType
layout
()
const
{
return
place_
.
layout
;
}
DataLayoutType
layout
()
const
{
return
place_
.
layout
;
}
short
device
()
const
{
return
place
().
device
;
}
const
Place
&
place
()
const
{
return
place_
;
}
const
Place
&
place
()
const
{
return
place_
;
}
const
std
::
string
&
name
()
const
{
return
name_
;
}
const
std
::
string
&
name
()
const
{
return
name_
;
}
...
@@ -121,9 +122,9 @@ class Type : public DataTypeBase {
...
@@ -121,9 +122,9 @@ class Type : public DataTypeBase {
Type
(
ID
id
,
const
std
::
string
&
name
,
bool
is_tensor
,
Type
(
ID
id
,
const
std
::
string
&
name
,
bool
is_tensor
,
TargetType
target
=
TargetType
::
kHost
,
TargetType
target
=
TargetType
::
kHost
,
PrecisionType
precision
=
PrecisionType
::
kFloat
,
PrecisionType
precision
=
PrecisionType
::
kFloat
,
DataLayoutType
layout
=
DataLayoutType
::
kNCHW
)
DataLayoutType
layout
=
DataLayoutType
::
kNCHW
,
short
device
=
0
)
:
DataTypeBase
(
id
,
is_tensor
),
:
DataTypeBase
(
id
,
is_tensor
),
place_
{
target
,
precision
,
layout
},
place_
{
target
,
precision
,
layout
,
device
},
name_
(
name
)
{}
name_
(
name
)
{}
protected:
protected:
...
@@ -131,6 +132,32 @@ class Type : public DataTypeBase {
...
@@ -131,6 +132,32 @@ class Type : public DataTypeBase {
const
std
::
string
name_
;
const
std
::
string
name_
;
};
};
// -------------------------------- compatible check ---------------------------
static
bool
TargetCompatible
(
const
Type
&
a
,
const
Type
&
b
)
{
return
(
a
.
IsVoid
()
||
b
.
IsVoid
())
||
//
a
.
target
()
==
b
.
target
();
}
static
bool
DataLayoutCompatible
(
const
Type
&
a
,
const
Type
&
b
)
{
return
(
a
.
IsVoid
()
||
b
.
IsVoid
())
||
//
(
a
.
IsTensor
()
&&
b
.
IsTensor
()
&&
a
.
layout
()
==
b
.
layout
());
}
static
bool
PrecisionCompatible
(
const
Type
&
a
,
const
Type
&
b
)
{
return
(
a
.
IsVoid
()
||
b
.
IsVoid
())
||
//
(
a
.
precision
()
==
b
.
precision
());
}
static
bool
DeviceCompatible
(
const
Type
&
a
,
const
Type
&
b
)
{
return
(
a
.
IsVoid
()
||
b
.
IsVoid
())
||
//
(
a
.
device
()
==
b
.
device
());
}
static
bool
TypeCompatible
(
const
Type
&
a
,
const
Type
&
b
)
{
return
TargetCompatible
(
a
,
b
)
&&
DataLayoutCompatible
(
a
,
b
)
&&
PrecisionCompatible
(
a
,
b
)
&&
DeviceCompatible
(
a
,
b
);
}
// -------------------------------- predefined types ---------------------------
// -------------------------------- predefined types ---------------------------
// TODO(Superjomn) make all the Types' constructs protected to make sure there
// TODO(Superjomn) make all the Types' constructs protected to make sure there
// is only one instance across the system.
// is only one instance across the system.
...
@@ -232,14 +259,14 @@ struct ParamType {
...
@@ -232,14 +259,14 @@ struct ParamType {
// For unsupported types.
// For unsupported types.
size_t
element_type_hash
{};
size_t
element_type_hash
{};
Place
tensor_place
{};
Place
tensor_place
{};
const
Type
*
type
_
;
const
Type
*
type
;
explicit
ParamType
()
=
default
;
explicit
ParamType
()
=
default
;
explicit
ParamType
(
size_t
element_type_hash
)
explicit
ParamType
(
size_t
element_type_hash
)
:
element_type_hash
(
element_type_hash
)
{}
:
element_type_hash
(
element_type_hash
)
{}
ParamType
(
size_t
element_type_hash
,
const
Place
&
place
)
ParamType
(
size_t
element_type_hash
,
const
Place
&
place
)
:
element_type_hash
(
element_type_hash
),
tensor_place
(
place
)
{}
:
element_type_hash
(
element_type_hash
),
tensor_place
(
place
)
{}
ParamType
(
const
Type
*
type
)
:
type
_
(
type
)
{
tensor_place
=
type_
->
place
();
}
ParamType
(
const
Type
*
type
)
:
type
(
type
)
{
tensor_place
=
type
->
place
();
}
std
::
string
DebugString
()
const
{
return
tensor_place
.
DebugString
();
}
std
::
string
DebugString
()
const
{
return
tensor_place
.
DebugString
();
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录