tf.compat.forward_compatible
Stay organized with collections
Save and categorize content based on your preferences.
Return true if the forward compatibility window has expired.
tf.compat.forward_compatible(
year, month, day
)
See Version
compatibility.
Forward-compatibility refers to scenarios where the producer of a TensorFlow
model (a GraphDef or SavedModel) is compiled against a version of the
TensorFlow library newer than what the consumer was compiled against. The
"producer" is typically a Python program that constructs and trains a model
while the "consumer" is typically another program that loads and serves the
model.
TensorFlow has been supporting a 3 week forward-compatibility window for
programs compiled from source at HEAD.
For example, consider the case where a new operation MyNewAwesomeAdd
is
created with the intent of replacing the implementation of an existing Python
wrapper - tf.add
. The Python wrapper implementation should change from
something like:
def add(inputs, name=None):
return gen_math_ops.add(inputs, name)
to:
from tensorflow.python.compat import compat
def add(inputs, name=None):
if compat.forward_compatible(year, month, day):
# Can use the awesome new implementation.
return gen_math_ops.my_new_awesome_add(inputs, name)
# To maintain forward compatibility, use the old implementation.
return gen_math_ops.add(inputs, name)
Where year
, month
, and day
specify the date beyond which binaries
that consume a model are expected to have been updated to include the
new operations. This date is typically at least 3 weeks beyond the date
the code that adds the new operation is committed.
Args |
year
|
A year (e.g., 2018). Must be an int .
|
month
|
A month (1 <= month <= 12) in year. Must be an int .
|
day
|
A day (1 <= day <= 31, or 30, or 29, or 28) in month. Must be an
int .
|
Returns |
True if the caller can expect that serialized TensorFlow graphs produced
can be consumed by programs that are compiled with the TensorFlow library
source code after (year, month, day).
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.forward_compatible\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/compat/compat.py#L65-L122) |\n\nReturn true if the forward compatibility window has expired.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.compat.forward_compatible`](https://www.tensorflow.org/api_docs/python/tf/compat/forward_compatible)\n\n\u003cbr /\u003e\n\n tf.compat.forward_compatible(\n year, month, day\n )\n\nSee [Version\ncompatibility](https://www.tensorflow.org/guide/versions#backward_and_partial_forward_compatibility).\n\nForward-compatibility refers to scenarios where the producer of a TensorFlow\nmodel (a GraphDef or SavedModel) is compiled against a version of the\nTensorFlow library newer than what the consumer was compiled against. The\n\"producer\" is typically a Python program that constructs and trains a model\nwhile the \"consumer\" is typically another program that loads and serves the\nmodel.\n\nTensorFlow has been supporting a 3 week forward-compatibility window for\nprograms compiled from source at HEAD.\n\nFor example, consider the case where a new operation `MyNewAwesomeAdd` is\ncreated with the intent of replacing the implementation of an existing Python\nwrapper - [`tf.add`](../../tf/math/add). The Python wrapper implementation should change from\nsomething like: \n\n def add(inputs, name=None):\n return gen_math_ops.add(inputs, name)\n\nto: \n\n from tensorflow.python.compat import compat\n\n def add(inputs, name=None):\n if compat.forward_compatible(year, month, day):\n # Can use the awesome new implementation.\n return gen_math_ops.my_new_awesome_add(inputs, name)\n # To maintain forward compatibility, use the old implementation.\n return gen_math_ops.add(inputs, name)\n\nWhere `year`, `month`, and `day` specify the date beyond which binaries\nthat consume a model are expected to have been updated to include the\nnew operations. This date is typically at least 3 weeks beyond the date\nthe code that adds the new operation is committed.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|---------------------------------------------------------------------------|\n| `year` | A year (e.g., 2018). Must be an `int`. |\n| `month` | A month (1 \\\u003c= month \\\u003c= 12) in year. Must be an `int`. |\n| `day` | A day (1 \\\u003c= day \\\u003c= 31, or 30, or 29, or 28) in month. Must be an `int`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| True if the caller can expect that serialized TensorFlow graphs produced can be consumed by programs that are compiled with the TensorFlow library source code after (year, month, day). ||\n\n\u003cbr /\u003e"]]