|
36 | 36 |
|
37 | 37 | _op_real_in_out_name = {
|
38 | 38 | "conv2d": [["Input", "Filter"], ["Output"]],
|
39 |
| - "conv2d_transpose": [["Input", "Filter"], ["Output"]], |
| 39 | + "depthwise_conv2d": [["Input", "Filter"], ["Output"]], |
40 | 40 | "pool2d": [["X"], ["Out"]],
|
41 | 41 | "elementwise_add": [["X", "Y"], ["Out"]],
|
42 | 42 | "softmax": [["X"], ["Out"]],
|
@@ -329,9 +329,9 @@ def __init__(self, moving_rate=0.9):
|
329 | 329 | super(ImperativeCalcOutScale, self).__init__()
|
330 | 330 | self._moving_rate = moving_rate
|
331 | 331 | self._out_scale_layer_type_list = (
|
332 |
| - BatchNorm, BatchNorm1D, BatchNorm2D, BatchNorm3D, Conv2D, |
333 |
| - Conv2DTranspose, LeakyReLU, Linear, PReLU, Pool2D, MaxPool1D, |
334 |
| - MaxPool2D, ReLU, ReLU6, Sigmoid, Softmax, Tanh, Swish) |
| 332 | + BatchNorm, BatchNorm1D, BatchNorm2D, BatchNorm3D, Conv2D, LeakyReLU, |
| 333 | + Linear, PReLU, Pool2D, MaxPool1D, MaxPool2D, ReLU, ReLU6, Sigmoid, |
| 334 | + Softmax, Tanh, Swish) |
335 | 335 | self._register_hook_handle_list = []
|
336 | 336 | self._out_scale_dict = collections.OrderedDict()
|
337 | 337 |
|
@@ -415,9 +415,10 @@ def save_quantized_model(self, layer, path, input_spec=None, **config):
|
415 | 415 |
|
416 | 416 | # Traverse all ops in the program and find out the op matching
|
417 | 417 | # the Layer in the dynamic graph.
|
418 |
| - layer_var_dict = {} |
| 418 | + layer_var_dict = collections.OrderedDict() |
419 | 419 | ops_list = [key for key, _ in self._out_scale_dict.items()]
|
420 | 420 | op_count = 0
|
| 421 | + conv_count = 0 |
421 | 422 | for block in inference_program.blocks:
|
422 | 423 | for op in block.ops:
|
423 | 424 | if op.type in _op_real_in_out_name:
|
@@ -472,6 +473,9 @@ def save_quantized_model(self, layer, path, input_spec=None, **config):
|
472 | 473 | layer_name = layer_name.replace('prelu', 'p_re_lu')
|
473 | 474 | if 'relu' in layer_name:
|
474 | 475 | layer_name = layer_name.replace('relu', 're_lu')
|
| 476 | + if 'conv2d' in layer_name: |
| 477 | + layer_name = 'conv2d_' + str(conv_count) |
| 478 | + conv_count = conv_count + 1 |
475 | 479 | if layer_name not in self._out_scale_dict:
|
476 | 480 | continue
|
477 | 481 | var_name_op_list[1]._set_attr('out_threshold',
|
|
0 commit comments