Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
5af81f83
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看板
未验证
提交
5af81f83
编写于
9月 07, 2020
作者:
W
wangchaochaohu
提交者:
GitHub
9月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix gpu kernel for numel Op (#27085)
上级
39d5bb6d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
5 deletion
+15
-5
paddle/fluid/operators/size_op.cc
paddle/fluid/operators/size_op.cc
+1
-1
paddle/fluid/operators/size_op.cu
paddle/fluid/operators/size_op.cu
+1
-1
paddle/fluid/operators/size_op.h
paddle/fluid/operators/size_op.h
+12
-2
python/paddle/tensor/manipulation.py
python/paddle/tensor/manipulation.py
+1
-1
未找到文件。
paddle/fluid/operators/size_op.cc
浏览文件 @
5af81f83
...
...
@@ -53,7 +53,7 @@ REGISTER_OPERATOR(
size
,
ops
::
SizeOp
,
ops
::
SizeOpMaker
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
);
REGISTER_OP_CPU_KERNEL
(
size
,
ops
::
SizeKernel
<
int
>
,
ops
::
SizeKernel
<
int
32
_t
>
,
REGISTER_OP_CPU_KERNEL
(
size
,
ops
::
SizeKernel
<
int
>
,
ops
::
SizeKernel
<
int
64
_t
>
,
ops
::
SizeKernel
<
paddle
::
platform
::
float16
>
,
ops
::
SizeKernel
<
float
>
,
ops
::
SizeKernel
<
double
>
,
ops
::
SizeKernel
<
bool
>
);
paddle/fluid/operators/size_op.cu
浏览文件 @
5af81f83
...
...
@@ -16,7 +16,7 @@ limitations under the License. */
REGISTER_OP_CUDA_KERNEL
(
size
,
paddle
::
operators
::
SizeKernel
<
int
>
,
paddle
::
operators
::
SizeKernel
<
int
32
_t
>
,
paddle
::
operators
::
SizeKernel
<
int
64
_t
>
,
paddle
::
operators
::
SizeKernel
<
paddle
::
platform
::
float16
>
,
paddle
::
operators
::
SizeKernel
<
float
>
,
paddle
::
operators
::
SizeKernel
<
bool
>
,
paddle
::
operators
::
SizeKernel
<
double
>
);
paddle/fluid/operators/size_op.h
浏览文件 @
5af81f83
...
...
@@ -26,8 +26,18 @@ class SizeKernel : public framework::OpKernel<T> {
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
*
in_t
=
ctx
.
Input
<
Tensor
>
(
"Input"
);
auto
*
out_t
=
ctx
.
Output
<
Tensor
>
(
"Out"
);
auto
out_data
=
out_t
->
mutable_data
<
int64_t
>
(
platform
::
CPUPlace
());
out_data
[
0
]
=
in_t
->
numel
();
auto
place
=
ctx
.
GetPlace
();
auto
out_data
=
out_t
->
mutable_data
<
int64_t
>
(
place
);
auto
cpu_place
=
platform
::
CPUPlace
();
if
(
place
==
cpu_place
)
{
out_data
[
0
]
=
in_t
->
numel
();
}
else
{
Tensor
cpu_tensor
;
auto
cpu_data
=
cpu_tensor
.
mutable_data
<
int64_t
>
(
out_t
->
dims
(),
cpu_place
);
cpu_data
[
0
]
=
in_t
->
numel
();
TensorCopy
(
cpu_tensor
,
place
,
out_t
);
}
}
};
}
// namespace operators
...
...
python/paddle/tensor/manipulation.py
浏览文件 @
5af81f83
...
...
@@ -1001,7 +1001,7 @@ def chunk(x, chunks, axis=0, name=None):
x_np = np.random.random([3, 9, 5]).astype("int32")
x = paddle.to_tensor(x_np)
out0, out1, out2
2
= paddle.chunk(x, chunks=3, axis=1)
out0, out1, out2 = paddle.chunk(x, chunks=3, axis=1)
# out0.shape [3, 3, 5]
# out1.shape [3, 3, 5]
# out2.shape [3, 3, 5]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录