csarofeen / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
http://pytorch.org
Other
26 stars 7 forks source link

Add nextafter op #2510

Open jacobhinkle opened 1 year ago

jacobhinkle commented 1 year ago

The nextafter(x, y) operation provides the nearest distinct representable floating point value to x between x and y. In CUDA these are obtained with the builtins nextafter and nextafterf.

In PyTorch, the torch.nextafter function is defined for any pair of arguments which would normally be promoted to either float32 or float64. So arguments which are both ints, bools, complex, or half-precision floats are not supported. This PR implements a binary op macro with a TypePromotionConfig that enforces that rule.