Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b69af7ad
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,发现更多精彩内容 >>
未验证
提交
b69af7ad
编写于
2月 28, 2023
作者:
张
张春乔
提交者:
GitHub
2月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[fp16] support fp16 on LocalResponseNorm (#50918)
* support fp16 on LocalResponseNorm * add docs in avgpool3d
上级
d841062b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
3 deletion
+31
-3
python/paddle/fluid/tests/unittests/test_lrn_op.py
python/paddle/fluid/tests/unittests/test_lrn_op.py
+26
-0
python/paddle/nn/functional/norm.py
python/paddle/nn/functional/norm.py
+4
-2
python/paddle/nn/layer/pooling.py
python/paddle/nn/layer/pooling.py
+1
-1
未找到文件。
python/paddle/fluid/tests/unittests/test_lrn_op.py
浏览文件 @
b69af7ad
...
...
@@ -328,6 +328,32 @@ class TestLocalResponseNormCAPI(unittest.TestCase):
res2_tran
=
np
.
transpose
(
res2
.
numpy
(),
(
0
,
3
,
1
,
2
))
np
.
testing
.
assert_allclose
(
res1
.
numpy
(),
res2_tran
,
rtol
=
1e-05
)
def
test_static_fp16_gpu
(
self
):
if
paddle
.
fluid
.
core
.
is_compiled_with_cuda
():
place
=
paddle
.
CUDAPlace
(
0
)
with
paddle
.
static
.
program_guard
(
paddle
.
static
.
Program
(),
paddle
.
static
.
Program
()
):
input
=
np
.
random
.
random
([
3
,
3
,
112
,
112
]).
astype
(
"float16"
)
x
=
paddle
.
static
.
data
(
name
=
"x"
,
shape
=
[
3
,
3
,
112
,
112
],
dtype
=
"float16"
)
m
=
paddle
.
nn
.
LocalResponseNorm
(
size
=
5
)
y
=
m
(
x
)
exe
=
paddle
.
static
.
Executor
(
place
)
res
=
exe
.
run
(
paddle
.
static
.
default_main_program
(),
feed
=
{
"x"
:
input
,
},
fetch_list
=
[
y
],
)
assert
np
.
array_equal
(
res
[
0
].
shape
,
input
.
shape
)
if
__name__
==
"__main__"
:
unittest
.
main
()
python/paddle/nn/functional/norm.py
浏览文件 @
b69af7ad
...
...
@@ -478,7 +478,7 @@ def local_response_norm(
Args:
x (Tensor): The input 3-D/4-D/5-D tensor. The data type is float32.
x (Tensor): The input 3-D/4-D/5-D tensor. The data type is float
16 or float
32.
size (int): The number of channels to sum over.
alpha (float, optional): The scaling parameter, positive. Default:1e-4
beta (float, optional): The exponent, positive. Default:0.75
...
...
@@ -509,7 +509,9 @@ def local_response_norm(
print(y.shape) # [3, 3, 112, 112]
"""
if
not
in_dynamic_mode
():
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
],
'local_response_norm'
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
],
'local_response_norm'
)
if
data_format
not
in
[
'NCL'
,
'NLC'
,
'NCHW'
,
'NHWC'
,
'NCDHW'
,
'NDHWC'
]:
raise
ValueError
(
"data_format should be in one of [NCL, NCHW, NCDHW, NLC, NHWC, NDHWC], "
...
...
python/paddle/nn/layer/pooling.py
浏览文件 @
b69af7ad
...
...
@@ -261,7 +261,7 @@ class AvgPool3D(Layer):
Shape:
- x(Tensor): The input tensor of avg pool3d operator, which is a 5-D tensor.
The data type can be float32, float64.
The data type can be float
16, float
32, float64.
- output(Tensor): The output tensor of avg pool3d operator, which is a 5-D tensor.
The data type is same as input x.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录