1/* Copyright 2020 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#ifndef TENSORFLOW_CORE_DATA_HASH_UTILS_H_
16#define TENSORFLOW_CORE_DATA_HASH_UTILS_H_
17
18#include "tensorflow/core/common_runtime/function.h"
19#include "tensorflow/core/framework/dataset.h"
20#include "tensorflow/core/framework/function.h"
21#include "tensorflow/core/framework/resource_mgr.h"
22#include "tensorflow/core/framework/tensor.h"
23
24namespace tensorflow {
25namespace data {
26
27// Returns a stable hash of the subgraph rooted at the given node.
28//
29// NOTE: There is currently no guarantee that the hash of a subgraph will stay
30// the same between TensorFlow builds.
31Status HashNode(const GraphDef& graph, const NodeDef& node, uint64* hash);
32Status HashNode(const GraphDef& graph, const NodeDef& node,
33 const FunctionLibraryDefinition& flib_def, uint64* hash);
34
35// Returns a stable hash of the given tensor.
36//
37// NOTE: There is currently no guarantee that the hash of a subgraph will stay
38// the same between TensorFlow builds.
39Status HashTensor(const Tensor& tensor, uint64* hash);
40
41// Returns a stable hash of the given graph.
42//
43// NOTE: There is currently no guarantee that the hash of a subgraph will stay
44// the same between TensorFlow builds.
45Status HashGraph(const GraphDef& graph, uint64* hash);
46
47// Determines whether the given graphs are equal, following the same logic used
48// for HashGraph. Returns OK if the graphs can be determined to be equal,
49// otherwise returns an error message explaining why the graphs couldn't be
50// determined to be equal.
51Status CheckGraphsEqual(const GraphDef& a, const GraphDef& b);
52
53// Determines whether the subgraphs rooted at the given nodes are equal
54// following the same logic used for HashGraph. Returns OK if the graphs can be
55// determined to be equal, otherwise returns an error message explaining why the
56// graphs couldn't be determined to be equal.
57Status CheckSubgraphsEqual(const GraphDef& a, const NodeDef* node_a,
58 const GraphDef& b, const NodeDef* node_b);
59} // namespace data
60} // namespace tensorflow
61
62#endif // TENSORFLOW_CORE_DATA_HASH_UTILS_H_
63