| 54 | |
| 55 | |
| 56 | class KernelRegistryStatistics: |
| 57 | def __init__(self): |
| 58 | self.num_ops_for_dtypes = { |
| 59 | "all": 0, |
| 60 | "float32": 0, |
| 61 | "float16": 0, |
| 62 | "bfloat16": 0, |
| 63 | } |
| 64 | |
| 65 | def update(self, supported_dtypes): |
| 66 | for dtype in supported_dtypes: |
| 67 | if dtype in self.num_ops_for_dtypes.keys(): |
| 68 | self.num_ops_for_dtypes[dtype] += 1 |
| 69 | elif dtype == "float": |
| 70 | self.num_ops_for_dtypes["float32"] += 1 |
| 71 | self.num_ops_for_dtypes["all"] += 1 |
| 72 | |
| 73 | def __str__(self): |
| 74 | res = "{ " |
| 75 | num_floats = int(self.num_ops_for_dtypes["float32"]) |
| 76 | for dtype, num in self.num_ops_for_dtypes.items(): |
| 77 | res += f"{dtype}: {num:4d}" |
| 78 | if dtype in ["float16", "bfloat16"]: |
| 79 | if num_floats != 0: |
| 80 | percent = float(self.num_ops_for_dtypes[dtype]) / float( |
| 81 | num_floats |
| 82 | ) |
| 83 | res += f"({percent * 100:.2f}%)" |
| 84 | else: |
| 85 | res += f"({0:.2f}%)" |
| 86 | res += " " |
| 87 | res += "}" |
| 88 | return res |
| 89 | |
| 90 | |
| 91 | def parse_paddle_kernels(lib="phi", kernel_type="function", print_detail=False): |
no outgoing calls
no test coverage detected