1 | |
2 | /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. |
3 | |
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | you may not use this file except in compliance with the License. |
6 | You may obtain a copy of the License at |
7 | |
8 | http://www.apache.org/licenses/LICENSE-2.0 |
9 | |
10 | Unless required by applicable law or agreed to in writing, software |
11 | distributed under the License is distributed on an "AS IS" BASIS, |
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | See the License for the specific language governing permissions and |
14 | limitations under the License. |
15 | ==============================================================================*/ |
16 | #ifndef TENSORFLOW_CORE_KERNELS_RESHAPE_UTIL_H_ |
17 | #define TENSORFLOW_CORE_KERNELS_RESHAPE_UTIL_H_ |
18 | |
19 | #include "tensorflow/core/framework/tensor_shape.h" |
20 | #include "tensorflow/core/framework/tensor_types.h" |
21 | #include "tensorflow/core/lib/core/status.h" |
22 | |
23 | namespace tensorflow { |
24 | |
25 | class OpKernelContext; |
26 | class Tensor; |
27 | |
28 | // Reshapes the input indices and input shape to the target shape. |
29 | // Note: This template is explicitly instantiated for CPU and GPU devices. |
30 | template <typename Device> |
31 | void ReshapeSparseTensor(OpKernelContext *context, |
32 | const Tensor &input_indices_in, |
33 | const Tensor &input_shape_in, |
34 | const Tensor &target_shape_in, int output_indices_idx, |
35 | int output_shape_idx); |
36 | |
37 | namespace functor { |
38 | |
39 | template <typename Device> |
40 | struct ReshapeSparseTensorFunctor { |
41 | Status operator()(OpKernelContext *context, const TensorShape &input_shape, |
42 | const TensorShape &output_shape, |
43 | typename TTypes<int64_t>::ConstMatrix input_indices, |
44 | typename TTypes<int64_t>::Matrix output_indices) const; |
45 | }; |
46 | |
47 | } // namespace functor |
48 | |
49 | } // namespace tensorflow |
50 | |
51 | #endif // TENSORFLOW_CORE_KERNELS_RESHAPE_UTIL_H_ |
52 | |