Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
0c25da39
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
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 {
// invoke its `allocate` method.
//
// 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
// nothing. However, it is generally not useful, since it will make performance
...
...
@@ -76,27 +76,26 @@ class AutoIncrementAllocator : public ManagedAllocator {
}
}
catch
(...)
{
// 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
// there are more than 1 allocation requests
// In this situation, the first allocation request would success
// and the second allocation request would fail if we do not use
// the newly created allocator by the first allocation request.
for
(
size_t
new_allocator_num
=
allocator_num_
.
load
();
allocator_num
<
new_allocator_num
;
++
allocator_num
)
{
for
(
cur
=
allocator_num
;
cur
<
allocator_num_
;
++
cur
)
{
try
{
auto
ret
=
callback
(
*
underlying_allocators_
[
allocator_num
]);
prev_success_allocator_
=
allocator_num
;
auto
ret
=
callback
(
*
underlying_allocators_
[
cur
]);
prev_success_allocator_
=
cur
;
return
std
::
move
(
ret
);
}
catch
(
BadAlloc
&
)
{
}
catch
(...)
{
std
::
rethrow_exception
(
std
::
current_exception
())
;
throw
;
}
}
// No suitable allocator
ManagedAllocator
*
new_allocator
;
{
...
...
@@ -108,7 +107,7 @@ class AutoIncrementAllocator : public ManagedAllocator {
underlying_allocators_
[
old_size
]
=
creator_
();
new_allocator
=
underlying_allocators_
[
old_size
].
get
();
prev_success_allocator_
=
old_size
;
allocator_num_
.
fetch_add
(
1
)
;
++
allocator_num_
;
}
PADDLE_ENFORCE
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录