Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5dda91a8
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看板
提交
5dda91a8
编写于
3月 02, 2023
作者:
C
cxxly
提交者:
Xiaoxu Chen
3月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix cast prim and vjp dtype mapping error bug
上级
ece6837f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
20 deletion
+26
-20
paddle/fluid/operators/cast_op.cc
paddle/fluid/operators/cast_op.cc
+1
-0
paddle/fluid/prim/api/composite_backward/composite_backward_api.h
...luid/prim/api/composite_backward/composite_backward_api.h
+1
-0
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_batch_norm.py
...unittests/prim/composite_ops/test_composite_batch_norm.py
+16
-16
python/paddle/incubate/autograd/primapi.py
python/paddle/incubate/autograd/primapi.py
+3
-3
python/paddle/jit/dy2static/program_translator.py
python/paddle/jit/dy2static/program_translator.py
+5
-1
未找到文件。
paddle/fluid/operators/cast_op.cc
浏览文件 @
5dda91a8
...
@@ -27,6 +27,7 @@ limitations under the License. */
...
@@ -27,6 +27,7 @@ limitations under the License. */
#include "paddle/fluid/prim/api/composite_backward/composite_backward_api.h"
#include "paddle/fluid/prim/api/composite_backward/composite_backward_api.h"
#include "paddle/fluid/prim/utils/static/composite_grad_desc_maker.h"
#include "paddle/fluid/prim/utils/static/composite_grad_desc_maker.h"
#include "paddle/fluid/prim/utils/static/desc_tensor.h"
#include "paddle/fluid/prim/utils/static/desc_tensor.h"
#include "paddle/phi/core/utils/data_type.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/fluid/prim/api/composite_backward/composite_backward_api.h
浏览文件 @
5dda91a8
...
@@ -944,6 +944,7 @@ void maximum_grad(const Tensor& x,
...
@@ -944,6 +944,7 @@ void maximum_grad(const Tensor& x,
}
}
}
}
template
<
typename
T
>
void
dropout_grad
(
const
Tensor
&
mask
,
void
dropout_grad
(
const
Tensor
&
mask
,
const
Tensor
&
out_grad
,
const
Tensor
&
out_grad
,
const
Scalar
&
p
,
const
Scalar
&
p
,
...
...
python/paddle/fluid/tests/unittests/prim/composite_ops/test_composite_batch_norm.py
浏览文件 @
5dda91a8
...
@@ -244,22 +244,22 @@ class TestCompositeBatchNorm(unittest.TestCase):
...
@@ -244,22 +244,22 @@ class TestCompositeBatchNorm(unittest.TestCase):
atol
=
attrs
.
get_atol
(
"forward"
),
atol
=
attrs
.
get_atol
(
"forward"
),
)
)
#
def test_forward(self):
def
test_forward
(
self
):
#
for i in self.training:
for
i
in
self
.
training
:
#
for j in self.dtypes:
for
j
in
self
.
dtypes
:
#
for m in self.momentum:
for
m
in
self
.
momentum
:
#
attrs.set_training(i)
attrs
.
set_training
(
i
)
#
attrs.set_dtype(j)
attrs
.
set_dtype
(
j
)
#
attrs.set_momentum(m)
attrs
.
set_momentum
(
m
)
#
self.compare_forward()
self
.
compare_forward
()
#
for n in self.shapes:
for
n
in
self
.
shapes
:
#
for s in self.data_formats:
for
s
in
self
.
data_formats
:
#
for t in self.use_global_stats:
for
t
in
self
.
use_global_stats
:
#
attrs.set_shape(n)
attrs
.
set_shape
(
n
)
#
attrs.set_data_format(s)
attrs
.
set_data_format
(
s
)
#
attrs.set_use_global_stats(t)
attrs
.
set_use_global_stats
(
t
)
#
self.compare_forward()
self
.
compare_forward
()
def
apply_to_static
(
net
,
use_cinn
):
def
apply_to_static
(
net
,
use_cinn
):
...
...
python/paddle/incubate/autograd/primapi.py
浏览文件 @
5dda91a8
...
@@ -226,7 +226,7 @@ def to_prim(blocks, exclude=frozenset()):
...
@@ -226,7 +226,7 @@ def to_prim(blocks, exclude=frozenset()):
if
not
core
.
_is_fwd_prim_enabled
():
if
not
core
.
_is_fwd_prim_enabled
():
return
return
if
isinstance
(
blocks
,
paddle
.
fluid
.
framework
.
Block
):
if
isinstance
(
blocks
,
paddle
.
fluid
.
framework
.
Block
):
logging
.
debug
(
"Atomize composite op to primitive ops begin."
)
logging
.
info
(
"Atomize composite op to primitive ops begin."
)
main_program
=
blocks
.
program
main_program
=
blocks
.
program
elif
isinstance
(
blocks
,
typing
.
Sequence
):
elif
isinstance
(
blocks
,
typing
.
Sequence
):
for
item
in
blocks
:
for
item
in
blocks
:
...
@@ -245,9 +245,9 @@ def to_prim(blocks, exclude=frozenset()):
...
@@ -245,9 +245,9 @@ def to_prim(blocks, exclude=frozenset()):
)
)
with
framework
.
program_guard
(
main_program
):
with
framework
.
program_guard
(
main_program
):
logging
.
debug
(
"Lowering composite forward ops begin..."
)
print
(
"Lowering composite forward ops begin..."
)
primx
.
_lower_composite
(
primx
.
_lower_composite
(
blocks
,
prim_config
[
"forward_blacklist"
]
|
exclude
blocks
,
prim_config
[
"forward_blacklist"
]
|
exclude
)
)
replace_ops
=
prim_config
[
"composite_ops_record"
]
replace_ops
=
prim_config
[
"composite_ops_record"
]
logging
.
debug
(
f
"Lowering composite forward ops finish:
{
replace_ops
}
"
)
print
(
f
"Lowering composite forward ops finish:
{
replace_ops
}
"
)
python/paddle/jit/dy2static/program_translator.py
浏览文件 @
5dda91a8
...
@@ -1218,7 +1218,11 @@ class ProgramCache:
...
@@ -1218,7 +1218,11 @@ class ProgramCache:
return
infer_program
return
infer_program
partial_program
=
partial_program_from
(
concrete_program
)
partial_program
=
partial_program_from
(
concrete_program
)
if
not
_in_amp_guard
()
and
not
_in_pure_fp16_guard
():
if
(
core
.
_is_fwd_prim_enabled
()
and
not
_in_amp_guard
()
and
not
_in_pure_fp16_guard
()
):
partial_program
.
set_hooker
(
PrimHooker
())
partial_program
.
set_hooker
(
PrimHooker
())
return
concrete_program
,
partial_program
return
concrete_program
,
partial_program
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录