We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5112253 commit 93a7905Copy full SHA for 93a7905
torchvision/transforms/functional_tensor.py
@@ -45,13 +45,18 @@ def get_image_num_channels(img: Tensor) -> int:
45
46
47
def _max_value(dtype: torch.dtype) -> int:
48
- return {
49
- torch.uint8: int(2 ** 8) - 1,
50
- torch.int8: int(2 ** 7) - 1,
51
- torch.int16: int(2 ** 15) - 1,
52
- torch.int32: int(2 ** 31) - 1,
53
- torch.int64: int(2 ** 63) - 1,
54
- }.get(dtype, 1)
+ if dtype == torch.uint8:
+ return int(2 ** 8) - 1
+ elif dtype == torch.int8:
+ return int(2 ** 7) - 1
+ elif dtype == torch.int16:
+ return int(2 ** 15) - 1
+ elif dtype == torch.int32:
55
+ return int(2 ** 31) - 1
56
+ elif dtype == torch.int64:
57
+ return int(2 ** 63) - 1
58
+ else:
59
+ return 1
60
61
62
def _assert_channels(img: Tensor, permitted: List[int]) -> None:
0 commit comments