| 29 | namespace { |
| 30 | |
| 31 | void WriteUpdateTo(const string& directory) { |
| 32 | OpCompatibilityLib compatibility( |
| 33 | directory, strings::StrCat("v", TF_MAJOR_VERSION), nullptr); |
| 34 | |
| 35 | // Write full copy of all ops to ops.pbtxt. |
| 36 | Env* env = Env::Default(); |
| 37 | { |
| 38 | const string& ops_file = compatibility.ops_file(); |
| 39 | printf("Writing ops to %s...\n", ops_file.c_str()); |
| 40 | TF_QCHECK_OK(WriteStringToFile(env, ops_file, compatibility.OpsString())); |
| 41 | } |
| 42 | |
| 43 | // Make sure the current version of ops are compatible with the |
| 44 | // historical versions, and generate a new history adding all |
| 45 | // changed ops. |
| 46 | OpCompatibilityLib::OpHistory out_op_history; |
| 47 | int changed_ops = 0; |
| 48 | int added_ops = 0; |
| 49 | TF_QCHECK_OK(compatibility.ValidateCompatible(env, &changed_ops, &added_ops, |
| 50 | &out_op_history)); |
| 51 | printf("%d changed ops\n%d added ops\n", changed_ops, added_ops); |
| 52 | |
| 53 | const string& history_dir = compatibility.op_history_directory(); |
| 54 | Status status = env->CreateDir(history_dir); |
| 55 | if (!errors::IsAlreadyExists(status)) { |
| 56 | TF_QCHECK_OK(status); |
| 57 | } |
| 58 | if (changed_ops + added_ops > 0 || !errors::IsAlreadyExists(status)) { |
| 59 | // Write out new op history. |
| 60 | printf("Writing updated op history to %s/...\n", history_dir.c_str()); |
| 61 | for (const auto& op_file : out_op_history) { |
| 62 | TF_QCHECK_OK(WriteStringToFile(env, |
| 63 | io::JoinPath(history_dir, op_file.first), |
| 64 | op_file.second.DebugString())); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } // namespace |
| 70 | } // namespace tensorflow |
no test coverage detected