Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
0c25da39
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看板
提交
0c25da39
编写于
10月 22, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine auto_increment_allocator
上级
ab87a882
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
9 deletion
+8
-9
paddle/fluid/memory/allocation/auto_increment_allocator.h
paddle/fluid/memory/allocation/auto_increment_allocator.h
+8
-9
未找到文件。
paddle/fluid/memory/allocation/auto_increment_allocator.h
浏览文件 @
0c25da39
...
@@ -31,7 +31,7 @@ namespace allocation {
...
@@ -31,7 +31,7 @@ namespace allocation {
// invoke its `allocate` method.
// invoke its `allocate` method.
//
//
// NOTE(yy): The AutoIncrementAllocator will prefer to allocate memory from
// NOTE(yy): The AutoIncrementAllocator will prefer to allocate memory from
// the latest sucessful allocator.
// the latest suc
c
essful allocator.
//
//
// NOTE(yy): We may need to release an underlying allocator if it allocate
// NOTE(yy): We may need to release an underlying allocator if it allocate
// nothing. However, it is generally not useful, since it will make performance
// nothing. However, it is generally not useful, since it will make performance
...
@@ -76,27 +76,26 @@ class AutoIncrementAllocator : public ManagedAllocator {
...
@@ -76,27 +76,26 @@ class AutoIncrementAllocator : public ManagedAllocator {
}
}
}
catch
(...)
{
}
catch
(...)
{
// if there is another type of allocation, just rethrow it.
// if there is another type of allocation, just rethrow it.
std
::
rethrow_exception
(
std
::
current_exception
())
;
throw
;
}
}
}
}
// No suitable allocator
// This happens when the first allocator is exhausted and
// This happens when the first allocator is exhausted and
// there are more than 1 allocation requests
// there are more than 1 allocation requests
// In this situation, the first allocation request would success
// In this situation, the first allocation request would success
// and the second allocation request would fail if we do not use
// and the second allocation request would fail if we do not use
// the newly created allocator by the first allocation request.
// the newly created allocator by the first allocation request.
for
(
size_t
new_allocator_num
=
allocator_num_
.
load
();
for
(
cur
=
allocator_num
;
cur
<
allocator_num_
;
++
cur
)
{
allocator_num
<
new_allocator_num
;
++
allocator_num
)
{
try
{
try
{
auto
ret
=
callback
(
*
underlying_allocators_
[
allocator_num
]);
auto
ret
=
callback
(
*
underlying_allocators_
[
cur
]);
prev_success_allocator_
=
allocator_num
;
prev_success_allocator_
=
cur
;
return
std
::
move
(
ret
);
return
std
::
move
(
ret
);
}
catch
(
BadAlloc
&
)
{
}
catch
(
BadAlloc
&
)
{
}
catch
(...)
{
}
catch
(...)
{
std
::
rethrow_exception
(
std
::
current_exception
())
;
throw
;
}
}
}
}
// No suitable allocator
ManagedAllocator
*
new_allocator
;
ManagedAllocator
*
new_allocator
;
{
{
...
@@ -108,7 +107,7 @@ class AutoIncrementAllocator : public ManagedAllocator {
...
@@ -108,7 +107,7 @@ class AutoIncrementAllocator : public ManagedAllocator {
underlying_allocators_
[
old_size
]
=
creator_
();
underlying_allocators_
[
old_size
]
=
creator_
();
new_allocator
=
underlying_allocators_
[
old_size
].
get
();
new_allocator
=
underlying_allocators_
[
old_size
].
get
();
prev_success_allocator_
=
old_size
;
prev_success_allocator_
=
old_size
;
allocator_num_
.
fetch_add
(
1
)
;
++
allocator_num_
;
}
}
PADDLE_ENFORCE
(
PADDLE_ENFORCE
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录