Fix automatic code generation bug for CNNs
This commit is contained in:
@@ -98,7 +98,7 @@ def decide_mode(network, weight_bit_width, input_uint8 = True):
|
|||||||
if(layer_type_name == 'Linear'):
|
if(layer_type_name == 'Linear'):
|
||||||
layer_type.append(layer_type_name)
|
layer_type.append(layer_type_name)
|
||||||
if(layer_type_name == 'Conv2d'):
|
if(layer_type_name == 'Conv2d'):
|
||||||
if(module.groups == module.in_channels):
|
if(module.groups == module.in_channels and module.groups != 1):
|
||||||
layer_type.append('DepthwiseConv2d')
|
layer_type.append('DepthwiseConv2d')
|
||||||
else:
|
else:
|
||||||
layer_type.append(layer_type_name)
|
layer_type.append(layer_type_name)
|
||||||
|
|||||||
+1
-1
@@ -265,7 +265,7 @@ def create_layer_mapping(bit_width):
|
|||||||
weight_scaling_min_val=2e-16,
|
weight_scaling_min_val=2e-16,
|
||||||
restrict_scaling_type=RestrictValueType.LOG_FP,
|
restrict_scaling_type=RestrictValueType.LOG_FP,
|
||||||
return_quant_tensor=True
|
return_quant_tensor=True
|
||||||
) if layer.groups != layer.in_channels else (
|
) if layer.groups != layer.in_channels or layer.groups == 1 else (
|
||||||
# Special case for depthwise convolutions
|
# Special case for depthwise convolutions
|
||||||
qnn.QuantConv2d(in_channels=layer.in_channels,
|
qnn.QuantConv2d(in_channels=layer.in_channels,
|
||||||
out_channels=layer.out_channels,
|
out_channels=layer.out_channels,
|
||||||
|
|||||||
Reference in New Issue
Block a user