From 04f4972685963bc6a505e8a757019a670d9753c0 Mon Sep 17 00:00:00 2001 From: James Keeling Date: Thu, 6 Feb 2020 00:31:44 -0800 Subject: [PATCH] Split up conv_2d kernels even further conv_2d_gpu_int.cu.cc takes a really long time to compile for GPU. This is causing very slow builds for some users. By splitting the file up even further, we can reduce the overall build time by allowing more parallelism. In my (somewhat limited) measurements, this reduces the time on the critical path from around 3.5 minutes to 2.5 minutes. PiperOrigin-RevId: 293536410 Change-Id: Ieeb9fe42b0a35adf98ec5034776b1452648fcf60 --- tensorflow/core/kernels/BUILD | 2 + tensorflow/core/kernels/conv_2d_gpu_int.cu.cc | 6 --- .../conv_2d_gpu_int_spatial_convolution.cu.cc | 37 ++++++++++++++++++ ...gpu_int_spatial_convolution_backward.cu.cc | 39 +++++++++++++++++++ 4 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution.cu.cc create mode 100644 tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution_backward.cu.cc diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index ae27014b190..a3d5d5d9435 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -308,6 +308,8 @@ tf_kernel_library( "conv_2d_gpu_float.cu.cc", "conv_2d_gpu_half.cu.cc", "conv_2d_gpu_int.cu.cc", + "conv_2d_gpu_int_spatial_convolution.cu.cc", + "conv_2d_gpu_int_spatial_convolution_backward.cu.cc", "conv_2d_gpu_uint16.cu.cc", "conv_2d_gpu_uint32.cu.cc", "conv_2d_gpu_uint64.cu.cc", diff --git a/tensorflow/core/kernels/conv_2d_gpu_int.cu.cc b/tensorflow/core/kernels/conv_2d_gpu_int.cu.cc index 0daf141784a..60d995a6ed9 100644 --- a/tensorflow/core/kernels/conv_2d_gpu_int.cu.cc +++ b/tensorflow/core/kernels/conv_2d_gpu_int.cu.cc @@ -29,16 +29,10 @@ namespace tensorflow { namespace functor { -// For 2d ops. -template struct SpatialConvolution; template struct MatMulConvFunctor; template struct TransformFilter; template struct PadInput; -template struct SpatialConvolutionBackwardInputFunc; -template struct SpatialConvolutionBackwardInputWithExplicitPaddingFunc< - Eigen::GpuDevice, int32>; - } // namespace functor } // namespace tensorflow diff --git a/tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution.cu.cc b/tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution.cu.cc new file mode 100644 index 00000000000..388704f76c3 --- /dev/null +++ b/tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution.cu.cc @@ -0,0 +1,37 @@ +/* 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 || TENSORFLOW_USE_ROCM + +#define EIGEN_USE_GPU + +#include +#include +#include +#include + +#include "tensorflow/core/kernels/conv_2d.h" +#include "tensorflow/core/kernels/conv_2d_gpu.h" + +namespace tensorflow { + +namespace functor { + +template struct SpatialConvolution; + +} // namespace functor +} // namespace tensorflow + +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM diff --git a/tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution_backward.cu.cc b/tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution_backward.cu.cc new file mode 100644 index 00000000000..b5e7156adac --- /dev/null +++ b/tensorflow/core/kernels/conv_2d_gpu_int_spatial_convolution_backward.cu.cc @@ -0,0 +1,39 @@ +/* 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 || TENSORFLOW_USE_ROCM + +#define EIGEN_USE_GPU + +#include +#include +#include +#include + +#include "tensorflow/core/kernels/conv_2d.h" +#include "tensorflow/core/kernels/conv_2d_gpu.h" + +namespace tensorflow { + +namespace functor { + +template struct SpatialConvolutionBackwardInputFunc; +template struct SpatialConvolutionBackwardInputWithExplicitPaddingFunc< + Eigen::GpuDevice, int32>; + +} // namespace functor +} // namespace tensorflow + +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM