1 | /* Copyright 2018 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_ROLL_OP_H_ |
17 | #define TENSORFLOW_CORE_KERNELS_ROLL_OP_H_ |
18 | |
19 | #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" |
20 | #include "tensorflow/core/framework/numeric_types.h" |
21 | #include "tensorflow/core/framework/op_kernel.h" |
22 | #include "tensorflow/core/framework/tensor_types.h" |
23 | |
24 | namespace tensorflow { |
25 | namespace functor { |
26 | |
27 | template <typename Device, typename T> |
28 | struct Roll { |
29 | // dim_size - the size of each dimension |
30 | // dim_range - the number of indices over in the flattened tensor |
31 | // you need to skip in order to make it over from one side of a dimension |
32 | // to the other. Used to make the shifts wrap around after a threshold. |
33 | // threshold - the index for each dimension that the roll starts to wrap |
34 | // back to the front |
35 | // isd - inner shift dimension |
36 | void operator()(const OpKernelContext* context, const int64_t num_elements, |
37 | const int num_dims, const gtl::ArraySlice<int32> dim_size, |
38 | const T* input, T* output, |
39 | const gtl::ArraySlice<int32> threshold, |
40 | const gtl::ArraySlice<int64_t> dim_range, const int64_t isd); |
41 | }; |
42 | |
43 | } // namespace functor |
44 | } // namespace tensorflow |
45 | |
46 | #endif // TENSORFLOW_CORE_KERNELS_ROLL_OP_H_ |
47 | |