80167f6dea0ba6b853d790a3d3a342368811f0da,test/test_tensorflow.py,MPITests,test_horovod_broadcast_grad_cpu,#MPITests#,879

Before Change


                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)
                with tf.device("/cpu:0"):
                    grad_out = tape.gradient(broadcasted_tensor, tensor)
            else:
                tensor = tf.cast(tensor, dtype=dtype)
                broadcasted_tensor = hvd.broadcast(tensor, root_rank)

                grad_ys = tf.ones([5] * dim)
                with tf.device("/cpu:0"):
                    grad = tf.gradients(broadcasted_tensor, tensor, grad_ys)[0]
                grad_out = self.evaluate(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,

After Change


        dims = [1, 2, 3]
        root_ranks = list(range(size))
        for dtype, dim, root_rank in itertools.product(dtypes, dims, root_ranks):
            with tf.device("/cpu:0"):
                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)
                    grad_ys = tf.ones([5] * dim)
                    grad = tf.gradients(broadcasted_tensor, tensor, grad_ys)[0]
                    grad_out = self.evaluate(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,
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 12

Instances


Project Name: horovod/horovod
Commit Name: 80167f6dea0ba6b853d790a3d3a342368811f0da
Time: 2020-01-07
Author: nvcastet@us.ibm.com
File Name: test/test_tensorflow.py
Class Name: MPITests
Method Name: test_horovod_broadcast_grad_cpu


Project Name: horovod/horovod
Commit Name: 53430d67269a53a83ea416412622f8704a26ef44
Time: 2020-07-21
Author: joshr@nvidia.com
File Name: test/test_tensorflow.py
Class Name: TensorFlowTests
Method Name: test_horovod_allgather_grad_cpu


Project Name: horovod/horovod
Commit Name: 80167f6dea0ba6b853d790a3d3a342368811f0da
Time: 2020-01-07
Author: nvcastet@us.ibm.com
File Name: test/test_tensorflow.py
Class Name: MPITests
Method Name: test_horovod_broadcast_grad_gpu


Project Name: horovod/horovod
Commit Name: 53430d67269a53a83ea416412622f8704a26ef44
Time: 2020-07-21
Author: joshr@nvidia.com
File Name: test/test_tensorflow.py
Class Name: TensorFlowTests
Method Name: test_horovod_allgather_grad_gpu