Postprocessing Functions

Module: polygraphy.tools.args

class ComparatorPostprocessArgs[source]

Bases: BaseArgs

Comparator Postprocessing: applying postprocessing to outputs.

parse_impl(args)[source]

Parses command-line arguments and populates the following attributes:

postprocess

Maps output names to Top-K parameters. Each value is an integer K (top-K along the last axis) or a (K, axis) tuple. For example:

{"output1": 5, "output2": (3, 1)}
Type:

Dict[str, Union[int, Tuple[int, int]]]

postprocess_func_script

Path to a script defining a custom postprocessing function.

Type:

str

postprocess_func_name

The name of the function in the script that performs postprocessing.

Type:

str

make_postprocess_func(script)[source]

Builds an invocation of the configured postprocessing function.

Returns:

An invocation of the postprocessing function (a Callable(IterationResult) -> IterationResult), or None if no postprocessing was configured.

Return type:

Optional[str]

add_to_script_impl(script, results_name)[source]
Parameters:

results_name (str) – The name of the variable containing results from Comparator.run().

Returns:

The name of the variable containing the post-processed results. This could be the same as the original name.

Return type:

str