Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ddfa6cf0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
11 个月 前同步成功
通知
2292
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ddfa6cf0
编写于
7月 06, 2017
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FIX: remove boost from memory folder
上级
adf8c95b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
34 addition
and
33 deletion
+34
-33
paddle/memory/memory.cc
paddle/memory/memory.cc
+26
-30
paddle/memory/memory.h
paddle/memory/memory.h
+8
-3
未找到文件。
paddle/memory/memory.cc
浏览文件 @
ddfa6cf0
...
...
@@ -32,7 +32,22 @@ detail::BuddyAllocator* GetCPUBuddyAllocator() {
return
a
;
}
#ifndef PADDLE_ONLY_CPU // The following code are for CUDA.
template
<
>
void
*
Alloc
<
platform
::
CPUPlace
>
(
platform
::
CPUPlace
place
,
size_t
size
)
{
return
GetCPUBuddyAllocator
()
->
Alloc
(
size
);
}
template
<
>
void
Free
<
platform
::
CPUPlace
>
(
platform
::
CPUPlace
place
,
void
*
p
)
{
GetCPUBuddyAllocator
()
->
Free
(
p
);
}
template
<
>
size_t
Used
<
platform
::
CPUPlace
>
(
platform
::
CPUPlace
place
)
{
return
GetCPUBuddyAllocator
()
->
Used
();
}
#ifndef PADDLE_ONLY_CPU
detail
::
BuddyAllocator
*
GetGPUBuddyAllocator
(
int
gpu_id
)
{
static
detail
::
BuddyAllocator
**
as
=
NULL
;
...
...
@@ -49,41 +64,22 @@ detail::BuddyAllocator* GetGPUBuddyAllocator(int gpu_id) {
return
as
[
gpu_id
];
}
#endif // PADDLE_ONLY_CPU
template
<
>
void
*
Alloc
<
platform
::
GPUPlace
>
(
platform
::
GPUPlace
place
,
size_t
size
)
{
return
GetGPUBuddyAllocator
(
place
.
device
)
->
Alloc
(
size
);
}
void
*
Alloc
(
platform
::
Place
pl
,
size_t
size
)
{
#ifndef PADDLE_ONLY_CPU
if
(
paddle
::
platform
::
is_gpu_place
(
pl
))
{
size_t
gpu_id
=
boost
::
get
<
platform
::
GPUPlace
>
(
pl
).
device
;
return
GetGPUBuddyAllocator
(
gpu_id
)
->
Alloc
(
size
);
}
#endif // PADDLE_ONLY_CPU
PADDLE_ASSERT
(
paddle
::
platform
::
is_cpu_place
(
pl
));
return
GetCPUBuddyAllocator
()
->
Alloc
(
size
);
template
<
>
void
Free
<
platform
::
GPUPlace
>
(
platform
::
GPUPlace
place
,
void
*
p
)
{
GetGPUBuddyAllocator
(
place
.
device
)
->
Free
(
p
);
}
void
Free
(
paddle
::
platform
::
Place
pl
,
void
*
p
)
{
#ifndef PADDLE_ONLY_CPU
if
(
paddle
::
platform
::
is_gpu_place
(
pl
))
{
size_t
gpu_id
=
boost
::
get
<
platform
::
GPUPlace
>
(
pl
).
device
;
GetGPUBuddyAllocator
(
gpu_id
)
->
Free
(
p
);
return
;
}
#endif // PADDLE_ONLY_CPU
PADDLE_ASSERT
(
paddle
::
platform
::
is_cpu_place
(
pl
));
GetCPUBuddyAllocator
()
->
Free
(
p
);
template
<
>
size_t
Used
<
platform
::
GPUPlace
>
(
platform
::
GPUPlace
place
)
{
return
GetGPUBuddyAllocator
(
place
.
device
)
->
Used
();
}
size_t
Used
(
paddle
::
platform
::
Place
pl
)
{
#ifndef PADDLE_ONLY_CPU
if
(
paddle
::
platform
::
is_gpu_place
(
pl
))
{
size_t
gpu_id
=
boost
::
get
<
platform
::
GPUPlace
>
(
pl
).
device
;
return
GetGPUBuddyAllocator
(
gpu_id
)
->
Used
();
}
#endif // PADDLE_ONLY_CPU
PADDLE_ASSERT
(
paddle
::
platform
::
is_cpu_place
(
pl
));
return
GetCPUBuddyAllocator
()
->
Used
();
}
}
// namespace memory
}
// namespace paddle
paddle/memory/memory.h
浏览文件 @
ddfa6cf0
...
...
@@ -19,9 +19,14 @@ limitations under the License. */
namespace
paddle
{
namespace
memory
{
void
*
Alloc
(
paddle
::
platform
::
Place
,
size_t
);
void
Free
(
paddle
::
platform
::
Place
,
void
*
);
size_t
Used
(
paddle
::
platform
::
Place
);
template
<
class
Place
>
void
*
Alloc
(
Place
,
size_t
);
template
<
class
Place
>
void
Free
(
Place
,
void
*
);
template
<
class
Place
>
size_t
Used
(
Place
);
}
// namespace memory
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录