aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/cwise_op_floor_div.cc
diff options
context:
space:
mode:
authorGravatar Andrew Selle <aselle@google.com>2016-10-18 16:08:51 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-10-18 17:23:52 -0700
commitbdae9c62caa19c7ecef1eca8e3b9149629404182 (patch)
treeca64c32090d9c21bb7942371bbd5f19b444e81bf /tensorflow/core/kernels/cwise_op_floor_div.cc
parent1855c80558fecebc1e8b90efbe2cfe8573bff38a (diff)
Add ops to implement NumPy parity for 1.0 in preparation for switching
We are holding off on switchover to the new ops for operator overloading and the Python API because of forward compatibility. - Implemented new FloorMod and FloorDiv which represent new implementations that match Pythonic semantics. These are not yet vectorized, but they are also not yet used. - Add TruncateMod in preparation to rename tf.mod to tf.truncateMod - Add RealDiv which only works on floating point inputs, but it uses Div's kernels - Add TruncateDiv which only works on integer inputs, but it also uses Div's kernels. Change: 136539473
Diffstat (limited to 'tensorflow/core/kernels/cwise_op_floor_div.cc')
-rw-r--r--tensorflow/core/kernels/cwise_op_floor_div.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/cwise_op_floor_div.cc b/tensorflow/core/kernels/cwise_op_floor_div.cc
new file mode 100644
index 0000000000..83b2771ed2
--- /dev/null
+++ b/tensorflow/core/kernels/cwise_op_floor_div.cc
@@ -0,0 +1,38 @@
+/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+
+#include "tensorflow/core/kernels/cwise_ops_common.h"
+
+namespace tensorflow {
+REGISTER5(BinaryOp, CPU, "FloorDiv", functor::safe_floor_div, uint8, uint16,
+ int16, int32, int64);
+#if GOOGLE_CUDA
+REGISTER4(BinaryOp, GPU, "FloorDiv", functor::floor_div, uint8, uint16, int16,
+ int64);
+#endif
+
+#if GOOGLE_CUDA
+// A special GPU kernel for int32.
+// TODO(b/25387198): Also enable int32 in device memory. This kernel
+// registration requires all int32 inputs and outputs to be in host memory.
+REGISTER_KERNEL_BUILDER(Name("FloorDiv")
+ .Device(DEVICE_GPU)
+ .HostMemory("x")
+ .HostMemory("y")
+ .HostMemory("z")
+ .TypeConstraint<int32>("T"),
+ BinaryOp<CPUDevice, functor::safe_floor_div<int32>>);
+#endif
+} // namespace tensorflow