Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6d7ee668
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看板
未验证
提交
6d7ee668
编写于
4月 14, 2023
作者:
C
chenxujun
提交者:
GitHub
4月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add angle,bmm tests (#52630)
上级
281ea2f4
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
122 addition
and
7 deletion
+122
-7
paddle/phi/kernels/gpu/angle_grad_kernel.cu
paddle/phi/kernels/gpu/angle_grad_kernel.cu
+3
-0
paddle/phi/kernels/gpu/angle_kernel.cu
paddle/phi/kernels/gpu/angle_kernel.cu
+3
-0
paddle/phi/kernels/gpu/bmm_grad_kernel.cu
paddle/phi/kernels/gpu/bmm_grad_kernel.cu
+2
-1
paddle/phi/kernels/gpu/bmm_kernel.cu
paddle/phi/kernels/gpu/bmm_kernel.cu
+8
-2
python/paddle/fluid/tests/unittests/test_angle_op.py
python/paddle/fluid/tests/unittests/test_angle_op.py
+47
-2
python/paddle/fluid/tests/unittests/test_bmm_op.py
python/paddle/fluid/tests/unittests/test_bmm_op.py
+48
-1
python/paddle/tensor/math.py
python/paddle/tensor/math.py
+11
-1
未找到文件。
paddle/phi/kernels/gpu/angle_grad_kernel.cu
浏览文件 @
6d7ee668
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "paddle/phi/kernels/impl/angle_grad_kernel_impl.h"
#include "paddle/phi/kernels/impl/angle_grad_kernel_impl.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/common/amp_type_traits.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/kernel_registry.h"
PD_REGISTER_KERNEL
(
angle_grad
,
PD_REGISTER_KERNEL
(
angle_grad
,
...
@@ -24,6 +25,8 @@ PD_REGISTER_KERNEL(angle_grad,
...
@@ -24,6 +25,8 @@ PD_REGISTER_KERNEL(angle_grad,
phi
::
AngleGradKernel
,
phi
::
AngleGradKernel
,
float
,
float
,
double
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
double
>
)
{
phi
::
dtype
::
complex
<
double
>
)
{
kernel
->
InputAt
(
1
).
SetDataType
(
phi
::
dtype
::
ToReal
(
kernel_key
.
dtype
()));
kernel
->
InputAt
(
1
).
SetDataType
(
phi
::
dtype
::
ToReal
(
kernel_key
.
dtype
()));
...
...
paddle/phi/kernels/gpu/angle_kernel.cu
浏览文件 @
6d7ee668
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "paddle/phi/kernels/impl/angle_kernel_impl.h"
#include "paddle/phi/kernels/impl/angle_kernel_impl.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/common/amp_type_traits.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/kernel_registry.h"
PD_REGISTER_KERNEL
(
angle
,
PD_REGISTER_KERNEL
(
angle
,
...
@@ -25,6 +26,8 @@ PD_REGISTER_KERNEL(angle,
...
@@ -25,6 +26,8 @@ PD_REGISTER_KERNEL(angle,
phi
::
AngleKernel
,
phi
::
AngleKernel
,
float
,
float
,
double
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
double
>
)
{
phi
::
dtype
::
complex
<
double
>
)
{
kernel
->
OutputAt
(
0
).
SetDataType
(
phi
::
DataType
::
UNDEFINED
);
kernel
->
OutputAt
(
0
).
SetDataType
(
phi
::
DataType
::
UNDEFINED
);
...
...
paddle/phi/kernels/gpu/bmm_grad_kernel.cu
浏览文件 @
6d7ee668
...
@@ -24,4 +24,5 @@ PD_REGISTER_KERNEL(bmm_grad,
...
@@ -24,4 +24,5 @@ PD_REGISTER_KERNEL(bmm_grad,
phi
::
BmmGradKernel
,
phi
::
BmmGradKernel
,
float
,
float
,
double
,
double
,
phi
::
dtype
::
float16
)
{}
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{}
paddle/phi/kernels/gpu/bmm_kernel.cu
浏览文件 @
6d7ee668
...
@@ -18,5 +18,11 @@
...
@@ -18,5 +18,11 @@
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/bmm_kernel_impl.h"
#include "paddle/phi/kernels/impl/bmm_kernel_impl.h"
PD_REGISTER_KERNEL
(
PD_REGISTER_KERNEL
(
bmm
,
bmm
,
GPU
,
ALL_LAYOUT
,
phi
::
BmmKernel
,
float
,
double
,
phi
::
dtype
::
float16
)
{}
GPU
,
ALL_LAYOUT
,
phi
::
BmmKernel
,
float
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{}
python/paddle/fluid/tests/unittests/test_angle_op.py
浏览文件 @
6d7ee668
...
@@ -15,11 +15,11 @@
...
@@ -15,11 +15,11 @@
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
eager_op_test
import
OpTest
from
eager_op_test
import
OpTest
,
convert_float_to_uint16
import
paddle
import
paddle
from
paddle
import
static
from
paddle
import
static
from
paddle.fluid
import
dygraph
from
paddle.fluid
import
core
,
dygraph
paddle
.
enable_static
()
paddle
.
enable_static
()
...
@@ -61,6 +61,51 @@ class TestAngleOpFloat(OpTest):
...
@@ -61,6 +61,51 @@ class TestAngleOpFloat(OpTest):
)
)
class
TestAngleFP16Op
(
TestAngleOpFloat
):
def
setUp
(
self
):
self
.
op_type
=
"angle"
self
.
python_api
=
paddle
.
angle
self
.
dtype
=
"float16"
self
.
x
=
np
.
linspace
(
-
5
,
5
,
101
).
astype
(
self
.
dtype
)
out_ref
=
np
.
angle
(
self
.
x
)
self
.
inputs
=
{
'X'
:
self
.
x
}
self
.
outputs
=
{
'Out'
:
out_ref
}
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
"core is not compiled with CUDA or not support bfloat16"
,
)
class
TestAngleBF16Op
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"angle"
self
.
python_api
=
paddle
.
angle
self
.
dtype
=
np
.
uint16
self
.
np_dtype
=
np
.
float32
self
.
x
=
np
.
linspace
(
-
5
,
5
,
101
).
astype
(
self
.
np_dtype
)
out_ref
=
np
.
angle
(
self
.
x
)
self
.
inputs
=
{
'X'
:
self
.
x
}
self
.
outputs
=
{
'Out'
:
out_ref
}
self
.
inputs
[
'X'
]
=
convert_float_to_uint16
(
self
.
inputs
[
'X'
])
self
.
outputs
[
'Out'
]
=
convert_float_to_uint16
(
self
.
outputs
[
'Out'
])
self
.
place
=
core
.
CUDAPlace
(
0
)
def
test_check_output
(
self
):
self
.
check_output_with_place
(
self
.
place
)
def
test_check_grad
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
],
'Out'
,
user_defined_grads
=
[
angle_grad
(
self
.
x
,
np
.
ones_like
(
self
.
x
)
/
self
.
x
.
size
)
],
)
class
TestAngleOpComplex
(
OpTest
):
class
TestAngleOpComplex
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"angle"
self
.
op_type
=
"angle"
...
...
python/paddle/fluid/tests/unittests/test_bmm_op.py
浏览文件 @
6d7ee668
...
@@ -15,10 +15,11 @@
...
@@ -15,10 +15,11 @@
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
eager_op_test
import
OpTest
,
paddle_static_guard
from
eager_op_test
import
OpTest
,
convert_float_to_uint16
,
paddle_static_guard
import
paddle
import
paddle
from
paddle
import
fluid
from
paddle
import
fluid
from
paddle.fluid
import
core
class
TestBmmOp
(
OpTest
):
class
TestBmmOp
(
OpTest
):
...
@@ -38,6 +39,52 @@ class TestBmmOp(OpTest):
...
@@ -38,6 +39,52 @@ class TestBmmOp(OpTest):
self
.
check_grad
([
'X'
,
'Y'
],
'Out'
)
self
.
check_grad
([
'X'
,
'Y'
],
'Out'
)
class
TestBmmFP16Op
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"bmm"
self
.
dtype
=
np
.
float16
self
.
python_api
=
paddle
.
tensor
.
bmm
X
=
np
.
random
.
random
((
10
,
3
,
4
)).
astype
(
"float16"
)
Y
=
np
.
random
.
random
((
10
,
4
,
5
)).
astype
(
"float16"
)
self
.
inputs
=
{
'X'
:
X
,
'Y'
:
Y
}
Out
=
np
.
matmul
(
X
,
Y
)
self
.
outputs
=
{
'Out'
:
Out
}
def
test_check_output
(
self
):
self
.
check_output
()
def
test_checkout_grad
(
self
):
self
.
check_grad
([
'X'
,
'Y'
],
'Out'
)
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
"core is not compiled with CUDA or not support bfloat16"
,
)
class
TestBmmBF16Op
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"bmm"
self
.
dtype
=
np
.
uint16
self
.
python_api
=
paddle
.
tensor
.
bmm
X
=
np
.
random
.
random
((
10
,
3
,
4
)).
astype
(
"float32"
)
Y
=
np
.
random
.
random
((
10
,
4
,
5
)).
astype
(
"float32"
)
self
.
inputs
=
{
'X'
:
X
,
'Y'
:
Y
}
Out
=
np
.
matmul
(
X
,
Y
)
self
.
outputs
=
{
'Out'
:
Out
}
self
.
inputs
[
'X'
]
=
convert_float_to_uint16
(
self
.
inputs
[
'X'
])
self
.
inputs
[
'Y'
]
=
convert_float_to_uint16
(
self
.
inputs
[
'Y'
])
self
.
outputs
[
'Out'
]
=
convert_float_to_uint16
(
self
.
outputs
[
'Out'
])
self
.
place
=
core
.
CUDAPlace
(
0
)
def
test_check_output
(
self
):
self
.
check_output_with_place
(
self
.
place
)
def
test_checkout_grad
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
,
'Y'
],
'Out'
)
class
API_TestBmm
(
unittest
.
TestCase
):
class
API_TestBmm
(
unittest
.
TestCase
):
def
test_out
(
self
):
def
test_out
(
self
):
with
paddle_static_guard
():
with
paddle_static_guard
():
...
...
python/paddle/tensor/math.py
浏览文件 @
6d7ee668
...
@@ -4858,7 +4858,17 @@ def angle(x, name=None):
...
@@ -4858,7 +4858,17 @@ def angle(x, name=None):
return
_C_ops
.
angle
(
x
)
return
_C_ops
.
angle
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
,
'complex64'
,
'complex128'
],
'angle'
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
,
'complex64'
,
'complex128'
,
'uint16'
,
],
'angle'
,
)
)
op_type
=
"angle"
op_type
=
"angle"
helper
=
LayerHelper
(
op_type
,
**
locals
())
helper
=
LayerHelper
(
op_type
,
**
locals
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录