(self, activated, use_cuda)
| 244 | |
| 245 | class MixedPrecisionManager: |
| 246 | def __init__(self, activated, use_cuda): |
| 247 | assert (not activated) or PyTorch_over_1_6, "Cannot use AMP for PyTorch version < 1.6" |
| 248 | |
| 249 | print("Using FP16:", activated) |
| 250 | self.activated = activated and use_cuda |
| 251 | if self.activated: |
| 252 | self.scaler = torch.cuda.amp.GradScaler() |
| 253 | |
| 254 | def context(self): |
| 255 | return torch.cuda.amp.autocast() if self.activated else NullContextManager() |
nothing calls this directly
no outgoing calls
no test coverage detected