Differences with torch.Tensor.flip
torch.Tensor.flip
torch.Tensor.flip(dims)
For more details, see torch.Tensor.flip.
mindspore.Tensor.flip
mindspore.Tensor.flip(dims)
For more details, see mindspore.Tensor.flip.
Differences
PyTorch: The torch.Tensor.flip
interface has differences from torch.flip
. Compared to torch.flip
, Tensor.flip
additionally supports scenarios where the dims
input is of type int.
MindSpore: The mindspore.flip
and mindspore.Tensor.flip
interfaces have the same functionality as torch.flip
and do not support input of type int.
Categories |
Subcategories |
PyTorch |
MindSpore |
Differences |
---|---|---|---|---|
Parameters |
Parameter 1 |
dims |
dims |
Same functionality, MindSpore does not support int input |
Code Example
# PyTorch
import numpy as np
import torch
input = torch.tensor(np.arange(1, 9).reshape((2, 2, 2)))
output = input.flip(1)
print(output)
# tensor([[[3, 4],
# [1, 2]],
# [[7, 8],
# [5, 6]]])
# MindSpore
import mindspore as ms
import mindspore.ops as ops
input = ms.Tensor(np.arange(1, 9).reshape((2, 2, 2)))
output = input.flip((1, ))
print(output)
# [[[3 4]
# [1 2]]
# [[7 8]
# [5 6]]]