Home | History | Annotate | Download | only in kernels
      1 /* Copyright 2017 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 #ifndef TENSORFLOW_CORE_KERNELS_BATCH_UTIL_H_
     16 #define TENSORFLOW_CORE_KERNELS_BATCH_UTIL_H_
     17 
     18 #include "tensorflow/core/framework/tensor.h"
     19 #include "tensorflow/core/lib/core/status.h"
     20 
     21 namespace tensorflow {
     22 namespace batch_util {
     23 
     24 // Copies element into the index^th slice of parent (in the 0th dimension).
     25 //
     26 // NOTE(mrry): The `element` argument is taken by value. Use `std::move()`
     27 // to move the `element` argument into this function, and the implementation
     28 // may be able to optimize the copy to a move. This is particularly important
     29 // for DT_STRING tensors.
     30 Status CopyElementToSlice(Tensor element, Tensor* parent, int64 index);
     31 
     32 // Copies the index^th slice of parent (in the 0th dimension) into element.
     33 Status CopySliceToElement(const Tensor& parent, Tensor* element, int64 index);
     34 
     35 // Zero-initializes the tensor `element` using the scalar stored in `padding`.
     36 // Both `element` and `padding` must have matching `dtype`.
     37 Status SetElementZero(Tensor* element, const Tensor& padding);
     38 
     39 // Copies `element` into a (0th dimension) slice of `parent`, assuming
     40 // the shape of `element` is strictly not larger along any axis than a
     41 // slice.
     42 Status CopyElementToLargerSlice(const Tensor& element, Tensor* parent,
     43                                 int index);
     44 
     45 }  // namespace batch_util
     46 }  // namespace tensorflow
     47 
     48 #endif  // TENSORFLOW_CORE_KERNELS_BATCH_UTIL_H_
     49