Home | History | Annotate | Download | only in inputs
      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 #include "tensorflow/core/platform/env.h"
     18 
     19 #include <vector>
     20 
     21 namespace tensorflow {
     22 namespace grappler {
     23 
     24 bool FilesExist(const std::vector<string>& files, std::vector<Status>* status) {
     25   return Env::Default()->FilesExist(files, status);
     26 }
     27 
     28 bool FilesExist(const std::set<string>& files) {
     29   return FilesExist(std::vector<string>(files.begin(), files.end()), nullptr);
     30 }
     31 
     32 bool FileExists(const std::string& file, Status* status) {
     33   *status = Env::Default()->FileExists(file);
     34   return status->ok();
     35 }
     36 
     37 Status ReadGraphDefFromFile(const std::string& graph_def_pbtxt_path,
     38                             GraphDef* result) {
     39   Status status;
     40   if (FileExists(graph_def_pbtxt_path, &status)) {
     41     return ReadTextProto(Env::Default(), graph_def_pbtxt_path, result);
     42   }
     43   return status;
     44 }
     45 
     46 }  // End namespace grappler
     47 }  // end namespace tensorflow
     48