experimental_experiment.xbuilder._shape_helper¶
- experimental_experiment.xbuilder._shape_helper.compatible_dimensions(*dims: Sequence[int | str]) bool [source]¶
Evaluates the fact all the dimensions can be equal or not.
- Parameters:
dims – dimensions
- Returns:
compatibility
<<<
from experimental_experiment.xbuilder._shape_helper import compatible_dimensions print(compatible_dimensions(1, 1)) # True print(compatible_dimensions(1, 2)) # False print(compatible_dimensions(1, "D")) # True print(compatible_dimensions(1, "D", "DD")) # True
>>>
True False True True
- experimental_experiment.xbuilder._shape_helper.compatible_shapes(sh1: Tuple[int | torch.SymInt | torch.SymFloat | float | str, ...], sh2: Tuple[int | torch.SymInt | torch.SymFloat | float | str, ...]) bool [source]¶
Checks that two shapes are compatible. If both static, they must be equal. If dynamic, the variable part must be compatible meaning they could be equal.
- Parameters:
sh1 – first shape
sh2 – seconde shape
- Returns:
compatibility
<<<
from experimental_experiment.xbuilder._shape_helper import compatible_shapes print(compatible_shapes((1, 2), (1, 2))) # True print(compatible_shapes((1, 2), (1, "D2"))) # True print(compatible_shapes(("D2", 2), (1, "D2"))) # False print(compatible_shapes(("D2", 2), (2, "D2"))) # True
>>>
True True False True