We have special handling for distributed variable in get_slot, but not create_slot, while these keys need to match. This change modifies get_slot to use _var_key as well to avoid confusion. It is also to prepare for a upcoming refactor in dist strat code. Note that we need to make sure the keys don't change, so existing checkpoints can still be used. A bunch of build rules are modified to break cyclic dependencies. PiperOrigin-RevId: 354341520 Change-Id: Ifd9786263024a11806ddde0c3bd1d36157ab8db7
255 lines
6.8 KiB
Python
255 lines
6.8 KiB
Python
# Description:
|
|
# Utilities for reading and writing object-based checkpoints.
|
|
|
|
load("//tensorflow:tensorflow.bzl", "tf_py_test")
|
|
load(
|
|
"//tensorflow/tools/test:performance.bzl",
|
|
"tf_py_logged_benchmark",
|
|
)
|
|
|
|
package(
|
|
default_visibility = [
|
|
"//tensorflow:internal",
|
|
],
|
|
licenses = ["notice"], # Apache 2.0
|
|
)
|
|
|
|
exports_files(["LICENSE"])
|
|
|
|
py_library(
|
|
name = "base",
|
|
srcs = ["base.py"],
|
|
srcs_version = "PY3",
|
|
deps = [
|
|
"//tensorflow/python:array_ops",
|
|
"//tensorflow/python:constant_op",
|
|
"//tensorflow/python:control_flow_ops",
|
|
"//tensorflow/python:dtypes",
|
|
"//tensorflow/python:framework_ops",
|
|
"//tensorflow/python:io_ops_gen",
|
|
"//tensorflow/python:platform",
|
|
"//tensorflow/python:util",
|
|
"//tensorflow/python/eager:context",
|
|
"//tensorflow/python/training/saving:saveable_object",
|
|
"@six_archive//:six",
|
|
],
|
|
)
|
|
|
|
tf_py_test(
|
|
name = "base_test",
|
|
srcs = ["base_test.py"],
|
|
deps = [
|
|
":base",
|
|
"//tensorflow/python:client_testlib",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "tracking",
|
|
srcs = ["tracking.py"],
|
|
srcs_version = "PY3",
|
|
deps = [
|
|
":base",
|
|
":data_structures",
|
|
],
|
|
)
|
|
|
|
tf_py_test(
|
|
name = "tracking_test",
|
|
srcs = ["tracking_test.py"],
|
|
deps = [
|
|
":base",
|
|
":tracking",
|
|
"//tensorflow/python:client_testlib",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "layer_utils",
|
|
srcs = ["layer_utils.py"],
|
|
srcs_version = "PY3",
|
|
)
|
|
|
|
py_library(
|
|
name = "data_structures",
|
|
srcs = ["data_structures.py"],
|
|
srcs_version = "PY3",
|
|
deps = [
|
|
":base",
|
|
":layer_utils",
|
|
"//tensorflow/python/saved_model:revived_types",
|
|
"@wrapt",
|
|
],
|
|
)
|
|
|
|
tf_py_test(
|
|
name = "data_structures_test",
|
|
srcs = ["data_structures_test.py"],
|
|
tags = [
|
|
"no_windows",
|
|
"nomac",
|
|
],
|
|
deps = [
|
|
":data_structures",
|
|
"//tensorflow/python:array_ops",
|
|
"//tensorflow/python:framework_test_lib",
|
|
"//tensorflow/python:layers",
|
|
"//tensorflow/python:math_ops",
|
|
"//tensorflow/python/eager:context",
|
|
"//tensorflow/python/eager:test",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "graph_view",
|
|
srcs = ["graph_view.py"],
|
|
srcs_version = "PY3",
|
|
deps = [
|
|
":base",
|
|
":tracking",
|
|
"//tensorflow/core:protos_all_py",
|
|
"//tensorflow/python:constant_op",
|
|
"//tensorflow/python:dtypes",
|
|
"//tensorflow/python:framework_ops",
|
|
"//tensorflow/python/training:optimizer",
|
|
"//tensorflow/python/training/saving:saveable_object",
|
|
"//tensorflow/python/training/saving:saveable_object_util",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "util",
|
|
srcs = ["util.py"],
|
|
srcs_version = "PY3",
|
|
deps = [
|
|
":base",
|
|
":data_structures",
|
|
":graph_view",
|
|
":tracking",
|
|
"//tensorflow/core:protos_all_py",
|
|
"//tensorflow/python:array_ops",
|
|
"//tensorflow/python:checkpoint_management",
|
|
"//tensorflow/python:constant_op",
|
|
"//tensorflow/python:dtypes",
|
|
"//tensorflow/python:errors",
|
|
"//tensorflow/python:framework_ops",
|
|
"//tensorflow/python:init_ops",
|
|
"//tensorflow/python:io_ops_gen",
|
|
"//tensorflow/python:lib",
|
|
"//tensorflow/python:platform",
|
|
"//tensorflow/python:pywrap_tensorflow",
|
|
"//tensorflow/python:saver",
|
|
"//tensorflow/python:session",
|
|
"//tensorflow/python:tensor_shape",
|
|
"//tensorflow/python:tensor_util",
|
|
"//tensorflow/python:util",
|
|
"//tensorflow/python:variable_scope",
|
|
"//tensorflow/python:variables",
|
|
"//tensorflow/python/eager:context",
|
|
"//tensorflow/python/eager:def_function",
|
|
"//tensorflow/python/saved_model:utils",
|
|
"//tensorflow/python/training/saving:checkpoint_options",
|
|
"//tensorflow/python/training/saving:functional_saver",
|
|
"//tensorflow/python/training/saving:saveable_object_util",
|
|
"@six_archive//:six",
|
|
],
|
|
)
|
|
|
|
tf_py_test(
|
|
name = "util_test",
|
|
srcs = ["util_test.py"],
|
|
tags = ["notsan"], # b/74395663
|
|
deps = [
|
|
":base",
|
|
":graph_view",
|
|
":tracking",
|
|
":util",
|
|
"//tensorflow/python:checkpoint_management",
|
|
"//tensorflow/python:client_testlib",
|
|
"//tensorflow/python:constant_op",
|
|
"//tensorflow/python:control_flow_ops",
|
|
"//tensorflow/python:dtypes",
|
|
"//tensorflow/python:framework_ops",
|
|
"//tensorflow/python:framework_test_lib",
|
|
"//tensorflow/python:init_ops",
|
|
"//tensorflow/python:platform",
|
|
"//tensorflow/python:pywrap_tensorflow",
|
|
"//tensorflow/python:resource_variable_ops",
|
|
"//tensorflow/python:saver",
|
|
"//tensorflow/python:session",
|
|
"//tensorflow/python:state_ops",
|
|
"//tensorflow/python:template",
|
|
"//tensorflow/python:training_util",
|
|
"//tensorflow/python:variable_scope",
|
|
"//tensorflow/python:variables",
|
|
"//tensorflow/python/eager:backprop",
|
|
"//tensorflow/python/eager:context",
|
|
"//tensorflow/python/eager:def_function",
|
|
"//tensorflow/python/eager:test",
|
|
"//tensorflow/python/saved_model:save",
|
|
"//tensorflow/python/training/saving:checkpoint_options",
|
|
"@absl_py//absl/testing:parameterized",
|
|
"@six_archive//:six",
|
|
],
|
|
)
|
|
|
|
tf_py_test(
|
|
name = "util_with_v1_optimizers_test",
|
|
srcs = ["util_with_v1_optimizers_test.py"],
|
|
tags = [
|
|
"notsan", # b/74395663
|
|
],
|
|
deps = [
|
|
":tracking",
|
|
":util",
|
|
"//tensorflow/python:framework_ops",
|
|
"//tensorflow/python:framework_test_lib",
|
|
"//tensorflow/python:init_ops",
|
|
"//tensorflow/python:resource_variable_ops",
|
|
"//tensorflow/python:session",
|
|
"//tensorflow/python:state_ops",
|
|
"//tensorflow/python:template",
|
|
"//tensorflow/python:training",
|
|
"//tensorflow/python:variable_scope",
|
|
"//tensorflow/python/eager:context",
|
|
"//tensorflow/python/eager:test",
|
|
"@six_archive//:six",
|
|
],
|
|
)
|
|
|
|
py_library(
|
|
name = "python_state",
|
|
srcs = ["python_state.py"],
|
|
srcs_version = "PY3",
|
|
deps = [
|
|
":base",
|
|
],
|
|
)
|
|
|
|
tf_py_test(
|
|
name = "python_state_test",
|
|
srcs = ["python_state_test.py"],
|
|
deps = [
|
|
":base",
|
|
":util",
|
|
"//tensorflow/python:client_testlib",
|
|
"//tensorflow/python:framework_test_lib",
|
|
"//tensorflow/python/module",
|
|
],
|
|
)
|
|
|
|
tf_py_test(
|
|
name = "benchmarks_test",
|
|
srcs = ["benchmarks_test.py"],
|
|
deps = [
|
|
":util",
|
|
"//tensorflow/python:framework_ops",
|
|
"//tensorflow/python:platform_test",
|
|
],
|
|
)
|
|
|
|
tf_py_logged_benchmark(
|
|
name = "benchmarks",
|
|
target = "//tensorflow/python/training/tracking:benchmarks_test",
|
|
)
|