56 def __init__(self, scale: float, is_uniform: bool, scale_list: List[float]):
57 self.
_scale = _cMaccel.Scale()
59 self.
_scale.is_uniform = is_uniform
60 self.
_scale.scale_list = scale_list
63 def from_cpp(cls, _scale: _cMaccel.Scale):
64 return cls(_scale.scale, _scale.is_uniform, _scale.scale_list)
67 def scale_list(self) -> List[float]:
68 return self.
_scale.scale_list
71 def scale(self) -> float:
75 def is_uniform(self) -> bool:
76 return self.
_scale.is_uniform
79 def scale_list(self, value: List[float]):
80 self.
_scale.scale_list = value
83 def scale(self, value: float):
87 def is_uniform(self, value: bool):
88 self.
_scale.is_uniform = value
90 def __getitem__(self, i: int) -> float:
99 return "{}({})".format(
100 self.__class__.__name__,
101 ", ".join(
"{}={}".format(k, v)
for k, v
in d.items()),
176 original_height: int = 0,
177 original_width: int = 0,
178 original_channel: int = 0,
179 reshaped_height: int = 0,
180 reshaped_width: int = 0,
181 reshaped_channel: int = 0,
187 max_channel: int = 0,
188 max_cache_size: int = 0,
206 def from_cpp(cls, _buffer_info: _cMaccel.BufferInfo):
208 _buffer_info.original_height,
209 _buffer_info.original_width,
210 _buffer_info.original_channel,
211 _buffer_info.reshaped_height,
212 _buffer_info.reshaped_width,
213 _buffer_info.reshaped_channel,
216 _buffer_info.channel,
217 _buffer_info.max_height,
218 _buffer_info.max_width,
219 _buffer_info.max_channel,
220 _buffer_info.max_cache_size,
224 def original_height(self) -> int:
228 def original_width(self) -> int:
232 def original_channel(self) -> int:
236 def reshaped_height(self) -> int:
240 def reshaped_width(self) -> int:
244 def reshaped_channel(self) -> int:
248 def height(self) -> int:
252 def width(self) -> int:
256 def channel(self) -> int:
260 def max_height(self) -> int:
264 def max_width(self) -> int:
268 def max_channel(self) -> int:
272 def max_cache_size(self) -> int:
275 @original_height.setter
276 def original_height(self, value: int):
279 @original_width.setter
280 def original_width(self, value: int):
283 @original_channel.setter
284 def original_channel(self, value: int):
287 @reshaped_height.setter
288 def reshaped_height(self, value: int):
291 @reshaped_width.setter
292 def reshaped_width(self, value: int):
295 @reshaped_channel.setter
296 def reshaped_channel(self, value: int):
300 def height(self, value: int):
304 def width(self, value: int):
308 def channel(self, value: int):
312 def max_height(self, value: int):
316 def max_width(self, value: int):
320 def max_channel(self, value: int):
323 @max_cache_size.setter
324 def max_cache_size(self, value: int):
327 def original_size(self) -> int:
330 def reshaped_size(self) -> int:
333 def size(self) -> int:
336 def original_shape(self) -> Tuple[int, int, int]:
339 def original_shape_chw(self) -> Tuple[int, int, int]:
342 def reshaped_shape(self) -> Tuple[int, int, int]:
345 def reshaped_shape_chw(self) -> Tuple[int, int, int]:
348 def shape(self) -> Tuple[int, int, int]:
351 def shape_chw(self) -> Tuple[int, int, int]:
370 return "{}({})".format(
371 self.__class__.__name__,
372 ", ".join(
"{}={}".format(k, v)
for k, v
in d.items()),
377 def __init__(self, num_cores: Optional[int] =
None):
379 _cMaccel.ModelConfig()
381 else _cMaccel.ModelConfig(num_cores)
384 def include_all_cores(self) -> bool:
387 def exclude_all_cores(self) -> bool:
390 def include(self, cluster: Cluster, core: Optional[Core] =
None) -> bool:
396 def exclude(self, cluster: Cluster, core: Optional[Core] =
None) -> bool:
402 def set_single_core_mode(
403 self, num_cores: Optional[int] =
None, core_ids: Optional[List[CoreId]] =
None
405 if num_cores
is not None and core_ids
is None:
407 elif core_ids
is not None and num_cores
is None:
409 [core_id._core_id
for core_id
in core_ids]
412 "`set_single_core_mode` needs either `num_cores` and `core_ids`."
415 def set_global_core_mode(self, clusters: List[Cluster]) -> bool:
416 return self.
_model_config.set_global_core_mode([c.value
for c
in clusters])
418 def set_global4_core_mode(self, clusters: List[Cluster]) -> bool:
419 return self.
_model_config.set_global4_core_mode([c.value
for c
in clusters])
421 def set_global8_core_mode(self) -> bool:
424 def get_core_mode(self) -> CoreMode:
427 def set_multi_core_mode(self, clusters: List[Cluster]) -> bool:
428 return self.
_model_config.set_multi_core_mode([c.value
for c
in clusters])
430 def set_auto_mode(self, num_cores: int = 1) -> bool:
433 def set_manual_mode(self) -> bool:
436 def get_core_allocation_policy(self) -> CoreAllocationPolicy:
439 def get_num_cores(self) -> int:
442 def force_single_npu_bundle(self, npu_bundle_index: int) -> bool:
443 return self.
_model_config.force_single_npu_bundle(npu_bundle_index)
445 def get_forced_npu_bundle_index(self) -> bool:
448 def set_async_pipeline_enabled(self, enable: bool):
451 def get_async_pipeline_enabled(self) -> bool:
455 def schedule_policy(self) -> SchedulePolicy:
459 def latency_set_policy(self) -> LatencySetPolicy:
463 def maintenance_policy(self) -> MaintenancePolicy:
467 def early_latencies(self) -> List[int]:
471 def finish_latencies(self) -> List[int]:
474 @schedule_policy.setter
475 def schedule_policy(self, policy: SchedulePolicy):
478 @latency_set_policy.setter
479 def latency_set_policy(self, policy: LatencySetPolicy):
482 @maintenance_policy.setter
483 def maintenance_policy(self, policy: MaintenancePolicy):
486 @early_latencies.setter
487 def early_latencies(self, latencies: List[int]):
490 @finish_latencies.setter
491 def finish_latencies(self, latencies: List[int]):
494 def get_core_ids(self) -> List[CoreId]:
508 return "{}({})".format(
509 self.__class__.__name__,
510 ", ".join(
"{}={}".format(k, v)
for k, v
in d.items()),