Home | History | Annotate | Download | only in kernels
      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 #define EIGEN_USE_THREADS
     17 
     18 #include <algorithm>
     19 #include <numeric>
     20 #include <unordered_map>
     21 #include <utility>
     22 
     23 #include "tensorflow/core/framework/op_kernel.h"
     24 #include "tensorflow/core/framework/register_types.h"
     25 #include "tensorflow/core/framework/tensor.h"
     26 #include "tensorflow/core/framework/types.h"
     27 #include "tensorflow/core/kernels/reshape_util.h"
     28 #include "tensorflow/core/lib/gtl/inlined_vector.h"
     29 
     30 namespace tensorflow {
     31 
     32 class SparseReshapeOp : public OpKernel {
     33  public:
     34   explicit SparseReshapeOp(OpKernelConstruction* context) : OpKernel(context) {}
     35 
     36   void Compute(OpKernelContext* context) override {
     37     Tensor output_indices;
     38     Tensor output_shape;
     39     Reshape(context, context->input(0), context->input(1), context->input(2),
     40             0 /* output indices index */, 1 /* output shape index */);
     41   }
     42 };
     43 
     44 REGISTER_KERNEL_BUILDER(Name("SparseReshape").Device(DEVICE_CPU),
     45                         SparseReshapeOp)
     46 }  // namespace tensorflow
     47