1/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15
16#ifndef TENSORFLOW_CORE_KERNELS_MAXPOOLING_OP_H_
17#define TENSORFLOW_CORE_KERNELS_MAXPOOLING_OP_H_
18// Functor definition for MaxPoolingOp, must be compilable by nvcc.
19
20#include "tensorflow/core/framework/numeric_types.h"
21#include "tensorflow/core/framework/tensor_types.h"
22#include "tensorflow/core/framework/type_traits.h"
23#include "tensorflow/core/kernels/eigen_pooling.h"
24#include "tensorflow/core/platform/types.h"
25
26namespace tensorflow {
27namespace functor {
28
29template <typename Device, typename T>
30struct SpatialMaxPooling {
31 void operator()(const Device& d, typename TTypes<T, 4>::Tensor output,
32 typename TTypes<T, 4>::ConstTensor input, int window_rows,
33 int window_cols, int row_stride, int col_stride,
34 const Eigen::PaddingType& padding) {
35 // Because we swap the layout, we swap the row/cols as well
36 output.swap_layout().device(d) =
37 Eigen::SpatialMaxPooling(input.swap_layout(), window_cols, window_rows,
38 col_stride, row_stride, padding);
39 }
40};
41
42template <typename Device>
43struct SpatialMaxPooling<Device, qint8> {
44 void operator()(const Device& d, typename TTypes<qint8, 4>::Tensor output,
45 typename TTypes<qint8, 4>::ConstTensor input, int window_rows,
46 int window_cols, int row_stride, int col_stride,
47 const Eigen::PaddingType& padding) {}
48};
49
50} // namespace functor
51
52} // namespace tensorflow
53
54#endif // TENSORFLOW_CORE_KERNELS_MAXPOOLING_OP_H_
55