Split topk GPU code into multiple files
This file was a bottleneck during compilation, often taking many minutes to compile. In local testing this change reduces the wall-clock build time for the topk GPU kernels from 155s to 48s. PiperOrigin-RevId: 228302319
This commit is contained in:
parent
81492c074a
commit
0ef4b19044
@ -3862,7 +3862,21 @@ tf_kernel_library(
|
||||
|
||||
tf_kernel_library(
|
||||
name = "topk_op",
|
||||
prefix = "topk_op",
|
||||
srcs = ["topk_op.cc"],
|
||||
hdrs = ["topk_op.h"],
|
||||
gpu_srcs = [
|
||||
"topk_op.h",
|
||||
"topk_op_gpu.h",
|
||||
"topk_op_gpu_double.cu.cc",
|
||||
"topk_op_gpu_float.cu.cc",
|
||||
"topk_op_gpu_half.cu.cc",
|
||||
"topk_op_gpu_int64.cu.cc",
|
||||
"topk_op_gpu_int32.cu.cc",
|
||||
"topk_op_gpu_int16.cu.cc",
|
||||
"topk_op_gpu_uint16.cu.cc",
|
||||
"topk_op_gpu_int8.cu.cc",
|
||||
"topk_op_gpu_uint8.cu.cc",
|
||||
],
|
||||
deps = NN_DEPS + if_cuda(["@cub_archive//:cub"]),
|
||||
)
|
||||
|
||||
|
@ -12,6 +12,8 @@ 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_TOPK_OP_GPU_H_
|
||||
#define TENSORFLOW_CORE_KERNELS_TOPK_OP_GPU_H_
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
|
||||
@ -561,14 +563,8 @@ struct TopKFunctor<GPUDevice, T> {
|
||||
};
|
||||
|
||||
} // end namespace functor
|
||||
|
||||
#define INSTANTIATE_TEMPLATE(type) \
|
||||
template struct functor::TopKFunctor<GPUDevice, type>;
|
||||
|
||||
TF_CALL_GPU_NUMBER_TYPES(INSTANTIATE_TEMPLATE);
|
||||
TF_CALL_INTEGRAL_TYPES(INSTANTIATE_TEMPLATE);
|
||||
#undef INSTANTIATE_TEMPLATE
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
||||
|
||||
#endif // TENSORFLOW_CORE_KERNELS_TOPK_OP_GPU_H_
|
28
tensorflow/core/kernels/topk_op_gpu_double.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_double.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, double>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_float.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_float.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, float>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_half.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_half.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, Eigen::half>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_int16.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_int16.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, int16>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_int32.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_int32.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, int32>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_int64.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_int64.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, int64>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_int8.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_int8.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, int8>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_uint16.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_uint16.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, uint16>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
28
tensorflow/core/kernels/topk_op_gpu_uint8.cu.cc
Normal file
28
tensorflow/core/kernels/topk_op_gpu_uint8.cu.cc
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#if GOOGLE_CUDA
|
||||
#define EIGEN_USE_GPU
|
||||
|
||||
#include "tensorflow/core/kernels/topk_op.h"
|
||||
#include "tensorflow/core/kernels/topk_op_gpu.h"
|
||||
|
||||
namespace tensorflow {
|
||||
using Eigen::GpuDevice;
|
||||
|
||||
template struct functor::TopKFunctor<GPUDevice, uint8>;
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // GOOGLE_CUDA
|
Loading…
Reference in New Issue
Block a user