Skip to content

Commit 80ccd9a

Browse files
Merge pull request #568 from psunn:master
PiperOrigin-RevId: 350298219
2 parents 973f5b3 + 6f96caa commit 80ccd9a

File tree

16 files changed

+824
-1
lines changed

16 files changed

+824
-1
lines changed

tensorflow_model_optimization/python/core/api/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ py_library(
88
"__init__.py",
99
"clustering/__init__.py",
1010
"clustering/keras/__init__.py",
11+
"experimental/__init__.py",
12+
"experimental/combine/__init__.py",
1113
"quantization/__init__.py",
1214
"quantization/keras/__init__.py",
1315
"quantization/keras/default_8bit/__init__.py",

tensorflow_model_optimization/python/core/api/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
1+
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -14,5 +14,6 @@
1414
# ==============================================================================
1515
"""Import API modules for Tensorflow Model Optimization."""
1616
from tensorflow_model_optimization.python.core.api import clustering
17+
from tensorflow_model_optimization.python.core.api import experimental
1718
from tensorflow_model_optimization.python.core.api import quantization
1819
from tensorflow_model_optimization.python.core.api import sparsity
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 experimental features."""
16+
from tensorflow_model_optimization.python.core.api.experimental import combine
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 collaborative optimization code."""
16+
from tensorflow_model_optimization.python.core.quantization.keras.collaborative_optimizations.prune_preserve.default_8bit_prune_preserve_quantize_scheme import (
17+
Default8BitPrunePreserveQuantizeScheme,)

tensorflow_model_optimization/python/core/quantization/keras/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ py_library(
1717
"//tensorflow_model_optimization/python/core/quantization/keras/graph_transformations",
1818
"//tensorflow_model_optimization/python/core/quantization/keras/layers",
1919
"//tensorflow_model_optimization/python/core/quantization/keras/default_8bit",
20+
"//tensorflow_model_optimization/python/core/quantization/keras/collaborative_optimizations",
2021
],
2122
)
2223

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package(default_visibility = ["//tensorflow_model_optimization:__subpackages__"])
2+
3+
licenses(["notice"])
4+
5+
py_library(
6+
name = "collaborative_optimizations",
7+
srcs = ["__init__.py"],
8+
srcs_version = "PY3",
9+
deps = ["//tensorflow_model_optimization/python/core/quantization/keras/collaborative_optimizations/prune_preserve"],
10+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
# ==============================================================================
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package(default_visibility = [
2+
"//tensorflow_model_optimization:__subpackages__",
3+
])
4+
5+
licenses(["notice"])
6+
7+
py_library(
8+
name = "prune_preserve",
9+
srcs = [
10+
"__init__.py",
11+
],
12+
srcs_version = "PY3",
13+
deps = [
14+
":default_8bit_prune_preserve_quantize_scheme",
15+
],
16+
)
17+
18+
py_library(
19+
name = "prune_preserve_quantize_registry",
20+
srcs = [
21+
"prune_preserve_quantize_registry.py",
22+
],
23+
srcs_version = "PY3",
24+
visibility = ["//visibility:private"],
25+
deps = [
26+
# tensorflow dep1,
27+
"//tensorflow_model_optimization/python/core/quantization/keras/default_8bit:default_8bit_quantize_registry",
28+
"//tensorflow_model_optimization/python/core/quantization/keras/default_8bit:default_8bit_quantizers",
29+
],
30+
)
31+
32+
py_test(
33+
name = "prune_preserve_quantize_registry_test",
34+
srcs = [
35+
"prune_preserve_quantize_registry_test.py",
36+
],
37+
python_version = "PY3",
38+
visibility = ["//visibility:private"],
39+
deps = [
40+
":prune_preserve_quantize_registry",
41+
# tensorflow dep1,
42+
"//tensorflow_model_optimization/python/core/quantization/keras/default_8bit:default_8bit_quantize_registry",
43+
"//tensorflow_model_optimization/python/core/sparsity/keras:prune_registry",
44+
],
45+
)
46+
47+
py_library(
48+
name = "default_8bit_prune_preserve_quantize_scheme",
49+
srcs = [
50+
"default_8bit_prune_preserve_quantize_scheme.py",
51+
],
52+
srcs_version = "PY3",
53+
visibility = ["//visibility:public"],
54+
deps = [
55+
":prune_preserve_quantize_registry",
56+
"//tensorflow_model_optimization/python/core/quantization/keras/default_8bit:default_8bit_quantize_scheme",
57+
],
58+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
# ==============================================================================
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
"""Default 8 bit Prune Preserve Quantization scheme which specifies how quantization should be applied."""
16+
17+
from tensorflow_model_optimization.python.core.quantization.keras.collaborative_optimizations.prune_preserve import (
18+
prune_preserve_quantize_registry)
19+
from tensorflow_model_optimization.python.core.quantization.keras.default_8bit import (
20+
default_8bit_quantize_scheme,)
21+
22+
23+
class Default8BitPrunePreserveQuantizeScheme(
24+
default_8bit_quantize_scheme.Default8BitQuantizeScheme):
25+
"""Default 8 bit Prune Preserve Quantization Scheme."""
26+
27+
def get_quantize_registry(self):
28+
return (prune_preserve_quantize_registry
29+
.Default8bitPrunePreserveQuantizeRegistry())
30+

0 commit comments

Comments
 (0)