(cls)
| 94 | @classmethod |
| 95 | @contextmanager |
| 96 | def empty_device_cache(cls): |
| 97 | yield |
| 98 | if cls.optimize_device_cache: |
| 99 | if is_torch_xpu_available(): |
| 100 | gc.collect() |
| 101 | torch.xpu.empty_cache() |
| 102 | gc.collect() |
| 103 | elif is_torch_npu_available(): |
| 104 | gc.collect() |
| 105 | torch.npu.empty_cache() |
| 106 | gc.collect() |
| 107 | elif torch.cuda.is_available(): |
| 108 | gc.collect() |
| 109 | torch.cuda.empty_cache() |
| 110 | gc.collect() |
| 111 | |
| 112 | |
| 113 | def randn_tensor( |
nothing calls this directly
no outgoing calls
no test coverage detected