Measure the quantization error of each operation A dictionary contains output differences for all operation will be returned as a result. Result is like: {'operation name 1': 0.933, 'operation name 2': 0.926} if verbose is set as True, this function will display error report at las
(
graph: BaseGraph,
dataloader: Iterable,
interested_outputs: Union[str, List[str]] = None,
collate_fn: Callable = None,
running_device='cuda',
method: str = 'snr',
steps: int = 8,
verbose: bool = True,
)
| 13 | |
| 14 | |
| 15 | def layerwise_error_analyse( |
| 16 | graph: BaseGraph, |
| 17 | dataloader: Iterable, |
| 18 | interested_outputs: Union[str, List[str]] = None, |
| 19 | collate_fn: Callable = None, |
| 20 | running_device='cuda', |
| 21 | method: str = 'snr', |
| 22 | steps: int = 8, |
| 23 | verbose: bool = True, |
| 24 | ) -> Dict[str, tuple]: |
| 25 | |
| 26 | """Measure the quantization error of each operation A dictionary contains |
| 27 | output differences for all operation will be returned as a result. |
| 28 | |
| 29 | Result is like: {'operation name 1': 0.933, 'operation name 2': 0.926} |
| 30 | |
| 31 | if verbose is set as True, this function will display error report at last. |
| 32 | |
| 33 | The key of the dictionary is an operation name while the value of corresponding key |
| 34 | is the difference between quantized output and float output of this operation. |
| 35 | |
| 36 | Result {'operation name 1': 0.933} means quantizing operation 1 |
| 37 | will generates 0.933 quantization error to output variable |
| 38 | |
| 39 | ATTENTION: Output difference is measured at operation-level. |
| 40 | |
| 41 | Args: |
| 42 | graph (BaseGraph): |
| 43 | A fully quantized graph instance. |
| 44 | |
| 45 | running_device (str): |
| 46 | A device string used to initialize a graph executor for the graph execution. |
| 47 | if a executor was given, this parameter will be skipped. |
| 48 | |
| 49 | dataloader (Iterator): |
| 50 | Test dataloader, this function will measure quantization error based on given data. |
| 51 | |
| 52 | collate_fn (Callable, optional): |
| 53 | An data preprocessing function provided by user to convert data from dataloader towards |
| 54 | executable format. If set as None, then no action will be taken during preprocessing. |
| 55 | |
| 56 | method (str, optional): |
| 57 | A string indicates a measurement to calculate the difference of quantized output and fp32 one. |
| 58 | 'cosine', 'snr', and 'mse' is supported in PPQ for now. |
| 59 | |
| 60 | steps (Int, optional) |
| 61 | computation steps. |
| 62 | |
| 63 | interested_outputs (Union[str, List[str]] = None) |
| 64 | a list contains your interested output variables. |
| 65 | if set as None, all graph output variables will be measured via this function. |
| 66 | |
| 67 | Returns: |
| 68 | A dictionary contains output differences for all operation will be returned from this function. |
| 69 | |
| 70 | Result is like: {'operation name 1': 0.933, 'operation name 2': 0.926} |
| 71 | """ |
| 72 |
no test coverage detected