Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
69d3f4e3
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
69d3f4e3
编写于
5月 19, 2023
作者:
D
Danyang Zhang
提交者:
GitHub
5月 19, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete bf16 of cross entropy (#53922)
* delete bf16 of cross entropy * delete bf16 of cross entropy
上级
eb193d8d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
3 addition
and
61 deletion
+3
-61
paddle/phi/kernels/gpu/cross_entropy_grad_kernel.cu
paddle/phi/kernels/gpu/cross_entropy_grad_kernel.cu
+1
-2
paddle/phi/kernels/gpu/cross_entropy_kernel.cu
paddle/phi/kernels/gpu/cross_entropy_kernel.cu
+1
-2
python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py
...uid/tests/unittests/test_softmax_with_cross_entropy_op.py
+1
-57
未找到文件。
paddle/phi/kernels/gpu/cross_entropy_grad_kernel.cu
浏览文件 @
69d3f4e3
...
@@ -297,8 +297,7 @@ PD_REGISTER_KERNEL(cross_entropy_with_softmax_grad,
...
@@ -297,8 +297,7 @@ PD_REGISTER_KERNEL(cross_entropy_with_softmax_grad,
phi
::
CrossEntropyWithSoftmaxGradKernel
,
phi
::
CrossEntropyWithSoftmaxGradKernel
,
float
,
float
,
double
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
float16
)
{}
phi
::
dtype
::
bfloat16
)
{}
#else
#else
PD_REGISTER_KERNEL
(
cross_entropy_with_softmax_grad
,
PD_REGISTER_KERNEL
(
cross_entropy_with_softmax_grad
,
GPU
,
GPU
,
...
...
paddle/phi/kernels/gpu/cross_entropy_kernel.cu
浏览文件 @
69d3f4e3
...
@@ -1479,8 +1479,7 @@ PD_REGISTER_KERNEL(cross_entropy_with_softmax,
...
@@ -1479,8 +1479,7 @@ PD_REGISTER_KERNEL(cross_entropy_with_softmax,
phi
::
CrossEntropyWithSoftmaxKernel
,
phi
::
CrossEntropyWithSoftmaxKernel
,
float
,
float
,
double
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
float16
)
{}
phi
::
dtype
::
bfloat16
)
{}
#else
#else
PD_REGISTER_KERNEL
(
cross_entropy_with_softmax
,
PD_REGISTER_KERNEL
(
cross_entropy_with_softmax
,
GPU
,
GPU
,
...
...
python/paddle/fluid/tests/unittests/test_softmax_with_cross_entropy_op.py
浏览文件 @
69d3f4e3
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
eager_op_test
import
OpTest
,
convert_float_to_uint16
,
paddle_static_guard
from
eager_op_test
import
OpTest
,
paddle_static_guard
from
test_softmax_op
import
stable_softmax
from
test_softmax_op
import
stable_softmax
import
paddle
import
paddle
...
@@ -918,62 +918,6 @@ class TestSoftmaxWithCrossEntropyOpBoundary1(TestSoftmaxWithCrossEntropyOp):
...
@@ -918,62 +918,6 @@ class TestSoftmaxWithCrossEntropyOpBoundary1(TestSoftmaxWithCrossEntropyOp):
self
.
use_softmax
=
True
self
.
use_softmax
=
True
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
"core is not compiled with CUDA and not support the bfloat16"
,
)
class
TestSoftmaxWithCrossEntropyOpBF16
(
TestSoftmaxWithCrossEntropyOp
):
def
setUp
(
self
):
self
.
initParams
()
self
.
op_type
=
"softmax_with_cross_entropy"
self
.
dtype
=
np
.
uint16
# NOTE: numpy bf16 have very low accuracy, use float32 for numpy check.
date_type
=
np
.
float32
logits
=
getattr
(
self
,
"logits"
,
np
.
random
.
uniform
(
0.1
,
1.0
,
self
.
shape
).
astype
(
date_type
),
)
softmax
=
np
.
apply_along_axis
(
stable_softmax
,
self
.
axis
,
logits
)
axis_dim
=
self
.
shape
[
self
.
axis
]
self
.
shape
[
self
.
axis
]
=
1
labels
=
np
.
random
.
randint
(
0
,
axis_dim
,
self
.
shape
,
dtype
=
"int64"
)
loss
=
cross_entropy
(
softmax
,
labels
,
self
.
soft_label
,
self
.
axis
)
self
.
inputs
=
{
"Logits"
:
convert_float_to_uint16
(
logits
),
"Label"
:
labels
,
}
self
.
outputs
=
{
"Softmax"
:
convert_float_to_uint16
(
softmax
),
"Loss"
:
convert_float_to_uint16
(
loss
),
}
self
.
attrs
=
{
"numeric_stable_mode"
:
self
.
numeric_stable_mode
,
"soft_label"
:
self
.
soft_label
,
}
if
self
.
axis
!=
-
1
:
self
.
attrs
[
'axis'
]
=
self
.
axis
def
test_check_output
(
self
):
place
=
core
.
CUDAPlace
(
0
)
if
self
.
python_api
is
not
None
:
self
.
check_output_with_place
(
place
)
self
.
check_output_with_place
(
place
,
atol
=
1e-2
)
def
test_check_grad
(
self
):
place
=
core
.
CUDAPlace
(
0
)
if
self
.
python_api
is
not
None
:
self
.
check_grad_with_place
(
place
,
[
"Logits"
],
"Loss"
)
self
.
check_grad_with_place
(
place
,
[
"Logits"
],
"Loss"
,
max_relative_error
=
0.1
)
class
TestSoftmaxWithCrossEntropyOpError
(
unittest
.
TestCase
):
class
TestSoftmaxWithCrossEntropyOpError
(
unittest
.
TestCase
):
def
test_errors
(
self
):
def
test_errors
(
self
):
with
program_guard
(
Program
(),
Program
()):
with
program_guard
(
Program
(),
Program
()):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录