PyTorch and MindSpore API Mapping Table
Mapping between TensorFlow APIs and MindSpore APIs, which is provided by the community. There may be differences in parameters, inputs, outputs, logic functions, and specific scenarios. For details, see the description of each API or the difference comparison provided.
More MindSpore developers are also welcome to participate in improving the mapping content.
General Difference Parameter Table
Because of the framework mechanism, MindSpore does not provide the following parameters for PyTorch:
Parameter Names |
Functions |
---|---|
out |
Indicates the output Tensor |
layout |
Indicates the memory distribution strategy |
device |
Indicates the Tensor storage location |
requires_grad |
Indicates whether to update the gradient |
generator |
Indicates a generator for pseudorandom number |
pin_memory |
Indicates whether to use locking page memory |
memory_format |
Indicates the memory format of the Tensor |
stable |
Indicates whether the sorting is stable |
inplace |
Indicates that the value of a variable is modified directly without changing the memory address of the variable |
sparse_grad |
Indicates whether to perform sparsification on the gradient |
size_average |
The deprecated parameter in PyTorch |
reduce |
The deprecated parameter in PyTorch |
PyTorch 1.8.1
torch
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the number or sequence of parameters is inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter default values are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the number or sequence of parameters is inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
torch.distributions
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
torch.distributed
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
torch.nn
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Cosistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Difference comparison is under development |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the number or sequence of parameters is inconsistent. |
||
Consistent |
||
Consistent |
torch.nn.functional
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter data types are inconsistent |
||
The functions are consistent, but the parameter data types are inconsistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the number or sequence of parameters is inconsistent. |
||
torch.nn.Module
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
Consistent |
torch.nn.utils
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
torch.Tensor
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the number or sequence of parameters is inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
The functions are consistent, but parameter names are different. |
||
Consistent |
||
Consistent |
||
The functions are consistent, but parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter default values are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent MindSpore only supports float16 and float32 inputs temporarily. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
torch.Tensor.norm is about to be deprecated, mindspore.Tensor.norm is completely consistent with torch.linalg.norm |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter data types are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. The split_size parameter is split_size_or_sections in MindSpore. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
the functions are consistent, but the parameter names are inconsistent. |
||
the functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent |
||
Consistent |
||
Consistent |
||
The functions are consistent, but the parameter names are inconsistent. |
torch.optim
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
torch.utils
PyTorch 1.8.1 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
None |
||
torchtext
TorchText 0.10.0 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
torchvision
TorchVision 0.10.0 APIs |
MindSpore APIs |
Descriptions |
---|---|---|
TorchVision 0.14.0 APIs |
MindSpore APIs |
Descriptions |
---|---|---|