Exposes the pointer as a Tensor without taking ownership of the original data. The pointer must remain valid for the entire lifetime of the created Tensor. You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. Additionally, all ot
(ptr:int, shape:tuple[int, ...], **kwargs)
| 503 | |
| 504 | @staticmethod |
| 505 | def from_blob(ptr:int, shape:tuple[int, ...], **kwargs) -> Tensor: |
| 506 | """ |
| 507 | Exposes the pointer as a Tensor without taking ownership of the original data. |
| 508 | The pointer must remain valid for the entire lifetime of the created Tensor. |
| 509 | |
| 510 | You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. |
| 511 | Additionally, all other keyword arguments are passed to the constructor of the tensor. |
| 512 | """ |
| 513 | r = Tensor.empty(*shape, **kwargs) |
| 514 | assert isinstance(r.device, str) |
| 515 | cast(Buffer, r.uop.buffer).allocate(external_ptr=ptr) |
| 516 | return r |
| 517 | |
| 518 | @staticmethod |
| 519 | def from_url(url:str, gunzip:bool=False, **kwargs) -> Tensor: |