Differences with torch.Tensor.repeat
The following mapping relationships can be found in this file.
PyTorch APIs |
MindSpore APIs |
---|---|
torch.Tensor.repeat |
mindspore.Tensor.tile |
torch.Tensor.repeat
torch.Tensor.repeat(*sizes) -> Tensor
For more information, see torch.Tensor.repeat.
mindspore.Tensor.tile
mindspore.Tensor.tile(multiples)
For more information, see mindspore.Tensor.tile.
Differences
The usage of mindspore.Tensor.tile
is basically the same with that of torch.Tensor.repeat
.
Categories |
Subcategories |
PyTorch |
MindSpore |
Differences |
---|---|---|---|---|
Parameters |
Parameter 1 |
*sizes |
multiples |
In PyTorch, parameter type is torch.Size or int and in MindSpore, parameter type must be tuple. |
Code Example
# PyTorch
import torch
input = torch.tensor([[1, 2], [3, 4]], dtype=torch.float32)
output = input.repeat(16, 1)
print(output.shape)
# torch.Size([32, 2])
# MindSpore
import mindspore
x = mindspore.Tensor([[1, 2], [3, 4]], dtype=mindspore.float32)
output = x.tile((16, 1))
print(output.shape)
# (32, 2)