class_docstr: A communication backend using Horovod.
class_docstr_tok: ["A","communication","backend","using","Horovod","."]
docstr: Performs allreduce on a single tensor or a list of tensor objects
  
  This function performs in-place summation of the input tensor over all the processes.
  
  The name `pushpull` is a generic term. In Horovod, its action is implemented via
  ring allreduce. Each operation is identified by the 'key'; if `key` is not provided, an
  incremented auto-generated name is used. The tensor type and shape must be
  the same on all processes for a given name. The reduction will not start until all processes
  are ready to send and receive the tensor.
  
  Parameters
  ----------
  key : str, int, or sequence of str or int
      Keys used to uniquely tag an operation.
  
  value : NDArray
      Tensor value on one process to be summed. If `out` is not specified, the `value` will
      be modified in-place
  
  out: NDArray
      Output tensor after allreduce. If not specified, the input tensor `value` will be
      modified in-place.
  
  priority : int, optional
      The priority of the operation.
      Higher priority operations are likely to be executed before other actions.
  
  Examples
  --------
  >>> # perform in-place allreduce on tensor a
  >>> shape = (2, 3)
  >>> nworker = kv.num_workers # assume there are 8 processes
  >>> a = mx.nd.ones(shape)
  >>> kv.pushpull('1', a)
  >>> print(a.asnumpy())
  [[ 8.  8.  8.]
  [ 8.  8.  8.]]
  
  >>> # perform allreduce on tensor a and output to b
  >>> a = mx.nd.ones(shape)
  >>> kv.pushpull('2', a, out=b)
  >>> print(b.asnumpy())
  [[ 8.  8.  8.]
  [ 8.  8.  8.]]
docstr_tok: ["Performs","allreduce","on","a","single","tensor","or","a","list","of","tensor","objects","This","function","performs","in-place","summation","of","the","input","tensor","over","all","the","processes",".","The","name","`","pushpull","`","is","a","generic","term",".","In","Horovod",",","its","action","is","implemented","via","ring","allreduce",".","Each","operation","is","identified","by","the","'key","'",";","if","`","key","`","is","not","provided",",","an","incremented","auto-generated","name","is","used",".","The","tensor","type","and","shape","must","be","the","same","on","all","processes","for","a","given","name",".","The","reduction","will","not","start","until","all","processes","are","ready","to","send","and","receive","the","tensor",".","Parameters","--","--","--","--","--","key",":","str",",","int",",","or","sequence","of","str","or","int","Keys","used","to","uniquely","tag","an","operation",".","value",":","NDArray","Tensor","value","on","one","process","to","be","summed",".","If","`","out","`","is","not","specified",",","the","`","value","`","will","be","modified","in-place","out",":","NDArray","Output","tensor","after","allreduce",".","If","not","specified",",","the","input","tensor","`","value","`","will","be","modified","in-place",".","priority",":","int",",","optional","The","priority","of","the","operation",".","Higher","priority","operations","are","likely","to","be","executed","before","other","actions",".","Examples","--","--","--","--",">",">",">","#","perform","in-place","allreduce","on","tensor","a",">",">",">","shape","=","(","2",",","3",")",">",">",">","nworker","=","kv.num_workers","#","assume","there","are","8","processes",">",">",">","a","=","mx.nd.ones","(","shape",")",">",">",">","kv.pushpull","(","'","1","'",",","a",")",">",">",">","print","(","a.asnumpy","(",")",")","[","[","8",".","8",".","8",".","]","[","8",".","8",".","8",".","]","]",">",">",">","#","perform","allreduce","on","tensor","a","and","output","to","b",">",">",">","a","=","mx.nd.ones","(","shape",")",">",">",">","kv.pushpull","(","'","2","'",",","a",",","out=b",")",">",">",">","print","(","b.asnumpy","(",")",")","[","[","8",".","8",".","8",".","]","[","8",".","8",".","8",".","]","]"]
code: def pushpull(self, key, value, out=None, priority=0):
      """Performs allreduce on a single tensor or a list of tensor objects
  
      This function performs in-place summation of the input tensor over all the processes.
  
      The name `pushpull` is a generic term. In Horovod, its action is implemented via
      ring allreduce. Each operation is identified by the 'key'; if `key` is not provided, an
      incremented auto-generated name is used. The tensor type and shape must be
      the same on all processes for a given name. The reduction will not start until all processes
      are ready to send and receive the tensor.
  
      Parameters
      ----------
      key : str, int, or sequence of str or int
          Keys used to uniquely tag an operation.
  
      value : NDArray
          Tensor value on one process to be summed. If `out` is not specified, the `value` will
          be modified in-place
  
      out: NDArray
          Output tensor after allreduce. If not specified, the input tensor `value` will be
          modified in-place.
  
      priority : int, optional
          The priority of the operation.
          Higher priority operations are likely to be executed before other actions.
  
      Examples
      --------
      >>> # perform in-place allreduce on tensor a
      >>> shape = (2, 3)
      >>> nworker = kv.num_workers # assume there are 8 processes
      >>> a = mx.nd.ones(shape)
      >>> kv.pushpull('1', a)
      >>> print(a.asnumpy())
      [[ 8.  8.  8.]
      [ 8.  8.  8.]]
  
      >>> # perform allreduce on tensor a and output to b
      >>> a = mx.nd.ones(shape)
      >>> kv.pushpull('2', a, out=b)
      >>> print(b.asnumpy())
      [[ 8.  8.  8.]
      [ 8.  8.  8.]]
      """
      import horovod.mxnet as hvd
  
      if out is None:
          value = value if isinstance(value, list) else [value]
          for v in value:
              hvd.allreduce_(
                  v, average=False, name=str(key), priority=priority
              )
      else:
          out = out if isinstance(out, list) else [out]
          value = value if isinstance(value, list) else [value]
          for o, v in zip(out, value):
              o[:] = hvd.allreduce(
                  v, average=False, name=str(key), priority=priority
              )
  
file_path: mxnet/python/mxnet/kvstore/horovod.py
imports: from __future__ import absolute_import
  from .base import KVStoreBase
label_desc: Use image node_id 4 for calling the Horovod obj's underlying member method code with example usage: obj.pushpull(key, value, out, priority) without return types