From 668afa892ea4325351bbe17b63b3c3301915d4c6 Mon Sep 17 00:00:00 2001 From: Galen Andrew Date: Tue, 4 Jan 2022 13:10:41 -0800 Subject: [PATCH] Migrate references to `dp_event` to Google DP libraries. PiperOrigin-RevId: 419663382 --- .../privacy/dp_query/discrete_gaussian_query.py | 4 +++- .../privacy/dp_query/distributed_discrete_gaussian_query.py | 3 ++- tensorflow_privacy/privacy/dp_query/gaussian_query.py | 2 +- tensorflow_privacy/privacy/dp_query/nested_query.py | 4 ++-- tensorflow_privacy/privacy/dp_query/no_privacy_query.py | 2 +- .../privacy/dp_query/quantile_adaptive_clip_sum_query.py | 3 ++- tensorflow_privacy/privacy/dp_query/tree_aggregation_query.py | 3 ++- tensorflow_privacy/privacy/dp_query/tree_range_query.py | 3 ++- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tensorflow_privacy/privacy/dp_query/discrete_gaussian_query.py b/tensorflow_privacy/privacy/dp_query/discrete_gaussian_query.py index 6797b6a..2b3db5d 100644 --- a/tensorflow_privacy/privacy/dp_query/discrete_gaussian_query.py +++ b/tensorflow_privacy/privacy/dp_query/discrete_gaussian_query.py @@ -16,10 +16,12 @@ 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 differential_privacy.python.accounting import dp_event + class DiscreteGaussianSumQuery(dp_query.SumAggregationDPQuery): """Implements DPQuery for discrete Gaussian sum queries. diff --git a/tensorflow_privacy/privacy/dp_query/distributed_discrete_gaussian_query.py b/tensorflow_privacy/privacy/dp_query/distributed_discrete_gaussian_query.py index 30031f6..e4d9559 100644 --- a/tensorflow_privacy/privacy/dp_query/distributed_discrete_gaussian_query.py +++ b/tensorflow_privacy/privacy/dp_query/distributed_discrete_gaussian_query.py @@ -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 differential_privacy.python.accounting import dp_event + class DistributedDiscreteGaussianSumQuery(dp_query.SumAggregationDPQuery): """Implements DPQuery for discrete distributed Gaussian sum queries. diff --git a/tensorflow_privacy/privacy/dp_query/gaussian_query.py b/tensorflow_privacy/privacy/dp_query/gaussian_query.py index 3edd2fb..e600613 100644 --- a/tensorflow_privacy/privacy/dp_query/gaussian_query.py +++ b/tensorflow_privacy/privacy/dp_query/gaussian_query.py @@ -22,8 +22,8 @@ import distutils import tensorflow.compat.v1 as tf -from tensorflow_privacy.privacy.analysis import dp_event from tensorflow_privacy.privacy.dp_query import dp_query +from differential_privacy.python.accounting import dp_event class GaussianSumQuery(dp_query.SumAggregationDPQuery): diff --git a/tensorflow_privacy/privacy/dp_query/nested_query.py b/tensorflow_privacy/privacy/dp_query/nested_query.py index b4e2247..2c4053a 100644 --- a/tensorflow_privacy/privacy/dp_query/nested_query.py +++ b/tensorflow_privacy/privacy/dp_query/nested_query.py @@ -20,11 +20,11 @@ from __future__ import print_function import collections import tensorflow.compat.v1 as tf - -from tensorflow_privacy.privacy.analysis import dp_event from tensorflow_privacy.privacy.dp_query import dp_query import tree +from differential_privacy.python.accounting import dp_event + class NestedQuery(dp_query.DPQuery): """Implements DPQuery interface for structured queries. diff --git a/tensorflow_privacy/privacy/dp_query/no_privacy_query.py b/tensorflow_privacy/privacy/dp_query/no_privacy_query.py index 3840003..c1837a0 100644 --- a/tensorflow_privacy/privacy/dp_query/no_privacy_query.py +++ b/tensorflow_privacy/privacy/dp_query/no_privacy_query.py @@ -19,8 +19,8 @@ from __future__ import print_function import tensorflow.compat.v1 as tf -from tensorflow_privacy.privacy.analysis import dp_event from tensorflow_privacy.privacy.dp_query import dp_query +from differential_privacy.python.accounting import dp_event class NoPrivacySumQuery(dp_query.SumAggregationDPQuery): diff --git a/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py b/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py index 15a8b36..94a2f98 100644 --- a/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py +++ b/tensorflow_privacy/privacy/dp_query/quantile_adaptive_clip_sum_query.py @@ -21,11 +21,12 @@ import collections import tensorflow.compat.v1 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 differential_privacy.python.accounting import dp_event + class QuantileAdaptiveClipSumQuery(dp_query.SumAggregationDPQuery): """`DPQuery` for Gaussian sum queries with adaptive clipping. diff --git a/tensorflow_privacy/privacy/dp_query/tree_aggregation_query.py b/tensorflow_privacy/privacy/dp_query/tree_aggregation_query.py index 70f9efa..4cceeb4 100644 --- a/tensorflow_privacy/privacy/dp_query/tree_aggregation_query.py +++ b/tensorflow_privacy/privacy/dp_query/tree_aggregation_query.py @@ -22,10 +22,11 @@ and `tree_aggregation.EfficientTreeAggregator`. 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 differential_privacy.python.accounting import dp_event + # TODO(b/193679963): define `RestartQuery` and move `RestartIndicator` to be # in the same module. diff --git a/tensorflow_privacy/privacy/dp_query/tree_range_query.py b/tensorflow_privacy/privacy/dp_query/tree_range_query.py index 471915b..2a4a984 100644 --- a/tensorflow_privacy/privacy/dp_query/tree_range_query.py +++ b/tensorflow_privacy/privacy/dp_query/tree_range_query.py @@ -20,11 +20,12 @@ import math 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 differential_privacy.python.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.