Copy the base half_plus_two to `export_path`. Outputs the files using the passed names (typically the constants above). The Twiddler can be used to update the MetaGraphDef before output.
| 54 | // Outputs the files using the passed names (typically the constants above). |
| 55 | // The Twiddler can be used to update the MetaGraphDef before output. |
| 56 | Status CopyExport(const string& export_path, const string& variables_filename, |
| 57 | const string& meta_graph_def_filename, |
| 58 | const MetaGraphDefTwiddler& twiddler) { |
| 59 | TF_RETURN_IF_ERROR(Env::Default()->CreateDir(export_path)); |
| 60 | const string orig_path = test_util::TestSrcDirPath(kExportPath); |
| 61 | { |
| 62 | const string source = io::JoinPath(orig_path, kVariablesFilename); |
| 63 | const string sink = io::JoinPath(export_path, variables_filename); |
| 64 | |
| 65 | string data; |
| 66 | TF_RETURN_IF_ERROR(ReadFileToString(Env::Default(), source, &data)); |
| 67 | TF_RETURN_IF_ERROR(WriteStringToFile(Env::Default(), sink, data)); |
| 68 | } |
| 69 | { |
| 70 | const string source = io::JoinPath(orig_path, kMetaGraphDefFilename); |
| 71 | const string sink = io::JoinPath(export_path, meta_graph_def_filename); |
| 72 | |
| 73 | MetaGraphDef graph_def; |
| 74 | TF_RETURN_IF_ERROR(ReadBinaryProto(Env::Default(), source, &graph_def)); |
| 75 | twiddler(&graph_def); |
| 76 | TF_RETURN_IF_ERROR( |
| 77 | WriteStringToFile(Env::Default(), sink, graph_def.SerializeAsString())); |
| 78 | } |
| 79 | return Status::OK(); |
| 80 | } |
| 81 | |
| 82 | string MakeSerializedExample(float x) { |
| 83 | tensorflow::Example example; |
no test coverage detected