Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a88d36aa
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2293
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a88d36aa
编写于
7月 26, 2023
作者:
H
hong
提交者:
GitHub
7月 26, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New ir support save combine (#55538)
* new ir support save combine * update * polish code
上级
74266762
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
16 deletion
+59
-16
paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc
...id/framework/new_executor/interpreter/interpreter_util.cc
+14
-12
paddle/fluid/framework/new_executor/new_executor_defs.cc
paddle/fluid/framework/new_executor/new_executor_defs.cc
+1
-1
paddle/fluid/framework/new_executor/new_ir_interpreter.cc
paddle/fluid/framework/new_executor/new_ir_interpreter.cc
+4
-2
paddle/fluid/ir/dialect/pd_op.yaml
paddle/fluid/ir/dialect/pd_op.yaml
+27
-0
test/ir/new_ir/test_standalone_new_ir.py
test/ir/new_ir/test_standalone_new_ir.py
+13
-1
未找到文件。
paddle/fluid/framework/new_executor/interpreter/interpreter_util.cc
浏览文件 @
a88d36aa
...
...
@@ -974,18 +974,20 @@ void BuildOpFuncList(
VLOG
(
6
)
<<
"op name"
<<
op_func_node
.
phi_op_name_
;
dialect
::
OpYamlInfoParser
op_yaml_info_parser
(
impl
->
get_op_info_
());
::
ir
::
BuildPhiContext
<
phi
::
InferMetaContext
,
phi
::
MetaTensor
,
phi
::
MetaTensor
,
paddle
::
small_vector
<
phi
::
MetaTensor
,
phi
::
kInputSmallVectorSize
>
,
paddle
::
small_vector
<
phi
::
MetaTensor
,
phi
::
kInputSmallVectorSize
>
,
false
>
((
*
it
),
value_2_name_map
,
scope
,
local_scope
,
op_yaml_info_parser
,
&
(
op_func_node
.
infer_meta_context_
));
if
(
op_func_node
.
infer_meta_interface_
)
{
::
ir
::
BuildPhiContext
<
phi
::
InferMetaContext
,
phi
::
MetaTensor
,
phi
::
MetaTensor
,
paddle
::
small_vector
<
phi
::
MetaTensor
,
phi
::
kInputSmallVectorSize
>
,
paddle
::
small_vector
<
phi
::
MetaTensor
,
phi
::
kInputSmallVectorSize
>
,
false
>
((
*
it
),
value_2_name_map
,
scope
,
local_scope
,
op_yaml_info_parser
,
&
(
op_func_node
.
infer_meta_context_
));
}
auto
kernel_name
=
attr_map
.
at
(
"kernel_name"
).
dyn_cast
<
ir
::
StrAttribute
>
().
AsString
();
...
...
paddle/fluid/framework/new_executor/new_executor_defs.cc
浏览文件 @
a88d36aa
...
...
@@ -161,7 +161,7 @@ Instruction::Instruction(size_t id,
is_artificial_
=
true
;
}
if
(
op_func_node_
.
infer_meta_interface
_
!=
nullptr
)
{
if
(
op_func_node_
.
phi_kernel
_
!=
nullptr
)
{
pre_define_context_
=
true
;
}
PADDLE_ENFORCE_GE
(
id
,
...
...
paddle/fluid/framework/new_executor/new_ir_interpreter.cc
浏览文件 @
a88d36aa
...
...
@@ -1028,8 +1028,10 @@ void NewIRInterpreter::RunInstruction(const Instruction& instr_node) {
VLOG
(
5
)
<<
"run new ir selected kernel"
;
auto
op_func_node
=
const_cast
<
OpFuncNode
*>
((
instr_node
.
OpFunc
()));
VLOG
(
5
)
<<
"begin to run op "
<<
op_func_node
->
phi_op_name_
;
op_func_node
->
infer_meta_interface_
->
infer_meta_
(
&
(
op_func_node
->
infer_meta_context_
));
if
(
op_func_node
->
infer_meta_interface_
)
{
op_func_node
->
infer_meta_interface_
->
infer_meta_
(
&
(
op_func_node
->
infer_meta_context_
));
}
VLOG
(
5
)
<<
"after run infer meta"
;
(
*
(
op_func_node
->
phi_kernel_
))(
&
(
op_func_node
->
kernel_context_
));
VLOG
(
5
)
<<
"after run kernel"
;
...
...
paddle/fluid/ir/dialect/pd_op.yaml
浏览文件 @
a88d36aa
...
...
@@ -38,6 +38,33 @@
inplace
:
null
backward
:
null
-
name
:
save_combine
inputs
:
-
typename
:
Tensor[]
name
:
X
optional
:
false
no_need_buffer
:
false
data_transform
:
{}
attrs
:
-
{
typename
:
str
,
name
:
file_path
}
-
{
typename
:
bool
,
name
:
overwrite
}
-
{
typename
:
bool
,
name
:
save_as_fp16
}
-
{
typename
:
bool
,
name
:
save_to_memory
}
outputs
:
-
{
typename
:
Tensor
,
name
:
out
,
optional
:
true
,
intermediate
:
false
}
no_need_buffer
:
null
data_transform
:
null
kernel
:
func
:
[
save_combine_tensor
]
param
:
[
X
,
file_path
,
overwrite
,
save_as_fp16
,
save_to_memory
]
backend
:
null
layout
:
null
data_type
:
null
dispatch
:
{
fetch
:
null
}
force_backend
:
null
inplace
:
null
backward
:
null
-
name
:
share_buffer_
inputs
:
-
typename
:
Tensor[]
...
...
test/ir/new_ir/test_standalone_new_ir.py
浏览文件 @
a88d36aa
...
...
@@ -106,7 +106,6 @@ class TestSelectedRows(unittest.TestCase):
def
test_with_new_ir
(
self
):
paddle
.
enable_static
()
# TODO(phlrain): support selected rows in GPU
# place = paddle.CUDAPlace(0) if paddle.is_compiled_with_cuda() else paddle.CPUPlace()
place
=
paddle
.
CPUPlace
()
exe
=
paddle
.
static
.
Executor
(
place
)
...
...
@@ -241,6 +240,19 @@ class TestSplitOp(unittest.TestCase):
np
.
testing
.
assert_array_equal
(
out
[
0
],
np_a
[
0
:
2
])
class
TestJitSaveOp
(
unittest
.
TestCase
):
def
test_with_new_ir
(
self
):
paddle
.
disable_static
()
linear
=
paddle
.
nn
.
Linear
(
10
,
10
)
path
=
"example_model/linear"
paddle
.
jit
.
save
(
linear
,
path
,
input_spec
=
[
paddle
.
static
.
InputSpec
([
10
,
10
],
'float32'
,
'x'
)],
)
if
__name__
==
"__main__"
:
paddle
.
enable_static
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录