Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
5b3f91df
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5b3f91df
编写于
7月 21, 2022
作者:
L
Li Min
提交者:
GitHub
7月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace with dygraph op calling method. (#44331)
* Replace with dygraph op calling method.
上级
32b3469a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
8 deletion
+14
-8
python/paddle/fluid/dygraph/math_op_patch.py
python/paddle/fluid/dygraph/math_op_patch.py
+5
-2
python/paddle/fluid/tests/unittests/test_var_base.py
python/paddle/fluid/tests/unittests/test_var_base.py
+1
-1
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+6
-2
python/paddle/tensor/manipulation.py
python/paddle/tensor/manipulation.py
+2
-3
未找到文件。
python/paddle/fluid/dygraph/math_op_patch.py
浏览文件 @
5b3f91df
...
...
@@ -376,8 +376,11 @@ def monkey_patch_math_varbase():
if
framework
.
_in_eager_mode_
else
(
'__rtruediv__'
,
_binary_creator_
(
'rtruediv__'
,
'elementwise_div'
,
True
,
None
)),
(
'__pow__'
,
_binary_creator_
(
'__pow__'
,
'elementwise_pow'
,
False
,
None
)),
(
'__pow__'
,
_binary_creator_
(
'__pow__'
,
'final_state_elementwise_pow'
,
False
,
None
,
True
))
if
framework
.
_in_eager_mode_
else
(
'__pow__'
,
_binary_creator_
(
'__pow__'
,
'elementwise_pow'
,
False
,
None
)),
(
'__rpow__'
,
_binary_creator_
(
'__rpow__'
,
'elementwise_pow'
,
True
,
None
)),
(
'__floordiv__'
,
...
...
python/paddle/fluid/tests/unittests/test_var_base.py
浏览文件 @
5b3f91df
...
...
@@ -1776,7 +1776,7 @@ class TestEagerTensorGradNameValue(unittest.TestCase):
b
=
a
**
2
self
.
assertEqual
(
a
.
_grad_value
(),
None
)
b
.
backward
()
self
.
assertEqual
(
'eager_in_tmp'
in
a
.
_grad_name
(),
True
)
# Note, for new dygraph, there are no generated grad name, so we skip the name check.
self
.
assertNotEqual
(
a
.
_grad_value
(),
None
)
...
...
python/paddle/tensor/creation.py
浏览文件 @
5b3f91df
...
...
@@ -663,8 +663,12 @@ def eye(num_rows, num_columns=None, dtype=None, name=None):
num_columns
=
num_rows
if
_non_static_mode
():
out
=
_C_ops
.
eye
(
'dtype'
,
dtype
,
'num_rows'
,
num_rows
,
'num_columns'
,
num_columns
)
if
in_dygraph_mode
():
out
=
_C_ops
.
final_state_eye
(
num_rows
,
num_columns
,
dtype
,
_current_expected_place
())
elif
_in_legacy_dygraph
():
out
=
_C_ops
.
eye
(
'dtype'
,
dtype
,
'num_rows'
,
num_rows
,
'num_columns'
,
num_columns
)
else
:
helper
=
LayerHelper
(
"eye"
,
**
locals
())
...
...
python/paddle/tensor/manipulation.py
浏览文件 @
5b3f91df
...
...
@@ -2705,8 +2705,7 @@ def scatter_nd_add(x, index, updates, name=None):
# [3, 5, 9, 10]
"""
if
in_dygraph_mode
():
op
=
getattr
(
_C_ops
,
'scatter_nd_add'
)
return
op
(
x
,
index
,
updates
)
return
_C_ops
.
final_state_scatter_nd_add
(
x
,
index
,
updates
)
else
:
if
_in_legacy_dygraph
():
op
=
getattr
(
_C_ops
,
'scatter_nd_add'
)
...
...
@@ -3002,7 +3001,7 @@ def broadcast_to(x, shape, name=None):
# [[1, 2, 3], [1, 2, 3]]
"""
if
paddle
.
in_dynamic_mode
():
return
_C_ops
.
expand_v2
(
x
,
'shape'
,
shape
)
return
_C_ops
.
final_state_expand
(
x
,
shape
)
if
isinstance
(
shape
,
Variable
):
assert
len
(
shape
.
shape
)
==
1
,
(
'shape must be an 1-D Tensor.'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录