diff options
author | 2016-02-10 13:52:47 -0800 | |
---|---|---|
committer | 2016-02-10 16:02:39 -0800 | |
commit | ea92856334a74519055a4e22aba7ceee5dd039a2 (patch) | |
tree | 5542d52c1be0a7802866ee83be77cdf82d4fc32d /tensorflow/core/framework/versions.cc | |
parent | b2757fb5797252bb1ef12bbf04be796cc83000cc (diff) |
Add versions to checkpoints
Checkpoints now have a version scheme analogous to that for GraphDefs. We have
no plans to ever deprecate a checkpoint version, but it's good to have the
scheme in place in case we need to.
Change: 114364388
Diffstat (limited to 'tensorflow/core/framework/versions.cc')
-rw-r--r-- | tensorflow/core/framework/versions.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tensorflow/core/framework/versions.cc b/tensorflow/core/framework/versions.cc new file mode 100644 index 0000000000..1373d7140f --- /dev/null +++ b/tensorflow/core/framework/versions.cc @@ -0,0 +1,55 @@ +/* Copyright 2015 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/core/framework/versions.h" +#include "tensorflow/core/lib/core/errors.h" +#include "tensorflow/core/public/version.h" + +namespace tensorflow { + +Status CheckVersions(const VersionDef& versions, int consumer, int min_producer, + const char* upper_name, const char* lower_name) { + // Guard against the caller misordering the arguments + if (consumer < min_producer) { + return errors::Internal(upper_name, " version check has consumer ", + consumer, " < min_producer ", min_producer, "."); + } + + // Check versions + if (versions.producer() < min_producer) { + return errors::InvalidArgument( + upper_name, " producer version ", versions.producer(), + " below min producer ", min_producer, " supported by TensorFlow ", + TF_VERSION_STRING, ". Please regenerate your ", lower_name, "."); + } + if (versions.min_consumer() > consumer) { + return errors::InvalidArgument( + upper_name, " min consumer version ", versions.min_consumer(), + " above current version ", consumer, " for TensorFlow ", + TF_VERSION_STRING, ". Please upgrade TensorFlow."); + } + for (const int bad_consumer : versions.bad_consumers()) { + if (bad_consumer == consumer) { + return errors::InvalidArgument( + upper_name, " disallows consumer version ", bad_consumer, + ". Please upgrade TensorFlow: this version is likely buggy."); + } + } + + // All good! + return Status::OK(); +} + +} // namespace tensorflow |