Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
20b12765
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看板
未验证
提交
20b12765
编写于
11月 18, 2020
作者:
W
wawltor
提交者:
GitHub
11月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
faster the compare ops dygraph model speed
faster the compare ops dygraph model speed
上级
5a9f6889
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
97 addition
and
6 deletion
+97
-6
python/paddle/fluid/tests/unittests/test_compare_op.py
python/paddle/fluid/tests/unittests/test_compare_op.py
+9
-0
python/paddle/tensor/logic.py
python/paddle/tensor/logic.py
+88
-6
未找到文件。
python/paddle/fluid/tests/unittests/test_compare_op.py
浏览文件 @
20b12765
...
...
@@ -93,6 +93,15 @@ def create_paddle_case(op_type, callback):
fetch_list
=
[
out
])
self
.
assertEqual
((
res
==
self
.
real_result
).
all
(),
True
)
def
test_dynamic_api
(
self
):
paddle
.
disable_static
()
x
=
paddle
.
to_tensor
(
self
.
input_x
)
y
=
paddle
.
to_tensor
(
self
.
input_y
)
op
=
eval
(
"paddle.%s"
%
(
self
.
op_type
))
out
=
op
(
x
,
y
)
self
.
assertEqual
((
out
.
numpy
()
==
self
.
real_result
).
all
(),
True
)
paddle
.
enable_static
()
def
test_broadcast_api_1
(
self
):
paddle
.
enable_static
()
with
program_guard
(
Program
(),
Program
()):
...
...
python/paddle/tensor/logic.py
浏览文件 @
20b12765
...
...
@@ -216,7 +216,20 @@ def equal(x, y, name=None):
result1 = paddle.equal(x, y)
print(result1.numpy()) # result1 = [True False False]
"""
out
=
fluid
.
layers
.
equal
(
x
,
y
,
name
=
name
,
cond
=
None
)
if
in_dygraph_mode
():
return
core
.
ops
.
equal
(
x
,
y
)
check_variable_and_dtype
(
x
,
"x"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"equal"
)
check_variable_and_dtype
(
y
,
"y"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"equal"
)
helper
=
LayerHelper
(
"equal"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
'bool'
)
out
.
stop_gradient
=
True
helper
.
append_op
(
type
=
'equal'
,
inputs
=
{
'X'
:
[
x
],
'Y'
:
[
y
]},
outputs
=
{
'Out'
:
[
out
]})
return
out
...
...
@@ -247,7 +260,22 @@ def greater_equal(x, y, name=None):
result1 = paddle.greater_equal(x, y)
print(result1.numpy()) # result1 = [True False True]
"""
out
=
fluid
.
layers
.
greater_equal
(
x
,
y
,
name
=
name
,
cond
=
None
)
if
in_dygraph_mode
():
return
core
.
ops
.
greater_equal
(
x
,
y
)
check_variable_and_dtype
(
x
,
"x"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"greater_equal"
)
check_variable_and_dtype
(
y
,
"y"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"greater_equal"
)
helper
=
LayerHelper
(
"greater_equal"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
'bool'
)
out
.
stop_gradient
=
True
helper
.
append_op
(
type
=
'greater_equal'
,
inputs
=
{
'X'
:
[
x
],
'Y'
:
[
y
]},
outputs
=
{
'Out'
:
[
out
]})
return
out
...
...
@@ -278,7 +306,22 @@ def greater_than(x, y, name=None):
result1 = paddle.greater_than(x, y)
print(result1.numpy()) # result1 = [False False True]
"""
out
=
fluid
.
layers
.
greater_than
(
x
,
y
,
name
=
name
,
cond
=
None
)
if
in_dygraph_mode
():
return
core
.
ops
.
greater_than
(
x
,
y
)
check_variable_and_dtype
(
x
,
"x"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"greater_than"
)
check_variable_and_dtype
(
y
,
"y"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"greater_than"
)
helper
=
LayerHelper
(
"greater_than"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
'bool'
)
out
.
stop_gradient
=
True
helper
.
append_op
(
type
=
'greater_than'
,
inputs
=
{
'X'
:
[
x
],
'Y'
:
[
y
]},
outputs
=
{
'Out'
:
[
out
]})
return
out
...
...
@@ -310,7 +353,20 @@ def less_equal(x, y, name=None):
result1 = paddle.less_equal(x, y)
print(result1.numpy()) # result1 = [True True False]
"""
out
=
fluid
.
layers
.
less_equal
(
x
,
y
,
name
=
name
,
cond
=
None
)
if
in_dygraph_mode
():
return
core
.
ops
.
less_equal
(
x
,
y
)
check_variable_and_dtype
(
x
,
"x"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"less_equal"
)
check_variable_and_dtype
(
y
,
"y"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"less_equal"
)
helper
=
LayerHelper
(
"less_equal"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
'bool'
)
out
.
stop_gradient
=
True
helper
.
append_op
(
type
=
'less_equal'
,
inputs
=
{
'X'
:
[
x
],
'Y'
:
[
y
]},
outputs
=
{
'Out'
:
[
out
]})
return
out
...
...
@@ -342,7 +398,20 @@ def less_than(x, y, name=None):
result1 = paddle.less_than(x, y)
print(result1.numpy()) # result1 = [False True False]
"""
out
=
fluid
.
layers
.
less_than
(
x
,
y
,
force_cpu
=
False
,
name
=
name
,
cond
=
None
)
if
in_dygraph_mode
():
return
core
.
ops
.
less_than
(
x
,
y
)
check_variable_and_dtype
(
x
,
"x"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"less_than"
)
check_variable_and_dtype
(
y
,
"y"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"less_than"
)
helper
=
LayerHelper
(
"less_than"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
'bool'
)
out
.
stop_gradient
=
True
helper
.
append_op
(
type
=
'less_than'
,
inputs
=
{
'X'
:
[
x
],
'Y'
:
[
y
]},
outputs
=
{
'Out'
:
[
out
]})
return
out
...
...
@@ -375,7 +444,20 @@ def not_equal(x, y, name=None):
result1 = paddle.not_equal(x, y)
print(result1.numpy()) # result1 = [False True True]
"""
out
=
fluid
.
layers
.
not_equal
(
x
,
y
,
name
=
name
,
cond
=
None
)
if
in_dygraph_mode
():
return
core
.
ops
.
not_equal
(
x
,
y
)
check_variable_and_dtype
(
x
,
"x"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"not_equal"
)
check_variable_and_dtype
(
y
,
"y"
,
[
"float32"
,
"float64"
,
"int32"
,
"int64"
],
"not_equal"
)
helper
=
LayerHelper
(
"not_equal"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
'bool'
)
out
.
stop_gradient
=
True
helper
.
append_op
(
type
=
'not_equal'
,
inputs
=
{
'X'
:
[
x
],
'Y'
:
[
y
]},
outputs
=
{
'Out'
:
[
out
]})
return
out
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录