Skip to content

Commit e22c61e

Browse files
authored
Migrate TF Static Quant to 3.x API (#1586)
Signed-off-by: zehao-intel <zehao.huang@intel.com>
1 parent b816d77 commit e22c61e

File tree

81 files changed

+18386
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+18386
-68
lines changed

neural_compressor/tensorflow/algorithms/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515

1616
from neural_compressor.tensorflow.algorithms.smoother import SmoothQuant
17-
from neural_compressor.tensorflow.algorithms.static_quant import KerasAdaptor
17+
from neural_compressor.tensorflow.algorithms.static_quant import KerasAdaptor, TensorFlowAdaptor

neural_compressor/tensorflow/algorithms/static_quant/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
# limitations under the License.
1414

1515
from neural_compressor.tensorflow.algorithms.static_quant.keras import KerasAdaptor
16+
from neural_compressor.tensorflow.algorithms.static_quant.tensorflow import TensorFlowAdaptor

neural_compressor/tensorflow/algorithms/static_quant/keras.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,23 @@
2828
import yaml
2929

3030
from neural_compressor.common import logger
31+
from neural_compressor.tensorflow.keras.layers import (
32+
DeQuantize,
33+
FakeQuant,
34+
QAvgPool2D,
35+
QConv2D,
36+
QDense,
37+
QDepthwiseConv2D,
38+
QMaxPool2D,
39+
QSeparableConv2D,
40+
Quantize,
41+
)
3142
from neural_compressor.tensorflow.quantization.config import StaticQuantConfig
3243
from neural_compressor.tensorflow.utils import deep_get, dump_elapsed_time
3344

3445

3546
def _add_supported_quantized_objects(custom_objects):
3647
"""Map all the quantized objects."""
37-
from .keras_utils.conv2d import QConv2D
38-
from .keras_utils.dense import QDense
39-
from .keras_utils.depthwise_conv2d import QDepthwiseConv2D
40-
from .keras_utils.pool2d import QAvgPool2D, QMaxPool2D
41-
from .keras_utils.quantizer import DeQuantize, FakeQuant, Quantize
42-
from .keras_utils.separable_conv2d import QSeparableConv2D
43-
4448
custom_objects["Quantize"] = Quantize
4549
custom_objects["DeQuantize"] = DeQuantize
4650
custom_objects["FakeQuant"] = FakeQuant

0 commit comments

Comments
 (0)