Execute forward propagation Arguments: *inputs: Variable length input list **kwargs: variable length keyword arguments
(self, *inputs, **kwargs)
| 586 | return sub_module_cuda_graph |
| 587 | |
| 588 | def forward(self, *inputs, **kwargs): |
| 589 | """Execute forward propagation |
| 590 | |
| 591 | Arguments: |
| 592 | *inputs: Variable length input list |
| 593 | **kwargs: variable length keyword arguments |
| 594 | """ |
| 595 | start = None |
| 596 | if self.model_profile_enabled and get_accelerator().device_name() == 'cuda' and self._config.enable_cuda_graph: |
| 597 | get_accelerator().synchronize() |
| 598 | start = time.time() |
| 599 | |
| 600 | if get_accelerator().device_name() == 'cuda' and self._config.enable_cuda_graph and not self.local_cuda_graph: |
| 601 | if self.cuda_graph_created: |
| 602 | outputs = self._graph_replay(*inputs, **kwargs) |
| 603 | else: |
| 604 | self._create_cuda_graph(*inputs, **kwargs) |
| 605 | outputs = self._graph_replay(*inputs, **kwargs) |
| 606 | |
| 607 | else: |
| 608 | outputs = self.module(*inputs, **kwargs) |
| 609 | |
| 610 | if self.model_profile_enabled and self._config.enable_cuda_graph: |
| 611 | get_accelerator().synchronize() |
| 612 | duration = (time.time() - start) * 1e3 # convert seconds to ms |
| 613 | self._model_times.append(duration) |
| 614 | |
| 615 | return outputs |
| 616 | |
| 617 | def _generate(self, *inputs, **kwargs): |
| 618 | # Reset KV-cache at the beginning of generate |
nothing calls this directly
no test coverage detected