65bb3580e5cdd9adee17b5f80fba949550931271,test/test_tensorflow.py,MPITests,test_horovod_broadcast_grad,#MPITests#,591
Before Change
if size == 1:
return
with self.test_session(config=self.config) as session:
// As of TensorFlow v1.9, gradients are not supported on
// integer tensors
dtypes = [tf.float32, tf.float64]
dims = [1, 2, 3]
root_ranks = list(range(size))
for dtype, dim, root_rank in itertools.product(
dtypes, dims, root_ranks):
tensor = tf.ones([5] * dim) * rank
if dtype == tf.bool:
tensor = tensor % 2
tensor = tf.cast(tensor, dtype=dtype)
broadcasted_tensor = hvd.broadcast(tensor, root_rank)
grad_ys = tf.ones([5] * dim)
grad = tf.gradients(broadcasted_tensor, tensor, grad_ys)[0]
grad_out = session.run(grad)
c = size if rank == root_rank else 0
expected = np.ones([5] * dim) * c
err = np.linalg.norm(expected - grad_out)
self.assertLess(err, 0.00000001,
"gradient %s differs from expected %s, "
"error: %s" % (grad_out, expected, str(err)))
def test_compression_fp16(self):
valid_dtypes = [tf.float16, tf.float32, tf.float64]
invalid_dtypes = [tf.uint8, tf.int8, tf.uint16, tf.int16,
tf.int32, tf.int64, tf.bool]
After Change
for dtype, dim, root_rank in itertools.product(
dtypes, dims, root_ranks):
if _executing_eagerly():
tensor = self.tfe.Variable(tf.ones([5] * dim) * rank)
else:
tensor = tf.ones([5] * dim) * rank
if dtype == tf.bool:
tensor = tensor % 2
if _executing_eagerly():
with tf.GradientTape() as tape:
tensor = tf.cast(tensor, dtype=dtype)
broadcasted_tensor = hvd.broadcast(tensor, root_rank)
grad_out = tape.gradient(broadcasted_tensor, tensor)
else:
tensor = tf.cast(tensor, dtype=dtype)
broadcasted_tensor = hvd.broadcast(tensor, root_rank)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: horovod/horovod
Commit Name: 65bb3580e5cdd9adee17b5f80fba949550931271
Time: 2019-01-09
Author: 38317191+kuroko1t@users.noreply.github.com
File Name: test/test_tensorflow.py
Class Name: MPITests
Method Name: test_horovod_broadcast_grad
Project Name: keras-team/keras
Commit Name: 0f4fec30f00b29aa206e36fe875c83ff6149b618
Time: 2017-02-06
Author: yves@dbtune.org
File Name: tests/keras/backend/test_backends.py
Class Name: TestBackend
Method Name: test_batch_dot_shape
Project Name: tensorflow/models
Commit Name: 0734276a9306c6801b508a50ae34d219eb950fb6
Time: 2019-11-01
Author: wcromar@google.com
File Name: official/vision/image_classification/mnist_test.py
Class Name: KerasMnistTest
Method Name: test_end_to_end