• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_UTIL_BATCH_UTIL_H_
16 #define TENSORFLOW_CORE_UTIL_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 // Copies the index^th slice of parent (in the 0th dimension) into element.
36 //
37 // NOTE(mrry): The implementation may be able to optimize the copy to a move.
38 // This is particularly important for DT_STRING tensors.
39 Status MaybeMoveSliceToElement(Tensor* parent, Tensor* element, int64 index);
40 
41 // Zero-initializes the tensor `element` using the scalar stored in `padding`.
42 // Both `element` and `padding` must have matching `dtype`.
43 Status SetElementZero(Tensor* element, const Tensor& padding);
44 
45 // Copies `element` into a (0th dimension) slice of `parent`, assuming
46 // the shape of `element` is strictly not larger along any axis than a
47 // slice.
48 Status CopyElementToLargerSlice(const Tensor& element, Tensor* parent,
49                                 int index);
50 
51 }  // namespace batch_util
52 }  // namespace tensorflow
53 
54 #endif  // TENSORFLOW_CORE_UTIL_BATCH_UTIL_H_
55