def compute(self, node, input_vals, output_val, use_numpy=True):
    after_reduce_gradient_cpu = ndarray.empty(shape=output_val.shape, ctx=ndarray.cpu(0))
    if use_numpy:
        gradient_val_cpu = ndarray.array(input_vals[0], ctx=ndarray.cpu(0))
    else:
        gradient_val_cpu = ndarray.array(input_vals[0].asnumpy(), ctx=ndarray.cpu(0))
    lib_communicate.DL_Communicate_Init(gradient_val_cpu.handle)
    lib_communicate.DL_Communicate(gradient_val_cpu.handle, after_reduce_gradient_cpu.handle)
    if use_numpy:
        output_val[:] = after_reduce_gradient_cpu.asnumpy()
    else:
        after_reduce_gradient_cpu.copyto(output_val)
def compute(self, node, input_vals, output_val, use_numpy=True):
    after_reduce_gradient_cpu = ndarray.empty(shape=output_val.shape, ctx=ndarray.cpu(0))
    if use_numpy:
        gradient_val_cpu = ndarray.array(input_vals[0], ctx=ndarray.cpu(0))
    else:
        gradient_val_cpu = ndarray.array(input_vals[0].asnumpy(), ctx=ndarray.cpu(0))
    lib_communicate.DL_Communicate_Init(gradient_val_cpu.handle)
    lib_communicate.DL_Communicate(gradient_val_cpu.handle, after_reduce_gradient_cpu.handle)
    if use_numpy:
        output_val[:] = after_reduce_gradient_cpu.asnumpy()
    else:
        after_reduce_gradient_cpu.copyto(output_val)