Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
b0941102
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b0941102
编写于
11月 02, 2021
作者:
W
wanghuancoder
提交者:
GitHub
11月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some bug, test=develop (#36888)
上级
093c4ec5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
10 deletion
+57
-10
paddle/fluid/framework/new_executor/interpretercore.cc
paddle/fluid/framework/new_executor/interpretercore.cc
+4
-3
paddle/fluid/framework/new_executor/interpretercore_util.cc
paddle/fluid/framework/new_executor/interpretercore_util.cc
+18
-5
paddle/fluid/framework/new_executor/new_executor_defs.h
paddle/fluid/framework/new_executor/new_executor_defs.h
+9
-0
paddle/fluid/operators/controlflow/fetch_v2_op.cc
paddle/fluid/operators/controlflow/fetch_v2_op.cc
+26
-2
未找到文件。
paddle/fluid/framework/new_executor/interpretercore.cc
浏览文件 @
b0941102
...
@@ -241,13 +241,14 @@ void InterpreterCore::BuildInplace() {
...
@@ -241,13 +241,14 @@ void InterpreterCore::BuildInplace() {
auto
&
outputs
=
instr
.
Outputs
();
auto
&
outputs
=
instr
.
Outputs
();
for
(
auto
&
pair
:
in_to_outs
)
{
for
(
auto
&
pair
:
in_to_outs
)
{
auto
iter
=
inputs
.
find
(
pair
.
first
);
auto
iter
=
inputs
.
find
(
pair
.
first
);
if
(
iter
!=
inputs
.
end
())
{
if
(
iter
!=
inputs
.
end
()
&&
!
iter
->
second
.
empty
()
)
{
if
(
BuildInplaceCheckVarIsOnlyInput
(
iter
->
second
[
0
]))
{
if
(
BuildInplaceCheckVarIsOnlyInput
(
iter
->
second
[
0
]))
{
auto
iterout
=
outputs
.
find
(
pair
.
second
);
auto
iterout
=
outputs
.
find
(
pair
.
second
);
if
(
iterout
!=
outputs
.
end
())
{
if
(
iterout
!=
outputs
.
end
()
&&
!
iterout
->
second
.
empty
()
)
{
auto
invar
=
global_scope_
->
Var
(
iter
->
second
[
0
]);
auto
invar
=
global_scope_
->
Var
(
iter
->
second
[
0
]);
auto
outvar
=
global_scope_
->
Var
(
iterout
->
second
[
0
]);
auto
outvar
=
global_scope_
->
Var
(
iterout
->
second
[
0
]);
if
(
invar
&&
outvar
)
{
if
(
invar
&&
outvar
&&
invar
->
IsType
<
LoDTensor
>
()
&&
outvar
->
IsType
<
LoDTensor
>
())
{
instr
.
AddInplace
(
invar
,
outvar
);
instr
.
AddInplace
(
invar
,
outvar
);
VLOG
(
3
)
<<
"inplace "
<<
vec_instruction_
[
i
].
OpBase
()
->
Type
()
VLOG
(
3
)
<<
"inplace "
<<
vec_instruction_
[
i
].
OpBase
()
->
Type
()
<<
" "
<<
global_scope_
->
GetNameById
(
iter
->
second
[
0
])
<<
" "
<<
global_scope_
->
GetNameById
(
iter
->
second
[
0
])
...
...
paddle/fluid/framework/new_executor/interpretercore_util.cc
浏览文件 @
b0941102
...
@@ -142,8 +142,8 @@ void build_variable_scope(const framework::ProgramDesc& pdesc,
...
@@ -142,8 +142,8 @@ void build_variable_scope(const framework::ProgramDesc& pdesc,
if
(
nullptr
==
var_scope
->
FindVar
(
var_name
))
{
if
(
nullptr
==
var_scope
->
FindVar
(
var_name
))
{
var_scope
->
AddVar
(
var_desc
->
Name
(),
var_desc
);
var_scope
->
AddVar
(
var_desc
->
Name
(),
var_desc
);
}
else
{
}
else
{
auto
*
var_desc
=
var_scope
->
VarDesc
(
var_name
);
auto
*
var_desc
_tmp
=
var_scope
->
VarDesc
(
var_name
);
if
(
nullptr
==
var_desc
)
{
if
(
nullptr
==
var_desc
_tmp
)
{
VLOG
(
3
)
<<
"update var:"
<<
var_name
<<
" desc from nullptr into "
VLOG
(
3
)
<<
"update var:"
<<
var_name
<<
" desc from nullptr into "
<<
var_desc
;
<<
var_desc
;
var_scope
->
VarMetaInfo
(
var_name
).
vardesc_
=
var_desc
;
var_scope
->
VarMetaInfo
(
var_name
).
vardesc_
=
var_desc
;
...
@@ -206,9 +206,22 @@ void apply_device_guard(const OperatorBase* op_base,
...
@@ -206,9 +206,22 @@ void apply_device_guard(const OperatorBase* op_base,
VLOG
(
3
)
<<
"Switch into CPUPlace by device_guard."
;
VLOG
(
3
)
<<
"Switch into CPUPlace by device_guard."
;
expected_kernel_key
->
place_
=
platform
::
CPUPlace
();
expected_kernel_key
->
place_
=
platform
::
CPUPlace
();
}
else
if
(
op_device
.
find
(
"gpu"
)
!=
std
::
string
::
npos
&&
}
else
if
(
op_device
.
find
(
"gpu"
)
!=
std
::
string
::
npos
&&
platform
::
is_gpu_place
(
place
))
{
(
platform
::
is_gpu_place
(
place
)
||
VLOG
(
3
)
<<
"Switch into "
<<
place
<<
" by device_guard."
;
platform
::
is_npu_place
(
place
)))
{
expected_kernel_key
->
place_
=
place
;
// when the Op that only has CPUKernel is assigned to GPU, the CPUKernel
// will be executed and a warning will be given at the same time.
if
(
op_base
->
SupportGPU
())
{
expected_kernel_key
->
place_
=
place
;
}
else
if
(
op_base
->
SupportNPU
())
{
expected_kernel_key
->
place_
=
place
;
}
else
{
expected_kernel_key
->
place_
=
platform
::
CPUPlace
();
LOG_FIRST_N
(
WARNING
,
1
)
<<
"Op("
<<
op_base
->
Type
()
<<
") has no CUDA implementation. It will be assigned to CPUPlace."
;
}
VLOG
(
3
)
<<
"Switch into "
<<
expected_kernel_key
->
place_
<<
" by device_guard."
;
}
else
{
}
else
{
PADDLE_THROW
(
PADDLE_THROW
(
platform
::
errors
::
Fatal
(
"Unsupported current place %s"
,
op_device
));
platform
::
errors
::
Fatal
(
"Unsupported current place %s"
,
op_device
));
...
...
paddle/fluid/framework/new_executor/new_executor_defs.h
浏览文件 @
b0941102
...
@@ -474,6 +474,15 @@ struct VariableMetaInfo {
...
@@ -474,6 +474,15 @@ struct VariableMetaInfo {
// TODO(zhiqiu): Maybe we need to add rwlock for VariableScope?
// TODO(zhiqiu): Maybe we need to add rwlock for VariableScope?
class
VariableScope
:
public
ScopeBase
{
class
VariableScope
:
public
ScopeBase
{
public:
public:
VariableScope
()
{
// for @EMPTY@ variable
var_list_
.
push_back
(
nullptr
);
name2id_
[
kEmptyVarName
]
=
0
;
VariableMetaInfo
info
;
info
.
var_ref_count_
=
0
;
info
.
vardesc_
=
nullptr
;
vec_meta_info_
.
push_back
(
info
);
}
Variable
*
FindVar
(
const
std
::
string
&
name
)
const
{
Variable
*
FindVar
(
const
std
::
string
&
name
)
const
{
auto
it
=
name2id_
.
find
(
name
);
auto
it
=
name2id_
.
find
(
name
);
if
(
it
!=
name2id_
.
end
())
{
if
(
it
!=
name2id_
.
end
())
{
...
...
paddle/fluid/operators/controlflow/fetch_v2_op.cc
浏览文件 @
b0941102
...
@@ -77,12 +77,35 @@ class FetchV2Op : public framework::OperatorWithKernel {
...
@@ -77,12 +77,35 @@ class FetchV2Op : public framework::OperatorWithKernel {
framework
::
OpKernelType
GetKernelTypeForVar
(
framework
::
OpKernelType
GetKernelTypeForVar
(
const
std
::
string
&
var_name
,
const
framework
::
Tensor
&
tensor
,
const
std
::
string
&
var_name
,
const
framework
::
Tensor
&
tensor
,
const
framework
::
OpKernelType
&
expected_kernel_type
)
const
override
{
const
framework
::
OpKernelType
&
expected_kernel_type
)
const
override
{
if
(
!
tensor
.
IsInitialized
())
{
return
expected_kernel_type
;
}
return
framework
::
OpKernelType
(
expected_kernel_type
.
data_type_
,
return
framework
::
OpKernelType
(
expected_kernel_type
.
data_type_
,
tensor
.
place
(),
tensor
.
layout
());
tensor
.
place
(),
tensor
.
layout
());
}
}
framework
::
OpKernelType
GetExpectedKernelType
(
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
*
fetch_var
=
ctx
.
InputVar
(
"X"
);
if
(
fetch_var
==
nullptr
)
{
return
framework
::
OpKernelType
(
framework
::
proto
::
VarType
::
FP32
,
platform
::
CPUPlace
());
}
if
(
fetch_var
->
IsType
<
framework
::
LoDTensor
>
())
{
auto
&
src_item
=
fetch_var
->
Get
<
framework
::
LoDTensor
>
();
if
(
!
src_item
.
IsInitialized
())
{
return
framework
::
OpKernelType
(
framework
::
proto
::
VarType
::
FP32
,
platform
::
CPUPlace
());
}
}
else
{
auto
&
src_item
=
fetch_var
->
Get
<
framework
::
LoDTensorArray
>
();
if
(
src_item
.
empty
()
||
!
src_item
[
0
].
IsInitialized
())
{
return
framework
::
OpKernelType
(
framework
::
proto
::
VarType
::
FP32
,
platform
::
CPUPlace
());
}
}
return
framework
::
OpKernelType
(
return
framework
::
OpKernelType
(
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
),
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
),
platform
::
CPUPlace
());
platform
::
CPUPlace
());
...
@@ -127,6 +150,9 @@ class FetchV2Kernel {
...
@@ -127,6 +150,9 @@ class FetchV2Kernel {
if
(
fetch_var
->
IsType
<
framework
::
LoDTensor
>
())
{
if
(
fetch_var
->
IsType
<
framework
::
LoDTensor
>
())
{
auto
&
src_item
=
fetch_var
->
Get
<
framework
::
LoDTensor
>
();
auto
&
src_item
=
fetch_var
->
Get
<
framework
::
LoDTensor
>
();
if
(
!
src_item
.
IsInitialized
())
{
return
;
}
auto
*
dst_item
=
&
(
BOOST_GET
(
framework
::
LoDTensor
,
fetch_list
->
at
(
col
)));
auto
*
dst_item
=
&
(
BOOST_GET
(
framework
::
LoDTensor
,
fetch_list
->
at
(
col
)));
bool
check_place
=
platform
::
is_cpu_place
(
src_item
.
place
())
||
bool
check_place
=
platform
::
is_cpu_place
(
src_item
.
place
())
||
platform
::
is_cuda_pinned_place
(
src_item
.
place
());
platform
::
is_cuda_pinned_place
(
src_item
.
place
());
...
@@ -173,9 +199,7 @@ class FetchV2OpProtoMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -173,9 +199,7 @@ class FetchV2OpProtoMaker : public framework::OpProtoAndCheckerMaker {
.
SetDefault
(
true
);
.
SetDefault
(
true
);
AddComment
(
R"DOC(
AddComment
(
R"DOC(
FetchV2 Operator.
FetchV2 Operator.
It should not be configured by users directly.
It should not be configured by users directly.
)DOC"
);
)DOC"
);
}
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录