Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
326b434a
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
326b434a
编写于
4月 09, 2018
作者:
X
Xin Pan
提交者:
GitHub
4月 09, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9699 from panyx0718/test
Avoid init_p2p all the times
上级
ddff83ff
b138d29c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
23 addition
and
15 deletion
+23
-15
paddle/fluid/framework/data_device_transform_test.cu
paddle/fluid/framework/data_device_transform_test.cu
+1
-1
paddle/fluid/framework/init.cc
paddle/fluid/framework/init.cc
+4
-2
paddle/fluid/framework/init.h
paddle/fluid/framework/init.h
+1
-1
paddle/fluid/framework/init_test.cc
paddle/fluid/framework/init_test.cc
+2
-2
paddle/fluid/framework/lod_tensor_test.cu
paddle/fluid/framework/lod_tensor_test.cu
+2
-2
paddle/fluid/framework/operator_test.cc
paddle/fluid/framework/operator_test.cc
+4
-4
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+2
-1
paddle/testing/paddle_gtest_main.cc
paddle/testing/paddle_gtest_main.cc
+1
-1
python/paddle/fluid/__init__.py
python/paddle/fluid/__init__.py
+6
-1
未找到文件。
paddle/fluid/framework/data_device_transform_test.cu
浏览文件 @
326b434a
...
...
@@ -105,7 +105,7 @@ static void BuildVar(const std::string& param_name,
TEST
(
Operator
,
CPUtoGPU
)
{
using
namespace
paddle
::
framework
;
using
namespace
paddle
::
platform
;
InitDevices
();
InitDevices
(
true
);
paddle
::
framework
::
Scope
scope
;
paddle
::
platform
::
CPUPlace
cpu_place
;
...
...
paddle/fluid/framework/init.cc
浏览文件 @
326b434a
...
...
@@ -64,7 +64,7 @@ void InitP2P(int count) {
#endif
}
void
InitDevices
()
{
void
InitDevices
(
bool
init_p2p
)
{
/*Init all avaiable devices by default */
std
::
vector
<
platform
::
Place
>
places
;
...
...
@@ -85,7 +85,9 @@ void InitDevices() {
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
places
.
emplace_back
(
platform
::
CUDAPlace
(
i
));
}
InitP2P
(
count
);
if
(
init_p2p
)
{
InitP2P
(
count
);
}
platform
::
DeviceContextPool
::
Init
(
places
);
}
...
...
paddle/fluid/framework/init.h
浏览文件 @
326b434a
...
...
@@ -24,7 +24,7 @@ void InitGflags(std::vector<std::string> &argv);
void
InitGLOG
(
const
std
::
string
&
prog_name
);
void
InitDevices
();
void
InitDevices
(
bool
init_p2p
);
}
// namespace framework
}
// namespace paddle
paddle/fluid/framework/init_test.cc
浏览文件 @
326b434a
...
...
@@ -21,7 +21,7 @@ TEST(InitDevices, CPU) {
using
paddle
::
platform
::
DeviceContextPool
;
#ifndef PADDLE_WITH_CUDA
InitDevices
();
InitDevices
(
true
);
DeviceContextPool
&
pool
=
DeviceContextPool
::
Instance
();
ASSERT_EQ
(
pool
.
size
(),
1U
);
#endif
...
...
@@ -33,7 +33,7 @@ TEST(InitDevices, CUDA) {
#ifdef PADDLE_WITH_CUDA
int
count
=
paddle
::
platform
::
GetCUDADeviceCount
();
InitDevices
();
InitDevices
(
true
);
DeviceContextPool
&
pool
=
DeviceContextPool
::
Instance
();
ASSERT_EQ
(
pool
.
size
(),
1U
+
static_cast
<
unsigned
>
(
count
));
#endif
...
...
paddle/fluid/framework/lod_tensor_test.cu
浏览文件 @
326b434a
...
...
@@ -30,7 +30,7 @@ __global__ void test(size_t* a, int size) {
}
TEST
(
LoD
,
data
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
LoD
lod
{{
0
,
1
,
2
}};
lod
.
push_back
({
0
,
2
,
4
,
5
});
...
...
@@ -46,7 +46,7 @@ TEST(LoD, data) {
}
TEST
(
LoDTensor
,
LoDInGPU
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
LoDTensor
lod_tensor
;
paddle
::
platform
::
CUDAPlace
place
(
0
);
...
...
paddle/fluid/framework/operator_test.cc
浏览文件 @
326b434a
...
...
@@ -72,7 +72,7 @@ REGISTER_OP_WITHOUT_GRADIENT(test_operator,
paddle
::
framework
::
OpWithoutKernelCheckerMaker
);
TEST
(
OperatorBase
,
all
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
proto
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"test_operator"
);
BuildVar
(
"input"
,
{
"IN1"
},
op_desc
.
add_inputs
());
...
...
@@ -198,7 +198,7 @@ REGISTER_OP_CPU_KERNEL(op_with_kernel,
// test with single input
TEST
(
OpKernel
,
all
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
paddle
::
framework
::
proto
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_with_kernel"
);
BuildVar
(
"x"
,
{
"IN1"
},
op_desc
.
add_inputs
());
...
...
@@ -228,7 +228,7 @@ REGISTER_OP_CPU_KERNEL(op_multi_inputs_with_kernel,
TEST
(
OpKernel
,
multi_inputs
)
{
using
namespace
paddle
::
framework
;
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
proto
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_multi_inputs_with_kernel"
);
...
...
@@ -269,7 +269,7 @@ class OperatorClone : public paddle::framework::OperatorBase {
};
TEST
(
Operator
,
Clone
)
{
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
OperatorClone
a
(
"ABC"
,
paddle
::
framework
::
VariableNameMap
{},
paddle
::
framework
::
VariableNameMap
{},
paddle
::
framework
::
AttributeMap
{});
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
326b434a
...
...
@@ -465,7 +465,8 @@ All parameter, weight, gradient are variables in Paddle.
m
.
def
(
"init_gflags"
,
framework
::
InitGflags
);
m
.
def
(
"init_glog"
,
framework
::
InitGLOG
);
m
.
def
(
"init_devices"
,
&
framework
::
InitDevices
);
m
.
def
(
"init_devices"
,
[](
bool
init_p2p
)
{
framework
::
InitDevices
(
init_p2p
);
});
m
.
def
(
"is_compiled_with_cuda"
,
IsCompiledWithCUDA
);
#ifdef PADDLE_WITH_CUDA
...
...
paddle/testing/paddle_gtest_main.cc
浏览文件 @
326b434a
...
...
@@ -41,6 +41,6 @@ int main(int argc, char** argv) {
paddle
::
memory
::
Used
(
paddle
::
platform
::
CUDAPlace
(
0
));
#endif
paddle
::
framework
::
InitDevices
();
paddle
::
framework
::
InitDevices
(
true
);
return
RUN_ALL_TESTS
();
}
python/paddle/fluid/__init__.py
浏览文件 @
326b434a
...
...
@@ -85,6 +85,8 @@ def __bootstrap__():
import
core
import
os
in_test
=
'unittest'
in
sys
.
modules
try
:
num_threads
=
int
(
os
.
getenv
(
'OMP_NUM_THREADS'
,
'1'
))
except
ValueError
:
...
...
@@ -109,8 +111,11 @@ def __bootstrap__():
core
.
init_gflags
([
sys
.
argv
[
0
]]
+
[
"--tryfromenv="
+
","
.
join
(
read_env_flags
)])
core
.
init_glog
(
sys
.
argv
[
0
])
core
.
init_devices
()
# don't init_p2p when in unittest to save time.
core
.
init_devices
(
not
in_test
)
# TODO(panyx0718): Avoid doing complex initialization logic in __init__.py.
# Consider paddle.init(args) or paddle.main(args)
layers
.
monkey_patch_variable
()
__bootstrap__
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录