예제 #1
0
def _int_(self):
    """Cast to an int32 tensor.

    Returns
    -------
    dragon.vm.torch.Tensor
        The self.

    """
    return array_funcs.cast(self, 'int32', True)
예제 #2
0
def half_(self):
    """Cast to a float16 tensor.

    Returns
    -------
    dragon.vm.torch.Tensor
        The self.

    """
    return array_funcs.cast(self, 'float16', True)
예제 #3
0
def _int(self):
    """Return an int32 tensor with the same data.

    Returns
    -------
    dragon.vm.torch.Tensor
        The output tensor.

    """
    return array_funcs.cast(self, 'int32', False)
예제 #4
0
def double_(self):
    """Cast to a float64 tensor.

    Returns
    -------
    dragon.vm.torch.Tensor
        The self.

    """
    return array_funcs.cast(self, 'float64', True)
예제 #5
0
def half(self):
    """Return a float16 tensor with the same data.

    Returns
    -------
    dragon.vm.torch.Tensor
        The output tensor.

    """
    return array_funcs.cast(self, 'float16', False)
예제 #6
0
def byte_(self):
    """Cast to an uint8 tensor.

    Returns
    -------
    dragon.vm.torch.Tensor
        The self.

    """
    return array_funcs.cast(self, 'uint8', True)
예제 #7
0
def byte(self):
    """Return an uint8 tensor with the same data.

    Returns
    -------
    dragon.vm.torch.Tensor
        The output tensor.

    """
    return array_funcs.cast(self, 'uint8', False)
예제 #8
0
def bool_(self):
    """Cast to a bool tensor.

    Returns
    -------
    dragon.vm.torch.Tensor
        The self.

    """
    return array_funcs.cast(self, 'bool', True)
예제 #9
0
def bool(self):
    """Return a bool tensor with the same data.

    Returns
    -------
    dragon.vm.torch.Tensor
        The output tensor.

    """
    return array_funcs.cast(self, 'bool', False)
예제 #10
0
def _type(self, dtype=None):
    """Return the data type.

    If ``dtype`` is not **None**, cast ``self`` to the new tensor.

    Parameters
    ----------
    dtype : str, optional
        The specified type.

    Returns
    -------
    Union[str, dragon.vm.torch.Tensor]
        The data type or new tensor.

    """
    if dtype is None:
        return self.dtype
    return array_funcs.cast(self, dtype, False)