torch.Tensor.dim_order¶
- Tensor.dim_order(ambiguity_check=False) tuple [source][source]¶
Returns the uniquely determined tuple of int describing the dim order or physical layout of
self
.The dim order represents how dimensions are laid out in memory, starting from the outermost to the innermost dimension.
Note that the dim order may not always be uniquely determined. If ambiguity_check is True, this function raises a RuntimeError when the dim order cannot be uniquely determined; If ambiguity_check is a list of memory formats, this function raises a RuntimeError when tensor can not be interpreted into exactly one of the given memory formats, or it cannot be uniquely determined. If ambiguity_check is False, it will return one of legal dim order(s) without checking its uniqueness. Otherwise, it will raise TypeError.
- Parameters
ambiguity_check (bool or List[torch.memory_format]) – The check method for ambiguity of dim order.
torch.empty (...) –
(0 –
1 –
2 –
3) –
torch.empty –
(0 –
2 –
1 –
3) –
torch.empty –
(0 –
2 –
3 –
1) –
torch.empty –
(0 –
1 –
2 –
3) –
try (>>>) –
torch.empty –
e (... except TypeError as) –
print (...) –
order (The tensor does not have unique dim) –
formats. (The ambiguity_check argument must be a python:bool or a list of memory) –
torch.empty –
ambiguity_check=[torch.contiguous_format (...) –
torch.channels_last] –
format (... ) # It can be mapped to contiguous) –
(0 –
1 –
2 –
3) –
try –
torch.empty –
e –
print –
formats. –
Warning
The dim_order tensor API is experimental and subject to change.