maccel.model.Model Class Reference

maccel.model.Model Class Reference#

SDK qb Runtime Library: maccel.model.Model Class Reference
SDK qb Runtime Library v0.29
MCS001-KR

Public Member Functions

 __init__ (self, str path, Optional[ModelConfig] model_config=None)
None launch (self, Accelerator acc)
None dispose (self)
bool is_target (self, CoreId core_id)
CoreMode get_core_mode (self)
List[CoreIdget_target_cores (self)
List[CoreIdtarget_cores (self)
Optional[List[np.ndarray]] infer (self, Union[np.ndarray, List[np.ndarray]] inputs, Optional[List[np.ndarray]] outputs=None, int cache_size=0)
List[np.ndarray] infer_to_float (self, Union[np.ndarray, List[np.ndarray],] inputs, int cache_size=0)
None infer_buffer (self, List[Buffer] inputs, List[Buffer] outputs, List[List[int]] shape=[], int cache_size=0)
None infer_speedrun (self)
Future infer_async (self, Union[np.ndarray, List[np.ndarray]] inputs)
None reposition_inputs (self, List[np.ndarray] inputs, List[Buffer] input_bufs, List[List[int]] seqlens=[])
None reposition_outputs (self, List[Buffer] output_bufs, List[np.ndarray] outputs, List[List[int]] seqlens=[])
int get_num_model_variants (self)
ModelVariantHandle get_model_variant_handle (self, variant_idx)
List[_Shape] get_model_input_shape (self)
List[_Shape] get_model_output_shape (self)
List[Scaleget_input_scale (self)
List[Scaleget_output_scale (self)
List[BufferInfoget_input_buffer_info (self)
List[BufferInfoget_output_buffer_info (self)
List[Bufferacquire_input_buffer (self, List[List[int]] seqlens=[])
List[Bufferacquire_output_buffer (self, List[List[int]] seqlens=[])
None release_buffer (self, List[Buffer] buffer)
int get_identifier (self)
str get_model_path (self)
List[CacheInfoget_cache_infos (self)
SchedulePolicy get_schedule_policy (self)
LatencySetPolicy get_latency_set_policy (self)
MaintenancePolicy get_maintenance_policy (self)
int get_latency_consumed (self)
int get_latency_finished (self)
None reset_cache_memory (self)
List[bytes] dump_cache_memory (self)
None load_cache_memory (self, List[bytes] bufs)
None dump_cache_memory_to (self, str cache_dir)
None load_cache_memory_from (self, str cache_dir)
int filter_cache_tail (self, int cache_size, int tail_size, List[bool] mask)
int move_cache_tail (self, int num_head, int num_tail, int cache_size)

Static Public Attributes

Optional[List[np.ndarray]] infer_chw = infer
List[np.ndarray] infer_chw_to_float = infer_to_float

Protected Attributes

 _model = _cMaccel.Model(path)
List[_Shape] _input_shape = self.get_model_input_shape()
List[_Shape] _output_shape = self.get_model_output_shape()
 _acc = acc

Detailed Description

Definition at line 108 of file model.py.

Constructor & Destructor Documentation

◆ __init__()

maccel.model.Model.__init__ ( self,
str path,
Optional[ModelConfig] model_config = None )

Definition at line 109 of file model.py.

Member Function Documentation

◆ launch()

None maccel.model.Model.launch ( self,
Accelerator acc )

Definition at line 120 of file model.py.

◆ dispose()

None maccel.model.Model.dispose ( self)

Definition at line 124 of file model.py.

◆ is_target()

bool maccel.model.Model.is_target ( self,
CoreId core_id )

Definition at line 128 of file model.py.

◆ get_core_mode()

CoreMode maccel.model.Model.get_core_mode ( self)

Definition at line 131 of file model.py.

◆ get_target_cores()

List[CoreId] maccel.model.Model.get_target_cores ( self)

Definition at line 134 of file model.py.

◆ target_cores()

List[CoreId] maccel.model.Model.target_cores ( self)

Definition at line 139 of file model.py.

◆ infer()

Optional[List[np.ndarray]] maccel.model.Model.infer ( self,
Union[np.ndarray, List[np.ndarray]] inputs,
Optional[List[np.ndarray]] outputs = None,
int cache_size = 0 )

Definition at line 148 of file model.py.

◆ infer_to_float()

List[np.ndarray] maccel.model.Model.infer_to_float ( self,
Union[ np.ndarray, List[np.ndarray], ] inputs,
int cache_size = 0 )

Definition at line 187 of file model.py.

◆ infer_buffer()

None maccel.model.Model.infer_buffer ( self,
List[Buffer] inputs,
List[Buffer] outputs,
List[List[int]] shape = [],
int cache_size = 0 )

Definition at line 212 of file model.py.

◆ infer_speedrun()

None maccel.model.Model.infer_speedrun ( self)

Definition at line 223 of file model.py.

◆ infer_async()

Future maccel.model.Model.infer_async ( self,
Union[np.ndarray, List[np.ndarray]] inputs )

Definition at line 226 of file model.py.

◆ reposition_inputs()

None maccel.model.Model.reposition_inputs ( self,
List[np.ndarray] inputs,
List[Buffer] input_bufs,
List[List[int]] seqlens = [] )

Definition at line 239 of file model.py.

◆ reposition_outputs()

None maccel.model.Model.reposition_outputs ( self,
List[Buffer] output_bufs,
List[np.ndarray] outputs,
List[List[int]] seqlens = [] )

Definition at line 250 of file model.py.

◆ get_num_model_variants()

int maccel.model.Model.get_num_model_variants ( self)

Definition at line 267 of file model.py.

◆ get_model_variant_handle()

ModelVariantHandle maccel.model.Model.get_model_variant_handle ( self,
variant_idx )

Definition at line 270 of file model.py.

◆ get_model_input_shape()

List[_Shape] maccel.model.Model.get_model_input_shape ( self)

Definition at line 275 of file model.py.

◆ get_model_output_shape()

List[_Shape] maccel.model.Model.get_model_output_shape ( self)

Definition at line 278 of file model.py.

◆ get_input_scale()

List[Scale] maccel.model.Model.get_input_scale ( self)

Definition at line 281 of file model.py.

◆ get_output_scale()

List[Scale] maccel.model.Model.get_output_scale ( self)

Definition at line 284 of file model.py.

◆ get_input_buffer_info()

List[BufferInfo] maccel.model.Model.get_input_buffer_info ( self)

Definition at line 287 of file model.py.

◆ get_output_buffer_info()

List[BufferInfo] maccel.model.Model.get_output_buffer_info ( self)

Definition at line 290 of file model.py.

◆ acquire_input_buffer()

List[Buffer] maccel.model.Model.acquire_input_buffer ( self,
List[List[int]] seqlens = [] )

Definition at line 293 of file model.py.

◆ acquire_output_buffer()

List[Buffer] maccel.model.Model.acquire_output_buffer ( self,
List[List[int]] seqlens = [] )

Definition at line 296 of file model.py.

◆ release_buffer()

None maccel.model.Model.release_buffer ( self,
List[Buffer] buffer )

Definition at line 299 of file model.py.

◆ get_identifier()

int maccel.model.Model.get_identifier ( self)

Definition at line 302 of file model.py.

◆ get_model_path()

str maccel.model.Model.get_model_path ( self)

Definition at line 305 of file model.py.

◆ get_cache_infos()

List[CacheInfo] maccel.model.Model.get_cache_infos ( self)

Definition at line 308 of file model.py.

◆ get_schedule_policy()

SchedulePolicy maccel.model.Model.get_schedule_policy ( self)

Definition at line 311 of file model.py.

◆ get_latency_set_policy()

LatencySetPolicy maccel.model.Model.get_latency_set_policy ( self)

Definition at line 314 of file model.py.

◆ get_maintenance_policy()

MaintenancePolicy maccel.model.Model.get_maintenance_policy ( self)

Definition at line 317 of file model.py.

◆ get_latency_consumed()

int maccel.model.Model.get_latency_consumed ( self)

Definition at line 320 of file model.py.

◆ get_latency_finished()

int maccel.model.Model.get_latency_finished ( self)

Definition at line 323 of file model.py.

◆ reset_cache_memory()

None maccel.model.Model.reset_cache_memory ( self)

Definition at line 326 of file model.py.

◆ dump_cache_memory()

List[bytes] maccel.model.Model.dump_cache_memory ( self)

Definition at line 329 of file model.py.

◆ load_cache_memory()

None maccel.model.Model.load_cache_memory ( self,
List[bytes] bufs )

Definition at line 333 of file model.py.

◆ dump_cache_memory_to()

None maccel.model.Model.dump_cache_memory_to ( self,
str cache_dir )

Definition at line 338 of file model.py.

◆ load_cache_memory_from()

None maccel.model.Model.load_cache_memory_from ( self,
str cache_dir )

Definition at line 341 of file model.py.

◆ filter_cache_tail()

int maccel.model.Model.filter_cache_tail ( self,
int cache_size,
int tail_size,
List[bool] mask )

Definition at line 344 of file model.py.

◆ move_cache_tail()

int maccel.model.Model.move_cache_tail ( self,
int num_head,
int num_tail,
int cache_size )

Definition at line 349 of file model.py.

Member Data Documentation

◆ infer_chw

Optional[List[np.ndarray]] maccel.model.Model.infer_chw = infer
static

Definition at line 209 of file model.py.

◆ infer_chw_to_float

List[np.ndarray] maccel.model.Model.infer_chw_to_float = infer_to_float
static

Definition at line 210 of file model.py.

◆ _model

maccel.model.Model._model = _cMaccel.Model(path)
protected

Definition at line 111 of file model.py.

◆ _input_shape

List[_Shape] maccel.model.Model._input_shape = self.get_model_input_shape()
protected

Definition at line 117 of file model.py.

◆ _output_shape

List[_Shape] maccel.model.Model._output_shape = self.get_model_output_shape()
protected

Definition at line 118 of file model.py.

◆ _acc

maccel.model.Model._acc = acc
protected

Definition at line 122 of file model.py.


The documentation for this class was generated from the following file: