Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d3ebf1e6
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看板
未验证
提交
d3ebf1e6
编写于
3月 13, 2023
作者:
W
wangxiaoning
提交者:
GitHub
3月 13, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[AMP OP&Test]add fp16 and bf16 OpTest for index_select (#51159)
* add fp16/bf16 * add grad bf16 * test name
上级
2305089f
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
53 addition
and
2 deletion
+53
-2
paddle/phi/kernels/cpu/index_select_kernel.cc
paddle/phi/kernels/cpu/index_select_kernel.cc
+1
-0
paddle/phi/kernels/gpu/index_select_grad_kernel.cu
paddle/phi/kernels/gpu/index_select_grad_kernel.cu
+1
-0
paddle/phi/kernels/gpu/index_select_kernel.cu
paddle/phi/kernels/gpu/index_select_kernel.cu
+1
-0
python/paddle/fluid/tests/unittests/test_index_select_op.py
python/paddle/fluid/tests/unittests/test_index_select_op.py
+49
-1
python/paddle/tensor/search.py
python/paddle/tensor/search.py
+1
-1
未找到文件。
paddle/phi/kernels/cpu/index_select_kernel.cc
浏览文件 @
d3ebf1e6
...
...
@@ -58,5 +58,6 @@ PD_REGISTER_KERNEL(index_select,
phi
::
IndexSelectKernel
,
float
,
double
,
phi
::
dtype
::
bfloat16
,
int
,
int64_t
)
{}
paddle/phi/kernels/gpu/index_select_grad_kernel.cu
浏览文件 @
d3ebf1e6
...
...
@@ -132,5 +132,6 @@ PD_REGISTER_KERNEL(index_select_grad,
float
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
int
,
int64_t
)
{}
paddle/phi/kernels/gpu/index_select_kernel.cu
浏览文件 @
d3ebf1e6
...
...
@@ -84,5 +84,6 @@ PD_REGISTER_KERNEL(index_select,
float
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
int
,
int64_t
)
{}
python/paddle/fluid/tests/unittests/test_index_select_op.py
浏览文件 @
d3ebf1e6
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
convert_float_to_uint16
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -81,6 +81,54 @@ class TestIndexSelectOpCaseSingleThread(TestIndexSelectOp):
self
.
index_size
=
10
class
TestIndexSelectFP16OP
(
TestIndexSelectOp
):
def
init_dtype_type
(
self
):
self
.
dim
=
1
self
.
x_type
=
np
.
float16
self
.
index_type
=
np
.
int64
self
.
x_shape
=
(
100
,
4
,
5
)
self
.
index_size
=
100
class
TestIndexSelectBF16Op
(
OpTest
):
def
setUp
(
self
):
self
.
python_api
=
paddle
.
index_select
self
.
op_type
=
"index_select"
self
.
init_dtype_type
()
index_np
=
np
.
random
.
randint
(
low
=
0
,
high
=
self
.
x_shape
[
self
.
dim
],
size
=
self
.
index_size
)
x_np
=
np
.
random
.
random
(
self
.
x_shape
).
astype
(
np
.
float32
)
self
.
inputs
=
{
'X'
:
convert_float_to_uint16
(
x_np
),
'Index'
:
index_np
}
self
.
attrs
=
{
'dim'
:
self
.
dim
}
outer_loop
=
np
.
prod
(
self
.
x_shape
[:
self
.
dim
])
x_reshape
=
[
outer_loop
]
+
list
(
self
.
x_shape
[
self
.
dim
:])
x_np_reshape
=
np
.
reshape
(
x_np
,
tuple
(
x_reshape
))
out_list
=
[]
for
i
in
range
(
outer_loop
):
for
j
in
range
(
self
.
index_size
):
out_list
.
append
(
x_np_reshape
[
i
,
index_np
[
j
]])
self
.
out_shape
=
list
(
self
.
x_shape
)
self
.
out_shape
[
self
.
dim
]
=
self
.
index_size
self
.
out_shape
=
tuple
(
self
.
out_shape
)
out
=
np
.
reshape
(
out_list
,
self
.
out_shape
)
self
.
outputs
=
{
'Out'
:
convert_float_to_uint16
(
out
)}
def
init_dtype_type
(
self
):
self
.
dim
=
1
self
.
x_type
=
np
.
uint16
self
.
index_type
=
np
.
int64
self
.
x_shape
=
(
100
,
4
,
5
)
self
.
index_size
=
100
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
True
)
def
test_check_grad_normal
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
check_eager
=
True
)
class
TestIndexSelectAPI
(
unittest
.
TestCase
):
def
input_data
(
self
):
self
.
data_x
=
np
.
array
(
...
...
python/paddle/tensor/search.py
浏览文件 @
d3ebf1e6
...
...
@@ -350,7 +350,7 @@ def index_select(x, index, axis=0, name=None):
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
[
'
bfloat16'
,
'
float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'paddle.tensor.search.index_select'
,
)
check_variable_and_dtype
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录