Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
64f18fa1
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看板
未验证
提交
64f18fa1
编写于
8月 23, 2023
作者:
C
Charles-hit
提交者:
GitHub
8月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix sum vjp and prim code gen cmake (#56542)
上级
f166ecc3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
22 deletion
+16
-22
paddle/fluid/ir/dialect/paddle_dialect/ir/pd_op_vjp_manual.cc
...le/fluid/ir/dialect/paddle_dialect/ir/pd_op_vjp_manual.cc
+1
-1
paddle/fluid/primitive/backend/CMakeLists.txt
paddle/fluid/primitive/backend/CMakeLists.txt
+3
-5
paddle/fluid/primitive/codegen/CMakeLists.txt
paddle/fluid/primitive/codegen/CMakeLists.txt
+6
-12
test/prim/new_ir_prim/test_vjp_prim.py
test/prim/new_ir_prim/test_vjp_prim.py
+6
-4
未找到文件。
paddle/fluid/ir/dialect/paddle_dialect/ir/pd_op_vjp_manual.cc
浏览文件 @
64f18fa1
...
...
@@ -78,7 +78,7 @@ std::vector<std::vector<ir::OpResult>> SumOp::Vjp(
bool
reduce_all
=
false
;
std
::
vector
<
std
::
vector
<
Tensor
>>
tensor_res
=
primitive
::
sum_vjp
(
x
,
out_grad
,
axis
,
keepdim
,
reduce_all
,
stop_gradients
);
std
::
vector
<
std
::
vector
<
ir
::
OpResult
>>
res
(
1
,
std
::
vector
<
ir
::
OpResult
>
(
1
));
std
::
vector
<
std
::
vector
<
ir
::
OpResult
>>
res
(
2
,
std
::
vector
<
ir
::
OpResult
>
(
1
));
if
(
tensor_res
[
0
][
0
].
defined
())
{
res
[
0
][
0
]
=
std
::
static_pointer_cast
<
primitive
::
LazyTensor
>
(
tensor_res
[
0
][
0
].
impl
())
...
...
paddle/fluid/primitive/backend/CMakeLists.txt
浏览文件 @
64f18fa1
set
(
eager_backend_files
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/primitive/backend/generated/generated_eager_backend.cc
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/generated/generated_eager_backend.cc
)
if
(
WITH_PYTHON OR NOT ON_INFER
)
cc_library
(
primitive_backend_eager_experimental
...
...
@@ -8,9 +7,8 @@ if(WITH_PYTHON OR NOT ON_INFER)
DEPS final_dygraph_function eager_utils phi
)
endif
()
set
(
static_backend_files
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/primitive/backend/generated/generated_static_backend.cc
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/primitive/backend/manual/manual_static_backend.cc
)
${
CMAKE_CURRENT_SOURCE_DIR
}
/generated/generated_static_backend.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/manual/manual_static_backend.cc
)
cc_library
(
primitive_backend_static_experimental
SRCS
${
static_backend_files
}
...
...
paddle/fluid/primitive/codegen/CMakeLists.txt
浏览文件 @
64f18fa1
set
(
fwd_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/operators/generator/parsed_ops/ops.parsed.yaml"
)
set
(
fwd_legacy_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/operators/generator/parsed_ops/legacy_ops.parsed.yaml"
)
set
(
rev_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/operators/generator/parsed_ops/backward_ops.parsed.yaml"
)
set
(
rev_legacy_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/operators/generator/parsed_ops/legacy_backward_ops.parsed.yaml"
)
set
(
parsed_yaml_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/operators/generator/parsed_ops"
)
set
(
fwd_path
${
parsed_yaml_path
}
/ops.parsed.yaml
)
set
(
fwd_legacy_path
${
parsed_yaml_path
}
/legacy_ops.parsed.yaml
)
set
(
rev_path
${
parsed_yaml_path
}
/backward_ops.parsed.yaml
)
set
(
rev_legacy_path
${
parsed_yaml_path
}
/legacy_backward_ops.parsed.yaml
)
set
(
prim_path
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/primitive/primitive.yaml"
)
set
(
templates_dir
"
${
PADDLE_SOURCE_DIR
}
/paddle/fluid/primitive/codegen/templates/"
)
...
...
test/prim/new_ir_prim/test_vjp_prim.py
浏览文件 @
64f18fa1
...
...
@@ -126,14 +126,15 @@ class TestVjpPrim(unittest.TestCase):
paddle
.
fluid
.
core
.
_set_prim_backward_enabled
(
True
)
dout
=
newir_program
.
block
().
ops
[
-
2
].
result
(
0
)
out_grads
=
[[
dout
]]
stop_gradients
=
[[
False
]]
stop_gradients
=
[[
False
]
,
[
True
]
]
sum_op
=
newir_program
.
block
().
ops
[
-
1
]
with
paddle
.
ir
.
core
.
program_guard
(
newir_program
):
grad_outs
=
call_vjp
(
sum_op
,
out_grads
,
stop_gradients
)
expand_op
=
newir_program
.
block
().
ops
[
-
1
]
self
.
assertEqual
(
len
(
grad_outs
),
1
)
self
.
assertEqual
(
len
(
grad_outs
),
2
)
self
.
assertEqual
(
len
(
newir_program
.
block
().
ops
),
8
)
self
.
assertEqual
(
expand_op
.
result
(
0
),
grad_outs
[
0
][
0
])
self
.
assertEqual
(
grad_outs
[
1
][
0
],
None
)
all_op_names
=
[
"pd.full"
,
"pd.full"
,
...
...
@@ -152,14 +153,15 @@ class TestVjpPrim(unittest.TestCase):
paddle
.
fluid
.
core
.
_set_prim_backward_enabled
(
False
)
dout
=
newir_program
.
block
().
ops
[
-
2
].
result
(
0
)
out_grads
=
[[
dout
]]
stop_gradients
=
[[
False
]]
stop_gradients
=
[[
False
]
,
[
True
]
]
sum_op
=
newir_program
.
block
().
ops
[
-
1
]
with
paddle
.
ir
.
core
.
program_guard
(
newir_program
):
grad_outs
=
call_vjp
(
sum_op
,
out_grads
,
stop_gradients
)
self
.
assertEqual
(
len
(
grad_outs
),
1
)
self
.
assertEqual
(
len
(
grad_outs
),
2
)
self
.
assertEqual
(
grad_outs
[
0
][
0
].
get_defining_op
().
name
(),
"pd.sum_grad"
)
self
.
assertEqual
(
grad_outs
[
1
][
0
],
None
)
self
.
assertEqual
(
len
(
newir_program
.
block
().
ops
),
6
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录