For example, if the tensor ``x`` is with a shape(4, 3, 2, 2) and ``repeat_times`` is a tuple (3, 2),
For example, if the tensor ``x`` is with a shape(4, 3, 2, 2) and ``repeat_times`` is a tuple (3, 2),
``repeat_times`` is first promoted to a tuple (1, 1, 3, 2).
``repeat_times`` is first promoted to a tuple (1, 1, 3, 2).
The following gives an using case:
The following gives an using case:
.. code-block:: text
.. code-block:: text
Input(x) is a 3-D tensor of shape (2, 3, 1):
Input(x) is a 3-D tensor of shape (2, 3, 1):
[
[
[[1], [2], [3]],
[[1], [2], [3]],
[[4], [5], [6]]
[[4], [5], [6]]
]
]
Attr(repeat_times): [1, 2, 2]
Attr(repeat_times): [1, 2, 2]
Output(out) is a 3-D tensor of shape (2, 6, 2):
Output(out) is a 3-D tensor of shape (2, 6, 2):
[
[
[[1, 1], [2, 2], [3, 3], [1, 1], [2, 2], [3, 3]],
[[1, 1], [2, 2], [3, 3], [1, 1], [2, 2], [3, 3]],
[[4, 4], [5, 5], [6, 6], [4, 4], [5, 5], [6, 6]]
[[4, 4], [5, 5], [6, 6], [4, 4], [5, 5], [6, 6]]
]
]
Args:
Args:
x (Tensor): The input tensor, its data type should be bool, float32, float64, int32. The rank of ``x`` should be in [1, 6].
x (Tensor): The input tensor, its data type should be bool, float32, float64, int32. The rank of ``x`` should be in [1, 6].
repeat_times (Tensor|tuple|list): The number of repeating times for each dimension of the input ``x``. If repeat_times is a list or tuple, the elements of
repeat_times (Tensor|tuple|list): The number of repeating times for each dimension of the input ``x``. If repeat_times is a list or tuple, the elements of
it should be integers or Tensors with shape [1]. If repeat_times is Tensor, it should be an 1-D Tensor. The size of its shape should be in [1, 6].
it should be integers or Tensors with shape [1]. If repeat_times is Tensor, it should be an 1-D Tensor. The size of its shape should be in [1, 6].
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name` .
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name` .
Returns:
Returns:
N-D Tensor. The data type is the same as ``x``. After tiling, each dimension of the output is equal to the corresponding dimension of ``x`` multiplying the corresponding value given by ``repeat_times`` .
N-D Tensor. The data type is the same as ``x``. After tiling, each dimension of the output is equal to the corresponding dimension of ``x`` multiplying the corresponding value given by ``repeat_times`` .
Raises:
Raises:
TypeError: The type of ``repeat_times`` must be list, tuple or Tensor.
TypeError: The type of ``repeat_times`` must be list, tuple or Tensor.
ValueError: The elements of ``repeat_times`` cannot be negative.
ValueError: The elements of ``repeat_times`` cannot be negative.
The rank of ``x`` should be less than or equal to 6, and the number of elements in ``shape`` should also be less than or equal to 6. The size of the dimension to expand must be 1.
Args:
x (Tensor): The input Tensor with rank in [1, 6]. The data type is bool, float32, float64 or int32.
shape (list|tuple|Tensor): The result shape after expanding. The data type is int32. If shape is a list or tuple, all elements of
it should be integers or Tensors with shape (1,). If shape is a Tensor, it should be an 1-D Tensor.
The value -1 in shape, means keeping the corresponding dimension unchanged.
name (str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` .
Returns:
Tensor: A Tensor with the given shape. The data type is the same as ``x``.
Raises:
TypeError: The type of ``shape`` must be list, tuple or Variable.
ValueError: The elements of ``shape`` must be positive or -1.