(tensors)
| 113 | |
| 114 | |
| 115 | def split_half_float_double_sparse(tensors): |
| 116 | device_type = get_accelerator().device_name() |
| 117 | supported_types = [ |
| 118 | "torch.{}.HalfTensor".format(device_type), "torch.{}.FloatTensor".format(device_type), |
| 119 | "torch.{}.DoubleTensor".format(device_type), "torch.{}.BFloat16Tensor".format(device_type), |
| 120 | SparseTensor.type() |
| 121 | ] |
| 122 | |
| 123 | for t in tensors: |
| 124 | assert t.type() in supported_types, f"attempting to reduce an unsupported grad type: {t.type()}" |
| 125 | |
| 126 | buckets = [] |
| 127 | for i, dtype in enumerate(supported_types): |
| 128 | bucket = [t for t in tensors if t.type() == dtype] |
| 129 | if bucket: |
| 130 | buckets.append((dtype, bucket)) |
| 131 | return buckets |
| 132 | |
| 133 | |
| 134 | FORWARD_MICRO_TIMER = 'forward_microstep' |
no test coverage detected