Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
012d45da
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
012d45da
编写于
2月 09, 2022
作者:
Z
zyfncg
提交者:
GitHub
2月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "【Pten】Adjust the Empyt dev_api (#39143)"
This reverts commit
9d4d0c3b
.
上级
9d4d0c3b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
16 deletion
+25
-16
paddle/pten/kernels/empty_kernel.h
paddle/pten/kernels/empty_kernel.h
+5
-5
paddle/pten/kernels/funcs/elementwise_base.h
paddle/pten/kernels/funcs/elementwise_base.h
+1
-1
paddle/pten/kernels/sparse/cpu/sparse_utils_kernel.cc
paddle/pten/kernels/sparse/cpu/sparse_utils_kernel.cc
+8
-4
paddle/pten/kernels/sparse/gpu/sparse_utils_kernel.cu
paddle/pten/kernels/sparse/gpu/sparse_utils_kernel.cu
+11
-6
未找到文件。
paddle/pten/kernels/empty_kernel.h
浏览文件 @
012d45da
...
...
@@ -32,7 +32,7 @@ void EmptyLikeKernel(const Context& dev_ctx, DenseTensor* out);
// TODO(chenweihang): the tensor creation method need to be replaced later,
// all kernel api call Empty here instead of making tensor self
template
<
typename
Context
>
template
<
typename
T
,
typename
Context
>
DenseTensor
Empty
(
const
Context
&
dev_ctx
,
DenseTensorMeta
&&
meta
)
{
pten
::
DenseTensor
dense_out
(
pten
::
make_intrusive
<
paddle
::
experimental
::
SharedStorage
>
(
...
...
@@ -43,10 +43,10 @@ DenseTensor Empty(const Context& dev_ctx, DenseTensorMeta&& meta) {
template
<
typename
T
,
typename
Context
>
DenseTensor
Empty
(
const
Context
&
dev_ctx
)
{
return
Empty
(
dev_ctx
,
{
paddle
::
experimental
::
CppTypeToDataType
<
T
>::
Type
(),
{
-
1
},
DataLayout
::
NCHW
});
return
Empty
<
T
,
Context
>
(
dev_ctx
,
{
paddle
::
experimental
::
CppTypeToDataType
<
T
>::
Type
(),
{
-
1
},
DataLayout
::
NCHW
});
}
template
<
typename
T
,
typename
Context
>
...
...
paddle/pten/kernels/funcs/elementwise_base.h
浏览文件 @
012d45da
...
...
@@ -392,7 +392,7 @@ static inline void GetDoubleGradSafeTensor(const DeviceContext &dev_ctx,
*
ddx_safe
=
*
ddx
;
}
else
{
auto
meta
=
pten
::
DenseTensorMeta
(
x
.
dtype
(),
x
.
dims
(),
x
.
layout
());
*
ddx_safe
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
meta
));
*
ddx_safe
=
pten
::
Empty
<
T
,
DeviceContext
>
(
dev_ctx
,
std
::
move
(
meta
));
ddx_safe
->
mutable_data
(
dev_ctx
.
GetPlace
());
paddle
::
operators
::
math
::
SetConstant
<
DeviceContext
,
T
>
set_zero
;
set_zero
(
dev_ctx
,
ddx_safe
,
static_cast
<
T
>
(
0
));
...
...
paddle/pten/kernels/sparse/cpu/sparse_utils_kernel.cc
浏览文件 @
012d45da
...
...
@@ -76,8 +76,10 @@ void DenseToSparseCooKernel(const Context& dev_ctx,
{
sparse_dim
,
static_cast
<
int64_t
>
(
non_zero_num
)},
DataLayout
::
NCHW
);
DenseTensorMeta
values_meta
(
x
.
meta
().
dtype
,
values_dims
,
x
.
meta
().
layout
);
pten
::
DenseTensor
indices
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
indices_meta
));
pten
::
DenseTensor
values
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
values_meta
));
pten
::
DenseTensor
indices
=
pten
::
Empty
<
int64_t
,
Context
>
(
dev_ctx
,
std
::
move
(
indices_meta
));
pten
::
DenseTensor
values
=
pten
::
Empty
<
T
,
Context
>
(
dev_ctx
,
std
::
move
(
values_meta
));
int64_t
*
indices_data
=
indices
.
mutable_data
<
int64_t
>
(
place
);
T
*
values_data
=
values
.
mutable_data
<
T
>
(
place
);
...
...
@@ -121,8 +123,10 @@ void SparseCsrToCooKernel(const Context& dev_ctx,
DenseTensorMeta
indices_meta
(
DataType
::
INT64
,
{
sparse_dim
,
non_zero_num
},
DataLayout
::
NCHW
);
DenseTensorMeta
values_meta
(
x
.
dtype
(),
{
non_zero_num
},
x
.
layout
());
pten
::
DenseTensor
indices
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
indices_meta
));
pten
::
DenseTensor
values
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
values_meta
));
pten
::
DenseTensor
indices
=
pten
::
Empty
<
int64_t
,
Context
>
(
dev_ctx
,
std
::
move
(
indices_meta
));
pten
::
DenseTensor
values
=
pten
::
Empty
<
T
,
Context
>
(
dev_ctx
,
std
::
move
(
values_meta
));
int64_t
*
coo_indices
=
indices
.
mutable_data
<
int64_t
>
(
place
);
int64_t
*
batch_ptr
=
x_dims
.
size
()
==
2
?
nullptr
:
coo_indices
;
int64_t
*
coo_rows_data
=
...
...
paddle/pten/kernels/sparse/gpu/sparse_utils_kernel.cu
浏览文件 @
012d45da
...
...
@@ -111,12 +111,14 @@ void DenseToSparseCooKernel(const Context& dev_ctx,
const
int
cols
=
dims_2d
[
1
];
auto
nums_meta
=
pten
::
DenseTensorMeta
(
DataType
::
INT32
,
{
1
},
pten
::
DataLayout
::
NCHW
);
DenseTensor
nums
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
nums_meta
));
DenseTensor
nums
=
pten
::
Empty
<
int64_t
,
Context
>
(
dev_ctx
,
std
::
move
(
nums_meta
));
auto
x_dims_meta
=
pten
::
DenseTensorMeta
(
DataType
::
INT64
,
{
static_cast
<
int64_t
>
(
x_dims
.
size
())},
pten
::
DataLayout
::
NCHW
);
DenseTensor
d_x_dims
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
x_dims_meta
));
DenseTensor
d_x_dims
=
pten
::
Empty
<
T
,
Context
>
(
dev_ctx
,
std
::
move
(
x_dims_meta
));
const
auto
place
=
dev_ctx
.
GetPlace
();
...
...
@@ -134,7 +136,8 @@ void DenseToSparseCooKernel(const Context& dev_ctx,
auto
temp_indexs_meta
=
pten
::
DenseTensorMeta
(
DataType
::
INT32
,
{
rows
},
pten
::
DataLayout
::
NCHW
);
DenseTensor
temp_indexs
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
temp_indexs_meta
));
DenseTensor
temp_indexs
=
pten
::
Empty
<
T
,
Context
>
(
dev_ctx
,
std
::
move
(
temp_indexs_meta
));
int
*
temp_indexs_ptr
=
temp_indexs
.
mutable_data
<
int
>
(
place
);
GetNonZeroNums
<<<
grid_size
,
block_size
,
0
,
dev_ctx
.
stream
()
>>>
(
x_data
,
rows
,
cols
,
nums_ptr
,
temp_indexs_ptr
);
...
...
@@ -266,9 +269,11 @@ void SparseCsrToCooKernel(const Context& dev_ctx,
DataType
::
INT64
,
{
sparse_dim
,
non_zero_num
},
DataLayout
::
NCHW
);
DenseTensorMeta
values_meta
(
x
.
dtype
(),
{
non_zero_num
},
x
.
layout
());
DenseTensorMeta
offsets_meta
(
DataType
::
INT32
,
{
batchs
},
DataLayout
::
NCHW
);
DenseTensor
indices
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
indices_meta
));
DenseTensor
values
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
values_meta
));
DenseTensor
offsets
=
pten
::
Empty
(
dev_ctx
,
std
::
move
(
offsets_meta
));
DenseTensor
indices
=
pten
::
Empty
<
int64_t
,
Context
>
(
dev_ctx
,
std
::
move
(
indices_meta
));
DenseTensor
values
=
pten
::
Empty
<
T
,
Context
>
(
dev_ctx
,
std
::
move
(
values_meta
));
DenseTensor
offsets
=
pten
::
Empty
<
T
,
Context
>
(
dev_ctx
,
std
::
move
(
offsets_meta
));
int64_t
*
coo_indices
=
indices
.
mutable_data
<
int64_t
>
(
place
);
int64_t
*
batch_ptr
=
x_dims
.
size
()
==
2
?
nullptr
:
coo_indices
;
int64_t
*
coo_rows_data
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录