neural_compressor.utils.create_obj_from_config
¶
Utility methods to create corresponding objects from configuration.
Module Contents¶
Functions¶
|
Get the function or the composed function from configuration. |
|
Get the preprocess function from configuration. |
|
Get the metrics function from configuration. |
|
Get the postprocess function from configuration. |
|
Get the algorithms from configuration. |
|
Create the dataset from the data source. |
|
Create the dataloader according to the framework. |
|
The interface to create evaluate function from config. |
|
The interface to create train function from config. |
- neural_compressor.utils.create_obj_from_config.get_func_from_config(func_dict, cfg, compose=True)¶
Get the function or the composed function from configuration.
- neural_compressor.utils.create_obj_from_config.get_preprocess(preprocesses, cfg, compose=True)¶
Get the preprocess function from configuration.
- neural_compressor.utils.create_obj_from_config.get_metrics(metrics, cfg, compose=True)¶
Get the metrics function from configuration.
- neural_compressor.utils.create_obj_from_config.get_postprocess(postprocesses, cfg, compose=True)¶
Get the postprocess function from configuration.
- neural_compressor.utils.create_obj_from_config.get_algorithm(algorithms, cfg, compose=False)¶
Get the algorithms from configuration.
- neural_compressor.utils.create_obj_from_config.create_dataset(framework, data_source, cfg_preprocess, cfg_filter)¶
Create the dataset from the data source.
- neural_compressor.utils.create_obj_from_config.create_dataloader(framework, dataloader_cfg)¶
Create the dataloader according to the framework.
- neural_compressor.utils.create_obj_from_config.create_eval_func(framework, dataloader, adaptor, metric, postprocess_cfg=None, iteration=-1, tensorboard=False, fp32_baseline=False)¶
The interface to create evaluate function from config.
- Parameters:
framework (str) – The string of framework.
dataloader (common.DataLoader) – The object of common.DataLoader.
adaptor (obj) – The object of adaptor.
metric – The evaluation metric.
postprocess_cfg – The postprocess configuration.
iteration – The number of iterations to evaluate.
tensorboard – Whether to use tensorboard.
fp32_baseline – The fp32 baseline score.
- Returns:
The constructed evaluation function
- neural_compressor.utils.create_obj_from_config.create_train_func(framework, dataloader, adaptor, train_cfg, hooks=None, callbacks=None)¶
The interface to create train function from config.
- Parameters:
framework (str) – The string of framework.
dataloader (common.DataLoader) – The object of common.DataLoader.
adaptor (obj) – The object of adaptor.
train_cfg (dict) – The dict of training related config.
hooks (dict) – The dict of training hooks, supported keys are: on_epoch_begin, on_epoch_end, on_step_begin, on_step_end. Their values are functions to be executed in adaptor layer.
- Returns:
The constructed train function