• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef TENSORFLOW_CORE_UTIL_STRIDED_SLICE_OP_H_
16 #define TENSORFLOW_CORE_UTIL_STRIDED_SLICE_OP_H_
17 
18 #include "tensorflow/core/framework/tensor.h"
19 #include "tensorflow/core/framework/tensor_shape.h"
20 #include "tensorflow/core/framework/types.h"
21 #include "tensorflow/core/lib/core/status.h"
22 #include "tensorflow/core/lib/gtl/inlined_vector.h"
23 
24 namespace tensorflow {
25 
26 // Runs validation on the strided slice op parameters.
27 //
28 // Is a separate translation unit from the kernel so that:
29 // 1. The op's shape function can use it.
30 // 2. The code size is reduced vs templating this on the kernel's type.
31 //
32 // Note that when input_shape is not fully specified, only <final_shape> and
33 // <processing_shape> are valid; <is_identity>, <is_simple_slice> and other
34 // output parameters will not be accurate.
35 //
36 // If <begin_tensor> or <end_tensor> are nullptr, <begin> and <end> will not be
37 // valid. In this case, <slice_dim0> and <is_identity> will be true only if a
38 // determination can be made based on the information given. A best effort is
39 // made to set <processing_shape> and <final_shape> based on <input_shape>, but
40 // some dimensions of <processing_shape> and/or <final_shape> may be unknown
41 // (-1). Any validation that can be done without complete information is
42 // performed.
43 Status ValidateStridedSliceOp(
44     const Tensor* begin_tensor, const Tensor* end_tensor,
45     const Tensor& strides_tensor, const PartialTensorShape& input_shape,
46     int32 begin_mask_spec, int32 end_mask_spec, const int32 ellipsis_mask,
47     int32 new_axis_mask, int32 shrink_axis_mask,
48     PartialTensorShape* processing_shape, PartialTensorShape* final_shape,
49     bool* is_identity, bool* is_simple_slice, bool* slice_dim0,
50     gtl::InlinedVector<int64, 4>* begin, gtl::InlinedVector<int64, 4>* end,
51     gtl::InlinedVector<int64, 4>* strides);
52 
53 // Same as above, but the outputs are TensorShape, not PartialTensorShape
54 Status ValidateStridedSliceOp(
55     const Tensor* begin_tensor, const Tensor* end_tensor,
56     const Tensor& strides_tensor, const PartialTensorShape& input_shape,
57     int32 begin_mask_spec, int32 end_mask_spec, const int32 ellipsis_mask,
58     int32 new_axis_mask, int32 shrink_axis_mask, TensorShape* processing_shape,
59     TensorShape* final_shape, bool* is_identity, bool* is_simple_slice,
60     bool* slice_dim0, gtl::InlinedVector<int64, 4>* begin,
61     gtl::InlinedVector<int64, 4>* end, gtl::InlinedVector<int64, 4>* strides);
62 
63 }  // namespace tensorflow
64 
65 #endif  // TENSORFLOW_CORE_UTIL_STRIDED_SLICE_OP_H_
66