spyrit.core.torch.assert_power_of_2
- spyrit.core.torch.assert_power_of_2(n, raise_error=True)[source]
Asserts that n is a power of 2.
- Args:
n (int): The number to check.
raise_error (bool, optional): Whether to raise an error if n is not a power of 2 or not. Default is True.
- Raises:
ValueError: If n is not a power of 2 and if raise_error is True.
- Returns:
bool: True if n is a power of 2, False otherwise.