Ran Chen 8a356e8ca5 [retry] Use same var key in _create_slots/get_slot in V1 optimizer
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
2021-01-28 10:48:00 -08:00

60 lines
1.5 KiB
Python

load("//tensorflow:tensorflow.bzl", "tf_py_test")
package(
licenses = ["notice"], # Apache 2.0
)
py_library(
name = "v2_compat",
srcs = ["v2_compat.py"],
srcs_version = "PY3",
visibility = ["//tensorflow:internal"],
deps = [
"//tensorflow/python:control_flow_v2_toggles",
"//tensorflow/python:framework_ops",
"//tensorflow/python:tensor_shape",
"//tensorflow/python:tf2",
"//tensorflow/python:variable_scope",
"//tensorflow/python/data/experimental/ops:counter",
"//tensorflow/python/data/experimental/ops:interleave_ops",
"//tensorflow/python/data/experimental/ops:random_ops",
"//tensorflow/python/data/experimental/ops:readers",
"//tensorflow/python/data/ops:dataset_ops",
"//tensorflow/python/data/ops:readers",
"//tensorflow/python/eager:monitoring",
"//tensorflow/python/util:tf_export",
],
)
py_library(
name = "compat",
srcs = ["compat.py"],
srcs_version = "PY3",
visibility = ["//tensorflow:internal"],
deps = [
"//tensorflow/python:util",
],
)
tf_py_test(
name = "compat_test",
size = "small",
srcs = ["compat_test.py"],
tags = ["nofwdcompat"],
deps = [
":compat",
"//tensorflow/python:client_testlib",
],
)
tf_py_test(
name = "disable_v2_behavior_test",
size = "small",
srcs = ["disable_v2_behavior_test.py"],
deps = [
":v2_compat",
"//tensorflow/python:client_testlib",
"//tensorflow/python:framework",
],
)