Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2982046b
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看板
未验证
提交
2982046b
编写于
7月 17, 2023
作者:
C
Chen Weihang
提交者:
GitHub
7月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove useless move (#55430)
上级
07567939
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
18 deletion
+16
-18
paddle/fluid/eager/tensor_wrapper.h
paddle/fluid/eager/tensor_wrapper.h
+6
-8
paddle/phi/api/lib/tensor.cc
paddle/phi/api/lib/tensor.cc
+10
-10
未找到文件。
paddle/fluid/eager/tensor_wrapper.h
浏览文件 @
2982046b
...
...
@@ -63,10 +63,9 @@ class TensorWrapper {
static_cast
<
phi
::
DenseTensor
*>
(
tensor
.
impl
().
get
());
// TODO(jiabin): It's not a good idea to set memory size to zero, find
// another way and change this.
intermidiate_tensor_
.
set_impl
(
std
::
move
(
std
::
make_shared
<
phi
::
DenseTensor
>
(
std
::
make_shared
<
phi
::
Allocation
>
(
nullptr
,
0
,
tensor
.
place
()),
std
::
move
(
dense_tensor
->
meta
()))));
intermidiate_tensor_
.
set_impl
(
std
::
make_shared
<
phi
::
DenseTensor
>
(
std
::
make_shared
<
phi
::
Allocation
>
(
nullptr
,
0
,
tensor
.
place
()),
dense_tensor
->
meta
()));
}
else
{
PADDLE_THROW
(
paddle
::
platform
::
errors
::
Fatal
(
"Unrecognized tensor type for no_need_buffer feature"
));
...
...
@@ -77,10 +76,9 @@ class TensorWrapper {
tensor
.
is_dense_tensor
()
&&
tensor
.
initialized
())
{
phi
::
DenseTensor
*
dense_tensor
=
static_cast
<
phi
::
DenseTensor
*>
(
tensor
.
impl
().
get
());
intermidiate_tensor_
.
set_impl
(
std
::
move
(
std
::
make_shared
<
phi
::
DenseTensor
>
(
std
::
make_shared
<
phi
::
Allocation
>
(
nullptr
,
0
,
tensor
.
place
()),
dense_tensor
->
meta
())));
intermidiate_tensor_
.
set_impl
(
std
::
make_shared
<
phi
::
DenseTensor
>
(
std
::
make_shared
<
phi
::
Allocation
>
(
nullptr
,
0
,
tensor
.
place
()),
dense_tensor
->
meta
()));
auto
pack_hook
=
egr
::
SavedTensorsHooks
::
GetInstance
().
GetPackHook
();
unpack_hook_
=
egr
::
SavedTensorsHooks
::
GetInstance
().
GetUnPackHook
();
packed_value_
=
(
*
pack_hook
)(
tensor
);
...
...
paddle/phi/api/lib/tensor.cc
浏览文件 @
2982046b
...
...
@@ -64,10 +64,10 @@ Tensor::Tensor(const Place &place) {
"the `place`, and datatype, shape, layout, etc. is also "
"required."
;
DefaultAllocator
alloc
(
place
);
impl_
=
std
::
m
ove
(
std
::
m
ake_shared
<
phi
::
DenseTensor
>
(
impl_
=
std
::
make_shared
<
phi
::
DenseTensor
>
(
&
alloc
,
std
::
move
(
phi
::
DenseTensorMeta
(
phi
::
DataType
::
FLOAT32
,
phi
::
make_ddim
({}),
phi
::
DataLayout
::
NCHW
))
))
;
phi
::
DenseTensorMeta
(
phi
::
DataType
::
FLOAT32
,
phi
::
make_ddim
({}),
phi
::
DataLayout
::
NCHW
));
}
Tensor
::
Tensor
(
const
Place
&
place
,
const
std
::
vector
<
int64_t
>
&
shape
)
{
...
...
@@ -80,11 +80,11 @@ Tensor::Tensor(const Place &place, const std::vector<int64_t> &shape) {
"the `place` and `shape`, and datatype, layout, etc. is also "
"required."
;
DefaultAllocator
alloc
(
place
);
impl_
=
std
::
m
ove
(
std
::
m
ake_shared
<
phi
::
DenseTensor
>
(
impl_
=
std
::
make_shared
<
phi
::
DenseTensor
>
(
&
alloc
,
std
::
move
(
phi
::
DenseTensorMeta
(
phi
::
DataType
::
FLOAT32
,
phi
::
make_ddim
({
shape
}),
phi
::
DataLayout
::
NCHW
))
));
phi
::
DenseTensorMeta
(
phi
::
DataType
::
FLOAT32
,
phi
::
make_ddim
({
shape
}),
phi
::
DataLayout
::
NCHW
));
}
Tensor
::
Tensor
(
std
::
shared_ptr
<
phi
::
TensorBase
>
tensor_impl
,
...
...
@@ -338,11 +338,11 @@ void *Tensor::data() {
// TODO(chenweihang): replace slice impl by API
Tensor
Tensor
::
slice
(
int64_t
begin_idx
,
int64_t
end_idx
)
const
{
if
(
is_dense_tensor
())
{
return
Tensor
(
std
::
make_shared
<
phi
::
DenseTensor
>
(
std
::
m
ove
(
phi
::
DenseTensorUtils
::
Slice
(
return
Tensor
(
std
::
m
ake_shared
<
phi
::
DenseTensor
>
(
phi
::
DenseTensorUtils
::
Slice
(
*
(
static_cast
<
phi
::
DenseTensor
*>
(
impl_
.
get
())),
begin_idx
,
end_idx
)))
)
;
end_idx
)));
}
else
{
PADDLE_THROW
(
phi
::
errors
::
Unimplemented
(
"Only support slice operation on DenseTensor now."
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录