Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
ccd83ef6
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ccd83ef6
编写于
4月 07, 2018
作者:
Y
Yi Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update
上级
903403b2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
17 deletion
+16
-17
paddle/fluid/memory/detail/memory_block_desc.cc
paddle/fluid/memory/detail/memory_block_desc.cc
+3
-3
paddle/fluid/memory/detail/meta_cache.cc
paddle/fluid/memory/detail/meta_cache.cc
+13
-14
未找到文件。
paddle/fluid/memory/detail/memory_block_desc.cc
浏览文件 @
ccd83ef6
...
...
@@ -61,12 +61,12 @@ inline size_t hash(const MemoryBlock::Desc& metadata, size_t initial_seed) {
}
// namespace
void
MemoryBlock
::
Desc
::
update_guards
()
{
guard_begin
=
hash
(
this
,
1
);
guard_end
=
hash
(
this
,
2
);
guard_begin
=
hash
(
*
this
,
1
);
guard_end
=
hash
(
*
this
,
2
);
}
bool
MemoryBlock
::
Desc
::
check_guards
()
const
{
return
guard_begin
==
hash
(
this
,
1
)
&&
guard_end
==
hash
(
this
,
2
);
return
guard_begin
==
hash
(
*
this
,
1
)
&&
guard_end
==
hash
(
*
this
,
2
);
}
}
// namespace detail
...
...
paddle/fluid/memory/detail/meta_cache.cc
浏览文件 @
ccd83ef6
...
...
@@ -22,29 +22,28 @@ namespace detail {
MetadataCache
::
MetadataCache
(
bool
uses_gpu
)
:
uses_gpu_
(
uses_gpu
)
{}
Me
tadata
MetadataCache
::
load
(
const
MemoryBlock
*
block
)
const
{
Me
moryBlock
::
Desc
MetadataCache
::
load
(
const
MemoryBlock
*
block
)
const
{
if
(
uses_gpu_
)
{
auto
existing_
metadata
=
cache_
.
find
(
block
);
PADDLE_ASSERT
(
existing_
metadata
->
second
.
check_guards
());
return
existing_
metadata
->
second
;
auto
existing_
desc
=
cache_
.
find
(
block
);
PADDLE_ASSERT
(
existing_
desc
->
second
.
check_guards
());
return
existing_
desc
->
second
;
}
else
{
auto
*
meta
=
reinterpret_cast
<
const
Metadata
*>
(
block
);
VLOG
(
10
)
<<
"Load Me
taData type="
<<
meta
->
type
;
PADDLE_ASSERT
(
meta
->
check_guards
());
return
*
reinterpret_cast
<
const
Me
tadata
*>
(
block
);
auto
*
desc
=
reinterpret_cast
<
const
MemoryBlock
::
Desc
*>
(
block
);
VLOG
(
10
)
<<
"Load Me
moryBlock::Desc type="
<<
desc
->
type
;
PADDLE_ASSERT
(
desc
->
check_guards
());
return
*
reinterpret_cast
<
const
Me
moryBlock
::
Desc
*>
(
block
);
}
}
void
MetadataCache
::
save
(
MemoryBlock
*
block
,
const
Metadata
&
original_metadata
)
{
auto
metadata
=
original_metadata
;
metadata
.
update_guards
();
const
MemoryBlock
::
Desc
&
original_desc
)
{
auto
desc
=
original_desc
;
desc
.
update_guards
();
if
(
uses_gpu_
)
{
cache_
[
block
]
=
metadata
;
cache_
[
block
]
=
desc
;
}
else
{
*
reinterpret_cast
<
Me
tadata
*>
(
block
)
=
metadata
;
*
reinterpret_cast
<
Me
moryBlock
::
Desc
*>
(
block
)
=
desc
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录