aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/topk_op.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-05-19 08:54:46 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-05-19 08:58:34 -0700
commitb07abe09fec37414fcb19f89365181305a89887a (patch)
treeff7ca720d338353144e035e752e3e564be0127fe /tensorflow/core/kernels/topk_op.h
parent2661ebb7b97fd229b390477af0dde76407934344 (diff)
Add a GPU implementation for the TopK op.
PiperOrigin-RevId: 156556243
Diffstat (limited to 'tensorflow/core/kernels/topk_op.h')
-rw-r--r--tensorflow/core/kernels/topk_op.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/topk_op.h b/tensorflow/core/kernels/topk_op.h
new file mode 100644
index 0000000000..799c3e8345
--- /dev/null
+++ b/tensorflow/core/kernels/topk_op.h
@@ -0,0 +1,42 @@
+/* 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.
+==============================================================================*/
+
+#ifndef TENSORFLOW_TOPK_OP_H_
+#define TENSORFLOW_TOPK_OP_H_
+
+#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
+#include "tensorflow/core/framework/op_kernel.h"
+#include "tensorflow/core/framework/tensor_types.h"
+#include "tensorflow/core/framework/types.h"
+#include "tensorflow/core/lib/core/errors.h"
+
+namespace tensorflow {
+
+namespace functor {
+
+template <typename Device, typename T>
+struct TopKFunctor {
+ static void Compute(OpKernelContext* context, bool sorted, int k,
+ const typename TTypes<T, 2>::ConstTensor& input,
+ const int64 num_rows, const int64 num_cols,
+ typename TTypes<T, 2>::Tensor* values,
+ typename TTypes<int, 2>::Tensor* indices);
+};
+
+} // end namespace functor
+
+} // end namespace tensorflow
+
+#endif // TENSORFLOW_TOPK_OP_H_