Skip to content

Commit

Permalink
Tensor dims_set
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Mar 16, 2023
1 parent 5ae7113 commit dd4bd3c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion returnn/tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"""

from __future__ import annotations
from typing import Optional, Union, Sequence, Tuple, Generic, TypeVar
from typing import Optional, Union, Sequence, Tuple, Generic, TypeVar, Set

from returnn.util.basic import NotSpecified
from .dim import Dim
Expand Down Expand Up @@ -130,6 +130,17 @@ def dims(self) -> Tuple[Dim, ...]:
"""
return self._dims

@property
def dims_set(self) -> Set[Dim]:
"""
:return: set of dim tags. in all high-level code, the order of dims is irrelevant.
The order must not play a role
(RETURNN principles: https://github.com/rwth-i6/returnn/wiki/RETURNN-principles).
Note that we do not include any implicit dims here.
Also see :func:`verify_out_shape` and https://github.com/rwth-i6/returnn/issues/1153.
"""
return set(self._dims)

@property
def raw_tensor(self) -> Optional[RawTensorType]:
"""
Expand Down

0 comments on commit dd4bd3c

Please sign in to comment.