1/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations 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
25namespace tensorflow {
26
27string RowPartitionTypeToString(RowPartitionType row_partition_type);
28
29Status 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.
34template <typename ContextType>
35Status 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
44Status GetRowPartitionTypesHelper(
45 const std::vector<string>& row_partition_type_strings,
46 std::vector<RowPartitionType>* row_partition_types);
47
48Status CombineRaggedTensorToTensorShapes(int ragged_rank,
49 const TensorShapeProto& shape,
50 const TensorShapeProto& value_shape,
51 TensorShapeProto* output_shape);
52
53int GetRaggedRank(const std::vector<RowPartitionType>& row_partition_types);
54
55Status 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