Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b6d0dac9
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
b6d0dac9
编写于
3月 24, 2023
作者:
Y
Yuang Liu
提交者:
GitHub
3月 24, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix roll kernel gpu bug. (#52012)
上级
5031b443
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
1 deletion
+37
-1
paddle/phi/kernels/gpu/roll_kernel_impl.h
paddle/phi/kernels/gpu/roll_kernel_impl.h
+1
-1
python/paddle/fluid/tests/unittests/test_roll_op.py
python/paddle/fluid/tests/unittests/test_roll_op.py
+36
-0
未找到文件。
paddle/phi/kernels/gpu/roll_kernel_impl.h
浏览文件 @
b6d0dac9
...
@@ -39,7 +39,7 @@ __global__ void RollCudaKernel(const T* input,
...
@@ -39,7 +39,7 @@ __global__ void RollCudaKernel(const T* input,
#pragma unroll
#pragma unroll
for
(
size_t
i
=
0
;
i
<
Rank
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
Rank
;
i
++
)
{
new_dim_idx
=
(
idx
/
strides
[
i
])
%
sizes
[
i
]
+
shifts
[
i
];
new_dim_idx
=
(
output_
idx
/
strides
[
i
])
%
sizes
[
i
]
+
shifts
[
i
];
if
(
new_dim_idx
>=
sizes
[
i
])
{
if
(
new_dim_idx
>=
sizes
[
i
])
{
output_idx
+=
(
shifts
[
i
]
-
sizes
[
i
])
*
strides
[
i
];
output_idx
+=
(
shifts
[
i
]
-
sizes
[
i
])
*
strides
[
i
];
}
else
{
}
else
{
...
...
python/paddle/fluid/tests/unittests/test_roll_op.py
浏览文件 @
b6d0dac9
...
@@ -61,6 +61,14 @@ class TestRollOpCase2(TestRollOp):
...
@@ -61,6 +61,14 @@ class TestRollOpCase2(TestRollOp):
self
.
axis
=
[
-
1
,
-
2
]
self
.
axis
=
[
-
1
,
-
2
]
class
TestRollOpCase3
(
TestRollOp
):
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
float32
self
.
x_shape
=
(
11
,
11
)
self
.
shifts
=
[
1
,
1
]
self
.
axis
=
[
-
1
,
1
]
class
TestRollFP16OP
(
TestRollOp
):
class
TestRollFP16OP
(
TestRollOp
):
def
init_dtype_type
(
self
):
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
float16
self
.
dtype
=
np
.
float16
...
@@ -77,6 +85,14 @@ class TestRollFP16OpCase2(TestRollOp):
...
@@ -77,6 +85,14 @@ class TestRollFP16OpCase2(TestRollOp):
self
.
axis
=
[
-
1
,
-
2
]
self
.
axis
=
[
-
1
,
-
2
]
class
TestRollFP16OpCase3
(
TestRollOp
):
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
float16
self
.
x_shape
=
(
11
,
11
)
self
.
shifts
=
[
1
,
1
]
self
.
axis
=
[
-
1
,
1
]
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
not
core
.
is_compiled_with_cuda
()
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
...
@@ -117,6 +133,26 @@ class TestRollBF16OpCase2(TestRollOp):
...
@@ -117,6 +133,26 @@ class TestRollBF16OpCase2(TestRollOp):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
],
'Out'
,
check_eager
=
True
)
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
],
'Out'
,
check_eager
=
True
)
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
"core is not complied with CUDA and not support the bfloat16"
,
)
class
TestRollBF16OpCase3
(
TestRollOp
):
def
init_dtype_type
(
self
):
self
.
dtype
=
np
.
uint16
self
.
x_shape
=
(
11
,
11
)
self
.
shifts
=
[
1
,
1
]
self
.
axis
=
[
-
1
,
1
]
self
.
place
=
core
.
CUDAPlace
(
0
)
def
test_check_output
(
self
):
self
.
check_output_with_place
(
self
.
place
,
check_eager
=
True
)
def
test_check_grad_normal
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
],
'Out'
,
check_eager
=
True
)
class
TestRollAPI
(
unittest
.
TestCase
):
class
TestRollAPI
(
unittest
.
TestCase
):
def
input_data
(
self
):
def
input_data
(
self
):
self
.
data_x
=
np
.
array
(
self
.
data_x
=
np
.
array
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录