Python
model_navigator.python
Python optimize API.
optimize
optimize(
model,
dataloader,
sample_count=DEFAULT_SAMPLE_COUNT,
batching=True,
target_device=CPU,
runners=None,
optimization_profile=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:
-
model
(Callable
) –Model inference function
-
dataloader
(SizedDataLoader
) –Sized iterable with data that will be feed to the model
-
sample_count
(int
, default:DEFAULT_SAMPLE_COUNT
) –Limits how many samples will be used from dataloader
-
batching
(Optional[bool]
, default:True
) –Enable or disable batching on first (index 0) dimension of the model
-
target_device
(Optional[DeviceKind]
, default:CPU
) –Target device for optimize process, default is CPU
-
runners
(Optional[Tuple[Union[str, Type[NavigatorRunner]], ...]]
, default:None
) –Use only runners provided as parameter
-
optimization_profile
(Optional[OptimizationProfile]
, default:None
) –Optimization profile for conversion and profiling
-
workspace
(Optional[Path]
, default:None
) –Workspace where packages will be extracted
-
verbose
(bool
, default:False
) –Enable verbose logging
-
debug
(bool
, default:False
) –Enable debug logging from commands
-
verify_func
(Optional[VerifyFunction]
, default:None
) –Function for additional model verification
-
custom_configs
(Optional[Sequence[CustomConfig]]
, default:None
) –Sequence of CustomConfigs used to control produced artifacts
Returns:
-
Package
–Package descriptor representing created package.