File tree Expand file tree Collapse file tree 1 file changed +1
-9
lines changed
torchvision/prototype/transforms/functional Expand file tree Collapse file tree 1 file changed +1
-9
lines changed Original file line number Diff line number Diff line change @@ -379,15 +379,7 @@ def convert_dtype_image_tensor(image: torch.Tensor, dtype: torch.dtype = torch.f
379379 if num_value_bits_input > num_value_bits_output :
380380 return image .bitwise_right_shift (num_value_bits_input - num_value_bits_output ).to (dtype )
381381 else :
382- # The bitshift kernel is not vectorized
383- # https://github.com/pytorch/pytorch/blob/703c19008df4700b6a522b0ae5c4b6d5ffc0906f/aten/src/ATen/native/cpu/BinaryOpsKernel.cpp#L315-L322
384- # This results in the multiplication actually being faster.
385- # TODO: If the bitshift kernel is optimized in core, replace the computation below with
386- # `image.to(dtype).bitwise_left_shift_(num_value_bits_output - num_value_bits_input)`
387- max_value_input = float (_FT ._max_value (dtype ))
388- max_value_output = float (_FT ._max_value (image .dtype ))
389- factor = int ((max_value_input + 1 ) // (max_value_output + 1 ))
390- return image .to (dtype ).mul_ (factor )
382+ return image .to (dtype ).bitwise_left_shift_ (num_value_bits_output - num_value_bits_input )
391383
392384
393385# We changed the name to align it with the new naming scheme. Still, `convert_image_dtype` is
You can’t perform that action at this time.
0 commit comments