Home | History | Annotate | Download | only in kernels
      1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #ifndef TENSORFLOW_KERNELS_GATHER_ND_OP_H_
     17 #define TENSORFLOW_KERNELS_GATHER_ND_OP_H_
     18 // Functor definition for GatherOp, must be compilable by nvcc.
     19 
     20 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
     21 #include "tensorflow/core/framework/tensor_types.h"
     22 #include "tensorflow/core/kernels/bounds_check.h"
     23 #include "tensorflow/core/platform/types.h"
     24 
     25 namespace tensorflow {
     26 
     27 class OpKernelContext;
     28 class Status;
     29 class Tensor;
     30 
     31 namespace functor {
     32 template <typename Device, typename T, typename Index, int IXDIM>
     33 struct GatherNdSlice {
     34   // Performs a slice gather op on (Tparams, Tindices), writing to Tout.
     35   // Returns an index to Tindices if the value at that index is out of range.
     36   // Returns -1 if all values of Tindices are in range.
     37   Index operator()(const Device& d, const Index slice_size,
     38                    typename TTypes<int32>::Scalar Tscratch,
     39                    typename TTypes<T, IXDIM + 1>::ConstTensor Tparams,
     40                    typename TTypes<Index>::ConstMatrix Tindices,
     41                    typename TTypes<T>::Matrix Tout);
     42 };
     43 
     44 template <typename Device, typename T, typename Index>
     45 Status DoGatherNd(OpKernelContext* c, const Tensor& params,
     46                   const Tensor& indices, Tensor* out);
     47 }  // namespace functor
     48 }  // namespace tensorflow
     49 
     50 #endif  // TENSORFLOW_KERNELS_GATHER_ND_OP_H_
     51