1 /* Copyright 2015 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_CORE_KERNELS_SPLIT_LIB_H_ 17 #define TENSORFLOW_CORE_KERNELS_SPLIT_LIB_H_ 18 // Functor definition for SplitOp, must be compilable by nvcc. 19 20 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" 21 #include "tensorflow/core/framework/tensor_types.h" 22 23 namespace tensorflow { 24 namespace functor { 25 26 template <typename Device, typename T> 27 struct SplitCustom { 28 void operator()(const Device& d, typename TTypes<T, 2>::Tensor output, 29 typename TTypes<T, 2>::ConstTensor input, 30 const Eigen::DSizes<Eigen::DenseIndex, 2>& slice_indices, 31 const Eigen::DSizes<Eigen::DenseIndex, 2>& slice_sizes); 32 }; 33 34 template <typename Device, typename T, int NDims> 35 struct Split { 36 void operator()(const Device& d, typename TTypes<T, NDims>::Tensor output, 37 typename TTypes<T, NDims>::ConstTensor input, 38 const Eigen::DSizes<Eigen::DenseIndex, NDims>& slice_indices, 39 const Eigen::DSizes<Eigen::DenseIndex, NDims>& slice_sizes); 40 }; 41 42 template <typename T, int NDims> 43 struct Split<Eigen::ThreadPoolDevice, T, NDims> { 44 void operator()(const Eigen::ThreadPoolDevice& d, 45 typename TTypes<T, NDims>::Tensor output, 46 typename TTypes<T, NDims>::ConstTensor input, 47 const Eigen::DSizes<Eigen::DenseIndex, NDims>& slice_indices, 48 const Eigen::DSizes<Eigen::DenseIndex, NDims>& slice_sizes); 49 }; 50 51 #ifdef TENSORFLOW_USE_SYCL 52 template <typename T, int NDims> 53 struct Split<Eigen::SyclDevice, T> { 54 void operator()(const Eigen::SyclDevice& d, 55 typename TTypes<T, NDims>::Tensor output, 56 typename TTypes<T, NDims>::ConstTensor input, 57 const Eigen::DSizes<Eigen::DenseIndex, NDims>& slice_indices, 58 const Eigen::DSizes<Eigen::DenseIndex, NDims>& slice_sizes); 59 }; 60 #endif // TENSORFLOW_USE_SYCL 61 62 } // namespace functor 63 } // namespace tensorflow 64 65 #endif // TENSORFLOW_CORE_KERNELS_SPLIT_LIB_H_ 66