utils.py 236 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
from typing import Any

try:
    from typing_extensions import Final  # noqa
except ImportError:
    from torch.jit import Final  # noqa

rusty1s's avatar
rusty1s committed
8

rusty1s's avatar
rusty1s committed
9
def is_scalar(other: Any) -> bool:
rusty1s's avatar
rusty1s committed
10
    return isinstance(other, int) or isinstance(other, float)