def _reduce(self):
        """Reduce data from multiple context to cpu."""
        ctx = context.cpu()
        if self._stype == 'default':
            block = self.list_data()
            data = ndarray.add_n(*(w.copyto(ctx) for w in block)) / len(block)
        else:
            # fetch all rows for 'row_sparse' param
            all_row_ids = ndarray.arange(0, self.shape[0], dtype='int64', ctx=ctx)
            data = ndarray.zeros(self.shape, stype='row_sparse', ctx=ctx)
            self._trainer._row_sparse_pull(self, data, all_row_ids, full_idx=True)
        return data
def _reduce ( self ) : ctx = context . cpu ( ) if self . _stype == 'default' : block = self . list_data ( ) data = ndarray . add_n ( * ( w . copyto ( ctx ) for w in block ) ) / len ( block ) else : all_row_ids = ndarray . arange ( 0 , self . shape [ 0 ] , dtype = 'int64' , ctx = ctx ) data = ndarray . zeros ( self . shape , stype = 'row_sparse' , ctx = ctx ) self . _trainer . _row_sparse_pull ( self , data , all_row_ids , full_idx = True ) return data
Reduce data from multiple context to cpu.