(tensor: Tensor, layout_cls: Type[Layout], **layout_kwargs)
| 210 | |
| 211 | |
| 212 | def convert_layout(tensor: Tensor, layout_cls: Type[Layout], **layout_kwargs): |
| 213 | assert isinstance(tensor, Tensor) |
| 214 | old_storage = tensor.storage |
| 215 | old_data = old_storage.layout.unswizzle_data(old_storage.data) |
| 216 | new_layout = layout_cls(old_data.shape, **layout_kwargs) |
| 217 | new_data = new_layout.swizzle_data(old_data) |
| 218 | attrs = {k.name: getattr(tensor, k.name) for k in fields(tensor) if k.name != "storage"} |
| 219 | return Tensor(Storage(new_data, new_layout), **attrs) |
no test coverage detected