Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
3d567864
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看板
未验证
提交
3d567864
编写于
11月 01, 2017
作者:
Q
qingqing01
提交者:
GitHub
11月 01, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5247 from qingqing01/memory_alignment
Allocate aligned memory by posix_memalign.
上级
26492210
e88e1964
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
17 addition
and
8 deletion
+17
-8
paddle/memory/detail/system_allocator.cc
paddle/memory/detail/system_allocator.cc
+10
-1
paddle/operators/nccl_op_test.cu
paddle/operators/nccl_op_test.cu
+3
-3
paddle/operators/reshape_op.cc
paddle/operators/reshape_op.cc
+1
-1
paddle/operators/save_load_op_test.cc
paddle/operators/save_load_op_test.cc
+3
-3
未找到文件。
paddle/memory/detail/system_allocator.cc
浏览文件 @
3d567864
...
...
@@ -41,7 +41,16 @@ void* CPUAllocator::Alloc(size_t& index, size_t size) {
index
=
0
;
// unlock memory
void
*
p
=
malloc
(
size
);
void
*
p
;
#ifdef PADDLE_USE_MKLDNN
// refer to https://github.com/01org/mkl-dnn/blob/master/include/mkldnn.hpp
// memory alignment
PADDLE_ENFORCE_EQ
(
posix_memalign
(
&
p
,
4096ul
,
size
),
0
);
#else
PADDLE_ENFORCE_EQ
(
posix_memalign
(
&
p
,
32ul
,
size
),
0
);
#endif
PADDLE_ENFORCE
(
p
,
"Fail to allocate CPU memory: size = %d ."
,
size
);
if
(
p
!=
nullptr
)
{
if
(
FLAGS_use_pinned_memory
)
{
...
...
paddle/operators/nccl_op_test.cu
浏览文件 @
3d567864
...
...
@@ -185,7 +185,7 @@ TEST_F(NCCLTester, ncclAllReduceOp) {
recv_tensor
.
numel
()
*
sizeof
(
float
),
static_cast
<
p
::
CUDADeviceContext
*>
(
dev_ctxs
[
i
])
->
stream
());
for
(
size
_t
j
=
0
;
j
<
f
::
product
(
kDims
);
++
j
)
{
for
(
int64
_t
j
=
0
;
j
<
f
::
product
(
kDims
);
++
j
)
{
ASSERT_NEAR
(
ct
[
j
],
result
,
1e-5
);
}
}
...
...
@@ -234,7 +234,7 @@ TEST_F(NCCLTester, ncclReduceOp) {
recv_tensor
.
numel
()
*
sizeof
(
float
),
static_cast
<
p
::
CUDADeviceContext
*>
(
dev_ctxs
[
kRoot
])
->
stream
());
for
(
int
j
=
0
;
j
<
f
::
product
(
kDims
);
++
j
)
{
for
(
int
64_t
j
=
0
;
j
<
f
::
product
(
kDims
);
++
j
)
{
ASSERT_NEAR
(
ct
[
j
],
result
,
1e-5
);
}
}
...
...
@@ -282,7 +282,7 @@ TEST_F(NCCLTester, ncclBcastOp) {
recv_tensor
.
numel
()
*
sizeof
(
float
),
static_cast
<
p
::
CUDADeviceContext
*>
(
dev_ctxs
[
idx
])
->
stream
());
for
(
size
_t
j
=
0
;
j
<
f
::
product
(
kDims
);
++
j
)
{
for
(
int64
_t
j
=
0
;
j
<
f
::
product
(
kDims
);
++
j
)
{
ASSERT_NEAR
(
ct
[
j
],
result
,
1e-5
);
}
}
...
...
paddle/operators/reshape_op.cc
浏览文件 @
3d567864
...
...
@@ -36,7 +36,7 @@ class ReshapeOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE
(
shape
.
size
()
>
0
,
"Attr(shape) shouldn't be empty."
);
auto
x_dims
=
ctx
->
GetInputDim
(
"X"
);
// TODO(qiao) change batch_size
for
(
in
t
i
=
1
;
i
<
shape
.
size
();
++
i
)
{
for
(
size_
t
i
=
1
;
i
<
shape
.
size
();
++
i
)
{
PADDLE_ENFORCE
(
shape
[
i
]
>
0
,
"Each dimension of shape "
"must be positiv except the first."
);
...
...
paddle/operators/save_load_op_test.cc
浏览文件 @
3d567864
...
...
@@ -34,7 +34,7 @@ TEST(SaveLoadOp, CPU) {
tensor
->
set_lod
(
expect_lod
);
int
*
expect
=
tensor
->
mutable_data
<
int
>
(
place
);
for
(
size_t
i
=
0
;
i
<
paddle
::
framework
::
product
(
tensor
->
dims
()
);
++
i
)
{
for
(
int64_t
i
=
0
;
i
<
tensor
->
numel
(
);
++
i
)
{
expect
[
i
]
=
static_cast
<
int
>
(
i
);
}
paddle
::
framework
::
AttributeMap
attrs
;
...
...
@@ -50,7 +50,7 @@ TEST(SaveLoadOp, CPU) {
"load"
,
{},
{{
"Out"
,
{
"out_var"
}}},
attrs
);
load_op
->
Run
(
scope
,
ctx
);
int
*
actual
=
target
->
data
<
int
>
();
for
(
size_t
i
=
0
;
i
<
paddle
::
framework
::
product
(
tensor
->
dims
()
);
++
i
)
{
for
(
int64_t
i
=
0
;
i
<
tensor
->
numel
(
);
++
i
)
{
EXPECT_EQ
(
expect
[
i
],
actual
[
i
]);
}
auto
&
actual_lod
=
target
->
lod
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录