Skip to content

Commit

Permalink
Migrate TF Static Quant to 3.x API (#1586)
Browse files Browse the repository at this point in the history
Signed-off-by: zehao-intel <zehao.huang@intel.com>
  • Loading branch information
zehao-intel authored Feb 23, 2024
1 parent b816d77 commit e22c61e
Show file tree
Hide file tree
Showing 81 changed files with 18,386 additions and 68 deletions.
2 changes: 1 addition & 1 deletion neural_compressor/tensorflow/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@


from neural_compressor.tensorflow.algorithms.smoother import SmoothQuant
from neural_compressor.tensorflow.algorithms.static_quant import KerasAdaptor
from neural_compressor.tensorflow.algorithms.static_quant import KerasAdaptor, TensorFlowAdaptor
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
# limitations under the License.

from neural_compressor.tensorflow.algorithms.static_quant.keras import KerasAdaptor
from neural_compressor.tensorflow.algorithms.static_quant.tensorflow import TensorFlowAdaptor
18 changes: 11 additions & 7 deletions neural_compressor/tensorflow/algorithms/static_quant/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,23 @@
import yaml

from neural_compressor.common import logger
from neural_compressor.tensorflow.keras.layers import (
DeQuantize,
FakeQuant,
QAvgPool2D,
QConv2D,
QDense,
QDepthwiseConv2D,
QMaxPool2D,
QSeparableConv2D,
Quantize,
)
from neural_compressor.tensorflow.quantization.config import StaticQuantConfig
from neural_compressor.tensorflow.utils import deep_get, dump_elapsed_time


def _add_supported_quantized_objects(custom_objects):
"""Map all the quantized objects."""
from .keras_utils.conv2d import QConv2D
from .keras_utils.dense import QDense
from .keras_utils.depthwise_conv2d import QDepthwiseConv2D
from .keras_utils.pool2d import QAvgPool2D, QMaxPool2D
from .keras_utils.quantizer import DeQuantize, FakeQuant, Quantize
from .keras_utils.separable_conv2d import QSeparableConv2D

custom_objects["Quantize"] = Quantize
custom_objects["DeQuantize"] = DeQuantize
custom_objects["FakeQuant"] = FakeQuant
Expand Down
Loading

0 comments on commit e22c61e

Please sign in to comment.