Skip to content

Commit 8e7a1a4

Browse files
Akshaya Purohitcopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 711551176 Change-Id: I78f6cc43a90c86e2249a53d597f42761f252c7d9
1 parent 3f187ea commit 8e7a1a4

File tree

4 files changed

+216
-94
lines changed

4 files changed

+216
-94
lines changed

qkeras/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#from .qtools.run_qtools import QTools
3636
#from .qtools.settings import cfg
3737
from .quantizers import * # pylint: disable=wildcard-import
38+
from .registry import * # pylint: disable=wildcard-import
3839
from .safe_eval import * # pylint: disable=wildcard-import
3940

4041

qkeras/quantizer_registry.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ==============================================================================
16+
"""Registry for QKeras quantizers."""
17+
18+
from . import registry
19+
20+
# Global registry for all QKeras quantizers.
21+
_QUANTIZERS_REGISTRY = registry.Registry()
22+
23+
24+
def register_quantizer(quantizer):
25+
"""Decorator for registering a quantizer."""
26+
_QUANTIZERS_REGISTRY.register(quantizer)
27+
# Return the quantizer after registering. This ensures any registered
28+
# quantizer class is properly defined.
29+
return quantizer
30+
31+
32+
def lookup_quantizer(name):
33+
"""Retrieves a quantizer from the quantizers registry."""
34+
return _QUANTIZERS_REGISTRY.lookup(name)

0 commit comments

Comments
 (0)