neural_compressor.objective
The objectives supported by neural_compressor, which is driven by accuracy.
To support new objective, developers just need implement a new subclass in this file.
Classes
The base class for precise benchmark supported by neural_compressor. |
|
Configuration Accuracy class. |
|
Configuration Performance class. |
|
Configuration Footprint class. |
|
Configuration ModelSize class. |
|
The base class for multiple benchmarks supported by neural_compressor. |
Functions
|
The class decorator used to register all Objective subclasses. |
|
Register a customized objective. |
Module Contents
- neural_compressor.objective.objective_registry(cls)[source]
The class decorator used to register all Objective subclasses.
- Parameters:
cls (object) – The class of register.
- Returns:
The class of register.
- Return type:
cls (object)
- neural_compressor.objective.objective_custom_registry(name, obj_cls)[source]
Register a customized objective.
Example:
from eural_compressor.objective import objective_custom_registry objective_cls = type(user_objective) name = user_objective.__class__.__name__ objective_cfg = name if deep_get(self.conf.usr_cfg, "tuning.objective") else [name] deep_set(self.conf.usr_cfg, user_obj_cfg, objective_cfg) self.conf.usr_cfg = DotDict(self.conf.usr_cfg) objective_custom_registry(name, objective_cls)
- class neural_compressor.objective.Objective[source]
The base class for precise benchmark supported by neural_compressor.
With built-in objectives, users can compress models with different objectives easily. In special cases, users can also register their own objective classes.
- class neural_compressor.objective.Accuracy[source]
Configuration Accuracy class.
Evaluate the accuracy.
- class neural_compressor.objective.Performance[source]
Configuration Performance class.
Evaluate the inference time.
- class neural_compressor.objective.Footprint[source]
Configuration Footprint class.
Evaluate the peak size of memory blocks during inference.
- class neural_compressor.objective.ModelSize[source]
Configuration ModelSize class.
Evaluate the model size.
- class neural_compressor.objective.MultiObjective(objectives, accuracy_criterion, metric_criterion=[True], metric_weight=None, obj_criterion=None, obj_weight=None, is_measure=False)[source]
The base class for multiple benchmarks supported by neural_compressor.
Example:
from neural_compressor.objective import MultiObjective obj = MultiObjective( objectives=['accuracy', 'modelsize', 'performance'], accuracy_criterion={'relative': 0.1}, obj_criterion=[True, False, False], obj_weight=[0.7, 0.2, 0.1])