How To Configure Pass
This document describes how to configure a Pass.
When configuring a Pass, the user can chose to set the values of parameters to their default value (no search), pre-defined search space (search for the best value from the possible options) or a combination of the two (fix some parameters to a certain value, default or user provided, and/or search for other parameters).
To fully configure a Pass, we need type and config.
type: This is the type of the Pass. Check out Passes for the full list of supported Passes.config: This is a dictionary of the config parameters and values. It must contain all required parameters. For optional parameters the default value or default searchable values can be overridden by providing user defined values. You can also assign the value for a specific parameter as"DEFAULT_VALUE"to use the default value or"SEARCHABLE_VALUES"to use the default searchable values (if available).
Let’s take the example of the OnnxQuantization Pass:
{
"type": "OnnxQuantization",
"data_config": "calib_data_config",
// set per_channel to "DEFAULT_VALUE"
"per_channel": "DEFAULT_VALUE",
// set reduce_range to "SEARCHABLE_VALUES" value
"reduce_range": "SEARCHABLE_VALUES",
// user defined value for weight_type
"weight_type": "QUInt8"
}
Note
type is case insensitive.
from olive.passes import OnnxQuantization
from olive.passes.olive_pass import create_pass_from_dict
onnx_quantization = create_pass_from_dict(OnnxQuantization,
config={
"data_config": "calib_data_config",
# set per_channel to "DEFAULT_VALUE" value
"per_channel": "DEFAULT_VALUE",
# set reduce_range to "SEARCHABLE_VALUES"
"reduce_range": "SEARCHABLE_VALUES"
# user defined value for weight_type
"weight_type": "QUInt8"
},
)