Home | History | Annotate | Download | only in kernels
      1 /* Copyright 2015 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_KERNELS_POOLING_OPS_3D_H_
     17 #define TENSORFLOW_KERNELS_POOLING_OPS_3D_H_
     18 
     19 #include "tensorflow/core/framework/op_kernel.h"
     20 #include "tensorflow/core/util/padding.h"
     21 #include "tensorflow/core/util/tensor_format.h"
     22 
     23 namespace tensorflow {
     24 
     25 enum PoolingType { MAX, AVG };
     26 
     27 template <typename Device, typename T, PoolingType Type>
     28 struct LaunchPoolingOp;
     29 
     30 template <typename Device, typename T>
     31 struct LaunchAvgPooling3dGradOp;
     32 
     33 template <typename Device, typename T>
     34 struct LaunchMaxPooling3dGradOp;
     35 
     36 template <typename Device, typename T>
     37 struct LaunchMaxPooling3dGradGradOp;
     38 
     39 // A helper class to manage sizes and shapes for 3d pooling operations.
     40 struct Pool3dParameters {
     41   // Updates context->status if there is an invalid input.
     42   Pool3dParameters(OpKernelContext* context, const std::vector<int32>& ksize,
     43                    const std::vector<int32>& stride, Padding padding,
     44                    TensorFormat data_format,
     45                    const TensorShape& tensor_in_shape);
     46 
     47   // Returns the shape of the output for "forward" pooling operations.
     48   TensorShape forward_output_shape();
     49 
     50   int depth;
     51 
     52   int tensor_in_planes;
     53   int tensor_in_cols;
     54   int tensor_in_rows;
     55   int tensor_in_batch;
     56 
     57   int window_planes;
     58   int window_cols;
     59   int window_rows;
     60   int depth_window;
     61 
     62   int plane_stride;
     63   int col_stride;
     64   int row_stride;
     65   int depth_stride;
     66 
     67   int64 out_plane;
     68   int64 out_height;
     69   int64 out_width;
     70 
     71   int64 pad_planes;
     72   int64 pad_cols;
     73   int64 pad_rows;
     74 
     75   TensorFormat data_format;
     76 };
     77 
     78 }  // namespace tensorflow
     79 
     80 #endif  // TENSORFLOW_KERNELS_POOLING_OPS_3D_H_
     81