Skip to content

Commit

Permalink
Enable winograd when kernel size is 3x3, stride is unit, and output i…
Browse files Browse the repository at this point in the history
…s 16 dividable
  • Loading branch information
hshen14 committed Dec 1, 2017
1 parent 9a565d6 commit b8b4ed0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/pycaffe/tune_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ def genOptimalModel(net, mkldnn_direct_time_map, mkldnn_winograd_time_map, optim
for index in range(0, len(net.layer)):
l = net.layer[index]
if l.type == "Convolution":
if mkldnn_winograd_time_map[l.name] < mkldnn_direct_time_map[l.name]:
if len(l.convolution_param.kernel_size) == 0:
continue
kernel_size = l.convolution_param.kernel_size[0]
stride = 1
if len(l.convolution_param.stride) != 0:
stride = l.convolution_param.stride[0]
if mkldnn_winograd_time_map[l.name] < mkldnn_direct_time_map[l.name] and kernel_size == 3 and stride == 1 and l.convolution_param.num_output % 16 ==0:
l.convolution_param.conv_algorithm = "winograd"
else:
l.convolution_param.conv_algorithm = "direct"
Expand Down

0 comments on commit b8b4ed0

Please sign in to comment.