Migrate references to dp_event to Google DP libraries.

PiperOrigin-RevId: 440204574
This commit is contained in:
A. Unique TensorFlower 2022-04-07 14:42:31 -07:00
parent 5493a3baf0
commit 676945d3a6
13 changed files with 49 additions and 19 deletions

View file

@ -13,3 +13,23 @@ git_repository(
remote = "https://github.com/bazelbuild/rules_python.git",
tag = "0.5.0",
)
git_repository(
name = "com_google_differential_py",
remote = "https://github.com/google/differential-privacy.git",
commit = "8536a3af6b147b1cce6f884826bfd5f2009ae50f",
)
# This is a workaround until the @com_google_differential_py WORKSPACE declares
# the nested differential-privacy/python/WORKSPACE as a local_repository, or
# https://github.com/bazelbuild/bazel/issues/1943 is fixed to support recursive
# WORKSPACE loading via git_repository.
load("@com_google_differential_py//python:accounting_py_deps.bzl", "accounting_py_deps")
accounting_py_deps()
# We can't directly use accounting_py_deps_init.bzl because it hard-codes a path
# to the requirements file that is relative to the workspace root.
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
name = "accounting_py_pip_deps",
requirements = "@com_google_differential_py//python:requirements.txt",
)

View file

@ -36,7 +36,7 @@ py_library(
deps = [
":discrete_gaussian_utils",
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -59,7 +59,7 @@ py_library(
deps = [
":discrete_gaussian_utils",
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -82,7 +82,7 @@ py_library(
deps = [
":dp_query",
":normalized_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -103,7 +103,7 @@ py_library(
srcs_version = "PY3",
deps = [
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -125,7 +125,7 @@ py_library(
srcs_version = "PY3",
deps = [
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -167,7 +167,7 @@ py_library(
srcs_version = "PY3",
deps = [
":dp_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -194,7 +194,7 @@ py_library(
":dp_query",
":gaussian_query",
":quantile_estimator_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -274,7 +274,7 @@ py_library(
deps = [
":dp_query",
":tree_aggregation",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)
@ -286,7 +286,7 @@ py_library(
":distributed_discrete_gaussian_query",
":dp_query",
":gaussian_query",
"//tensorflow_privacy/privacy/analysis:dp_event",
"@com_google_differential_py//python/dp_accounting:dp_event",
],
)

View file

@ -16,10 +16,11 @@
import collections
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import discrete_gaussian_utils
from tensorflow_privacy.privacy.dp_query import dp_query
from com_google_differential_py.python.dp_accounting import dp_event
class DiscreteGaussianSumQuery(dp_query.SumAggregationDPQuery):
"""Implements DPQuery for discrete Gaussian sum queries.

View file

@ -16,10 +16,11 @@
import collections
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import discrete_gaussian_utils
from tensorflow_privacy.privacy.dp_query import dp_query
from com_google_differential_py.python.dp_accounting import dp_event
class DistributedDiscreteGaussianSumQuery(dp_query.SumAggregationDPQuery):
"""Implements DPQuery for discrete distributed Gaussian sum queries.

View file

@ -16,10 +16,11 @@
import collections
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import dp_query
from tensorflow_privacy.privacy.dp_query import normalized_query
from com_google_differential_py.python.dp_accounting import dp_event
class DistributedSkellamSumQuery(dp_query.SumAggregationDPQuery):
"""Implements DPQuery interface for discrete distributed sum queries.

View file

@ -17,9 +17,10 @@ import collections
import distutils
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import dp_query
from com_google_differential_py.python.dp_accounting import dp_event
class GaussianSumQuery(dp_query.SumAggregationDPQuery):
"""Implements DPQuery interface for Gaussian sum queries.

View file

@ -16,10 +16,11 @@
import collections
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import dp_query
import tree
from com_google_differential_py.python.dp_accounting import dp_event
class NestedQuery(dp_query.DPQuery):
"""Implements DPQuery interface for structured queries.

View file

@ -14,9 +14,10 @@
"""Implements DPQuery interface for no privacy average queries."""
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import dp_query
from com_google_differential_py.python.dp_accounting import dp_event
class NoPrivacySumQuery(dp_query.SumAggregationDPQuery):
"""Implements DPQuery interface for a sum query with no privacy.

View file

@ -16,11 +16,12 @@
import collections
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import dp_query
from tensorflow_privacy.privacy.dp_query import gaussian_query
from tensorflow_privacy.privacy.dp_query import quantile_estimator_query
from com_google_differential_py.python.dp_accounting import dp_event
class QuantileAdaptiveClipSumQuery(dp_query.SumAggregationDPQuery):
"""`DPQuery` for Gaussian sum queries with adaptive clipping.

View file

@ -35,10 +35,11 @@ corresponding epsilon for a `target_delta` and `noise_multiplier` to achieve
import attr
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import dp_query
from tensorflow_privacy.privacy.dp_query import tree_aggregation
from com_google_differential_py.python.dp_accounting import dp_event
# TODO(b/193679963): define `RestartQuery` and move `RestartIndicator` to be
# in the same module.

View file

@ -22,11 +22,12 @@ from typing import Optional
import attr
import tensorflow as tf
from tensorflow_privacy.privacy.analysis import dp_event
from tensorflow_privacy.privacy.dp_query import distributed_discrete_gaussian_query
from tensorflow_privacy.privacy.dp_query import dp_query
from tensorflow_privacy.privacy.dp_query import gaussian_query
from com_google_differential_py.python.dp_accounting import dp_event
def _build_tree_from_leaf(leaf_nodes: tf.Tensor, arity: int) -> tf.RaggedTensor:
"""A function constructs a complete tree given all the leaf nodes.

View file

@ -13,6 +13,7 @@ py_library(
":single_layer_softmax",
"//tensorflow_privacy/privacy/analysis:compute_dp_sgd_privacy_lib",
"//tensorflow_privacy/privacy/optimizers:dp_optimizer_keras",
"@com_google_differential_py//python/dp_accounting:common",
],
)

View file

@ -35,7 +35,7 @@ from tensorflow_privacy.privacy.logistic_regression import datasets
from tensorflow_privacy.privacy.logistic_regression import single_layer_softmax
from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras
from differential_privacy.python.accounting import common
from com_google_differential_py.python.dp_accounting import common
@tf.keras.utils.register_keras_serializable(package='Custom', name='Kifer')