Skip to content

Commit cb52f5d

Browse files
alanchiaotensorflower-gardener
authored andcommitted
Remove pruning wildcard imports for determining what symbols are public APIs, to mirror quantization.
This prevents accidentally exposing private symbols as public APIs. Validated that build_docs.py produces API docs with expected symbols, even without `private_map` blacklist. PiperOrigin-RevId: 317025882
1 parent 73a314c commit cb52f5d

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

build_docs.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ def main(unused_argv):
8080
code_url_prefix=FLAGS.code_url_prefix,
8181
search_hints=FLAGS.search_hints,
8282
site_path=FLAGS.site_path,
83-
private_map={
84-
"tfmot.sparsity.keras": [
85-
# List of internal classes which get exposed when imported.
86-
"InputLayer", "custom_object_scope", "pruning_sched",
87-
"pruning_wrapper", "absolute_import", "division", "print_function"
88-
]
89-
},
9083
)
9184

9285
doc_generator.build(output_dir=FLAGS.output_dir)

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,19 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515
"""Module containing sparsity code built on Keras abstractions."""
16-
# pylint: disable=wildcard-import
16+
# pylint: disable=g-bad-import-order
17+
18+
from tensorflow_model_optimization.python.core.sparsity.keras.prune import prune_low_magnitude
19+
from tensorflow_model_optimization.python.core.sparsity.keras.prune import prune_scope
20+
from tensorflow_model_optimization.python.core.sparsity.keras.prune import strip_pruning
21+
22+
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_callbacks import UpdatePruningStep
23+
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_callbacks import PruningSummaries
24+
25+
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_schedule import PruningSchedule
26+
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_schedule import ConstantSparsity
27+
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_schedule import PolynomialDecay
28+
1729
from tensorflow_model_optimization.python.core.sparsity.keras.prunable_layer import PrunableLayer
18-
from tensorflow_model_optimization.python.core.sparsity.keras.prune import *
19-
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_callbacks import *
20-
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_schedule import *
21-
# pylint: enable=wildcard-import
30+
31+
# pylint: enable=g-bad-import-order

0 commit comments

Comments
 (0)