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, int NDims> |
28 | void Split<Eigen::ThreadPoolDevice, T, NDims>::operator()( |
29 | const Eigen::ThreadPoolDevice& d, typename TTypes<T, NDims>::Tensor output, |
30 | typename TTypes<T, NDims>::ConstTensor input, |
31 | const Eigen::DSizes<Eigen::DenseIndex, NDims>& slice_indices, |
32 | const Eigen::DSizes<Eigen::DenseIndex, NDims>& 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) \ |
41 | template struct Split<Eigen::ThreadPoolDevice, T, 2>; \ |
42 | template struct Split<Eigen::ThreadPoolDevice, T, 3>; |
43 | |
44 | TF_CALL_ALL_TYPES(DEFINE_CPU_KERNELS) |
45 | DEFINE_CPU_KERNELS(quint8) |
46 | |
47 | |
48 | } // namespace functor |
49 | } // namespace tensorflow |
50 | |