1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_CORE_UTIL_RAGGED_TO_DENSE_UTIL_H_ |
17 | #define TENSORFLOW_CORE_UTIL_RAGGED_TO_DENSE_UTIL_H_ |
18 | |
19 | #include "tensorflow/core/framework/op.h" |
20 | #include "tensorflow/core/framework/shape_inference.h" |
21 | #include "tensorflow/core/framework/tensor_shape.h" |
22 | #include "tensorflow/core/framework/tensor_shape.pb.h" |
23 | #include "tensorflow/core/util/ragged_to_dense_util_common.h" |
24 | |
25 | namespace tensorflow { |
26 | |
27 | string RowPartitionTypeToString(RowPartitionType row_partition_type); |
28 | |
29 | Status GetRowPartitionTypesHelper( |
30 | const std::vector<string>& row_partition_type_strings, |
31 | std::vector<RowPartitionType>* row_partition_types); |
32 | |
33 | // ContextType must be InferenceContext or OpKernelConstruction. |
34 | template <typename ContextType> |
35 | Status GetRowPartitionTypes( |
36 | ContextType* context, std::vector<RowPartitionType>* row_partition_types) { |
37 | std::vector<string> row_partition_type_strings; |
38 | TF_RETURN_IF_ERROR( |
39 | context->GetAttr("row_partition_types" , &row_partition_type_strings)); |
40 | return GetRowPartitionTypesHelper(row_partition_type_strings, |
41 | row_partition_types); |
42 | } |
43 | |
44 | Status GetRowPartitionTypesHelper( |
45 | const std::vector<string>& row_partition_type_strings, |
46 | std::vector<RowPartitionType>* row_partition_types); |
47 | |
48 | Status CombineRaggedTensorToTensorShapes(int ragged_rank, |
49 | const TensorShapeProto& shape, |
50 | const TensorShapeProto& value_shape, |
51 | TensorShapeProto* output_shape); |
52 | |
53 | int GetRaggedRank(const std::vector<RowPartitionType>& row_partition_types); |
54 | |
55 | Status ValidateDefaultValueShape(const TensorShapeProto& default_value_shape, |
56 | const TensorShapeProto& value_shape); |
57 | |
58 | } // namespace tensorflow |
59 | |
60 | #endif // TENSORFLOW_CORE_UTIL_RAGGED_TO_DENSE_UTIL_H_ |
61 | |