'Assign value to the tensor.
Arguments:
value (int, float, GPUTensor, OpTreeNode): The value to be assigned.'

def _assign(self, value):

    stream = self.backend.stream
    if isinstance(value, (int, float)):
        if self.is_contiguous:
            value = self.dtype.type(value)
            if (self.dtype.itemsize == 1):
                drv.memset_d8_async(self.gpudata, unpack_from('B', value)[0], self.size, stream)
            elif (self.dtype.itemsize == 2):
                drv.memset_d16_async(self.gpudata, unpack_from('H', value)[0], self.size, stream)
            else:
                drv.memset_d32_async(self.gpudata, unpack_from('I', value)[0], self.size, stream)
        else:
            OpTreeNode.build('assign', self, value)
    elif isinstance(value, GPUTensor):
        if (self.is_contiguous and value.is_contiguous and (self.dtype == value.dtype) and (self.shape == value.shape)):
            drv.memcpy_dtod_async(self.gpudata, value.gpudata, self.nbytes, stream)
        else:
            OpTreeNode.build('assign', self, value)
    elif isinstance(value, OpTreeNode):
        OpTreeNode.build('assign', self, value)
    elif isinstance(value, np.ndarray):
        self.set(value)
    else:
        raise TypeError(('Invalid    type    for    assignment:    %s' % type(value)))
    return self
