class_docstr: Tests for ops in byteps.mxnet.
docstr: Test that the byteps_push_pull correctly sums 1D, 2D, 3D tensors.
code: def test_byteps_push_pull_inplace(self):
      """Test that the byteps_push_pull correctly sums 1D, 2D, 3D tensors."""
      size = bps.size()
      dtypes = ["float16", "float32", "float64"]
      dims = [1, 2, 3]
      count = 0
      ctx = self._current_context()
      shapes = [(), (17), (17, 17), (17, 17, 17)]
      for dtype, dim in itertools.product(dtypes, dims):
          mx.random.seed(1234, ctx=ctx)
          tensor = mx.nd.random.uniform(
              -100, 100, shape=shapes[dim], ctx=ctx
          )
          tensor = tensor.astype(dtype)
          multiplied = tensor.copy()
          bps.byteps_declare_tensor("tensor_" + str(count))
          bps.byteps_push_pull(tensor, name="tensor_" + str(count))
          max_difference = mx.nd.max(mx.nd.subtract(tensor, multiplied))
          count += 1
  
          # Threshold for floating point equality depends on number of
          # ranks, since we're comparing against precise multiplication.
          if size <= 3 or dtype in ["int32", "int64"]:
              threshold = 0
          elif size < 10:
              threshold = 1e-4
          elif size < 15:
              threshold = 5e-4
          else:
              break
  
          if max_difference > threshold:
              print(
                  "self", count, dtype, dim, max_difference, threshold
              )
              print("tensor", bps.rank(), tensor)
              print("multiplied", bps.rank(), multiplied)
          assert (
              max_difference <= threshold
          ), "bps.byteps_push_pull produces \
                                                   incorrect results for self"
  
      print("test_byteps_push_pull_inplace passed")
  
file_path: byteps/tests/test_mxnet.py
imports: import itertools
  import unittest
  import byteps.mxnet
  import mxnet
  import numpy
  from meta_test import MetaTest
label_desc: Use image node_id 4 for calling the MXTest obj's underlying member method code with example usage: obj.test_byteps_push_pull_inplace() without return types