in optimum/quanto/quantize.py [0:0]
def quantization_map(model: torch.nn.Module) -> Dict[str, Dict[str, str]]:
"""Returns the quantization map of a module
The quantization map is a dictionary of quantization parameters indexed
by the module submodule names (including prefix).
This is mainly used for serialization.
Args:
model (`torch.nn.Module`): the root module to map.
Returns:
a dictionary of quantization parameters indexed by layer names.
"""
config = {}
for name, m in model.named_modules():
if isinstance(m, QModuleMixin):
config[name] = {
"weights": "none" if m.weight_qtype is None else m.weight_qtype.name,
"activations": "none" if m.activation_qtype is None else m.activation_qtype.name,
}
return config