(model, cal_dataset, chunk_idx: str)
| 309 | |
| 310 | |
| 311 | def calibrate_model(model, cal_dataset, chunk_idx: str): |
| 312 | with torch.no_grad(): |
| 313 | for inp in tqdm(cal_dataset, desc="Calibrating Model: "): |
| 314 | # pass prompt and response |
| 315 | for batch in tqdm(inp[chunk_idx].keys(), desc="Batch: "): |
| 316 | if inp[chunk_idx][batch] is not None: |
| 317 | inputs_embeds = torch.tensor(inp[chunk_idx][batch]["hidden_state"]) |
| 318 | mask = torch.tensor(inp[chunk_idx][batch]["mask"]) |
| 319 | pos_emb = torch.tensor(inp[chunk_idx][batch]["pos_emb"]) |
| 320 | cache = torch.tensor(inp[chunk_idx][batch]["cache"]) |
| 321 | model(inputs_embeds, mask, pos_emb, *torch.split(cache, 1, dim=0)) |
| 322 | |
| 323 | |
| 324 | def export_to_et_ir( |
no test coverage detected