Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3c3a11a0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
3c3a11a0
编写于
8月 04, 2017
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add use_mkldnn flag
上级
def959a8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
4 deletion
+34
-4
paddle/gserver/layers/MkldnnLayer.h
paddle/gserver/layers/MkldnnLayer.h
+3
-1
paddle/trainer/TrainerConfigHelper.cpp
paddle/trainer/TrainerConfigHelper.cpp
+2
-0
paddle/utils/Flags.cpp
paddle/utils/Flags.cpp
+7
-0
paddle/utils/Flags.h
paddle/utils/Flags.h
+1
-0
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+21
-3
未找到文件。
paddle/gserver/layers/MkldnnLayer.h
浏览文件 @
3c3a11a0
...
...
@@ -35,8 +35,10 @@ public:
virtual
bool
init
(
const
LayerMap
&
layerMap
,
const
ParameterMap
&
parameterMap
)
{
return
Layer
::
init
(
layerMap
,
parameterMap
);
CHECK
(
FLAGS_use_mkldnn
)
<<
"MkldnnLayers only support use_mkldnn."
<<
"Please set WITH_MKLDNN=ON"
;
// TODO(TJ): deivecId
return
Layer
::
init
(
layerMap
,
parameterMap
);
}
void
resetOutput
(
size_t
height
,
size_t
width
)
{
;
}
...
...
paddle/trainer/TrainerConfigHelper.cpp
浏览文件 @
3c3a11a0
...
...
@@ -28,6 +28,7 @@ DECLARE_bool(with_cost);
DECLARE_bool
(
with_gpu
);
DECLARE_bool
(
parallel_nn
);
DECLARE_string
(
config_args
);
DECLARE_bool
(
use_mkldnn
);
const
char
*
kConfigParserModuleName
=
"paddle.trainer.config_parser"
;
const
char
*
kConfigParserFuncName
=
"parse_config_and_serialize"
;
...
...
@@ -44,6 +45,7 @@ TrainerConfigHelper::TrainerConfigHelper(const std::string &configFilePath)
configArgs
<<
"trainer_id="
<<
FLAGS_trainer_id
<<
",local="
<<
FLAGS_local
<<
",with_cost="
<<
FLAGS_with_cost
<<
",use_gpu="
<<
FLAGS_use_gpu
<<
",parallel_nn="
<<
FLAGS_parallel_nn
<<
",use_mkldnn="
<<
FLAGS_use_mkldnn
<<
",cudnn_version="
<<
hl_get_cudnn_lib_version
();
if
(
!
FLAGS_config_args
.
empty
())
{
configArgs
<<
","
<<
FLAGS_config_args
;
...
...
paddle/utils/Flags.cpp
浏览文件 @
3c3a11a0
...
...
@@ -20,6 +20,13 @@ DEFINE_bool(use_gpu, false, "Only support CPU training");
DEFINE_bool
(
use_gpu
,
true
,
"Whether to use GPU for training"
);
#endif
#ifdef PADDLE_USE_MKLDNN
// TODO(TJ): change to true when MKLDNN layers support multi-inputs
DEFINE_bool
(
use_mkldnn
,
false
,
"Default still keep use CPU training"
);
#else
DEFINE_bool
(
use_mkldnn
,
false
,
"Only support CPU training"
);
#endif
DEFINE_bool
(
parallel_nn
,
false
,
"Whether to use multi-threads to calculate one neural network."
...
...
paddle/utils/Flags.h
浏览文件 @
3c3a11a0
...
...
@@ -40,3 +40,4 @@ DECLARE_bool(show_layer_stat);
DECLARE_string
(
predict_file
);
DECLARE_bool
(
prev_batch_state
);
DECLARE_string
(
init_model_path
);
DECLARE_bool
(
use_mkldnn
);
python/paddle/trainer/config_parser.py
浏览文件 @
3c3a11a0
...
...
@@ -1604,6 +1604,8 @@ class MultiClassCrossEntropySelfNormCostLayer(LayerBase):
@
config_layer
(
'fc'
)
class
FCLayer
(
LayerBase
):
layer_type
=
'fc'
def
__init__
(
self
,
name
,
size
,
...
...
@@ -1611,14 +1613,25 @@ class FCLayer(LayerBase):
bias
=
True
,
error_clipping_threshold
=
None
,
**
xargs
):
super
(
FCLayer
,
self
).
__init__
(
name
,
'fc'
,
size
,
inputs
=
inputs
,
**
xargs
)
use_mkldnn
=
bool
(
int
(
g_command_config_args
.
get
(
"use_mkldnn"
,
0
)))
if
use_mkldnn
:
self
.
layer_type
=
'mkldnn_fc'
config_assert
(
len
(
inputs
)
==
1
,
"MkldnnFCLayer support one and only one input!"
)
super
(
FCLayer
,
self
).
__init__
(
name
,
self
.
layer_type
,
size
,
inputs
=
inputs
,
**
xargs
)
for
input_index
in
xrange
(
len
(
self
.
inputs
)):
input_layer
=
self
.
get_input_layer
(
input_index
)
psize
=
self
.
config
.
size
*
input_layer
.
size
dims
=
[
input_layer
.
size
,
self
.
config
.
size
]
format
=
self
.
inputs
[
input_index
].
format
sparse
=
format
==
"csr"
or
format
==
"csc"
if
use_mkldnn
:
dims
=
[
self
.
config
.
size
,
input_layer
.
size
]
config_assert
(
not
sparse
,
"MkldnnFCLayer do not support sparse format yet"
)
else
:
dims
=
[
input_layer
.
size
,
self
.
config
.
size
]
if
sparse
:
psize
=
self
.
inputs
[
input_index
].
nnz
else
:
...
...
@@ -1631,6 +1644,11 @@ class FCLayer(LayerBase):
self
.
config
.
error_clipping_threshold
=
error_clipping_threshold
@
config_layer
(
'mkldnn_fc'
)
class
MkldnnFcLayer
(
FCLayer
):
layer_type
=
'mkldnn_fc'
@
config_layer
(
'selective_fc'
)
class
SelectiveFCLayer
(
LayerBase
):
def
__init__
(
self
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录