Utility to update the "rmin" and "rmax" values in activation stats dictionary.
(
tensor_name: str,
tensor_value: Union[int, float],
activation_stats_dict: Dict[str, Dict[str, float]],
)
| 858 | |
| 859 | |
| 860 | def _update_tensor_range( |
| 861 | tensor_name: str, |
| 862 | tensor_value: Union[int, float], |
| 863 | activation_stats_dict: Dict[str, Dict[str, float]], |
| 864 | ) -> None: |
| 865 | """ |
| 866 | Utility to update the "rmin" and "rmax" values in activation stats dictionary. |
| 867 | """ |
| 868 | tensor_min = np.min(np.array(tensor_value).flatten()) |
| 869 | tensor_max = np.max(np.array(tensor_value).flatten()) |
| 870 | activation_stats_dict[tensor_name]["rmin"] = tensor_min |
| 871 | activation_stats_dict[tensor_name]["rmax"] = tensor_max |
| 872 | if tensor_name in activation_stats_dict: |
| 873 | activation_stats_dict[tensor_name]["rmin"] = min( |
| 874 | tensor_min, activation_stats_dict[tensor_name]["rmin"] |
| 875 | ) |
| 876 | activation_stats_dict[tensor_name]["rmax"] = max( |
| 877 | tensor_max, activation_stats_dict[tensor_name]["rmax"] |
| 878 | ) |
| 879 | else: |
| 880 | activation_stats_dict[tensor_name]["rmin"] = tensor_min |
| 881 | activation_stats_dict[tensor_name]["rmax"] = tensor_max |
| 882 | |
| 883 | |
| 884 | def _combine_lists_with_common_elements(data: List[List[str]]) -> List[List[str]]: |