Skip to content

Conversation

@zehao-intel
Copy link
Contributor

@zehao-intel zehao-intel commented Nov 20, 2023

Description

This PR includes the code of the implementation of INC 3.0 New API for Keras Static Quant.

  • quantize_model API aligned with TFMOT.
  • Support Static Quant for Keras model

More algorithms might be added in later PRs.

3.0 API Usage

Users should pass the model, quant_config and calib_dataloader as arguments to this quantize_model API.
model: A tf.keras.Model instance
quant_config: A KerasStaticQuantConfig instance, the usage is the same as nc.config.PostTrainingQuantConfig.
calib_dataloader: A Dataloader for calibration.

PTQ for Keras models

from neural_compressor.tensorflow import StaticQuantConfig, quantize_model

config = StaticQuantConfig(backend="itex")
model = keras.models.load_model("./baseline_model")
q_model = quantize_model(model, config, calib_dataloader=CustomDataloader())

How has this PR been tested?

Pre-CI

Dependency Change?

No

zehao-intel and others added 6 commits November 20, 2023 11:57
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
@zehao-intel zehao-intel requested a review from yiliu30 November 21, 2023 02:02
@yiliu30
Copy link
Contributor

yiliu30 commented Nov 21, 2023

The 3.x tf binary includes neural_compressor.common and neural_compressor.tensorflow instead of neural_compressor.keras. Please align with @chensuyue.

@yiliu30 yiliu30 added the INC3.X label Nov 21, 2023
@chensuyue chensuyue added this to the v2.4 milestone Nov 21, 2023
@chensuyue
Copy link
Contributor

chensuyue commented Nov 22, 2023

Please move 3.x test here: https://github.com/intel/neural-compressor/tree/master/test/3x
I will add separate CI for keras 3.x.

zehao-intel and others added 14 commits November 23, 2023 15:05
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
@zehao-intel
Copy link
Contributor Author

zehao-intel commented Nov 24, 2023

All comments above have been solved.

Signed-off-by: chensuyue <suyue.chen@intel.com>
Signed-off-by: chensuyue <suyue.chen@intel.com>
Signed-off-by: chensuyue <suyue.chen@intel.com>
@chensuyue chensuyue force-pushed the zehao/keras3.0newapi branch from 6d7a8b7 to aca6b24 Compare November 24, 2023 08:42
chensuyue and others added 4 commits November 25, 2023 19:41
Signed-off-by: chensuyue <suyue.chen@intel.com>
Signed-off-by: zehao-intel <zehao.huang@intel.com>
Signed-off-by: chensuyue <suyue.chen@intel.com>
chensuyue and others added 2 commits November 27, 2023 12:11
Signed-off-by: chensuyue <suyue.chen@intel.com>
@chensuyue chensuyue requested a review from ftian1 November 27, 2023 06:35
Signed-off-by: zehao-intel <zehao.huang@intel.com>
@chensuyue chensuyue merged commit 2627d33 into master Nov 28, 2023
@chensuyue chensuyue deleted the zehao/keras3.0newapi branch November 28, 2023 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants