1
2/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations 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
23namespace tensorflow {
24
25class OpKernelContext;
26class 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.
30template <typename Device>
31void 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
37namespace functor {
38
39template <typename Device>
40struct 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