Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7bf97d2c
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看板
未验证
提交
7bf97d2c
编写于
5月 25, 2023
作者:
H
HongyuJia
提交者:
GitHub
5月 25, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[0D-Tensor] Support elementwise_sub,mul,div (#54064)
上级
48edbb28
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
4 addition
and
22 deletion
+4
-22
paddle/fluid/framework/paddle2cinn/cinn_zero_tensor_trick_pass.cc
...luid/framework/paddle2cinn/cinn_zero_tensor_trick_pass.cc
+4
-1
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_div_op.py
+0
-9
python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
+0
-9
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
+0
-3
未找到文件。
paddle/fluid/framework/paddle2cinn/cinn_zero_tensor_trick_pass.cc
浏览文件 @
7bf97d2c
...
...
@@ -59,7 +59,10 @@ void CinnZeroTensorTrickPass::ApplyImpl(ir::Graph* graph) const {
}
// CINN ops in this white list support 0D-Tensor
const
std
::
unordered_set
<
std
::
string
>
white_op_list
{
"elementwise_add"
};
const
std
::
unordered_set
<
std
::
string
>
white_op_list
{
"elementwise_add"
,
"elementwise_sub"
,
"elementwise_mul"
,
"elementwise_div"
};
std
::
unordered_set
<
std
::
string
>
white_tensor_name
;
// enable white_op_list only when graph_node_size = 1, which means single op
// test
...
...
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
浏览文件 @
7bf97d2c
...
...
@@ -143,9 +143,6 @@ class TestElementwiseDivOp_ZeroDim1(ElementwiseDivOp):
self
.
x_shape
=
[]
self
.
y_shape
=
[]
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
class
TestElementwiseDivOp_ZeroDim2
(
ElementwiseDivOp
):
def
init_shape
(
self
):
...
...
@@ -161,9 +158,6 @@ class TestElementwiseDivOp_ZeroDim2(ElementwiseDivOp):
def
compute_gradient_y
(
self
,
grad_out
,
out
,
y
):
return
np
.
sum
(
-
1
*
grad_out
*
out
/
y
.
reshape
([
1
,
1
]))
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
class
TestElementwiseDivOp_ZeroDim3
(
ElementwiseDivOp
):
def
init_shape
(
self
):
...
...
@@ -179,9 +173,6 @@ class TestElementwiseDivOp_ZeroDim3(ElementwiseDivOp):
def
compute_gradient_y
(
self
,
grad_out
,
out
,
y
):
return
-
1
*
grad_out
*
out
/
y
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
...
...
python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py
浏览文件 @
7bf97d2c
...
...
@@ -148,9 +148,6 @@ class TestElementwiseMulOp_ZeroDim1(ElementwiseMulOp):
self
.
y
=
np
.
random
.
uniform
(
0.1
,
1
,
[]).
astype
(
self
.
dtype
)
self
.
out
=
np
.
multiply
(
self
.
x
,
self
.
y
)
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
class
TestElementwiseMulOp_ZeroDim2
(
ElementwiseMulOp
):
def
init_input_output
(
self
):
...
...
@@ -158,9 +155,6 @@ class TestElementwiseMulOp_ZeroDim2(ElementwiseMulOp):
self
.
y
=
np
.
random
.
uniform
(
0.1
,
1
,
[]).
astype
(
self
.
dtype
)
self
.
out
=
np
.
multiply
(
self
.
x
,
self
.
y
)
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
class
TestElementwiseMulOp_ZeroDim3
(
ElementwiseMulOp
):
def
init_input_output
(
self
):
...
...
@@ -168,9 +162,6 @@ class TestElementwiseMulOp_ZeroDim3(ElementwiseMulOp):
self
.
y
=
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
self
.
dtype
)
self
.
out
=
np
.
multiply
(
self
.
x
,
self
.
y
)
def
if_enable_cinn
(
self
):
self
.
enable_cinn
=
False
class
TestBF16ElementwiseMulOp
(
OpTest
):
def
setUp
(
self
):
...
...
python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py
浏览文件 @
7bf97d2c
...
...
@@ -135,7 +135,6 @@ class TestElementwiseSubOp_ZeroDim1(TestElementwiseOp):
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
self
.
if_check_prim
()
self
.
if_enable_cinn
()
class
TestElementwiseSubFP16OP_ZeroDim1
(
TestElementwiseSubOp_ZeroDim1
):
...
...
@@ -182,7 +181,6 @@ class TestElementwiseSubOp_ZeroDim2(TestElementwiseOp):
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
self
.
if_check_prim
()
self
.
if_enable_cinn
()
class
TestElementwiseSubFP16OP_ZeroDim2
(
TestElementwiseSubOp_ZeroDim2
):
...
...
@@ -229,7 +227,6 @@ class TestElementwiseSubOp_ZeroDim3(TestElementwiseOp):
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
-
self
.
inputs
[
'Y'
]}
self
.
if_check_prim
()
self
.
if_enable_cinn
()
class
TestElementwiseSubFP16OP_ZeroDim3
(
TestElementwiseSubOp_ZeroDim3
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录