Python
model_navigator.api.python
Python optimize API.
optimize(model, dataloader, sample_count=DEFAULT_SAMPLE_COUNT, batching=True, target_device=DeviceKind.CPU, runners=None, profiler_config=None, workspace=None, verbose=False, debug=False, verify_func=None, custom_configs=None)
Entrypoint for Python model optimize.
Perform correctness testing, profiling and model verification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Callable
|
Model inference function |
required |
dataloader |
SizedDataLoader
|
Sized iterable with data that will be feed to the model |
required |
sample_count |
int
|
Limits how many samples will be used from dataloader |
DEFAULT_SAMPLE_COUNT
|
batching |
Optional[bool]
|
Enable or disable batching on first (index 0) dimension of the model |
True
|
target_device |
Optional[DeviceKind]
|
Target device for optimize process, default is CPU |
DeviceKind.CPU
|
runners |
Optional[Union[Union[str, Type[NavigatorRunner]], Tuple[Union[str, Type[NavigatorRunner]], ...]]]
|
Use only runners provided as paramter |
None
|
profiler_config |
Optional[ProfilerConfig]
|
Profiling config |
None
|
workspace |
Optional[Path]
|
Workspace where packages will be extracted |
None
|
verbose |
bool
|
Enable verbose logging |
False
|
debug |
bool
|
Enable debug logging from commands |
False
|
verify_func |
Optional[VerifyFunction]
|
Function for additional model verifcation |
None
|
custom_configs |
Optional[Sequence[CustomConfig]]
|
Sequence of CustomConfigs used to control produced artifacts |
None
|
Returns:
Type | Description |
---|---|
Package
|
Package descriptor representing created package. |