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 | #ifndef TENSORFLOW_CORE_KERNELS_DILATION_OPS_H_ |
17 | #define TENSORFLOW_CORE_KERNELS_DILATION_OPS_H_ |
18 | |
19 | #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" |
20 | #include "tensorflow/core/framework/tensor_types.h" |
21 | #include "tensorflow/core/platform/types.h" |
22 | |
23 | namespace tensorflow { |
24 | namespace functor { |
25 | |
26 | template <typename Device, typename T> |
27 | struct Dilation { |
28 | // We assume that the tensor sizes are correct. |
29 | void operator()(const Device& d, typename TTypes<T, 4>::ConstTensor input, |
30 | typename TTypes<T, 3>::ConstTensor filter, int stride_rows, |
31 | int stride_cols, int rate_rows, int rate_cols, int pad_top, |
32 | int pad_left, typename TTypes<T, 4>::Tensor output); |
33 | }; |
34 | |
35 | template <typename Device, typename T> |
36 | struct DilationBackpropInput { |
37 | // We assume that the tensor sizes are correct. |
38 | // To avoid storing the argmax values during forward computation, we recompute |
39 | // the argmax during backward computation, which is the reason why we provide |
40 | // filter as argument to the backward computation routine. |
41 | void operator()(const Device& d, typename TTypes<T, 4>::ConstTensor input, |
42 | typename TTypes<T, 3>::ConstTensor filter, |
43 | typename TTypes<T, 4>::ConstTensor out_backprop, |
44 | int stride_rows, int stride_cols, int rate_rows, |
45 | int rate_cols, int pad_top, int pad_left, |
46 | typename TTypes<T, 4>::Tensor in_backprop); |
47 | }; |
48 | |
49 | template <typename Device, typename T> |
50 | struct DilationBackpropFilter { |
51 | // We assume that the tensor sizes are correct. |
52 | // To avoid storing the argmax values during forward computation, we recompute |
53 | // the argmax during backward computation, which is the reason why we provide |
54 | // filter as argument to the backward computation routine. |
55 | void operator()(const Device& d, typename TTypes<T, 4>::ConstTensor input, |
56 | typename TTypes<T, 3>::ConstTensor filter, |
57 | typename TTypes<T, 4>::ConstTensor out_backprop, |
58 | int stride_rows, int stride_cols, int rate_rows, |
59 | int rate_cols, int pad_top, int pad_left, |
60 | typename TTypes<T, 3>::Tensor filter_backprop); |
61 | }; |
62 | |
63 | } // namespace functor |
64 | } // namespace tensorflow |
65 | |
66 | #endif // TENSORFLOW_CORE_KERNELS_DILATION_OPS_H_ |
67 | |