Commit 9a828c2e authored by Keith Rush's avatar Keith Rush Committed by tensorflow-copybara
Browse files

Deletes reference context.

With migration of form_utils_test, the reference context / executor will be dead code.

Further, there are outstanding bugs indicating that the reference context should be removed from the public API, and used in unit tests--however, it is not used for any unit tests any longer. Therefore, preferring to remove.

PiperOrigin-RevId: 413804412
parent 8184a1c2
......@@ -158,16 +158,3 @@ with an iree compiler and an [execution stack](execution.md#execution-stack)
with an
[executor.IreeExecutor](https://github.com/tensorflow/federated/blob/main/tensorflow_federated/python/core/backends/iree/executor.py)
delegating to an external IREE runtime.
## Reference
A
[reference_context.ReferenceContext](https://github.com/tensorflow/federated/blob/main/tensorflow_federated/python/core/backends/reference/reference_context.py)
is a
[context_base.Context](https://github.com/tensorflow/federated/blob/main/tensorflow_federated/python/core/impl/context_stack/context_base.py)
that compiles and executes ASTs. Note that the `ReferenceContext` does not
inherit from
[execution_context.ExecutionContext](https://github.com/tensorflow/federated/blob/main/tensorflow_federated/python/core/impl/execution_contexts/sync_execution_context.py)
and the runtime is not implemented as an
[execution stack](execution.md#execution-stack); instead the compiler and
runtime are trivially implemented inline in the `ReferenceContext`.
......@@ -17,7 +17,6 @@ py_library(
deps = [
"//tensorflow_federated/python/core/backends/mapreduce",
"//tensorflow_federated/python/core/backends/native",
"//tensorflow_federated/python/core/backends/reference",
"//tensorflow_federated/python/core/backends/test",
"//tensorflow_federated/python/core/backends/xla",
],
......
......@@ -22,6 +22,5 @@ expressibe in TFF.
from tensorflow_federated.python.core.backends import mapreduce
from tensorflow_federated.python.core.backends import native
from tensorflow_federated.python.core.backends import reference
from tensorflow_federated.python.core.backends import test
from tensorflow_federated.python.core.backends import xla
......@@ -87,7 +87,7 @@ py_test(
":test_utils",
"//tensorflow_federated/python/core/api:computations",
"//tensorflow_federated/python/core/api:test_case",
"//tensorflow_federated/python/core/backends/reference:reference_context",
"//tensorflow_federated/python/core/backends/test:execution_contexts",
"//tensorflow_federated/python/core/impl/compiler:building_blocks",
"//tensorflow_federated/python/core/impl/compiler:transformation_utils",
"//tensorflow_federated/python/core/impl/compiler:tree_analysis",
......
......@@ -23,7 +23,7 @@ from tensorflow_federated.python.core.api import test_case
from tensorflow_federated.python.core.backends.mapreduce import form_utils
from tensorflow_federated.python.core.backends.mapreduce import forms
from tensorflow_federated.python.core.backends.mapreduce import test_utils as mapreduce_test_utils
from tensorflow_federated.python.core.backends.reference import reference_context
from tensorflow_federated.python.core.backends.test import execution_contexts
from tensorflow_federated.python.core.impl.compiler import building_blocks
from tensorflow_federated.python.core.impl.compiler import transformation_utils
from tensorflow_federated.python.core.impl.compiler import tree_analysis
......@@ -656,8 +656,16 @@ class GetMapReduceFormForIterativeProcessTest(MapReduceFormTestCase,
def test_mnist_training_round_trip(self):
it = form_utils.get_iterative_process_for_map_reduce_form(
mapreduce_test_utils.get_mnist_training_example())
mrf = form_utils.get_map_reduce_form_for_iterative_process(it)
# TODO(b/208887729): We disable grappler to work around attempting to hoist
# transformed functions of the same name into the eager context. When this
# execution is C++-backed, this can go away.
grappler_config = tf.compat.v1.ConfigProto()
grappler_config.graph_options.rewrite_options.disable_meta_optimizer = True
mrf = form_utils.get_map_reduce_form_for_iterative_process(
it, grappler_config)
new_it = form_utils.get_iterative_process_for_map_reduce_form(mrf)
state1 = it.initialize()
state2 = new_it.initialize()
self.assertAllClose(state1, state2)
......@@ -1046,7 +1054,7 @@ class AsFunctionOfSomeSubparametersTest(test_case.TestCase):
if __name__ == '__main__':
# The reference context is used here because it is currently the only context
# which implements the `tff.federated_secure_sum_bitwidth` intrinsic.
reference_context.set_reference_context()
# The test execution context replaces all secure intrinsics with insecure
# reductions.
execution_contexts.set_test_execution_context()
test_case.main()
load("@rules_python//python:defs.bzl", "py_library", "py_test")
package(default_visibility = [
":reference_packages",
"//tensorflow_federated/python/core:core_visibility",
# TODO(b/192368386): One backend should not depend on another backend.
"//tensorflow_federated/python/core/backends/mapreduce:mapreduce_packages",
])
package_group(
name = "reference_packages",
packages = ["//tensorflow_federated/python/core/backends/reference/..."],
)
licenses(["notice"])
py_library(
name = "reference",
srcs = ["__init__.py"],
srcs_version = "PY3",
visibility = ["//tensorflow_federated/python/core/backends:__pkg__"],
deps = [
":reference_context",
],
)
py_library(
name = "reference_context",
srcs = ["reference_context.py"],
srcs_version = "PY3",
deps = [
"//tensorflow_federated/python/common_libs:py_typecheck",
"//tensorflow_federated/python/common_libs:structure",
"//tensorflow_federated/python/core/impl/compiler:building_blocks",
"//tensorflow_federated/python/core/impl/compiler:compiler_pipeline",
"//tensorflow_federated/python/core/impl/compiler:intrinsic_defs",
"//tensorflow_federated/python/core/impl/compiler:intrinsic_reductions",
"//tensorflow_federated/python/core/impl/compiler:transformations",
"//tensorflow_federated/python/core/impl/compiler:tree_transformations",
"//tensorflow_federated/python/core/impl/computation:computation_impl",
"//tensorflow_federated/python/core/impl/context_stack:context_base",
"//tensorflow_federated/python/core/impl/context_stack:context_stack_impl",
"//tensorflow_federated/python/core/impl/executors:cardinalities_utils",
"//tensorflow_federated/python/core/impl/types:computation_types",
"//tensorflow_federated/python/core/impl/types:placements",
"//tensorflow_federated/python/core/impl/types:type_analysis",
"//tensorflow_federated/python/core/impl/types:type_conversions",
"//tensorflow_federated/python/core/impl/utils:tensorflow_utils",
],
)
py_test(
name = "reference_context_test",
size = "small",
srcs = ["reference_context_test.py"],
python_version = "PY3",
srcs_version = "PY3",
deps = [
":reference_context",
"//tensorflow_federated/python/common_libs:structure",
"//tensorflow_federated/python/core/api:computations",
"//tensorflow_federated/python/core/api:test_case",
"//tensorflow_federated/python/core/impl/compiler:building_block_factory",
"//tensorflow_federated/python/core/impl/compiler:building_blocks",
"//tensorflow_federated/python/core/impl/computation:computation_impl",
"//tensorflow_federated/python/core/impl/context_stack:context_stack_impl",
"//tensorflow_federated/python/core/impl/federated_context:intrinsics",
"//tensorflow_federated/python/core/impl/federated_context:value_impl",
"//tensorflow_federated/python/core/impl/types:computation_types",
"//tensorflow_federated/python/core/impl/types:placements",
"//tensorflow_federated/python/core/impl/utils:tensorflow_utils",
],
)
# Copyright 2020, The TensorFlow Federated Authors.
#
# 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.
"""Libraries for interacting with reference backends."""
from tensorflow_federated.python.core.backends.reference.reference_context import create_reference_context
from tensorflow_federated.python.core.backends.reference.reference_context import set_reference_context
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment