1/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#ifndef TENSORFLOW_CORE_KERNELS_NEXTAFTER_OP_H_
17#define TENSORFLOW_CORE_KERNELS_NEXTAFTER_OP_H_
18
19#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
20#include "tensorflow/core/kernels/cwise_ops.h"
21
22namespace tensorflow {
23namespace functor {
24
25template <typename T>
26struct nextafter_op {
27 // GPU kernels on ROCm may have issues including standard C++ APIs. Use
28 // specialized member functions and invoke HIP runtime APIs instead.
29#if !TENSORFLOW_USE_ROCM
30 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T operator()(const T& x1,
31 const T& x2) const {
32 return std::nextafter(x1, x2);
33 }
34#else
35 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const float operator()(
36 const float& x1, const float& x2) const {
37 return nextafterf(x1, x2);
38 }
39 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const double operator()(
40 const double& x1, const double& x2) const {
41 return nextafter(x1, x2);
42 }
43#endif
44};
45
46template <typename T>
47struct nextafter : base<T, nextafter_op<T>> {};
48
49} // namespace functor
50} // namespace tensorflow
51
52#endif // TENSORFLOW_CORE_KERNELS_NEXTAFTER_OP_H_
53