1from typeguard
import typechecked
13 @brief Configuration for resource management during model compilation.
18 "weight_dtype":
"float32",
19 "use_gpu_only_for_calibration":
True,
20 "weight_memory_method": 1,
24 "weight_dtype":
"weightDtype",
25 "use_gpu_only_for_calibration":
"useGPUOnlyForCalibration",
26 "weight_memory_method":
"weightMemoryMethod",
30 "weight_memory_method": [0, 4],
33 weight_memory_methods = [
44 use_gpu_only_for_calibration: bool,
45 weight_memory_method: int,
46 optional: bool = optional,
49 @brief Initialize the ResourceManagementConfig.
50 @param weight_dtype str. Weight data type for calibration (e.g., "float32", "float16").
51 @param use_gpu_only_for_calibration bool. If True, use GPU only during the calibration phase.
52 @param weight_memory_method int. Weight memory management method index.<br>
53 0: DeleteFloat - Delete float weights after quantization.<br>
54 1: SaveFloat - Save float weights to disk.<br>
55 2: MoveFloat - Move float weights to CPU.<br>
56 3: KeepFloat - Keep float weights in memory.<br>
57 4: KeepAll - Keep all weights in memory.<br>
58 @param optional bool. Indicates whether this config is optional. Use the default value defined as a class variable.
67 def default_config(cls):
71 def from_kwargs(cls, **kwargs):
73 updated_kwargs = dict()
76 updated_kwargs[key] = kwargs[key]
77 params[key] = kwargs[key]
80 return cls(**params, optional=cls.
optional)
83 f
"Please review the configuration kwargs passed to {cls.__name__}. These kwargs were updated and will be used: {updated_kwargs}"
88 """Create ResourceManagementConfig from dictionary (JSON structure)"""
91 if "weightDtype" in config_dict:
92 params[
"weight_dtype"] = config_dict[
"weightDtype"]
93 if "useGPUOnlyForCalibration" in config_dict:
94 params[
"use_gpu_only_for_calibration"] = config_dict[
95 "useGPUOnlyForCalibration"
98 if "weightMemory" in config_dict:
99 weight_memory = config_dict[
"weightMemory"]
100 if "method" in weight_memory:
101 params[
"weight_memory_method"] = weight_memory[
"method"]
107 "resourceManagement": {
120 @brief Create ResourceManagementConfig with partial parameters merged with defaults.
122 params = ResourceManagementConfig.DEFAULTS.copy()
123 params.update(kwargs)
125 **params, optional=ResourceManagementConfig.optional
Configuration for resource management during model compilation.
list weight_memory_methods
ResourceManagementConfig get_resource_management_config(**kwargs)
Create ResourceManagementConfig with partial parameters merged with defaults.
__init__(self, str weight_dtype, bool use_gpu_only_for_calibration, int weight_memory_method, bool optional=optional)
Initialize the ResourceManagementConfig.
use_gpu_only_for_calibration
from_dict(cls, dict config_dict)
Create ResourceManagementConfig from dictionary (JSON structure)