Configuring 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 require three things: type, default_to_search, and config.

  • type: This is the type of the Pass. Check out Passes for the full list of supported Passes.

  • default_to_search: This decides whether to use the default value (default_to_search=False) or the default search space, if any, (default_to_search=True) for the optional parameters. This is False by default.

  • 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 search space (dependending on whether default_to_search is False or True) can be overridden by providing user defined values. You can also assign the value for a specific parameter as "DEFAULT" to use the default value or "DEFAULT_SEARCH" to use the default search values (if available).

Let’s take the example of the OnnxQuantization Pass:

{
    "type": "OnnxQuantization",
    "default_to_search": true,
    "config": {
        "user_script": "./user_script.py",
        "dataloader_func": "glue_calibration_reader",
        // set per_channel to "DEFAULT" value
        "per_channel": "DEFAULT",
        // set reduce_range to "DEFAULT_SEARCH" value
        // redundant since default_to_search is true
        "reduce_range": "DEFAULT_SEARCH",
        // user defined value for weight_type
        "weight_type": "QUInt8"
    }
}

Note

type is case insensitive.