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 #define EIGEN_USE_THREADS 17 18 #include "tensorflow/core/kernels/split_lib.h" 19 20 #include "tensorflow/core/framework/numeric_types.h" 21 #include "tensorflow/core/framework/register_types.h" 22 #include "tensorflow/core/framework/tensor_types.h" 23 24 namespace tensorflow { 25 namespace functor { 26 27 template <typename T> 28 void Split<Eigen::ThreadPoolDevice, T>::operator()( 29 const Eigen::ThreadPoolDevice& d, typename TTypes<T, 3>::Tensor output, 30 typename TTypes<T, 3>::ConstTensor input, 31 const Eigen::DSizes<Eigen::DenseIndex, 3>& slice_indices, 32 const Eigen::DSizes<Eigen::DenseIndex, 3>& slice_sizes) { 33 if (output.size() < 131072) { 34 output = input.slice(slice_indices, slice_sizes); 35 } else { 36 output.device(d) = input.slice(slice_indices, slice_sizes); 37 } 38 } 39 40 #define DEFINE_CPU_KERNELS(T) template struct Split<Eigen::ThreadPoolDevice, T>; 41 42 TF_CALL_ALL_TYPES(DEFINE_CPU_KERNELS) 43 DEFINE_CPU_KERNELS(quint8) 44 45 #ifdef TENSORFLOW_USE_SYCL 46 template <typename T> 47 void Split<Eigen::SyclDevice, T>::operator()( 48 const Eigen::SyclDevice& d, typename TTypes<T, 3>::Tensor output, 49 typename TTypes<T, 3>::ConstTensor input, 50 const Eigen::DSizes<Eigen::DenseIndex, 3>& slice_indices, 51 const Eigen::DSizes<Eigen::DenseIndex, 3>& slice_sizes) { 52 output.device(d) = input.slice(slice_indices, slice_sizes); 53 } 54 55 #define DEFINE_SYCL_KERNELS(T) template struct Split<Eigen::SyclDevice, T>; 56 57 TF_CALL_GPU_NUMBER_TYPES_NO_HALF(DEFINE_SYCL_KERNELS); 58 #endif // TENSORFLOW_USE_SYCL 59 60 } // namespace functor 61 } // namespace tensorflow 62