Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
00ded2ea
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看板
未验证
提交
00ded2ea
编写于
5月 11, 2023
作者:
W
WangZhen
提交者:
GitHub
5月 11, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix div error when dtype is int64 in static mode (#53705)
* Fix div error when dtype is int64 in static mode * Fix out dtype
上级
fb8ea98c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
1 deletion
+28
-1
python/paddle/fluid/layers/math_op_patch.py
python/paddle/fluid/layers/math_op_patch.py
+9
-1
test/dygraph_to_static/test_tensor_methods.py
test/dygraph_to_static/test_tensor_methods.py
+19
-0
未找到文件。
python/paddle/fluid/layers/math_op_patch.py
浏览文件 @
00ded2ea
...
@@ -409,11 +409,19 @@ def monkey_patch_variable():
...
@@ -409,11 +409,19 @@ def monkey_patch_variable():
self
=
other_var
self
=
other_var
other_var
=
tmp
other_var
=
tmp
if
(
op_type
==
"divide"
or
op_type
==
"elementwise_div"
)
and
self
.
dtype
in
_supported_int_dtype_
:
self
=
astype
(
self
,
'float32'
)
other_var
=
astype
(
other_var
,
'float32'
)
# NOTE(zhiqiu): the output of compare operator should be bool.
# NOTE(zhiqiu): the output of compare operator should be bool.
if
method_name
in
compare_ops
:
if
method_name
in
compare_ops
:
out
=
create_new_tmp_var
(
current_block
(
self
),
dtype
=
"bool"
)
out
=
create_new_tmp_var
(
current_block
(
self
),
dtype
=
"bool"
)
else
:
else
:
out
=
create_new_tmp_var
(
current_block
(
self
),
dtype
=
lhs_dtype
)
out
=
create_new_tmp_var
(
current_block
(
self
),
dtype
=
safe_get_dtype
(
self
)
)
axis
=
-
1
axis
=
-
1
if
other_var
.
ndim
>
0
and
other_var
.
shape
[
0
]
==
-
1
:
if
other_var
.
ndim
>
0
and
other_var
.
shape
[
0
]
==
-
1
:
...
...
test/dygraph_to_static/test_tensor_methods.py
浏览文件 @
00ded2ea
...
@@ -101,5 +101,24 @@ class TestTensorSize(unittest.TestCase):
...
@@ -101,5 +101,24 @@ class TestTensorSize(unittest.TestCase):
np
.
testing
.
assert_allclose
(
dygraph_res
,
static_res
,
rtol
=
1e-5
)
np
.
testing
.
assert_allclose
(
dygraph_res
,
static_res
,
rtol
=
1e-5
)
@
paddle
.
jit
.
to_static
def
true_div
(
x
,
y
):
z
=
x
/
y
return
z
class
TestTrueDiv
(
unittest
.
TestCase
):
def
_run
(
self
,
to_static
):
paddle
.
jit
.
enable_to_static
(
to_static
)
x
=
paddle
.
to_tensor
([
3
],
dtype
=
'int64'
)
y
=
paddle
.
to_tensor
([
4
],
dtype
=
'int64'
)
return
true_div
(
x
,
y
).
numpy
()
def
test_ture_div
(
self
):
dygraph_res
=
self
.
_run
(
to_static
=
False
)
static_res
=
self
.
_run
(
to_static
=
True
)
np
.
testing
.
assert_allclose
(
dygraph_res
,
static_res
,
rtol
=
1e-5
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录