tile#

ivy.tile(x, /, repeats, *, out=None)[source]#

Construct an array by repeating x the number of times given by reps.

Parameters:
  • x (Union[Array, NativeArray]) – Input array.

  • repeats (Iterable[int]) – The number of repetitions of x along each axis.

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – The tiled output array.

Examples

With ivy.Array input:

>>> x = ivy.array([1,2,3,4])
>>> y = ivy.tile(x, 3)
>>> print(y)
ivy.array([1,2,3,4,1,2,3,4,1,2,3,4])
>>> x = ivy.array([[1,2,3],
...                [4,5,6]])
>>> y = ivy.tile(x, (2,3))
>>> print(y)
ivy.array([[1,2,3,1,2,3,1,2,3],
           [4,5,6,4,5,6,4,5,6],
           [1,2,3,1,2,3,1,2,3],
           [4,5,6,4,5,6,4,5,6]])
>>> x = ivy.array([[[0], [1]]])
>>> y = ivy.tile(x,(2,2,3))
>>> print(y)
ivy.array([[[0,0,0],
            [1,1,1],
            [0,0,0],
            [1,1,1]],
           [[0,0,0],
            [1,1,1],
            [0,0,0],
            [1,1,1]]])

With ivy.Container input:

>>> x = ivy.Container( a = ivy.array([0,1,2]), b = ivy.array([[3],[4]]))
>>> y = ivy.tile(x, (1,2))
>>> print(y)
{
    a: ivy.array([[0,1,2,0,1,2]]),
    b: ivy.array([[3,3],[4,4]])
}

# Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts ivy.Container instances in place of any of the arguments.

Array.tile(self, /, repeats, *, out=None)[source]#

ivy.Array instance method variant of ivy.tile. This method simply wraps the function, and so the docstring for ivy.tile also applies to this method with minimal changes.

Parameters:
  • self (Array) – Input array.

  • repeats (Iterable[int]) – The number of repetitions of x along each axis.

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – The tiled output array.

Examples

>>> x = ivy.array([[0], [1], [2]])
>>> y = x.tile((3,2))
>>> print(y)
ivy.array([[0,0],
           [1,1],
           [2,2],
           [0,0],
           [1,1],
           [2,2],
           [0,0],
           [1,1],
           [2,2]])
Container.tile(self, /, repeats, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.tile. This method simply wraps the function, and so the docstring for ivy.tile also applies to this method with minimal changes.

Parameters:
  • self (Container) – Input container.

  • repeats (Union[Iterable[int], Container]) – The number of repetitions of x along each axis.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – The container output with tiled leaves.

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = x.tile((2,3))
>>> print(y)
{
    a: (<class ivy.data_classes.array.array.Array> shape=[4, 6]),
    b: (<class ivy.data_classes.array.array.Array> shape=[2, 6])
}