diff --git a/tensorflow/python/kernel_tests/resource_variable_ops_test.py b/tensorflow/python/kernel_tests/resource_variable_ops_test.py index 87fc2bec2e2..eebd81964e0 100644 --- a/tensorflow/python/kernel_tests/resource_variable_ops_test.py +++ b/tensorflow/python/kernel_tests/resource_variable_ops_test.py @@ -134,13 +134,19 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase, def testEagerDeepCopy(self): with context.eager_mode(): init_value = np.ones((4, 4, 4)) - variable = resource_variable_ops.ResourceVariable(init_value, - name="init") + variable = resource_variable_ops.ResourceVariable( + init_value, + name="init", + synchronization=variables.VariableSynchronization.ON_READ, + aggregation=variables.VariableAggregation.SUM) copied_variable = copy.deepcopy(variable) self.assertEqual(variable.name, copied_variable.name) self.assertEqual(variable.shape, copied_variable.shape) self.assertEqual(variable.device, copied_variable.device) + self.assertEqual(variable.synchronization, + copied_variable.synchronization) + self.assertEqual(variable.aggregation, copied_variable.aggregation) # The copied variable should have the same value as the original. self.assertAllEqual(variable.numpy(), copied_variable.numpy()) diff --git a/tensorflow/python/ops/resource_variable_ops.py b/tensorflow/python/ops/resource_variable_ops.py index 0c7c3af3864..a3289a5ae5b 100644 --- a/tensorflow/python/ops/resource_variable_ops.py +++ b/tensorflow/python/ops/resource_variable_ops.py @@ -502,7 +502,9 @@ class BaseResourceVariable(variables.VariableV1, core.Tensor): constraint=self._constraint, dtype=self._dtype, name=self._shared_name, - distribute_strategy=self._distribute_strategy) + distribute_strategy=self._distribute_strategy, + synchronization=self.synchronization, + aggregation=self.aggregation) memo[self._unique_id] = copied_variable return copied_variable