Skip to content

Commit f13d725

Browse files
committed
add mkldnn_lrn python interface and add it to simple net
1 parent 343b1a9 commit f13d725

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

paddle/gserver/tests/mkldnn_simple_net.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ tmp = img_pool_layer(input=tmp,
5151
padding=1,
5252
pool_type=MaxPooling())
5353

54+
tmp = img_cmrnorm_layer(input=tmp, size=5, scale=0.0001, power=0.75)
55+
5456
tmp = fc_layer(input=tmp,
5557
size=channels,
5658
bias_attr=False,

python/paddle/trainer/config_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,11 +2287,17 @@ class Conv3DLayer(Conv3DLayerBase):
22872287
class NormLayer(LayerBase):
22882288
def __init__(self, name, inputs, **xargs):
22892289
super(NormLayer, self).__init__(name, 'norm', 0, inputs=inputs, **xargs)
2290+
use_mkldnn = bool(int(g_command_config_args.get("use_mkldnn", 0)))
2291+
use_mkldnn = True if use_mkldnn and self.inputs[
2292+
0].norm.norm_type == 'cmrnorm-projection' else False
2293+
self.config.type = 'mkldnn_lrn' if use_mkldnn else self.config.type
22902294
for input_index in xrange(len(self.inputs)):
22912295
input_layer = self.get_input_layer(input_index)
22922296
norm_conf = self.config.inputs[input_index].norm_conf
22932297
parse_norm(self.inputs[input_index].norm, input_layer.name,
22942298
norm_conf)
2299+
norm_conf.scale = self.inputs[
2300+
input_index].norm.scale if use_mkldnn else norm_conf.scale
22952301
self.set_cnn_layer(name, norm_conf.output_y, norm_conf.output_x,
22962302
norm_conf.channels, False)
22972303
if norm_conf.norm_type == "cross-channel-norm":

0 commit comments

Comments
 (0)