(
cls, elem: torch.Tensor, proxy: torch.fx.Proxy, is_immutable: bool = False
)
| 243 | |
| 244 | @staticmethod |
| 245 | def __new__( |
| 246 | cls, elem: torch.Tensor, proxy: torch.fx.Proxy, is_immutable: bool = False |
| 247 | ) -> torch.Tensor: |
| 248 | # assert not elem.requires_grad or not torch.is_grad_enabled() |
| 249 | |
| 250 | r = torch.Tensor._make_subclass(cls, elem, elem.requires_grad) |
| 251 | assert isinstance(r, PythonTensor) |
| 252 | r.is_immutable: bool = is_immutable |
| 253 | r.update_proxy(proxy) |
| 254 | return r |
| 255 | |
| 256 | def update_proxy(self, proxy: torch.fx.Proxy) -> None: |
| 257 | self.proxy = proxy |