MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / __getattr__

Method __getattr__

lit_gpt/utils_old.py:163–188  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

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)})"

Callers

nothing calls this directly

Calls 1

_load_tensorMethod · 0.95

Tested by

no test coverage detected