Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 711551176
Change-Id: I78f6cc43a90c86e2249a53d597f42761f252c7d9
  • Loading branch information
Akshaya Purohit authored and copybara-github committed Jan 3, 2025
1 parent 3f187ea commit 8e7a1a4
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 94 deletions.
1 change: 1 addition & 0 deletions qkeras/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#from .qtools.run_qtools import QTools
#from .qtools.settings import cfg
from .quantizers import * # pylint: disable=wildcard-import
from .registry import * # pylint: disable=wildcard-import
from .safe_eval import * # pylint: disable=wildcard-import


Expand Down
34 changes: 34 additions & 0 deletions qkeras/quantizer_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2024 Google LLC
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Registry for QKeras quantizers."""

from . import registry

# Global registry for all QKeras quantizers.
_QUANTIZERS_REGISTRY = registry.Registry()


def register_quantizer(quantizer):
"""Decorator for registering a quantizer."""
_QUANTIZERS_REGISTRY.register(quantizer)
# Return the quantizer after registering. This ensures any registered
# quantizer class is properly defined.
return quantizer


def lookup_quantizer(name):
"""Retrieves a quantizer from the quantizers registry."""
return _QUANTIZERS_REGISTRY.lookup(name)
Loading

0 comments on commit 8e7a1a4

Please sign in to comment.