Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d1e2c61b
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看板
未验证
提交
d1e2c61b
编写于
3月 16, 2023
作者:
R
Roc
提交者:
GitHub
3月 16, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Comp index select (#51215)
上级
f824bc0d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
2 deletion
+17
-2
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+1
-0
python/paddle/fluid/tests/unittests/test_index_select_op.py
python/paddle/fluid/tests/unittests/test_index_select_op.py
+5
-2
python/paddle/incubate/autograd/composite_rules.py
python/paddle/incubate/autograd/composite_rules.py
+9
-0
python/paddle/incubate/autograd/primitives.py
python/paddle/incubate/autograd/primitives.py
+2
-0
未找到文件。
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
d1e2c61b
...
...
@@ -1199,6 +1199,7 @@ set(TEST_CINN_OPS
test_stack_op
test_activation_op
test_full_like_op
test_index_select_op
test_fill_any_like_op
test_concat_op
test_top_k_v2_op
...
...
python/paddle/fluid/tests/unittests/test_index_select_op.py
浏览文件 @
d1e2c61b
...
...
@@ -28,7 +28,9 @@ class TestIndexSelectOp(OpTest):
def
setUp
(
self
):
self
.
python_api
=
paddle
.
index_select
self
.
op_type
=
"index_select"
self
.
prim_op_type
=
"comp"
self
.
init_dtype_type
()
index_np
=
np
.
random
.
randint
(
low
=
0
,
high
=
self
.
x_shape
[
self
.
dim
],
size
=
self
.
index_size
)
...
...
@@ -57,10 +59,10 @@ class TestIndexSelectOp(OpTest):
self
.
index_size
=
100
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
(
check_eager
=
True
,
check_prim
=
True
)
def
test_check_grad_normal
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
check_eager
=
True
)
self
.
check_grad
([
'X'
],
'Out'
,
check_eager
=
True
,
check_prim
=
True
)
class
TestIndexSelectOpCase2
(
TestIndexSelectOp
):
...
...
@@ -92,6 +94,7 @@ class TestIndexSelectFP16OP(TestIndexSelectOp):
self
.
index_size
=
100
# no scatter op (the backward op of index_select/gather) for bf16
class
TestIndexSelectBF16Op
(
OpTest
):
def
setUp
(
self
):
self
.
python_api
=
paddle
.
index_select
...
...
python/paddle/incubate/autograd/composite_rules.py
浏览文件 @
d1e2c61b
...
...
@@ -393,6 +393,15 @@ def hard_swish_composite(x):
return
res
@
REGISTER_COMPOSITE
(
'index_select'
)
def
index_select_composite
(
x
,
index
,
axis
):
"""define composite rule of op index_select."""
if
axis
<
0
:
axis
=
len
(
x
.
shape
)
+
axis
res
=
gather
(
x
,
index
,
axis
=
axis
)
return
res
@
REGISTER_COMPOSITE
(
'sigmoid'
)
def
sigmoid_composite
(
x
):
"""
...
...
python/paddle/incubate/autograd/primitives.py
浏览文件 @
d1e2c61b
...
...
@@ -34,6 +34,7 @@ from paddle.tensor import erfinv # noqa: F401
from
paddle.tensor
import
exp
# noqa: F401
from
paddle.tensor
import
expm1
# noqa: F401
from
paddle.tensor
import
full
# noqa: F401
from
paddle.tensor
import
gather
# noqa: F401
from
paddle.tensor
import
greater_equal
# noqa: F401
from
paddle.tensor
import
lgamma
# noqa: F401
from
paddle.tensor
import
log
# noqa: F401
...
...
@@ -124,6 +125,7 @@ others = [
'cast',
'fill_constant',
'reshape',
'gather'
'full',
'tile',
'concat',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录