(self, name)
| 161 | # gc.collect would be costly here, maybe do it optionally |
| 162 | |
| 163 | def __getattr__(self, name): |
| 164 | # properties |
| 165 | ## TODO: device, is_...?? |
| 166 | ## TODO: mH, mT, H, T, data, imag, real |
| 167 | ## name ??? |
| 168 | if name in { |
| 169 | "dtype", |
| 170 | "grad", |
| 171 | "grad_fn", |
| 172 | "layout", |
| 173 | "names", |
| 174 | "ndim", |
| 175 | "output_nr", |
| 176 | "requires_grad", |
| 177 | "retains_grad", |
| 178 | "shape", |
| 179 | "volatile", |
| 180 | }: |
| 181 | return getattr(self.metatensor, name) |
| 182 | if name in {"size"}: |
| 183 | return getattr(self.metatensor, name) |
| 184 | # materializing with contiguous is needed for quantization |
| 185 | if name in {"contiguous"}: |
| 186 | return getattr(self._load_tensor(), name) |
| 187 | |
| 188 | raise AttributeError(f"{type(self)} does not have {name}") |
| 189 | |
| 190 | def __repr__(self): |
| 191 | return f"NotYetLoadedTensor({repr(self.metatensor)})" |
nothing calls this directly
no test coverage detected