(weight, dtype=None, device=None, copy=False)
| 108 | |
| 109 | def quantize(self): |
| 110 | def cast_to(weight, dtype=None, device=None, copy=False): |
| 111 | if device is None or weight.device == device: |
| 112 | if not copy: |
| 113 | if dtype is None or weight.dtype == dtype: |
| 114 | return weight |
| 115 | return weight.to(dtype=dtype, copy=copy) |
| 116 | |
| 117 | r = torch.empty_like(weight, dtype=dtype, device=device) |
| 118 | r.copy_(weight) |
| 119 | return r |
| 120 | |
| 121 | def cast_weight(s, input=None, dtype=None, device=None): |
| 122 | if input is not None: |