• 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 
16 #ifndef TENSORFLOW_COMPILER_XLA_PROTOBUF_UTIL_H_
17 #define TENSORFLOW_COMPILER_XLA_PROTOBUF_UTIL_H_
18 
19 #include "absl/time/time.h"
20 #include "tensorflow/compiler/xla/statusor.h"
21 #include "tensorflow/compiler/xla/types.h"
22 #include "tensorflow/core/platform/protobuf.h"
23 
24 namespace xla {
25 namespace protobuf_util {
26 
27 // Returns true if m1 is equal to m2.
28 //
29 // WARNING: We use protocol buffer serialization and then check for
30 // equality of the serialized representation, which may miss some
31 // cases of equality.  However, for the purposes of the XLA code
32 // base, this form of equality checking is sufficient.
33 extern bool ProtobufEquals(const tensorflow::protobuf::Message& m1,
34                            const tensorflow::protobuf::Message& m2);
35 
36 // Writes the given message in binary proto to the path formed by joining
37 // 'directory/file_name.pb'. The 'directory' is recursively created if it
38 // doesn't already exist, and the 'file_name' is sanitized by replacing
39 // illegal characters with underscore '_'.
40 Status DumpProtoToDirectory(const tensorflow::protobuf::Message& message,
41                             const string& directory, const string& file_name);
42 
43 // Registers a function that may either expand a dirpath or forward the original
44 // dirpath along as-is.
45 void RegisterDirectoryExpander(const std::function<string(string)>& expander);
46 
47 }  // namespace protobuf_util
48 }  // namespace xla
49 
50 #endif  // TENSORFLOW_COMPILER_XLA_PROTOBUF_UTIL_H_
51