Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
eeb4d165
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
eeb4d165
编写于
4月 14, 2023
作者:
S
superwinner1
提交者:
GitHub
4月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【Hackathon No.55】add erf FP16 test and BF16 test (#52136)
* add erf FP16 test
上级
ddcc1002
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
74 addition
and
12 deletion
+74
-12
paddle/phi/kernels/funcs/eigen/erf.cc
paddle/phi/kernels/funcs/eigen/erf.cc
+6
-4
paddle/phi/kernels/funcs/eigen/erf.cu
paddle/phi/kernels/funcs/eigen/erf.cu
+6
-4
paddle/phi/kernels/gpu/erf_grad_kernel.cu
paddle/phi/kernels/gpu/erf_grad_kernel.cu
+3
-1
paddle/phi/kernels/gpu/erf_kernel.cu
paddle/phi/kernels/gpu/erf_kernel.cu
+9
-2
python/paddle/fluid/tests/unittests/test_erf_op.py
python/paddle/fluid/tests/unittests/test_erf_op.py
+50
-1
未找到文件。
paddle/phi/kernels/funcs/eigen/erf.cc
浏览文件 @
eeb4d165
...
...
@@ -11,6 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/float16.h"
#include "paddle/phi/kernels/funcs/eigen/eigen_function.h"
#include "paddle/phi/kernels/funcs/eigen/extensions.h"
...
...
@@ -46,10 +47,11 @@ struct EigenErfGrad<Eigen::DefaultDevice, T> {
}
};
#define INSTANTIATION(FUNCTOR) \
template struct FUNCTOR<Eigen::DefaultDevice, float>; \
template struct FUNCTOR<Eigen::DefaultDevice, double>; \
template struct FUNCTOR<Eigen::DefaultDevice, dtype::float16>
#define INSTANTIATION(FUNCTOR) \
template struct FUNCTOR<Eigen::DefaultDevice, float>; \
template struct FUNCTOR<Eigen::DefaultDevice, double>; \
template struct FUNCTOR<Eigen::DefaultDevice, dtype::float16>; \
template struct FUNCTOR<Eigen::DefaultDevice, dtype::bfloat16>
INSTANTIATION
(
EigenErf
);
INSTANTIATION
(
EigenErfGrad
);
#undef INSTANTIATION
...
...
paddle/phi/kernels/funcs/eigen/erf.cu
浏览文件 @
eeb4d165
...
...
@@ -14,6 +14,7 @@ limitations under the License. */
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/float16.h"
#include "paddle/phi/kernels/funcs/eigen/eigen_function.h"
#include "paddle/phi/kernels/funcs/eigen/extensions.h"
...
...
@@ -47,10 +48,11 @@ struct EigenErfGrad<Eigen::GpuDevice, T> {
}
};
#define INSTANTIATION(FUNCTOR) \
template struct FUNCTOR<Eigen::GpuDevice, float>; \
template struct FUNCTOR<Eigen::GpuDevice, double>; \
template struct FUNCTOR<Eigen::GpuDevice, dtype::float16>
#define INSTANTIATION(FUNCTOR) \
template struct FUNCTOR<Eigen::GpuDevice, float>; \
template struct FUNCTOR<Eigen::GpuDevice, double>; \
template struct FUNCTOR<Eigen::GpuDevice, dtype::float16>; \
template struct FUNCTOR<Eigen::GpuDevice, dtype::bfloat16>
INSTANTIATION
(
EigenErf
);
INSTANTIATION
(
EigenErfGrad
);
#undef INSTANTIATION
...
...
paddle/phi/kernels/gpu/erf_grad_kernel.cu
浏览文件 @
eeb4d165
...
...
@@ -15,6 +15,7 @@ limitations under the License. */
#include "paddle/phi/kernels/erf_grad_kernel.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/float16.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/erf_grad_kernel_impl.h"
...
...
@@ -25,4 +26,5 @@ PD_REGISTER_KERNEL(erf_grad,
phi
::
ErfGradKernel
,
float
,
double
,
phi
::
dtype
::
float16
)
{}
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{}
paddle/phi/kernels/gpu/erf_kernel.cu
浏览文件 @
eeb4d165
...
...
@@ -15,9 +15,16 @@ limitations under the License. */
#include "paddle/phi/kernels/erf_kernel.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/float16.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/erf_kernel_impl.h"
PD_REGISTER_KERNEL
(
erf
,
GPU
,
ALL_LAYOUT
,
phi
::
ErfKernel
,
float
,
double
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
erf
,
GPU
,
ALL_LAYOUT
,
phi
::
ErfKernel
,
float
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{}
python/paddle/fluid/tests/unittests/test_erf_op.py
浏览文件 @
eeb4d165
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
eager_op_test
import
OpTest
from
eager_op_test
import
OpTest
,
convert_float_to_uint16
from
scipy.special
import
erf
import
paddle
...
...
@@ -68,5 +68,54 @@ class TestErfLayer(unittest.TestCase):
self
.
assertTrue
(
'erf'
in
y
.
name
)
class
TestErfFP16OP
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"erf"
self
.
prim_op_type
=
"prim"
self
.
public_python_api
=
paddle
.
erf
self
.
python_api
=
paddle
.
erf
self
.
dtype
=
np
.
float16
self
.
x_shape
=
[
11
,
17
]
x
=
np
.
random
.
uniform
(
-
1
,
1
,
size
=
self
.
x_shape
).
astype
(
self
.
dtype
)
y_ref
=
erf
(
x
).
astype
(
self
.
dtype
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
y_ref
}
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
check_prim
=
True
)
@
unittest
.
skipIf
(
not
paddle
.
fluid
.
core
.
is_compiled_with_cuda
()
or
not
paddle
.
fluid
.
core
.
is_bfloat16_supported
(
paddle
.
fluid
.
core
.
CUDAPlace
(
0
)
),
"core is not complied with CUDA and not support the bfloat16"
,
)
class
TestErfBF16OP
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"erf"
self
.
prim_op_type
=
"prim"
self
.
public_python_api
=
paddle
.
erf
self
.
python_api
=
paddle
.
erf
self
.
dtype
=
np
.
uint16
self
.
x_shape
=
[
11
,
17
]
x
=
np
.
random
.
uniform
(
-
1
,
1
,
size
=
self
.
x_shape
).
astype
(
np
.
float32
)
y_ref
=
erf
(
x
).
astype
(
np
.
float32
)
self
.
inputs
=
{
'X'
:
convert_float_to_uint16
(
x
)}
self
.
outputs
=
{
'Out'
:
convert_float_to_uint16
(
y_ref
)}
def
test_check_output
(
self
):
place
=
paddle
.
fluid
.
core
.
CUDAPlace
(
0
)
self
.
check_output_with_place
(
place
)
def
test_check_grad
(
self
):
place
=
paddle
.
fluid
.
core
.
CUDAPlace
(
0
)
self
.
check_grad_with_place
(
place
,
[
'X'
],
'Out'
,
check_prim
=
True
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录