Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
f5e430c5
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f5e430c5
编写于
9月 14, 2021
作者:
W
WeiXin
提交者:
GitHub
9月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
slice_op support bool tensor. (#35586)
上级
97a73e1d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
26 addition
and
4 deletion
+26
-4
paddle/fluid/operators/eigen/pad.cc
paddle/fluid/operators/eigen/pad.cc
+1
-0
paddle/fluid/operators/eigen/pad.cu
paddle/fluid/operators/eigen/pad.cu
+1
-0
paddle/fluid/operators/eigen/slice.cu
paddle/fluid/operators/eigen/slice.cu
+1
-0
paddle/fluid/operators/slice_op.cc
paddle/fluid/operators/slice_op.cc
+7
-4
python/paddle/fluid/tests/unittests/test_slice_op.py
python/paddle/fluid/tests/unittests/test_slice_op.py
+16
-0
未找到文件。
paddle/fluid/operators/eigen/pad.cc
浏览文件 @
f5e430c5
...
...
@@ -51,6 +51,7 @@ struct EigenPad<Eigen::DefaultDevice, T, Rank> {
template struct FUNCTOR<Eigen::DefaultDevice, TYPE, 4>; \
template struct FUNCTOR<Eigen::DefaultDevice, TYPE, 5>; \
template struct FUNCTOR<Eigen::DefaultDevice, TYPE, 6>
INSTANTIATION
(
EigenPad
,
bool
);
INSTANTIATION
(
EigenPad
,
int
);
INSTANTIATION
(
EigenPad
,
int64_t
);
INSTANTIATION
(
EigenPad
,
float
);
...
...
paddle/fluid/operators/eigen/pad.cu
浏览文件 @
f5e430c5
...
...
@@ -53,6 +53,7 @@ struct EigenPad<Eigen::GpuDevice, T, Rank> {
template struct FUNCTOR<Eigen::GpuDevice, TYPE, 4>; \
template struct FUNCTOR<Eigen::GpuDevice, TYPE, 5>; \
template struct FUNCTOR<Eigen::GpuDevice, TYPE, 6>
INSTANTIATION
(
EigenPad
,
bool
);
INSTANTIATION
(
EigenPad
,
int
);
INSTANTIATION
(
EigenPad
,
int64_t
);
INSTANTIATION
(
EigenPad
,
float
);
...
...
paddle/fluid/operators/eigen/slice.cu
浏览文件 @
f5e430c5
...
...
@@ -53,6 +53,7 @@ struct EigenSlice<Eigen::GpuDevice, T, Rank> {
template struct FUNCTOR<Eigen::GpuDevice, TYPE, 4>; \
template struct FUNCTOR<Eigen::GpuDevice, TYPE, 5>; \
template struct FUNCTOR<Eigen::GpuDevice, TYPE, 6>
INSTANTIATION
(
EigenSlice
,
bool
);
INSTANTIATION
(
EigenSlice
,
int
);
INSTANTIATION
(
EigenSlice
,
int64_t
);
INSTANTIATION
(
EigenSlice
,
float
);
...
...
paddle/fluid/operators/slice_op.cc
浏览文件 @
f5e430c5
...
...
@@ -434,7 +434,8 @@ REGISTER_OPERATOR(slice_grad, ops::SliceOpGrad,
ops
::
SliceOpGradVarTypeInference
);
REGISTER_OP_CPU_KERNEL
(
slice
,
ops
::
SliceKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
slice
,
ops
::
SliceKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
...
...
@@ -444,7 +445,8 @@ REGISTER_OP_CPU_KERNEL(
paddle
::
platform
::
complex
<
double
>>
);
REGISTER_OP_CPU_KERNEL
(
slice_grad
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
slice_grad
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
...
...
@@ -454,7 +456,8 @@ REGISTER_OP_CPU_KERNEL(
paddle
::
platform
::
complex
<
double
>>
);
REGISTER_OP_CUDA_KERNEL
(
slice
,
ops
::
SliceKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
,
slice
,
ops
::
SliceKernel
<
paddle
::
platform
::
CUDADeviceContext
,
bool
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int
>
,
ops
::
SliceKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int64_t
>
,
...
...
@@ -466,7 +469,7 @@ REGISTER_OP_CUDA_KERNEL(
paddle
::
platform
::
complex
<
double
>>
);
REGISTER_OP_CUDA_KERNEL
(
slice_grad
,
slice_grad
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
bool
>
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
ops
::
SliceGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int
>
,
...
...
python/paddle/fluid/tests/unittests/test_slice_op.py
浏览文件 @
f5e430c5
...
...
@@ -553,6 +553,22 @@ class TestSliceApiWithTensor(unittest.TestCase):
self
.
assertTrue
(
np
.
array_equal
(
a_1
.
numpy
(),
a_2
.
numpy
()))
def
test_bool_tensor
(
self
):
with
paddle
.
fluid
.
dygraph
.
guard
():
array
=
(
np
.
arange
(
60
).
reshape
([
3
,
4
,
5
])
%
3
).
astype
(
'bool'
)
tt
=
paddle
.
to_tensor
(
array
)
tt
.
stop_gradient
=
False
starts
=
[
0
,
1
,
2
]
ends
=
[
3
,
5
,
4
]
axes
=
[
0
,
1
,
2
]
y_paddle
=
paddle
.
slice
(
tt
,
axes
,
starts
,
ends
)
y_np
=
tt
[
0
:
3
,
1
:
5
,
2
:
4
]
self
.
assertTrue
(
paddle
.
bool
==
y_paddle
.
dtype
)
self
.
assertTrue
(
np
.
array_equal
(
y_paddle
.
numpy
(),
y_np
))
class
TestSliceApiWithLoDTensorArray
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录