Function
to_list
(
x: Union[torch.Size, int, List[int], Tuple[int]]
)
Source from the content-addressed store, hash-verified
| 357 | """ |
| 358 | |
| 359 | def to_list( |
| 360 | x: Union[torch.Size, int, List[int], Tuple[int]] |
| 361 | ) -> Union[List[int], List[torch.Size]]: |
| 362 | if isinstance(x, torch.Size) or isinstance(x, tuple): |
| 363 | return list(x) |
| 364 | elif isinstance(x, int): |
| 365 | return [x] |
| 366 | else: |
| 367 | return x |
| 368 | |
| 369 | tensor_size = to_list(spec.shape) |
| 370 | tensor_dim_order = to_list(spec.dim_order) |
Tested by
no test coverage detected