Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a152315b
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看板
未验证
提交
a152315b
编写于
11月 19, 2019
作者:
Z
Zeng Jinle
提交者:
GitHub
11月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine Tensor method, test=develop (#21031)
上级
b5d8ba83
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
11 deletion
+14
-11
paddle/fluid/framework/selected_rows.h
paddle/fluid/framework/selected_rows.h
+1
-1
paddle/fluid/framework/tensor.cc
paddle/fluid/framework/tensor.cc
+4
-3
paddle/fluid/framework/tensor.h
paddle/fluid/framework/tensor.h
+6
-5
paddle/fluid/framework/tensor_impl.h
paddle/fluid/framework/tensor_impl.h
+3
-2
未找到文件。
paddle/fluid/framework/selected_rows.h
浏览文件 @
a152315b
...
...
@@ -58,7 +58,7 @@ class SelectedRows {
rwlock_
.
reset
(
new
RWLock
);
}
platform
::
Place
place
()
const
{
return
value_
->
place
();
}
const
platform
::
Place
&
place
()
const
{
return
value_
->
place
();
}
const
Tensor
&
value
()
const
{
return
*
value_
;
}
...
...
paddle/fluid/framework/tensor.cc
浏览文件 @
a152315b
...
...
@@ -34,8 +34,8 @@ size_t Tensor::memory_size() const {
return
holder_
==
nullptr
?
0UL
:
holder_
->
size
()
-
offset_
;
}
void
*
Tensor
::
mutable_data
(
platform
::
Place
place
,
proto
::
VarType
::
Type
typ
e
,
size_t
requested_size
)
{
void
*
Tensor
::
mutable_data
(
const
platform
::
Place
&
plac
e
,
proto
::
VarType
::
Type
type
,
size_t
requested_size
)
{
type_
=
type
;
PADDLE_ENFORCE_GE
(
numel
(),
0
,
"When calling this method, the Tensor's numel must be "
...
...
@@ -60,7 +60,8 @@ void* Tensor::mutable_data(platform::Place place, proto::VarType::Type type,
offset_
);
}
void
*
Tensor
::
mutable_data
(
platform
::
Place
place
,
size_t
requested_size
)
{
void
*
Tensor
::
mutable_data
(
const
platform
::
Place
&
place
,
size_t
requested_size
)
{
PADDLE_ENFORCE_NOT_NULL
(
this
->
holder_
,
"Cannot invoke mutable data if current hold nothing."
);
return
mutable_data
(
place
,
type_
,
requested_size
);
...
...
paddle/fluid/framework/tensor.h
浏览文件 @
a152315b
...
...
@@ -87,12 +87,12 @@ class Tensor {
* @note If not exist, then allocation.
*/
template
<
typename
T
>
T
*
mutable_data
(
platform
::
Place
place
,
size_t
requested_size
=
0
);
T
*
mutable_data
(
const
platform
::
Place
&
place
,
size_t
requested_size
=
0
);
void
*
mutable_data
(
platform
::
Place
place
,
proto
::
VarType
::
Type
type
,
void
*
mutable_data
(
const
platform
::
Place
&
place
,
proto
::
VarType
::
Type
type
,
size_t
requested_size
=
0
);
void
*
mutable_data
(
platform
::
Place
place
,
size_t
requested_size
=
0
);
void
*
mutable_data
(
const
platform
::
Place
&
place
,
size_t
requested_size
=
0
);
/**
* @brief Return a pointer to mutable memory block.
...
...
@@ -104,7 +104,8 @@ class Tensor {
* @note If not exist, then allocation.
*/
template
<
typename
T
>
T
*
mutable_data
(
DDim
dims
,
platform
::
Place
place
,
size_t
requested_size
=
0
);
T
*
mutable_data
(
const
DDim
&
dims
,
const
platform
::
Place
&
place
,
size_t
requested_size
=
0
);
/*! Return the dimensions of the memory block. */
const
DDim
&
dims
()
const
;
...
...
@@ -128,7 +129,7 @@ class Tensor {
*/
Tensor
Slice
(
int64_t
begin_idx
,
int64_t
end_idx
)
const
;
platform
::
Place
place
()
const
{
const
platform
::
Place
&
place
()
const
{
PADDLE_ENFORCE_NOT_NULL
(
holder_
,
"Tensor not initialized yet when Tensor::place() is called."
);
return
holder_
->
place
();
...
...
paddle/fluid/framework/tensor_impl.h
浏览文件 @
a152315b
...
...
@@ -51,7 +51,7 @@ inline T* Tensor::data() {
}
template
<
typename
T
>
inline
T
*
Tensor
::
mutable_data
(
DDim
dims
,
platform
::
Place
place
,
inline
T
*
Tensor
::
mutable_data
(
const
DDim
&
dims
,
const
platform
::
Place
&
place
,
size_t
requested_size
)
{
static_assert
(
std
::
is_pod
<
T
>::
value
,
"T must be POD"
);
Resize
(
dims
);
...
...
@@ -59,7 +59,8 @@ inline T* Tensor::mutable_data(DDim dims, platform::Place place,
}
template
<
typename
T
>
inline
T
*
Tensor
::
mutable_data
(
platform
::
Place
place
,
size_t
requested_size
)
{
inline
T
*
Tensor
::
mutable_data
(
const
platform
::
Place
&
place
,
size_t
requested_size
)
{
static_assert
(
std
::
is_pod
<
T
>::
value
,
"T must be POD"
);
return
reinterpret_cast
<
T
*>
(
mutable_data
(
place
,
DataTypeTrait
<
T
>::
DataType
(),
requested_size
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录