-
Notifications
You must be signed in to change notification settings - Fork 74k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing declarations for explicit instantiations in concat_lib an…
…d split_lib, and add new headers concat_lib_gpu.h and split_lib_gpu.h to contain them (and the declaration of the primary templates). The current behaviour (using externally defined instantiations without having seen a declaration of those external instantiations) is undesirable and effectively deprecated, and is warned about by -Wundefined-func-template. PiperOrigin-RevId: 237158146
- Loading branch information
1 parent
58e052b
commit 87cd62e
Showing
9 changed files
with
212 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
|
||
#ifndef TENSORFLOW_CORE_KERNELS_CONCAT_LIB_GPU_H_ | ||
#define TENSORFLOW_CORE_KERNELS_CONCAT_LIB_GPU_H_ | ||
|
||
#define EIGEN_USE_THREADS | ||
#define EIGEN_USE_GPU | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" | ||
#include "tensorflow/core/framework/register_types.h" | ||
#include "tensorflow/core/kernels/concat_lib.h" | ||
#include "tensorflow/core/kernels/cuda_device_array_gpu.h" | ||
|
||
namespace tensorflow { | ||
|
||
template <typename T, typename IntType> | ||
void ConcatGPUSlice( | ||
const Eigen::GpuDevice& gpu_device, | ||
const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& | ||
inputs_flat, | ||
typename TTypes<T, 2>::Matrix* output); | ||
|
||
template <typename T, typename IntType> | ||
void ConcatGPUImpl(const Eigen::GpuDevice& d, | ||
const CudaDeviceArrayStruct<const T*>& input_ptrs, | ||
const CudaDeviceArrayStruct<IntType>& ptr_offsets, | ||
bool same_size, int slice_size, | ||
typename TTypes<T, 2>::Matrix* output); | ||
|
||
// Explicit instantiations in concat_lib_gpu_impl.cu.cc. | ||
#define REGISTER(T) \ | ||
extern template void ConcatGPUSlice<T, int32>( \ | ||
const Eigen::GpuDevice& gpu_device, \ | ||
const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& \ | ||
inputs_flat, \ | ||
typename TTypes<T, 2>::Matrix* output); \ | ||
extern template void ConcatGPUSlice<T, int64>( \ | ||
const Eigen::GpuDevice& gpu_device, \ | ||
const std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>>& \ | ||
inputs_flat, \ | ||
typename TTypes<T, 2>::Matrix* output); \ | ||
extern template void ConcatGPUImpl<T, int32>( \ | ||
const Eigen::GpuDevice& d, \ | ||
const CudaDeviceArrayStruct<const T*>& input_ptrs, \ | ||
const CudaDeviceArrayStruct<int32>& ptr_offsets, bool fixed_size, \ | ||
int split_size, typename TTypes<T, 2>::Matrix* output); \ | ||
extern template void ConcatGPUImpl<T, int64>( \ | ||
const Eigen::GpuDevice& d, \ | ||
const CudaDeviceArrayStruct<const T*>& input_ptrs, \ | ||
const CudaDeviceArrayStruct<int64>& ptr_offsets, bool fixed_size, \ | ||
int split_size, typename TTypes<T, 2>::Matrix* output); | ||
|
||
TF_CALL_GPU_NUMBER_TYPES(REGISTER); | ||
TF_CALL_complex64(REGISTER); | ||
TF_CALL_complex128(REGISTER); | ||
TF_CALL_int32(REGISTER); // Needed for TensorLists. | ||
TF_CALL_int64(REGISTER); | ||
TF_CALL_int16(REGISTER); | ||
TF_CALL_bfloat16(REGISTER); | ||
TF_CALL_bool(REGISTER); | ||
TF_CALL_uint8(REGISTER); | ||
#undef REGISTER | ||
|
||
} // namespace tensorflow | ||
|
||
#endif // TENSORFLOW_CORE_KERNELS_CONCAT_LIB_GPU_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
|
||
#ifndef TENSORFLOW_CORE_KERNELS_SPLIT_LIB_GPU_H_ | ||
#define TENSORFLOW_CORE_KERNELS_SPLIT_LIB_GPU_H_ | ||
|
||
#define EIGEN_USE_THREADS | ||
#define EIGEN_USE_GPU | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" | ||
#include "tensorflow/core/framework/register_types.h" | ||
#include "tensorflow/core/kernels/cuda_device_array_gpu.h" | ||
#include "tensorflow/core/kernels/split_lib.h" | ||
|
||
namespace tensorflow { | ||
|
||
template <typename T> | ||
struct SplitOpGPULaunch { | ||
void Run(const Eigen::GpuDevice& d, const T* input, int32 prefix_dim_size, | ||
int32 split_dim_size, int32 suffix_dim_size, | ||
const CudaDeviceArrayStruct<T*>& output_ptr_data); | ||
}; | ||
|
||
template <typename T, typename IntType> | ||
struct SplitVOpGPULaunch { | ||
void Run(const Eigen::GpuDevice& d, bool fixed, const T* input, | ||
int total_cols, int total_rows, | ||
const CudaDeviceArrayStruct<IntType>& output_scan, | ||
const CudaDeviceArrayStruct<T*>& output_ptr_data); | ||
}; | ||
|
||
// Explicit instantiations in split_lib_gpu.cu.cc. | ||
#define REGISTER_GPU_KERNEL(T) \ | ||
extern template struct SplitOpGPULaunch<T>; \ | ||
extern template struct SplitVOpGPULaunch<T, int32>; \ | ||
extern template struct SplitVOpGPULaunch<T, int64>; | ||
|
||
TF_CALL_GPU_NUMBER_TYPES(REGISTER_GPU_KERNEL); | ||
TF_CALL_complex64(REGISTER_GPU_KERNEL); | ||
TF_CALL_complex128(REGISTER_GPU_KERNEL); | ||
TF_CALL_bfloat16(REGISTER_GPU_KERNEL); | ||
#undef REGISTER_GPU_KERNEL | ||
|
||
} // namespace tensorflow | ||
|
||
#endif // TENSORFLOW_CORE_KERNELS_SPLIT_LIB_GPU_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters