Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f2f1de7b
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看板
未验证
提交
f2f1de7b
编写于
4月 21, 2022
作者:
R
Ruibiao Chen
提交者:
GitHub
4月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support cinn_launch op in standalone executor (#42046)
* Support cinn_launch OP in standalone executor * Remove some redundant code
上级
3da8066a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
4 deletion
+38
-4
paddle/fluid/framework/new_executor/interpretercore.cc
paddle/fluid/framework/new_executor/interpretercore.cc
+10
-1
paddle/fluid/framework/new_executor/interpretercore_util.cc
paddle/fluid/framework/new_executor/interpretercore_util.cc
+14
-3
paddle/fluid/framework/new_executor/new_executor_defs.cc
paddle/fluid/framework/new_executor/new_executor_defs.cc
+10
-0
paddle/fluid/framework/new_executor/new_executor_defs.h
paddle/fluid/framework/new_executor/new_executor_defs.h
+4
-0
未找到文件。
paddle/fluid/framework/new_executor/interpretercore.cc
浏览文件 @
f2f1de7b
...
...
@@ -428,8 +428,17 @@ void InterpreterCore::BuildAndCacheInstructionCtx(Instruction* instr_node) {
}
outs_map
.
emplace
(
var_name_item
.
first
,
std
::
move
(
out_vars
));
}
// set runtime_ctx and infershape_ctx_
instr_node
->
ResetContext
(
ins_map
,
outs_map
);
if
(
instr_node
->
OpBase
()
->
Type
()
==
"cinn_launch"
)
{
// OP use scope in
// kernel
Scope
*
local_scope
=
create_local_scope_
?
global_scope_
->
GetMutableLocalScope
()
:
global_scope_
->
GetMutableScope
();
instr_node
->
ResetContextWithScope
(
ins_map
,
outs_map
,
*
local_scope
);
}
else
{
instr_node
->
ResetContext
(
ins_map
,
outs_map
);
}
}
void
InterpreterCore
::
BuildSkipShareLoDInfo
()
{
...
...
paddle/fluid/framework/new_executor/interpretercore_util.cc
浏览文件 @
f2f1de7b
...
...
@@ -392,8 +392,19 @@ void build_op_func_list(const platform::Place& place,
platform
::
DeviceContextPool
::
Instance
();
auto
*
dev_ctx
=
pool
.
Get
(
place
);
Scope
scope
;
Scope
*
runtime_scope
=
&
scope
;
// NOTE(Ruibiao): We do not encourage directly using scope in OP kernel.
// But some OPs do have such behavior (e.g., cinn_launch OP). Here special
// treatment for them.
if
(
op_with_kernel
->
Type
()
==
"cinn_launch"
)
{
VLOG
(
6
)
<<
"OP("
<<
op_with_kernel
->
Type
()
<<
") use scope in kernel, "
"so pass a real scope to "
"ExecutionContext"
;
runtime_scope
=
local_scope
;
}
auto
expected_kernel_key
=
op_with_kernel
->
GetExpectedKernelType
(
ExecutionContext
(
*
op
,
scope
,
*
dev_ctx
,
runtime_context
));
ExecutionContext
(
*
op
,
*
runtime_
scope
,
*
dev_ctx
,
runtime_context
));
op_with_kernel
->
ResetKernelType
(
new
OpKernelType
(
expected_kernel_key
));
// change device by the device_guard()
...
...
@@ -441,8 +452,8 @@ void build_op_func_list(const platform::Place& place,
op_with_kernel
->
Info
().
infer_shape_
(
&
infer_shape_ctx
);
}
auto
exec_ctx
=
ExecutionContext
(
*
op_with_kernel
,
scope
,
*
dev_ctx
,
runtime_context
);
auto
exec_ctx
=
ExecutionContext
(
*
op_with_kernel
,
*
runtime_scope
,
*
dev_ctx
,
runtime_context
);
auto
run_phi_kernel
=
false
;
if
(
phi
::
KernelFactory
::
Instance
().
HasCompatiblePhiKernel
(
...
...
paddle/fluid/framework/new_executor/new_executor_defs.cc
浏览文件 @
f2f1de7b
...
...
@@ -755,6 +755,16 @@ void Instruction::ResetContext(const VariableValueMap& in_vars,
new
ExecutionContext
(
*
OpBase
(),
scope_
,
dev_ctx_
,
*
runtime_ctx_
.
get
()));
}
void
Instruction
::
ResetContextWithScope
(
const
VariableValueMap
&
in_vars
,
const
VariableValueMap
&
out_vars
,
const
framework
::
Scope
&
scope
)
{
runtime_ctx_
.
reset
(
new
RuntimeContext
(
in_vars
,
out_vars
));
infershape_ctx_
.
reset
(
new
InterpretercoreInferShapeContext
(
*
OpBase
(),
*
runtime_ctx_
.
get
()));
execution_ctx_
.
reset
(
new
ExecutionContext
(
*
OpBase
(),
scope
,
dev_ctx_
,
*
runtime_ctx_
.
get
()));
}
std
::
shared_ptr
<
RuntimeContext
>
Instruction
::
InnerRuntimeContext
()
const
{
return
runtime_ctx_
;
}
...
...
paddle/fluid/framework/new_executor/new_executor_defs.h
浏览文件 @
f2f1de7b
...
...
@@ -347,6 +347,10 @@ class Instruction {
void
ResetContext
(
const
VariableValueMap
&
in_vars
,
const
VariableValueMap
&
out_vars
);
void
ResetContextWithScope
(
const
VariableValueMap
&
in_vars
,
const
VariableValueMap
&
out_vars
,
const
framework
::
Scope
&
scope
);
std
::
shared_ptr
<
RuntimeContext
>
InnerRuntimeContext
()
const
;
std
::
shared_ptr
<
InterpretercoreInferShapeContext
>
InnerInferShapeContext
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录