Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
4a7f0698
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
4a7f0698
编写于
8月 14, 2018
作者:
M
Michal Gallus
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add consts to new MKLDNN integration
Also replace memory types from int64_t to size_t
上级
6588d0e0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
14 deletion
+14
-14
paddle/fluid/framework/tensor.cc
paddle/fluid/framework/tensor.cc
+3
-3
paddle/fluid/framework/tensor.h
paddle/fluid/framework/tensor.h
+4
-4
paddle/fluid/framework/tensor_impl.h
paddle/fluid/framework/tensor_impl.h
+2
-2
paddle/fluid/operators/conv_mkldnn_op.cc
paddle/fluid/operators/conv_mkldnn_op.cc
+5
-5
未找到文件。
paddle/fluid/framework/tensor.cc
浏览文件 @
4a7f0698
...
...
@@ -32,7 +32,7 @@ size_t Tensor::memory_size() const {
}
void
*
Tensor
::
mutable_data
(
platform
::
Place
place
,
std
::
type_index
type
,
int64
_t
requested_size
)
{
size
_t
requested_size
)
{
if
(
holder_
!=
nullptr
)
{
holder_
->
set_type
(
type
);
}
...
...
@@ -40,7 +40,7 @@ void* Tensor::mutable_data(platform::Place place, std::type_index type,
"When calling this method, the Tensor's numel must be "
"equal or larger than zero. "
"Please check Tensor::Resize has been called first."
);
int64
_t
size
=
requested_size
?
requested_size
:
numel
()
*
SizeOfType
(
type
);
size
_t
size
=
requested_size
?
requested_size
:
numel
()
*
SizeOfType
(
type
);
/* some versions of boost::variant don't have operator!= */
if
(
holder_
==
nullptr
||
!
(
holder_
->
place
()
==
place
)
||
holder_
->
size
()
<
size
+
offset_
)
{
...
...
@@ -69,7 +69,7 @@ void* Tensor::mutable_data(platform::Place place, std::type_index type,
offset_
);
}
void
*
Tensor
::
mutable_data
(
platform
::
Place
place
,
int64
_t
requested_size
)
{
void
*
Tensor
::
mutable_data
(
platform
::
Place
place
,
size
_t
requested_size
)
{
PADDLE_ENFORCE
(
this
->
holder_
!=
nullptr
,
"Cannot invoke mutable data if current hold nothing."
);
return
mutable_data
(
place
,
holder_
->
type
(),
requested_size
);
...
...
paddle/fluid/framework/tensor.h
浏览文件 @
4a7f0698
...
...
@@ -89,12 +89,12 @@ class Tensor {
* @note If not exist, then allocation.
*/
template
<
typename
T
>
T
*
mutable_data
(
platform
::
Place
place
,
int64
_t
requested_size
=
0
);
T
*
mutable_data
(
platform
::
Place
place
,
size
_t
requested_size
=
0
);
void
*
mutable_data
(
platform
::
Place
place
,
std
::
type_index
type
,
int64
_t
requested_size
=
0
);
size
_t
requested_size
=
0
);
void
*
mutable_data
(
platform
::
Place
place
,
int64
_t
requested_size
=
0
);
void
*
mutable_data
(
platform
::
Place
place
,
size
_t
requested_size
=
0
);
/**
* @brief Return a pointer to mutable memory block.
...
...
@@ -106,7 +106,7 @@ class Tensor {
* @note If not exist, then allocation.
*/
template
<
typename
T
>
T
*
mutable_data
(
DDim
dims
,
platform
::
Place
place
,
int64
_t
requested_size
=
0
);
T
*
mutable_data
(
DDim
dims
,
platform
::
Place
place
,
size
_t
requested_size
=
0
);
/*! Return the dimensions of the memory block. */
const
DDim
&
dims
()
const
;
...
...
paddle/fluid/framework/tensor_impl.h
浏览文件 @
4a7f0698
...
...
@@ -47,14 +47,14 @@ inline T* Tensor::data() {
template
<
typename
T
>
inline
T
*
Tensor
::
mutable_data
(
DDim
dims
,
platform
::
Place
place
,
int64
_t
requested_size
)
{
size
_t
requested_size
)
{
static_assert
(
std
::
is_pod
<
T
>::
value
,
"T must be POD"
);
Resize
(
dims
);
return
mutable_data
<
T
>
(
place
,
requested_size
);
}
template
<
typename
T
>
inline
T
*
Tensor
::
mutable_data
(
platform
::
Place
place
,
int64
_t
requested_size
)
{
inline
T
*
Tensor
::
mutable_data
(
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
,
typeid
(
T
),
requested_size
));
}
...
...
paddle/fluid/operators/conv_mkldnn_op.cc
浏览文件 @
4a7f0698
...
...
@@ -53,15 +53,15 @@ class ConvMKLDNNHandler : public platform::MKLDNNHandler {
key_
+=
"-BWD"
;
}
size_t
GetDstMemorySize
()
{
size_t
GetDstMemorySize
()
const
{
return
conv_pd_
->
dst_primitive_desc
().
get_size
();
}
size_t
GetDiffWeightsMemorySize
()
{
size_t
GetDiffWeightsMemorySize
()
const
{
return
conv_bwd_weights_pd_
->
diff_weights_primitive_desc
().
get_size
();
}
size_t
GetDiffSourceMemorySize
()
{
size_t
GetDiffSourceMemorySize
()
const
{
return
conv_bwd_data_pd_
->
diff_src_primitive_desc
().
get_size
();
}
...
...
@@ -491,7 +491,7 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel<T> {
handler
.
AcquireDiffDstMemoryFromWeightsPrimitive
(
user_diff_dst_memory_p
,
pipeline
);
size_t
size
=
handler
.
GetDiffWeightsMemorySize
();
const
size_t
size
=
handler
.
GetDiffWeightsMemorySize
();
filter_grad_data
=
filter_grad
->
mutable_data
<
T
>
(
ctx
.
GetPlace
(),
size
);
auto
diff_weights_memory_p
=
...
...
@@ -516,7 +516,7 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel<T> {
handler
.
AcquireDiffDstMemoryFromDataPrimitive
(
user_diff_dst_memory_p
,
pipeline
);
size_t
size
=
handler
.
GetDiffSourceMemorySize
();
const
size_t
size
=
handler
.
GetDiffSourceMemorySize
();
input_grad_data
=
input_grad
->
mutable_data
<
T
>
(
ctx
.
GetPlace
(),
size
);
auto
diff_src_memory_p
=
handler
.
AcquireDiffSrcMemoryFromDataPrimitive
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录