MCPcopy Create free account
hub / github.com/ali-vilab/ACE_plus / FormalACEPlusSolver

Class FormalACEPlusSolver

modules/ace_plus_solver.py:12–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10from tqdm import tqdm
11@SOLVERS.register_class()
12class FormalACEPlusSolver(LatentDiffusionSolver):
13 def __init__(self, cfg, logger=None):
14 super().__init__(cfg, logger=logger)
15 self.probe_prompt = cfg.get("PROBE_PROMPT", None)
16 self.probe_hw = cfg.get("PROBE_HW", [])
17
18 @torch.no_grad()
19 def run_eval(self):
20 self.eval_mode()
21 self.before_all_iter(self.hooks_dict[self._mode])
22 all_results = []
23 for batch_idx, batch_data in tqdm(
24 enumerate(self.datas[self._mode].dataloader)):
25 self.before_iter(self.hooks_dict[self._mode])
26 if self.sample_args:
27 batch_data.update(self.sample_args.get_lowercase_dict())
28 with torch.autocast(device_type='cuda',
29 enabled=self.use_amp,
30 dtype=self.dtype):
31 results = self.run_step_eval(transfer_data_to_cuda(batch_data),
32 batch_idx,
33 step=self.total_iter,
34 rank=we.rank)
35 all_results.extend(results)
36 self.after_iter(self.hooks_dict[self._mode])
37 log_data, log_label = self.save_results(all_results)
38 self.register_probe({'eval_label': log_label})
39 self.register_probe({
40 'eval_image':
41 ProbeData(log_data,
42 is_image=True,
43 build_html=True,
44 build_label=log_label)
45 })
46 self.after_all_iter(self.hooks_dict[self._mode])
47
48 @torch.no_grad()
49 def run_test(self):
50 self.test_mode()
51 self.before_all_iter(self.hooks_dict[self._mode])
52 all_results = []
53 for batch_idx, batch_data in tqdm(
54 enumerate(self.datas[self._mode].dataloader)):
55 self.before_iter(self.hooks_dict[self._mode])
56 if self.sample_args:
57 batch_data.update(self.sample_args.get_lowercase_dict())
58 with torch.autocast(device_type='cuda',
59 enabled=self.use_amp,
60 dtype=self.dtype):
61 results = self.run_step_eval(transfer_data_to_cuda(batch_data),
62 batch_idx,
63 step=self.total_iter,
64 rank=we.rank)
65 all_results.extend(results)
66 self.after_iter(self.hooks_dict[self._mode])
67 log_data, log_label = self.save_results(all_results)
68 self.register_probe({'test_label': log_label})
69 self.register_probe({

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected