torch.Tensor.dim_order¶
- Tensor.dim_order(ambiguity_check=False) tuple [來源][來源]¶
傳回唯一確定的 int 元組,描述
self
的維度順序或物理佈局。維度順序表示維度在記憶體中的佈局方式,從最外層維度到最內層維度。
請注意,維度順序可能並不總是能唯一確定。如果 ambiguity_check 為 True,則當無法唯一確定維度順序時,此函數會引發 RuntimeError;如果 ambiguity_check 是記憶體格式的列表,則當 tensor 無法被解釋為給定的記憶體格式之一時,或者無法被唯一確定時,此函數會引發 RuntimeError。如果 ambiguity_check 為 False,它將返回其中一個合法的維度順序,而不檢查其唯一性。否則,它將引發 TypeError。
- 參數
ambiguity_check (bool 或 List[torch.memory_format]) – 維度順序不明確時的檢查方法。
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. –
警告
dim_order tensor API 尚在實驗階段,可能會變更。