Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
97ab6aa6
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看板
未验证
提交
97ab6aa6
编写于
8月 04, 2023
作者:
J
jiangfan06
提交者:
GitHub
8月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] Add int support for elementwise_sub/elementwise_div (#55920)
上级
91873469
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
280 addition
and
117 deletion
+280
-117
paddle/phi/backends/xpu/xpu2_op_list.cc
paddle/phi/backends/xpu/xpu2_op_list.cc
+5
-1
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
+8
-2
paddle/phi/kernels/xpu/elementwise_subtract_kernel.cc
paddle/phi/kernels/xpu/elementwise_subtract_kernel.cc
+1
-0
test/xpu/test_elementwise_div_op_xpu.py
test/xpu/test_elementwise_div_op_xpu.py
+266
-114
未找到文件。
paddle/phi/backends/xpu/xpu2_op_list.cc
浏览文件 @
97ab6aa6
...
...
@@ -231,7 +231,10 @@ XPUOpMap& get_kl2_ops() {
{
"elementwise_div_grad"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
})},
{
"elementwise_div"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
})},
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
,
phi
::
DataType
::
INT64
,
phi
::
DataType
::
INT32
})},
{
"elementwise_floordiv"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
})},
{
"elementwise_max_grad"
,
...
...
@@ -256,6 +259,7 @@ XPUOpMap& get_kl2_ops() {
{
"elementwise_sub"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
,
phi
::
DataType
::
INT32
,
phi
::
DataType
::
INT64
})},
{
"elementwise_mod"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
...
...
paddle/phi/kernels/xpu/elementwise_divide_kernel.cc
浏览文件 @
97ab6aa6
...
...
@@ -44,5 +44,11 @@ void DivideKernel(const Context& dev_ctx,
}
// namespace phi
PD_REGISTER_KERNEL
(
divide
,
XPU
,
ALL_LAYOUT
,
phi
::
DivideKernel
,
phi
::
dtype
::
float16
,
float
)
{}
PD_REGISTER_KERNEL
(
divide
,
XPU
,
ALL_LAYOUT
,
phi
::
DivideKernel
,
float
,
phi
::
dtype
::
float16
,
int
,
int64_t
)
{}
paddle/phi/kernels/xpu/elementwise_subtract_kernel.cc
浏览文件 @
97ab6aa6
...
...
@@ -44,4 +44,5 @@ PD_REGISTER_KERNEL(subtract,
phi
::
SubtractKernel
,
float
,
phi
::
dtype
::
float16
,
int
,
int64_t
)
{}
test/xpu/test_elementwise_div_op_xpu.py
浏览文件 @
97ab6aa6
...
...
@@ -48,13 +48,20 @@ class XPUTestElementwiseDivOp(XPUOpTestWrapper):
"""
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
13
,
17
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
13
,
17
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
13
,
17
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
def
test_check_output
(
self
):
if
paddle
.
is_compiled_with_xpu
():
...
...
@@ -95,161 +102,306 @@ class XPUTestElementwiseDivOp(XPUOpTestWrapper):
class
TestElementwiseDivOp_ZeroDim1
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
-
1
,
1
,
[]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
-
1
,
1
,
[]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
/
self
.
inputs
[
'Y'
]}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
-
1
,
1
,
[]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
-
1
,
1
,
[]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
/
self
.
inputs
[
'Y'
]}
class
TestElementwiseDivOp_ZeroDim2
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
-
1
,
1
,
[
13
,
17
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
-
1
,
1
,
[]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
/
self
.
inputs
[
'Y'
]}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
13
,
17
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
-
1
,
1
,
[
13
,
17
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
-
1
,
1
,
[]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
/
self
.
inputs
[
'Y'
]}
@
skip_check_grad_ci
(
reason
=
"[skip shape check] Use y_shape(1) to test broadcast."
)
class
TestElementwiseDivOp_scalar
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
20
,
3
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
/
self
.
inputs
[
'Y'
]}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
20
,
3
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
1
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
20
,
3
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
/
self
.
inputs
[
'Y'
]}
class
TestElementwiseDivOp_Vector
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
class
TestElementwiseDivOp_broadcast_0
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
,
3
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
100
,
3
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
].
reshape
(
100
,
1
,
1
)
}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
,
3
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
100
,
1
,
1
)
)
}
self
.
attrs
=
{
'axis'
:
0
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
100
,
1
,
1
)
)
}
class
TestElementwiseDivOp_broadcast_1
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
100
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
100
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
].
reshape
(
1
,
100
,
1
)
}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
100
,
4
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
1
,
100
,
1
)
)
}
self
.
attrs
=
{
'axis'
:
1
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
1
,
100
,
1
)
)
}
class
TestElementwiseDivOp_broadcast_2
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
1
,
1
,
100
)
)
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
3
,
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
].
reshape
(
1
,
1
,
100
)
}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
1
,
1
,
100
)
)
}
class
TestElementwiseDivOp_broadcast_3
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
10
,
12
,
5
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
12
]).
astype
(
self
.
dtype
),
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
10
,
12
,
5
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
10
,
12
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
].
reshape
(
1
,
10
,
12
,
1
)
}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
10
,
12
,
5
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
12
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
1
,
10
,
12
,
1
)
)
}
self
.
attrs
=
{
'axis'
:
1
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
].
reshape
(
1
,
10
,
12
,
1
)
)
}
class
TestElementwiseDivOp_broadcast_4
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
50
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
1
,
50
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
3
,
50
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
1
,
50
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
50
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
1
,
50
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
class
TestElementwiseDivOp_broadcast_5
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
20
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
1
,
20
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
3
,
4
,
20
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
3
,
1
,
20
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
4
,
20
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
1
,
20
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
class
TestElementwiseDivOp_commonuse_1
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
1
,
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
3
,
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
1
,
1
,
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
100
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
1
,
1
,
100
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
class
TestElementwiseDivOp_commonuse_2
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
30
,
3
,
1
,
5
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
30
,
1
,
4
,
1
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
30
,
3
,
1
,
5
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
30
,
1
,
4
,
1
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
30
,
3
,
1
,
5
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
30
,
1
,
4
,
1
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
class
TestElementwiseDivOp_xsize_lessthan_ysize
(
ElementwiseDivOp
):
def
init_input_output
(
self
):
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
12
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
10
,
12
]).
astype
(
self
.
dtype
),
}
if
self
.
dtype
==
np
.
int32
or
self
.
dtype
==
np
.
int64
:
self
.
inputs
=
{
'X'
:
np
.
random
.
randint
(
1
,
100
,
[
10
,
12
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
randint
(
1
,
100
,
[
2
,
3
,
10
,
12
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
]
//
self
.
inputs
[
'Y'
]}
else
:
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
10
,
12
]).
astype
(
self
.
dtype
),
'Y'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
3
,
10
,
12
]).
astype
(
self
.
dtype
),
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
self
.
attrs
=
{
'axis'
:
2
}
self
.
outputs
=
{
'Out'
:
np
.
divide
(
self
.
inputs
[
'X'
],
self
.
inputs
[
'Y'
])
}
class
TestElementwiseDivBroadcast
(
unittest
.
TestCase
):
def
test_shape_with_batch_sizes
(
self
):
with
fluid
.
program_guard
(
fluid
.
Program
()):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录