Package
model_navigator.package.package
Package module - structure to snapshot optimization result.
Package
Class for storing pipeline execution status.
Initialize object.
Parameters:
-
status
(Status
) –A navigator execution status
-
workspace
(Workspace
) –Workspace for package files
-
model
(Optional[object]
, default:None
) –An optional model
Source code in model_navigator/package/package.py
config
property
Generate configuration from package.
Returns:
-
CommonConfig
–The configuration object
framework
property
Framework for which package was created.
Returns:
-
Framework
–Framework object for package
_create_status_file
Create a status.yaml file for package.
Source code in model_navigator/package/package.py
_delete_status_file
_get_custom_configs
Build custom configs from config data.
Parameters:
-
custom_configs
(Dict[str, Union[Dict, CustomConfigForFormat]]
) –Dictionary with custom configs data
Returns:
-
Dict
–List with mapped objects
Source code in model_navigator/package/package.py
_get_runner
Load runner.
Parameters:
-
model_key
(str
) –Unique key of the model.
-
runner_name
(str
) –Name of the runner.
-
return_type
(TensorType
) –Type of the runner output.
-
device
(str
) –Device on which the model has been executed
-
inplace
(bool
, default:False
) –Indicate if runner is in inplace mode.
-
runner_config
(Optional[RunnerConfig]
, default:None
) –Runner configuration.
Returns:
-
NavigatorRunner
–NavigatorRunner object
Source code in model_navigator/package/package.py
_status_serializable_dict
Convert status to serializable dict.
Source code in model_navigator/package/package.py
get_best_model_status
Returns ModelStatus of best model for given strategy.
Parameters:
-
strategies
(Optional[List[RuntimeSearchStrategy]]
, default:None
) –List of strategies for finding the best model. Strategies are selected in provided order. When first fails, next strategy from the list is used. When no strategies have been provided it defaults to [
MaxThroughputAndMinLatencyStrategy
,MinLatencyStrategy
] -
include_source
(bool
, default:True
) –Flag if Python based model has to be included in analysis
Returns:
-
ModelStatus
–ModelStatus of best model for given strategy or None.
Source code in model_navigator/package/package.py
get_best_runtime
Returns best runtime for given strategy.
Parameters:
-
strategies
(Optional[List[RuntimeSearchStrategy]]
, default:None
) –List of strategies for finding the best model. Strategies are selected in provided order. When first fails, next strategy from the list is used. When no strategies have been provided it defaults to [
MaxThroughputAndMinLatencyStrategy
,MinLatencyStrategy
] -
include_source
(bool
, default:True
) –Flag if Python based model has to be included in analysis
-
inplace
(bool
, default:False
) –should only inplace supported runners be included in analysis
Returns:
-
–
Best runtime for given strategy.
Source code in model_navigator/package/package.py
get_model_path
Return path of the model.
Parameters:
-
model_key
(str
) –Unique key of the model.
Raises:
-
ModelNavigatorNotFoundError
–When model not found.
Returns:
-
Path
(Path
) –model path
Source code in model_navigator/package/package.py
get_runner
Get the runner according to the strategy.
Parameters:
-
strategies
(Optional[List[RuntimeSearchStrategy]]
, default:None
) –List of strategies for finding the best model. Strategies are selected in provided order. When first fails, next strategy from the list is used. When no strategies have been provided it defaults to [
MaxThroughputAndMinLatencyStrategy
,MinLatencyStrategy
] -
include_source
(bool
, default:True
) –Flag if Python based model has to be included in analysis
-
return_type
(TensorType
, default:NUMPY
) –The type of the output tensor. Defaults to
TensorType.NUMPY
. If the return_type supports CUDA tensors (e.g. TensorType.TORCH) and the input tensors are on CUDA, there will be no additional data transfer between CPU and GPU. -
device
(str
, default:'cuda'
) –Device where model is going to be executed. Defaults to
"cuda"
. -
inplace
(bool
, default:False
) –Indicate that runner is in inplace mode.
Returns:
-
NavigatorRunner
–The optimal runner for the optimized model.
Source code in model_navigator/package/package.py
is_empty
Validate if package is empty - no models were produced.
Returns:
-
bool
–True if empty package, False otherwise.
Source code in model_navigator/package/package.py
load_source_model
Load model defined in Python code.
Parameters:
-
model
(object
) –A model object