• 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 #include "tensorflow/core/grappler/inputs/utils.h"
17 
18 #include <vector>
19 
20 #include "tensorflow/core/platform/env.h"
21 
22 namespace tensorflow {
23 namespace grappler {
24 
FilesExist(const std::vector<string> & files,std::vector<Status> * status)25 bool FilesExist(const std::vector<string>& files, std::vector<Status>* status) {
26   return Env::Default()->FilesExist(files, status);
27 }
28 
FilesExist(const std::set<string> & files)29 bool FilesExist(const std::set<string>& files) {
30   return FilesExist(std::vector<string>(files.begin(), files.end()), nullptr);
31 }
32 
FileExists(const string & file,Status * status)33 bool FileExists(const string& file, Status* status) {
34   *status = Env::Default()->FileExists(file);
35   return status->ok();
36 }
37 
ReadGraphDefFromFile(const string & graph_def_path,GraphDef * result)38 Status ReadGraphDefFromFile(const string& graph_def_path, GraphDef* result) {
39   Status status;
40   if (!ReadBinaryProto(Env::Default(), graph_def_path, result).ok()) {
41     return ReadTextProto(Env::Default(), graph_def_path, result);
42   }
43   return status;
44 }
45 
ReadMetaGraphDefFromFile(const string & graph_def_path,MetaGraphDef * result)46 Status ReadMetaGraphDefFromFile(const string& graph_def_path,
47                                 MetaGraphDef* result) {
48   Status status;
49   if (!ReadBinaryProto(Env::Default(), graph_def_path, result).ok()) {
50     return ReadTextProto(Env::Default(), graph_def_path, result);
51   }
52   return status;
53 }
54 
55 }  // End namespace grappler
56 }  // end namespace tensorflow
57