Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
db5fd2a1
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看板
未验证
提交
db5fd2a1
编写于
9月 08, 2021
作者:
W
will-jl944
提交者:
GitHub
9月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
multiply supports bool
multiply supports bool
上级
a2dbb0c2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
4 deletion
+23
-4
paddle/fluid/operators/elementwise/elementwise_mul_op.cc
paddle/fluid/operators/elementwise/elementwise_mul_op.cc
+4
-0
paddle/fluid/operators/elementwise/elementwise_mul_op.cu
paddle/fluid/operators/elementwise/elementwise_mul_op.cu
+3
-0
python/paddle/fluid/tests/unittests/test_multiply.py
python/paddle/fluid/tests/unittests/test_multiply.py
+12
-0
python/paddle/tensor/math.py
python/paddle/tensor/math.py
+4
-4
未找到文件。
paddle/fluid/operators/elementwise/elementwise_mul_op.cc
浏览文件 @
db5fd2a1
...
...
@@ -132,6 +132,7 @@ REGISTER_OP_CPU_KERNEL(
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUDeviceContext
,
paddle
::
platform
::
complex
<
float
>>
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUDeviceContext
,
...
...
@@ -142,6 +143,7 @@ REGISTER_OP_CPU_KERNEL(
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
paddle
::
platform
::
complex
<
float
>>
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
...
...
@@ -156,6 +158,8 @@ REGISTER_OP_CPU_KERNEL(
int
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
paddle
::
platform
::
complex
<
float
>>
,
ops
::
ElementwiseMulDoubleGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
...
...
paddle/fluid/operators/elementwise/elementwise_mul_op.cu
浏览文件 @
db5fd2a1
...
...
@@ -121,6 +121,7 @@ REGISTER_OP_CUDA_KERNEL(
ops
::
ElementwiseMulKernel
<
plat
::
CUDADeviceContext
,
double
>
,
ops
::
ElementwiseMulKernel
<
plat
::
CUDADeviceContext
,
int
>
,
ops
::
ElementwiseMulKernel
<
plat
::
CUDADeviceContext
,
int64_t
>
,
ops
::
ElementwiseMulKernel
<
plat
::
CUDADeviceContext
,
bool
>
,
ops
::
ElementwiseMulKernel
<
plat
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
ElementwiseMulKernel
<
plat
::
CUDADeviceContext
,
plat
::
complex
<
float
>>
,
ops
::
ElementwiseMulKernel
<
plat
::
CUDADeviceContext
,
plat
::
complex
<
double
>>
);
...
...
@@ -130,6 +131,7 @@ REGISTER_OP_CUDA_KERNEL(
ops
::
ElementwiseMulGradKernel
<
plat
::
CUDADeviceContext
,
double
>
,
ops
::
ElementwiseMulGradKernel
<
plat
::
CUDADeviceContext
,
int
>
,
ops
::
ElementwiseMulGradKernel
<
plat
::
CUDADeviceContext
,
int64_t
>
,
ops
::
ElementwiseMulGradKernel
<
plat
::
CUDADeviceContext
,
bool
>
,
ops
::
ElementwiseMulGradKernel
<
plat
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
ElementwiseMulGradKernel
<
plat
::
CUDADeviceContext
,
plat
::
complex
<
float
>>
,
...
...
@@ -141,6 +143,7 @@ REGISTER_OP_CUDA_KERNEL(
ops
::
ElementwiseMulDoubleGradKernel
<
plat
::
CUDADeviceContext
,
double
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
plat
::
CUDADeviceContext
,
int
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
plat
::
CUDADeviceContext
,
int64_t
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
plat
::
CUDADeviceContext
,
bool
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
plat
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
ElementwiseMulDoubleGradKernel
<
plat
::
CUDADeviceContext
,
plat
::
complex
<
float
>>
,
...
...
python/paddle/fluid/tests/unittests/test_multiply.py
浏览文件 @
db5fd2a1
...
...
@@ -70,6 +70,12 @@ class TestMultiplyApi(unittest.TestCase):
res
=
self
.
_run_static_graph_case
(
x_data
,
y_data
)
self
.
assertTrue
(
np
.
allclose
(
res
,
np
.
multiply
(
x_data
,
y_data
)))
# test static computation graph: boolean
x_data
=
np
.
random
.
choice
([
True
,
False
],
size
=
[
200
])
y_data
=
np
.
random
.
choice
([
True
,
False
],
size
=
[
200
])
res
=
self
.
_run_static_graph_case
(
x_data
,
y_data
)
self
.
assertTrue
(
np
.
allclose
(
res
,
np
.
multiply
(
x_data
,
y_data
)))
# test dynamic computation graph: 1-d array
x_data
=
np
.
random
.
rand
(
200
)
y_data
=
np
.
random
.
rand
(
200
)
...
...
@@ -88,6 +94,12 @@ class TestMultiplyApi(unittest.TestCase):
res
=
self
.
_run_dynamic_graph_case
(
x_data
,
y_data
)
self
.
assertTrue
(
np
.
allclose
(
res
,
np
.
multiply
(
x_data
,
y_data
)))
# test dynamic computation graph: boolean
x_data
=
np
.
random
.
choice
([
True
,
False
],
size
=
[
200
])
y_data
=
np
.
random
.
choice
([
True
,
False
],
size
=
[
200
])
res
=
self
.
_run_dynamic_graph_case
(
x_data
,
y_data
)
self
.
assertTrue
(
np
.
allclose
(
res
,
np
.
multiply
(
x_data
,
y_data
)))
class
TestMultiplyError
(
unittest
.
TestCase
):
def
test_errors
(
self
):
...
...
python/paddle/tensor/math.py
浏览文件 @
db5fd2a1
...
...
@@ -196,10 +196,10 @@ def _elementwise_op(helper):
assert
x
is
not
None
,
'x cannot be None in {}'
.
format
(
original_op_type
)
assert
y
is
not
None
,
'y cannot be None in {}'
.
format
(
original_op_type
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
,
'bool'
],
original_op_type
)
check_variable_and_dtype
(
y
,
'y'
,
[
'float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
y
,
'y'
,
[
'float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
,
'bool'
],
original_op_type
)
axis
=
helper
.
kwargs
.
get
(
'axis'
,
-
1
)
...
...
@@ -473,8 +473,8 @@ def multiply(x, y, name=None):
``paddle.multiply`` supports broadcasting. If you would like to know more about broadcasting, please refer to :ref:`user_guide_broadcasting` .
Args:
x (Tensor): the input tensor, its data type should be
float32, float64, int32, int64
.
y (Tensor): the input tensor, its data type should be
float32, float64, int32, int64
.
x (Tensor): the input tensor, its data type should be
one of float32, float64, int32, int64, bool
.
y (Tensor): the input tensor, its data type should be
one of float32, float64, int32, int64, bool
.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
Returns:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录