1 /* Copyright 2019 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_CONCAT_LIB_GPU_H_ 17 #define TENSORFLOW_CORE_KERNELS_CONCAT_LIB_GPU_H_ 18 19 #define EIGEN_USE_THREADS 20 #define EIGEN_USE_GPU 21 22 #include <memory> 23 #include <vector> 24 25 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" 26 #include "tensorflow/core/framework/register_types.h" 27 #include "tensorflow/core/kernels/concat_lib.h" 28 #include "tensorflow/core/kernels/gpu_device_array_gpu.h" 29 30 namespace tensorflow { 31 32 template <typename T, typename IntType> 33 void ConcatGPUSlice( 34 const Eigen::GpuDevice& gpu_device, 35 const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& 36 inputs_flat, 37 typename TTypes<T, 2>::Matrix* output); 38 39 template <typename T, typename IntType> 40 void ConcatGPUImpl(const Eigen::GpuDevice& d, 41 const GpuDeviceArrayStruct<const T*>& input_ptrs, 42 const GpuDeviceArrayStruct<IntType>& ptr_offsets, 43 bool same_size, int slice_size, 44 typename TTypes<T, 2>::Matrix* output); 45 46 // Explicit instantiations in concat_lib_gpu_impl.cu.cc. 47 #define REGISTER(T) \ 48 extern template void ConcatGPUSlice<T, int32>( \ 49 const Eigen::GpuDevice& gpu_device, \ 50 const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& \ 51 inputs_flat, \ 52 typename TTypes<T, 2>::Matrix* output); \ 53 extern template void ConcatGPUSlice<T, int64>( \ 54 const Eigen::GpuDevice& gpu_device, \ 55 const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& \ 56 inputs_flat, \ 57 typename TTypes<T, 2>::Matrix* output); \ 58 extern template void ConcatGPUImpl<T, int32>( \ 59 const Eigen::GpuDevice& d, \ 60 const GpuDeviceArrayStruct<const T*>& input_ptrs, \ 61 const GpuDeviceArrayStruct<int32>& ptr_offsets, bool fixed_size, \ 62 int split_size, typename TTypes<T, 2>::Matrix* output); \ 63 extern template void ConcatGPUImpl<T, int64>( \ 64 const Eigen::GpuDevice& d, \ 65 const GpuDeviceArrayStruct<const T*>& input_ptrs, \ 66 const GpuDeviceArrayStruct<int64>& ptr_offsets, bool fixed_size, \ 67 int split_size, typename TTypes<T, 2>::Matrix* output); 68 69 TF_CALL_GPU_NUMBER_TYPES(REGISTER); 70 TF_CALL_complex64(REGISTER); 71 TF_CALL_complex128(REGISTER); 72 TF_CALL_int32(REGISTER); // Needed for TensorLists. 73 TF_CALL_int64(REGISTER); 74 TF_CALL_int16(REGISTER); 75 TF_CALL_bfloat16(REGISTER); 76 TF_CALL_bool(REGISTER); 77 TF_CALL_uint8(REGISTER); 78 #undef REGISTER 79 80 } // namespace tensorflow 81 82 #endif // TENSORFLOW_CORE_KERNELS_CONCAT_LIB_GPU_H_ 83