Skip to content

Commit

Permalink
Add 16 bit input\output to stack & concat operators in TPC.v4 (#1158)
Browse files Browse the repository at this point in the history
Add 16 bit input\output to stack & concat operators in TPC.v4
  • Loading branch information
elad-c authored Aug 12, 2024
1 parent 27b0742 commit dc28638
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def generate_tp_model(default_config: OpQuantizationConfig,
default_qco.clone_and_edit(enable_activation_quantization=False,
supported_input_activation_n_bits=(8, 16))
.clone_and_edit_weight_attribute(enable_weights_quantization=False))
tp.OperatorsSet("Default16BitInout", const_configuration_options_inout16)

# Create Mixed-Precision quantization configuration options from the given list of OpQuantizationConfig objects
mixed_precision_configuration_options = tp.QuantizationConfigOptions(mixed_precision_cfg_list,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
if version.parse(tf.__version__) >= version.parse("2.13"):
from keras.src.layers import Conv2D, DepthwiseConv2D, Dense, Reshape, ZeroPadding2D, Dropout, \
MaxPooling2D, Activation, ReLU, Add, Subtract, Multiply, PReLU, Flatten, Cropping2D, LeakyReLU, Permute, \
Conv2DTranspose, Identity
Conv2DTranspose, Identity, Concatenate
else:
from keras.layers import Conv2D, DepthwiseConv2D, Dense, Reshape, ZeroPadding2D, Dropout, \
MaxPooling2D, Activation, ReLU, Add, Subtract, Multiply, PReLU, Flatten, Cropping2D, LeakyReLU, Permute, \
Conv2DTranspose, Identity
Conv2DTranspose, Identity, Concatenate

from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.v4.tp_model import get_tp_model
import model_compression_toolkit as mct
Expand Down Expand Up @@ -93,6 +93,8 @@ def generate_keras_tpc(name: str, tp_model: tp.TargetPlatformModel):

with keras_tpc:
tp.OperationsSetToLayers("NoQuantization", no_quant_list)
tp.OperationsSetToLayers("Default16BitInout", [tf.stack,
tf.concat, Concatenate])
tp.OperationsSetToLayers("Conv",
[Conv2D,
DepthwiseConv2D,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def generate_pytorch_tpc(name: str, tp_model: tp.TargetPlatformModel):
topk,
squeeze,
MaxPool2d])
tp.OperationsSetToLayers("Default16BitInout", [torch.stack, torch.cat])

tp.OperationsSetToLayers("Conv", [Conv2d, ConvTranspose2d],
attr_mapping=pytorch_linear_attr_mapping)
Expand Down

0 comments on commit dc28638

Please sign in to comment.