• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2016 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 // Helper functions to run 3d pooling on GPU using CuDNN.
17 
18 #ifndef TENSORFLOW_CORE_KERNELS_CUDNN_POOLING_GPU_H_
19 #define TENSORFLOW_CORE_KERNELS_CUDNN_POOLING_GPU_H_
20 
21 #include <array>
22 
23 #include "tensorflow/core/framework/op_kernel.h"
24 
25 #if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
26 #include "tensorflow/core/platform/stream_executor.h"
27 #endif
28 
29 #include "tensorflow/core/util/padding.h"
30 
31 namespace tensorflow {
32 
33 #if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
34 
35 // Runs (avg/max)pooling on GPU.
36 // Dimension order for all array arguments is: x, y, z.
37 template <typename T>
38 class DnnPooling3dOp {
39  public:
40   static void Compute(OpKernelContext* context,
41                       se::dnn::PoolingMode pooling_mode,
42                       const std::array<int64, 3>& size,
43                       const std::array<int64, 3>& stride,
44                       const std::array<int64, 3>& padding,
45                       TensorFormat data_format, const Tensor& tensor_in,
46                       Tensor* output);
47 };
48 
49 // Computes the gradient of (avg/max)pooling on GPU.
50 // Dimension order for all array arguments is: x, y, z.
51 template <typename T>
52 class DnnPooling3dGradOp {
53  public:
54   static void Compute(OpKernelContext* context,
55                       se::dnn::PoolingMode pooling_mode,
56                       const std::array<int64, 3>& window,
57                       const std::array<int64, 3>& stride,
58                       const std::array<int64, 3>& padding,
59                       const std::array<int64, 3>& output_size,
60                       TensorFormat data_format, const Tensor& out_backprop,
61                       const TensorShape& tensor_in_shape,
62                       const Tensor* tensor_in, const Tensor* tensor_out,
63                       Tensor* input_backprop);
64 };
65 
66 #endif
67 
68 }  // namespace tensorflow
69 
70 #endif  // TENSORFLOW_CORE_KERNELS_CUDNN_POOLING_GPU_H_
71