(module, inputs, outputs)
| 222 | |
| 223 | |
| 224 | def get_op_stats(module, inputs, outputs): |
| 225 | if not isinstance(outputs, tuple) and not isinstance(outputs, list): |
| 226 | outputs = (outputs,) |
| 227 | rst = { |
| 228 | "input_shapes": [i.shape for i in inputs], |
| 229 | "output_shapes": [o.shape for o in outputs], |
| 230 | } |
| 231 | valid_flag = False |
| 232 | for key, _dict, fallback in _iter_list: |
| 233 | for _type in _dict: |
| 234 | if isinstance(module, _type): |
| 235 | value = _dict[_type](module, inputs, outputs) |
| 236 | valid_flag = True |
| 237 | break |
| 238 | else: |
| 239 | if fallback is not None: |
| 240 | value = fallback(module, inputs, outputs) |
| 241 | continue |
| 242 | |
| 243 | if isinstance(key, tuple): |
| 244 | assert isinstance(value, tuple) |
| 245 | for k, v in zip(key, value): |
| 246 | rst[k] = v |
| 247 | else: |
| 248 | rst[key] = value |
| 249 | |
| 250 | if valid_flag: |
| 251 | return rst |
| 252 | else: |
| 253 | return None |
| 254 | return |
| 255 | |
| 256 | |
| 257 | def sum_op_stats(flops, bar_length_max=20): |
no outgoing calls
no test coverage detected