Adds model/cache size info and optionally config info to results.
(config, results, model_size, cache_size, num_model_params, incl_config=False)
| 207 | |
| 208 | |
| 209 | def collate_results(config, results, model_size, cache_size, num_model_params, incl_config=False): |
| 210 | """Adds model/cache size info and optionally config info to results.""" |
| 211 | results["sizes"] = { |
| 212 | "model_size_in_gb": model_size / 1e9, |
| 213 | "cache_size_in_gb": cache_size / 1e9, |
| 214 | "model_params_in_billions": num_model_params / 1e9, |
| 215 | } |
| 216 | if incl_config: |
| 217 | results["config"] = {} |
| 218 | for k, v in dict(config.get_keys()).items(): |
| 219 | results["config"][k] = str(v) if k == "dtype" else v # json fails with original dtype |
| 220 | return results |
| 221 | |
| 222 | |
| 223 | def flatten_dict(dictionary, prefix="", sep="_"): |
no test coverage detected