aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/cwise_ops.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-12-22 12:42:59 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-22 12:46:28 -0800
commite4532d20973c4c00854492362665317551661c18 (patch)
tree398527e29bd30d39237adb4785be5069fdb646fa /tensorflow/core/kernels/cwise_ops.h
parent673641c2d6a27fa97ee05453d671853731a4c602 (diff)
Merge changes from github.
PiperOrigin-RevId: 179953488
Diffstat (limited to 'tensorflow/core/kernels/cwise_ops.h')
-rw-r--r--tensorflow/core/kernels/cwise_ops.h40
1 files changed, 22 insertions, 18 deletions
diff --git a/tensorflow/core/kernels/cwise_ops.h b/tensorflow/core/kernels/cwise_ops.h
index d32185b6bf..da70b1e314 100644
--- a/tensorflow/core/kernels/cwise_ops.h
+++ b/tensorflow/core/kernels/cwise_ops.h
@@ -26,24 +26,28 @@ limitations under the License.
#include "tensorflow/core/kernels/bounds_check.h"
namespace Eigen {
-namespace internal {
+namespace numext {
+#if GOOGLE_CUDA
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<float> exp(
+ const std::complex<float>& x) {
+ auto com = ::expf(x.real());
+ auto res_real = com * ::cosf(x.imag());
+ auto res_imag = com * ::sinf(x.imag());
+ return std::complex<float>(res_real, res_imag);
+}
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<double> exp(
+ const std::complex<double>& x) {
+ auto com = ::exp(x.real());
+ auto res_real = com * ::cos(x.imag());
+ auto res_imag = com * ::sin(x.imag());
+ return std::complex<double>(res_real, res_imag);
+}
+#endif
+} // namespace numext
-// TODO(rmlarsen): Get rid of fmod2 once fmod is upstreamed to Eigen.
-template <typename T>
-struct scalar_fmod2_op {
- EIGEN_EMPTY_STRUCT_CTOR(scalar_fmod2_op)
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T operator()(const T& a,
- const T& b) const {
- return std::fmod(a, b);
- }
-};
-template <typename T>
-struct functor_traits<scalar_fmod2_op<T>> {
- enum {
- Cost = 13, // Reciprocal throughput of FPREM on Haswell.
- PacketAccess = false,
- };
-};
+namespace internal {
template <typename T>
struct scalar_asinh_op {
@@ -702,7 +706,7 @@ struct safe_div : base<T, Eigen::internal::safe_div_or_mod_op<
};
template <typename T>
-struct fmod : base<T, Eigen::internal::scalar_fmod2_op<T>> {};
+struct fmod : base<T, Eigen::internal::scalar_fmod_op<T>> {};
template <typename T>
struct mod : base<T, Eigen::internal::scalar_mod2_op<T>> {};