tile(input, dims) → Tensor¶
Constructs a tensor by repeating the elements of
dimsargument specifies the number of repetitions in each dimension.
dimsspecifies fewer dimensions than
inputhas, then ones are prepended to
dimsuntil all dimensions are specified. For example, if
inputhas shape (8, 6, 4, 2) and
dimsis (2, 2), then
dimsis treated as (1, 1, 2, 2).
inputhas fewer dimensions than
inputis treated as if it were unsqueezed at dimension zero until it has as many dimensions as
dimsspecifies. For example, if
inputhas shape (4, 2) and
dimsis (3, 3, 2, 2), then
inputis treated as if it had the shape (1, 1, 4, 2).
This function is similar to NumPy’s tile function.
The interface is consistent with PyTorch. The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.tile.html.
input (oneflow.Tensor) – the tensor whose elements to repeat.
dims (tuple) – the number of repetitions per dimension.
>>> import oneflow as flow >>> import numpy as np >>> np_arr = np.random.randn(5, 3, 6, 9).astype(np.float32) >>> input = flow.Tensor(np_arr) >>> out = input.tile(2,1,2,1) >>> out.shape oneflow.Size([10, 3, 12, 9]) >>> x = np.random.randn(5, 2, 1) >>> input = flow.Tensor(x) >>> out = input.tile(3,4) >>> out.shape oneflow.Size([5, 6, 4])