Skip to content

Commit f08d37a

Browse files
Xharktensorflower-gardener
authored andcommitted
Makes quantization scheme APIs public.
PiperOrigin-RevId: 367104089
1 parent 43c7e28 commit f08d37a

File tree

7 files changed

+97
-0
lines changed

7 files changed

+97
-0
lines changed

tensorflow_model_optimization/python/core/api/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ py_library(
1313
"quantization/__init__.py",
1414
"quantization/keras/__init__.py",
1515
"quantization/keras/default_8bit/__init__.py",
16+
"quantization/keras/default_8bit/default_8bit_transforms/__init__.py",
17+
"quantization/keras/graph_transformations/__init__.py",
18+
"quantization/keras/graph_transformations/model_transformer/__init__.py",
19+
"quantization/keras/graph_transformations/transforms/__init__.py",
1620
"quantization/keras/quantizers/__init__.py",
1721
"sparsity/__init__.py",
1822
"sparsity/keras/__init__.py",

tensorflow_model_optimization/python/core/api/quantization/keras/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# submodules
1919
from tensorflow_model_optimization.python.core.api.quantization.keras import quantizers
2020
from tensorflow_model_optimization.python.core.api.quantization.keras import default_8bit
21+
from tensorflow_model_optimization.python.core.api.quantization.keras import graph_transformations
2122

2223
# quantize all layers with default quantization implementation.
2324
from tensorflow_model_optimization.python.core.quantization.keras.quantize import quantize_model
@@ -30,6 +31,7 @@
3031
# quantize with custom quantization parameterization or implementation, or
3132
# handle custom Keras layers.
3233
from tensorflow_model_optimization.python.core.quantization.keras.quantize_config import QuantizeConfig
34+
from tensorflow_model_optimization.python.core.quantization.keras.quantize_wrapper import QuantizeWrapper
3335

3436
# Deserialize quantized model for Keras h5 format.
3537
from tensorflow_model_optimization.python.core.quantization.keras.quantize import quantize_scope

tensorflow_model_optimization/python/core/api/quantization/keras/default_8bit/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"""Module containing 8bit default quantization scheme."""
1616
# pylint: disable=g-bad-import-order
1717

18+
# submodules
19+
from tensorflow_model_optimization.python.core.api.quantization.keras.default_8bit import default_8bit_transforms
20+
1821
# The 8bit default quantization scheme classes.
1922
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_quantize_scheme import Default8BitQuantizeScheme
2023
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_quantize_layout_transform import Default8BitQuantizeLayoutTransform
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Module containing 8bit default transforms."""
16+
17+
# The 8bit default transform classes.
18+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import ConcatTransform
19+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import ConcatTransform3Inputs
20+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import ConcatTransform4Inputs
21+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import ConcatTransform5Inputs
22+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import ConcatTransform6Inputs
23+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import Conv2DBatchNormActivationQuantize
24+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import Conv2DBatchNormQuantize
25+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import Conv2DBatchNormReLUQuantize
26+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import Conv2DReshapeBatchNormActivationQuantize
27+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import Conv2DReshapeBatchNormQuantize
28+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import Conv2DReshapeBatchNormReLUQuantize
29+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import InputLayerQuantize
30+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import LayerReluActivationQuantize
31+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import LayerReLUQuantize
32+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import SeparableConv1DQuantize
33+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit.default_8bit_transforms import SeparableConvQuantize
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Module containing code for graph transformation."""
16+
17+
# submodules
18+
from tensorflow_model_optimization.python.core.api.quantization.keras.graph_transformations import model_transformer
19+
from tensorflow_model_optimization.python.core.api.quantization.keras.graph_transformations import transforms
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Module containing classes for model transformer."""
16+
17+
from tensorflow_model_optimization.python.core.quantization.keras.graph_transformations.model_transformer import ModelTransformer
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Module containing classes for transform."""
16+
17+
from tensorflow_model_optimization.python.core.quantization.keras.graph_transformations.transforms import LayerNode
18+
from tensorflow_model_optimization.python.core.quantization.keras.graph_transformations.transforms import LayerPattern
19+
from tensorflow_model_optimization.python.core.quantization.keras.graph_transformations.transforms import Transform

0 commit comments

Comments
 (0)