PyTorchCompressionEngine
CLASS - PyTorchCompressionEngine() :
Object that contains the Entry points to CLIKA Compression Engine.
Methods
deploy
deploy(
- clika_state_path:
Union[str, Path]
- output_dir_path:
Union[str, Path]
- file_suffix:
Optional[str]
= None- input_shapes:
Union[list, tuple, List[list], List[tuple], Tuple[tuple], Tuple[list], None]
= None- graph_author:
Optional[str]
= None- graph_description:
Optional[str]
= None- **kwargs:
dict
) ‑>
str
Deploy the CLIKA State to the Format specified when the CLIKA state was created.
Parameters:
- clika_state_path (
Union[str, Path]
) - Path to the CLIKA state directory or file - output_dir_path (
Union[str, Path]
) - Where to save the generated Model file - file_suffix (
Optional[str]
) - Any string to prepend to the filename - input_shapes (
Optional[Union[list, tuple, List[list], List[tuple], Tuple[tuple], Tuple[list]]]
) - Sequence or Sequence of Sequences that indicate the Input shape of the resulting Model. In the case of a single input model, you could pass tuple or a list such as: (1, 3, 224, 224) In-case of a multiple-input model, you could pass [(1, 3, 224, 224), (1, 3, 120)] corresponding to the input shapes that your model takes. A 'None' value represents dynamic shape. - graph_author (
Optional[str]
) - Optional string to specify who created the Graph for the Model on the resulting File - graph_description (
Optional[str]
) - Optional string to specify Description for the Model on the resulting File - kwargs (
Optional[dict]
) - Not used at the moment.
Returns:
str
: Path to the deployed Model
optimize
optimize(
- output_path:
Union[str, Path]
- settings:
Settings
- model:
object
- init_training_dataset_fn:
Callable[[], Any]
- init_evaluation_dataset_fn:
Optional[Callable[[], Any]]
- optimizer:
object
- training_losses:
dict
- training_metrics:
Optional[dict]
= None- evaluation_losses:
Optional[dict]
= None- evaluation_metrics:
Optional[dict]
= None- callbacks:
Optional[List[BaseCallback]]
= None- **kwargs:
dict
) ‑>
str
Entry point for running Compression.
Parameters:
- output_path (
str/Path
) - Path to save the files being generated by the library - settings (
Settings
) - Settings that contains all the necessary information to run the model - model (
torch.nn.Module
) - torch nn Module - init_training_dataset_fn (
Callable[[], Any]
) - Pointer to a function that initializes the Dataloaders - init_evaluation_dataset_fn (
Optional[Callable[[], Any]]
) - Pointer to a function that initializes the Dataloaders - optimizer (
torch.optim.Optimizer
) - Optimizer object. In PyTorch it's an object from: torch.optim... When Resuming, 'optimizer' can be set to None unless it is a custom Optimizer. - training_losses (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Loss Object used for Training. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - training_metrics (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Metric Object used for Training. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - evaluation_losses (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Loss Object used for Evaluation. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - evaluation_metrics (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Metric Object used for Evaluation. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - callbacks (
List[BaseCallback]
) - Callbacks that will be called during compression to update the status of it. - kwargs (
Optional[dict]
) - Not used at the moment
Returns:
str
: Path to the latest CLIKA state
resume
resume(
- clika_state_path:
Union[str, Path]
- init_training_dataset_fn:
Callable[[], Any]
- init_evaluation_dataset_fn:
Optional[Callable[[], Any]]
- optimizer:
Optional[object]
= None- training_losses:
dict
- training_metrics:
Optional[dict]
= None- evaluation_losses:
Optional[dict]
= None- evaluation_metrics:
Optional[dict]
= None- callbacks:
Optional[List[BaseCallback]]
= None- new_settings:
Optional[Settings]
= None- resume_start_epoch:
Optional[int]
= None- **kwargs:
dict
) ‑>
str
Resumes a Compression Job from Given path. This can be used to fine-tune the model using more Data or just resume a run that had to be stopped. This can be used to finetune on more Data or just resume a run that had to be stopped.
Parameters:
- clika_state_path (
Union[str, Path]
) - Path to the CLIKA state directory or file - init_training_dataset_fn (
Callable[[], Any]
) - Pointer to a function that initializes the Dataloaders - init_evaluation_dataset_fn (
Optional[Callable[[], Any]]
) - Pointer to a function that initializes the Dataloaders - optimizer (
torch.optim.Optimizer
) - Optimizer object. In PyTorch it's an object from: torch.optim... When Resuming, 'optimizer' can be set to None unless it is a custom Optimizer. - training_losses (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Loss Object used for Training. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - training_metrics (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Metric Object used for Training. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - evaluation_losses (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Loss Object used for Evaluation. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - evaluation_metrics (
Dict[str, Callable]
) - Dictionary mapping between a Name to a Metric Object used for Evaluation. Can be a function that accepts (preds, target) or a Metric that implements an interface like torchmetrics. - callbacks (
List[BaseCallback]
) - Callbacks that will be called during compression to update the status of it. - multi_gpu (
bool
) - whether or not to do Multi-GPU compression - new_settings (
Settings
) - object to use for the Compression Run.TrainingSettings
andDeploymentSettings
will be updated with this. - resume_start_epoch (
Optional[int]
) - Will override the Epoch present in the CLIKA State directory at Path. - kwargs (
Optional[dict]
) - Unsupported for now.
Returns:
str
: Path to latest CLIKA State path