Skip to content

Commit 88e2cec

Browse files
cleans up config building
1 parent ac5ecd7 commit 88e2cec

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

keras_hub/src/models/backbone.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,24 @@ def get_config(self):
9191
}
9292

9393
# Add quantization support by utilizing `DTypePolicyMap`
94+
dtype = None
9495
try:
9596
if isinstance(
9697
self.dtype_policy, keras.dtype_policies.DTypePolicyMap
9798
):
98-
config.update({"dtype": self.dtype_policy})
99+
dtype= self.dtype_policy
99100
else:
100101
policy_map = keras.dtype_policies.DTypePolicyMap()
101102
for layer in self._flatten_layers():
102103
if layer.quantization_mode is not None:
103104
policy_map[layer.path] = layer.dtype_policy
104105
if len(policy_map) > 0:
105-
config.update({"dtype": policy_map})
106+
dtype = policy_map
106107
# Before Keras 3.2, there is no `keras.dtype_policies.get`.
107108
except AttributeError:
108-
config.update({"dtype": None})
109+
pass
110+
111+
config.update({"dtype": dtype})
109112
return config
110113

111114
@classmethod

0 commit comments

Comments
 (0)