Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99b8dbb

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/paddle into add-ReduceOp
2 parents 477a6a0 + dcfd31d commit 99b8dbb

132 files changed

Lines changed: 5304 additions & 1386 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmark/paddle/image/provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ def initHook(settings, height, width, color, num_class, **kwargs):
2222
def process(settings, file_list):
2323
for i in xrange(1024):
2424
img = np.random.rand(1, settings.data_size).reshape(-1, 1).flatten()
25-
lab = random.randint(0, settings.num_class)
25+
lab = random.randint(0, settings.num_class - 1)
2626
yield img.astype('float32'), int(lab)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
set -e
2+
3+
unset OMP_NUM_THREADS MKL_NUM_THREADS
4+
export OMP_DYNAMIC="FALSE"
5+
export KMP_AFFINITY="granularity=fine,compact,0,0"
6+
7+
function train() {
8+
topology=$1
9+
bs=$2
10+
use_mkldnn=$3
11+
if [ $3 == "True" ]; then
12+
thread=1
13+
log="logs/${topology}-mkldnn-${bs}.log"
14+
elif [ $3 == "False" ]; then
15+
thread=`nproc`
16+
log="logs/${topology}-${thread}mklml-${bs}.log"
17+
else
18+
echo "Wrong input $3, use True or False."
19+
fi
20+
args="batch_size=${bs}"
21+
config="${topology}.py"
22+
paddle train --job=time \
23+
--config=$config \
24+
--use_mkldnn=$use_mkldnn \
25+
--use_gpu=False \
26+
--trainer_count=$thread \
27+
--log_period=10 \
28+
--test_period=100 \
29+
--config_args=$args \
30+
2>&1 | tee ${log}
31+
}
32+
33+
if [ ! -d "train.list" ]; then
34+
echo " " > train.list
35+
fi
36+
if [ ! -d "logs" ]; then
37+
mkdir logs
38+
fi
39+
40+
#========== mkldnn ==========#
41+
train vgg 64 True
42+
train vgg 128 True
43+
train vgg 256 True
44+
45+
#========== mklml ===========#
46+
train vgg 64 False
47+
train vgg 128 False
48+
train vgg 256 False

benchmark/paddle/image/vgg.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env python
2+
from paddle.trainer_config_helpers import *
3+
4+
height = 224
5+
width = 224
6+
num_class = 1000
7+
batch_size = get_config_arg('batch_size', int, 64)
8+
layer_num = get_config_arg('layer_num', int, 19)
9+
10+
args = {'height': height, 'width': width, 'color': True, 'num_class': num_class}
11+
define_py_data_sources2(
12+
"train.list", None, module="provider", obj="process", args=args)
13+
14+
settings(
15+
batch_size=batch_size,
16+
learning_rate=0.01 / batch_size,
17+
learning_method=MomentumOptimizer(0.9),
18+
regularization=L2Regularization(0.0005 * batch_size))
19+
20+
img = data_layer(name='image', size=height * width * 3)
21+
22+
23+
def vgg_network(vgg_num=3):
24+
tmp = img_conv_group(
25+
input=img,
26+
num_channels=3,
27+
conv_padding=1,
28+
conv_num_filter=[64, 64],
29+
conv_filter_size=3,
30+
conv_act=ReluActivation(),
31+
pool_size=2,
32+
pool_stride=2,
33+
pool_type=MaxPooling())
34+
35+
tmp = img_conv_group(
36+
input=tmp,
37+
conv_num_filter=[128, 128],
38+
conv_padding=1,
39+
conv_filter_size=3,
40+
conv_act=ReluActivation(),
41+
pool_stride=2,
42+
pool_type=MaxPooling(),
43+
pool_size=2)
44+
45+
channels = []
46+
for i in range(vgg_num):
47+
channels.append(256)
48+
tmp = img_conv_group(
49+
input=tmp,
50+
conv_num_filter=channels,
51+
conv_padding=1,
52+
conv_filter_size=3,
53+
conv_act=ReluActivation(),
54+
pool_stride=2,
55+
pool_type=MaxPooling(),
56+
pool_size=2)
57+
channels = []
58+
for i in range(vgg_num):
59+
channels.append(512)
60+
tmp = img_conv_group(
61+
input=tmp,
62+
conv_num_filter=channels,
63+
conv_padding=1,
64+
conv_filter_size=3,
65+
conv_act=ReluActivation(),
66+
pool_stride=2,
67+
pool_type=MaxPooling(),
68+
pool_size=2)
69+
tmp = img_conv_group(
70+
input=tmp,
71+
conv_num_filter=channels,
72+
conv_padding=1,
73+
conv_filter_size=3,
74+
conv_act=ReluActivation(),
75+
pool_stride=2,
76+
pool_type=MaxPooling(),
77+
pool_size=2)
78+
79+
tmp = fc_layer(
80+
input=tmp,
81+
size=4096,
82+
act=ReluActivation(),
83+
layer_attr=ExtraAttr(drop_rate=0.5))
84+
85+
tmp = fc_layer(
86+
input=tmp,
87+
size=4096,
88+
act=ReluActivation(),
89+
layer_attr=ExtraAttr(drop_rate=0.5))
90+
91+
return fc_layer(input=tmp, size=num_class, act=SoftmaxActivation())
92+
93+
94+
if layer_num == 16:
95+
vgg = vgg_network(3)
96+
elif layer_num == 19:
97+
vgg = vgg_network(4)
98+
else:
99+
print("Wrong layer number.")
100+
101+
lab = data_layer('label', num_class)
102+
loss = cross_entropy(input=vgg, label=lab)
103+
outputs(loss)

cmake/generic.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function(nv_library TARGET_NAME)
253253
foreach(source_file ${nv_library_SRCS})
254254
string(REGEX REPLACE "\\.[^.]*$" "" source ${source_file})
255255
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${source}.h)
256-
list(APPEND cc_library_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${source}.h)
256+
list(APPEND nv_library_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${source}.h)
257257
endif()
258258
endforeach()
259259
add_style_check_target(${TARGET_NAME} ${nv_library_SRCS} ${nv_library_HEADERS})

cmake/util.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ function(link_paddle_exe TARGET_NAME)
9797
target_link_libraries(${TARGET_NAME} log)
9898
endif(ANDROID)
9999

100+
if(WITH_MKLDNN AND WITH_MKLML AND MKLDNN_IOMP_DIR)
101+
target_link_libraries(${TARGET_NAME} "-L${MKLDNN_IOMP_DIR} -liomp5 -Wl,--as-needed")
102+
endif()
103+
100104
add_dependencies(${TARGET_NAME} ${external_project_dependencies})
101105
endfunction()
102106

0 commit comments

Comments
 (0)