PyTorch与MindSpore API映射表

查看源文件

由社区提供的PyTorch APIs和MindSpore APIs之间的映射,可能在参数、输入、输出、逻辑功能和特定场景等方面存在差异,可详见各API描述或已提供的差异对比。

也欢迎更多的MindSpore开发者参与完善映射内容。关于PyTorch与MindSpore关于框架机制差异,请参考:优化器对比随机数策略对比参数初始化对比

API映射一致标准及例外场景

API映射一致标准:API功能一致,参数个数或顺序一致,参数数据类型一致,参数默认值一致,参数名一致。同时满足所有一致条件被认为是API映射一致。

以下例外场景也被认为是API映射一致,

例外场景1:相较于API映射一致标准,仅API参数的输入数据类型支持范围不一样,包含以下3种子场景:

(1)MindSpore的API支持传入int,float,bool等类型的参数,但不支持传入int8或float64等小位宽数据类型的参数。

(2)MindSpore的API不支持传入复数类型的参数。

例外场景2:相较于MindSpore的API,PyTorch的API多出的参数是通用差异参数。通用差异参数存在的原因是PyTorch有部分参数是为性能优化等非功能性而增加的参数,MindSpore的性能优化机制与PyTorch不同。

例外场景3:如果能保证MindSpore的API在使用默认配置(或用户不配置)的情况下,能够实现与PyTorch对应API完全一致的功能,则MindSpore的API多于PyTorch的API的参数,功能不被认为是差异。

例外场景4:MindSpore将API中与PyTorch重载机制相关参数的默认值设置为None,PyTorch对应API的相应参数无默认值。

下面是例外场景4的举例, 在PyTorch 1.8.1中,torch.argmax具有两种API重载形式,分别是torch.argmax(input)和torch.argmax(input, dim, keepdim=False),其中torch.argmax(input)返回输入Tensor中的最大值元素的索引,torch.argmax(input, dim, keepdim=False)返回输入Tensor在指定轴上最大值的索引。

mindspore.ops.argmax只有一种API形式,即mindspore.ops.argmax(input, dim=None, keepdim=False),但mindspore.ops.argmax(input)与torch.argmax(input)功能相同,mindspore.ops.argmax(input, dim, keepdim)与torch.argmax(input, dim, keepdim)功能相同。相较于torch.argmax,mindspore.ops.argmax参数dim的默认值被设置为None,仅是为了适配torch.argmax的两种API重载形式,因此例外场景4也被认为是API映射一致。

通用差异参数表

因为框架机制原因,MindSpore不提供PyTorch的以下参数:

参数名

功能

说明

out

表示输出的Tensor

把运算结果赋值给out参数,MindSpore目前无此机制

layout

表示内存分布策略

PyTorch支持torch.strided和torch.sparse_coo两种模式, MindSpore目前无此机制

device

表示Tensor存放位置

包含设备类型及可选设备号,MindSpore目前支持算子或网络级别的设备调度

requires_grad

表示是否更新梯度

MindSpore中可以通过Parameter.requires_grad控制

pin_memory

表示是否使用锁页内存

MindSpore目前无此机制

memory_format

表示Tensor的内存格式

MindSpore目前无此机制

stable

表示是否稳定排序

一般用在排序算法的API中,MindSpore目前无此功能

inplace

表示在不更改变量内存地址的情况下,直接修改变量的值

MindSpore目前提供少量inplace的API,例如assign_add

sparse_grad

表示是否对梯度稀疏化

MindSpore目前无此机制

size_average

PyTorch废弃参数

MindSpore中可以使用reduction参数替代

reduce

PyTorch废弃参数

MindSpore中可以使用reduction参数替代

torch

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.abs

mindspore.ops.abs

一致

torch.absolute

mindspore.ops.absolute

一致

torch.acos

mindspore.ops.acos

一致

torch.acosh

mindspore.ops.acosh

一致

torch.add

mindspore.ops.add

一致

torch.addbmm

mindspore.ops.addbmm

一致

torch.addcdiv

mindspore.ops.addcdiv

一致

torch.addcmul

mindspore.ops.addcmul

一致

torch.addmm

mindspore.ops.addmm

一致

torch.addmv

mindspore.ops.addmv

一致

torch.addr

mindspore.ops.addr

功能一致,参数名不同

torch.all

mindspore.ops.all

差异对比

torch.amax

mindspore.ops.amax

差异对比

torch.amin

mindspore.ops.amin

差异对比

torch.angle

mindspore.ops.angle

一致

torch.any

mindspore.ops.any

差异对比

torch.arange

mindspore.ops.arange

一致

torch.arccos

mindspore.ops.arccos

一致

torch.arccosh

mindspore.ops.arccosh

一致

torch.arcsin

mindspore.ops.arcsin

功能一致,参数名不同

torch.arcsinh

mindspore.ops.arcsinh

一致

torch.arctan

mindspore.ops.arctan

一致

torch.arctanh

mindspore.ops.arctanh

一致

torch.argmax

mindspore.ops.argmax

一致

torch.argmin

mindspore.ops.argmin

差异对比

torch.argsort

mindspore.ops.argsort

功能一致,参数名不同

torch.asin

mindspore.ops.asin

一致

torch.asinh

mindspore.ops.asinh

一致

torch.atan

mindspore.ops.atan

一致

torch.atan2

mindspore.ops.atan2

一致

torch.atanh

mindspore.ops.atanh

一致

torch.atleast_1d

mindspore.ops.atleast_1d

功能一致,参数名不同

torch.atleast_2d

mindspore.ops.atleast_2d

功能一致,参数名不同

torch.atleast_3d

mindspore.ops.atleast_3d

功能一致,参数名不同

torch.baddbmm

mindspore.ops.baddbmm

一致

torch.bartlett_window

mindspore.ops.bartlett_window

一致

torch.bernoulli

mindspore.ops.bernoulli

功能一致,参数个数或顺序不一致

torch.bincount

mindspore.ops.bincount

一致

torch.bitwise_and

mindspore.ops.bitwise_and

一致

torch.bitwise_or

mindspore.ops.bitwise_or

一致

torch.bitwise_xor

mindspore.ops.bitwise_xor

一致

torch.blackman_window

mindspore.ops.blackman_window

一致

torch.block_diag

mindspore.ops.block_diag

功能一致,参数名不同

torch.bmm

mindspore.ops.bmm

功能一致,参数名不同

torch.bucketize

mindspore.ops.bucketize

差异对比

torch.broadcast_to

mindspore.ops.broadcast_to

差异对比

torch.cat

mindspore.ops.cat

功能一致,参数数据类型不一致

torch.cdist

mindspore.ops.cdist

差异对比

torch.ceil

mindspore.ops.ceil

一致

torch.cholesky

mindspore.ops.cholesky

功能一致,参数名不同

torch.cholesky_solve

mindspore.ops.cholesky_solve

一致

torch.chunk

mindspore.ops.chunk

功能一致,参数名不同

torch.clamp

mindspore.ops.clamp

一致

torch.clip

mindspore.ops.clip

一致

torch.column_stack

mindspore.ops.column_stack

一致

torch.combinations

mindspore.ops.combinations

功能一致,参数名不同

torch.conj

mindspore.ops.conj

一致

torch.copysign

mindspore.ops.copysign

功能一致,参数名不同

torch.cos

mindspore.ops.cos

功能一致,参数数据类型不一致

torch.cosh

mindspore.ops.cosh

一致

torch.count_nonzero

mindspore.ops.count_nonzero

功能一致,参数名不同

torch.cross

mindspore.ops.cross

一致

torch.cummax

mindspore.ops.cummax

功能一致,参数名不同

torch.cummin

mindspore.ops.cummin

功能一致,参数名不同

torch.cumprod

mindspore.ops.cumprod

一致

torch.cumsum

mindspore.ops.cumsum

功能一致,参数名不同

torch.deg2rad

mindspore.ops.deg2rad

功能一致,参数数据类型不一致

torch.diag

mindspore.ops.diag

差异对比

torch.diag_embed

mindspore.ops.diag_embed

一致

torch.diagflat

mindspore.ops.diagflat

一致

torch.diagonal

mindspore.ops.diagonal

一致

torch.diff

mindspore.ops.diff

功能一致,参数名不同

torch.digamma

mindspore.ops.digamma

一致

torch.dist

mindspore.ops.dist

一致

torch.div

mindspore.ops.div

一致

torch.divide

mindspore.ops.divide

一致

torch.dot

mindspore.ops.tensor_dot

差异对比

torch.dstack

mindspore.ops.dstack

功能一致,参数名不同

torch.einsum

mindspore.ops.einsum

一致

torch.eq

mindspore.ops.equal

一致

torch.erf

mindspore.ops.erf

一致

torch.erfc

mindspore.ops.erfc

一致

torch.erfinv

mindspore.ops.erfinv

功能一致,参数数据类型不一致

torch.exp

mindspore.ops.exp

一致

torch.exp2

mindspore.ops.exp2

一致

torch.expm1

mindspore.ops.expm1

一致

torch.eye

mindspore.ops.eye

一致

torch.flatten

mindspore.ops.flatten

差异对比

torch.float_power

mindspore.ops.float_power

差异对比

torch.flip

mindspore.ops.flip

一致

torch.fliplr

mindspore.ops.fliplr

一致

torch.flipud

mindspore.ops.flipud

一致

torch.floor

mindspore.ops.floor

功能一致,参数数据类型不一致

torch.floor_divide

mindspore.ops.floor_divide

一致

torch.fmax

mindspore.ops.fmax

一致

torch.fmod

mindspore.ops.fmod

一致

torch.frac

mindspore.ops.frac

功能一致,参数名不同

torch.full

mindspore.ops.full

一致

torch.full_like

mindspore.ops.full_like

一致

torch.gcd

mindspore.ops.gcd

一致

torch.ge

mindspore.ops.ge

功能一致,参数名不同

torch.geqrf

mindspore.ops.geqrf

一致

torch.ger

mindspore.ops.ger

差异对比

torch.greater

mindspore.ops.greater

一致

torch.greater_equal

mindspore.ops.greater_equal

一致

torch.gt

mindspore.ops.gt

功能一致,参数名不同

torch.hann_window

mindspore.ops.hann_window

一致

torch.heaviside

mindspore.ops.heaviside

一致

torch.hstack

mindspore.ops.hstack

一致

torch.histc

mindspore.ops.histc

一致

torch.hypot

mindspore.ops.hypot

一致

torch.hamming_window

mindspore.ops.hamming_window

一致

torch.i0

mindspore.ops.i0

一致

torch.igamma

mindspore.ops.igamma

一致

torch.igammac

mindspore.ops.igammac

一致

torch.imag

mindspore.ops.imag

一致

torch.index_select

mindspore.ops.index_select

功能一致,参数名不同

torch.inner

mindspore.ops.inner

一致

torch.inverse

mindspore.ops.inverse

一致

torch.isclose

mindspore.ops.isclose

功能一致,参数数据类型不一致

torch.isfinite

mindspore.ops.isfinite

功能一致,参数名不同

torch.isinf

mindspore.ops.isinf

一致

torch.isnan

mindspore.ops.isnan

功能一致,参数名不同

torch.isneginf

mindspore.ops.isneginf

一致

torch.isposinf

mindspore.ops.isposinf

一致

torch.isreal

mindspore.ops.isreal

一致

torch.is_complex

mindspore.ops.is_complex

功能一致,参数名不同

torch.is_floating_point

mindspore.ops.is_floating_point

功能一致,参数名不同

torch.is_nonzero

mindspore.ops.is_nonzero

一致

torch.is_tensor

mindspore.ops.is_tensor

一致

torch.kaiser_window

mindspore.ops.kaiser_window

一致

torch.kron

mindspore.ops.kron

一致

torch.lcm

mindspore.ops.lcm

一致

torch.ldexp

mindspore.ops.ldexp

功能一致,参数名不同

torch.le

mindspore.ops.le

功能一致,参数名不同

torch.lerp

mindspore.ops.lerp

一致

torch.less

mindspore.ops.less

功能一致,参数名不同

torch.less_equal

mindspore.ops.less_equal

功能一致,参数名不同

torch.linalg.cond

mindspore.ops.cond

一致

torch.linalg.eigvals

mindspore.ops.eigvals

一致

torch.linalg.norm

mindspore.ops.norm

一致

torch.linspace

mindspore.ops.linspace

功能一致,参数个数或顺序不一致

torch.log

mindspore.ops.log

功能一致,参数数据类型不一致

torch.log2

mindspore.ops.log2

功能一致,参数数据类型不一致

torch.log10

mindspore.ops.log10

功能一致,参数数据类型不一致

torch.logaddexp

mindspore.ops.logaddexp

一致

torch.logaddexp2

mindspore.ops.logaddexp2

一致

torch.logcumsumexp

mindspore.ops.logcumsumexp

功能一致,参数名不同

torch.log1p

mindspore.ops.log1p

一致

torch.logdet

mindspore.ops.logdet

一致

torch.logical_and

mindspore.ops.logical_and

一致

torch.logical_not

mindspore.ops.logical_not

一致

torch.logical_or

mindspore.ops.logical_or

一致

torch.logical_xor

mindspore.ops.logical_xor

一致

torch.logit

mindspore.ops.logit

一致

torch.logspace

mindspore.ops.logspace

一致

torch.logsumexp

mindspore.ops.logsumexp

功能一致,参数名不同

torch.lt

mindspore.ops.lt

一致

torch.lu_solve

mindspore.ops.lu_solve

一致

torch.lu_unpack

mindspore.ops.lu_unpack

一致

torch.masked_select

mindspore.ops.masked_select

一致

torch.matmul

mindspore.ops.matmul

一致

torch.max

mindspore.ops.max

差异对比

torch.maximum

mindspore.ops.maximum

功能一致,参数名不同

torch.mean

mindspore.ops.mean

功能一致,参数名不同

torch.median

mindspore.ops.median

差异对比

torch.meshgrid

mindspore.ops.meshgrid

差异对比

torch.mm

mindspore.ops.mm

一致

torch.mul

mindspore.ops.mul

一致

torch.min

mindspore.ops.min

差异对比

torch.minimum

mindspore.ops.minimum

功能一致,参数名不同

torch.msort

mindspore.ops.msort

一致

torch.moveaxis

mindspore.ops.moveaxis

一致

torch.movedim

mindspore.ops.movedim

一致

torch.multinomial

mindspore.ops.multinomial

功能一致,参数默认值不一致

torch.multiply

mindspore.ops.multiply

一致

torch.mv

mindspore.ops.mv

功能一致,参数名不同

torch.mvlgamma

mindspore.ops.mvlgamma

功能一致,参数数据类型不一致

torch.nan_to_num

mindspore.ops.nan_to_num

一致

torch.nansum

mindspore.ops.nansum

一致

torch.narrow

mindspore.ops.narrow

功能一致,参数名不同

torch.ne

mindspore.ops.ne

功能一致,参数名不同

torch.neg

mindspore.ops.neg

一致

torch.negative

mindspore.ops.negative

一致

torch.nextafter

mindspore.ops.nextafter

一致

torch.nonzero

mindspore.ops.nonzero

一致

torch.normal

mindspore.ops.normal

功能一致,参数个数或顺序不一致

torch.not_equal

mindspore.ops.not_equal

一致

torch.numel

mindspore.ops.numel

一致

torch.ones

mindspore.ops.ones

差异对比

torch.ones_like

mindspore.ops.ones_like

一致

torch.orgqr

mindspore.ops.orgqr

一致

torch.ormqr

mindspore.ops.ormqr

功能一致,参数名不同

torch.outer

mindspore.ops.outer

一致

torch.poisson

mindspore.ops.random_poisson

差异对比

torch.polar

mindspore.ops.polar

一致

torch.polygamma

mindspore.ops.polygamma

功能一致,参数数据类型不一致

torch.pow

mindspore.ops.pow

一致

torch.prod

mindspore.ops.prod

差异对比

torch.rad2deg

mindspore.ops.rad2deg

功能一致,参数数据类型不一致

torch.rand

mindspore.ops.rand

一致

torch.rand_like

mindspore.ops.rand_like

一致

torch.randn

mindspore.ops.randn

一致

torch.randn_like

mindspore.ops.randn_like

一致

torch.randint

mindspore.ops.randint

功能一致,默认值不同

torch.randint_like

mindspore.ops.randint_like

功能一致,默认值不同

torch.randperm

mindspore.ops.randperm

功能一致,参数名不同

torch.range

mindspore.ops.range

功能一致,参数个数或顺序不一致

torch.ravel

mindspore.ops.ravel

一致

torch.real

mindspore.ops.real

一致

torch.reciprocal

mindspore.ops.reciprocal

一致

torch.remainder

mindspore.ops.remainder

一致

torch.renorm

mindspore.ops.renorm

差异对比

torch.repeat_interleave

mindspore.ops.repeat_interleave

功能一致,参数名不同

torch.reshape

mindspore.ops.reshape

一致

torch.roll

mindspore.ops.roll

一致

torch.rot90

mindspore.ops.rot90

一致

torch.round

mindspore.ops.round

一致

torch.row_stack

mindspore.ops.row_stack

一致

torch.rsqrt

mindspore.ops.rsqrt

一致

torch.searchsorted

mindspore.ops.searchsorted

一致

torch.scatter

mindspore.ops.scatter

差异对比

torch.scatter_add

mindspore.ops.tensor_scatter_elements

差异对比

torch.sgn

mindspore.ops.sgn

一致

torch.sigmoid

mindspore.ops.sigmoid

一致

torch.sign

mindspore.ops.sign

一致

torch.signbit

mindspore.ops.signbit

一致

torch.sin

mindspore.ops.sin

一致

torch.sinc

mindspore.ops.sinc

一致

torch.sinh

mindspore.ops.sinh

一致

torch.slogdet

mindspore.ops.slogdet

一致

torch.sort

mindspore.ops.sort

功能一致,参数名不同

torch.split

mindspore.ops.split

功能一致,参数名不同

torch.stack

mindspore.ops.stack

功能一致,参数名不同

torch.squeeze

mindspore.ops.squeeze

功能一致,参数名不一致

torch.std

mindspore.ops.std

差异对比

torch.std_mean

mindspore.ops.std_mean

差异对比

torch.sqrt

mindspore.ops.sqrt

功能一致,参数名不同

torch.square

mindspore.ops.square

一致

torch.sub

mindspore.ops.subtract

功能一致,参数名不同

torch.subtract

mindspore.ops.subtract

一致

torch.sum

mindspore.ops.sum

一致

torch.svd

mindspore.ops.svd

差异对比

torch.swapaxes

mindspore.ops.swapaxes

一致

torch.swapdims

mindspore.ops.swapdims

一致

torch.t

mindspore.ops.t

一致

torch.tan

mindspore.ops.tan

一致

torch.tanh

mindspore.ops.tanh

一致

torch.tensor_split

mindspore.ops.tensor_split

功能一致,参数名不同

torch.tile

mindspore.ops.tile

功能一致,参数名不同

torch.topk

mindspore.ops.topk

一致

torch.trace

mindspore.ops.trace

一致

torch.transpose

mindspore.ops.swapaxes

一致

torch.trapz

mindspore.ops.trapz

一致

torch.tril

mindspore.ops.tril

一致

torch.tril_indices

mindspore.ops.tril_indices

一致

torch.triu_indices

mindspore.ops.triu_indices

一致

torch.true_divide

mindspore.ops.true_divide

一致

torch.trunc

mindspore.ops.trunc

一致

torch.unbind

mindspore.ops.unbind

一致

torch.unique

mindspore.ops.unique

差异对比

torch.unique_consecutive

mindspore.ops.unique_consecutive

功能一致,参数名不同

torch.unsqueeze

mindspore.ops.unsqueeze

一致

torch.vander

mindspore.ops.vander

一致

torch.var

mindspore.ops.var

差异对比

torch.var_mean

mindspore.ops.var_mean

差异对比

torch.view_as_real

mindspore.ops.view_as_real

一致

torch.vstack

mindspore.ops.vstack

功能一致,参数名不同

torch.where

mindspore.ops.where

一致

torch.xlogy

mindspore.ops.xlogy

一致

torch.zeros

mindspore.ops.zeros

差异对比

torch.zeros_like

mindspore.ops.zeros_like

一致

PyTorch 1.12 APIs

MindSpore APIs

说明

torch.hsplit

mindspore.ops.hsplit

一致

torch.permute

mindspore.ops.permute

一致

torch.vsplit

mindspore.ops.vsplit

一致

torch.generator

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.get_rng_state

mindspore.get_rng_state

一致

torch.initial_seed

mindspore.initial_seed

一致

torch.manual_seed

mindspore.manual_seed

一致

torch.seed

mindspore.seed

一致

torch.set_rng_state

mindspore.set_rng_state

一致

torch.Generator

mindspore.Generator

一致

torch.distributions

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.distributions.laplace.Laplace

mindspore.ops.standard_laplace

差异对比

torch.distributed

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.distributed.all_gather

mindspore.communication.comm_func.all_gather_into_tensor

差异对比

torch.distributed.all_reduce

mindspore.communication.comm_func.all_reduce

差异对比

torch.distributed.scatter

mindspore.communication.comm_func.scatter_tensor

差异对比

torch.distributed.gather

mindspore.communication.comm_func.gather_into_tensor

差异对比

torch.distributed.barrier

mindspore.communication.comm_func.barrier

差异对比

torch.distributed.broadcast

mindspore.communication.comm_func.broadcast

差异对比

torch.distributed.get_rank

mindspore.communication.get_rank

差异对比

torch.distributed.init_process_group

mindspore.communication.init

差异对比

torch.distributed.new_group

mindspore.communication.create_group

差异对比

torch.distributed.reduce_scatter

mindspore.communication.comm_func.reduce_scatter_tensor

差异对比

torch.distributed.reduce

mindspore.communication.comm_func.reduce

差异对比

PyTorch 2.0.0 APIs

MindSpore APIs

说明

torch.distributed.all_to_all_single

mindspore.communication.comm_func.all_to_all_single_with_output_shape

差异对比

torch.distributed.all_to_all

mindspore.communication.comm_func.all_to_all_with_output_shape

差异对比

torch.distributed.batch_isend_irecv

mindspore.communication.comm_func.batch_isend_irecv

一致

torch.distributed.P2POp

mindspore.communication.comm_func.P2POp

一致

torch.distributed.isend

mindspore.communication.comm_func.isend

一致

torch.distributed.irecv

mindspore.communication.comm_func.irecv

一致

torch.nn

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.nn.AdaptiveAvgPool1d

mindspore.nn.AdaptiveAvgPool1d

差异对比

torch.nn.AdaptiveAvgPool2d

mindspore.nn.AdaptiveAvgPool2d

一致

torch.nn.AdaptiveAvgPool3d

mindspore.nn.AdaptiveAvgPool3d

一致

torch.nn.AdaptiveMaxPool1d

mindspore.nn.AdaptiveMaxPool1d

差异对比

torch.nn.AdaptiveMaxPool2d

mindspore.nn.AdaptiveMaxPool2d

一致

torch.nn.AdaptiveMaxPool3d

mindspore.nn.AdaptiveMaxPool3d

一致

torch.nn.AvgPool1d

mindspore.nn.AvgPool1d

差异对比

torch.nn.AvgPool2d

mindspore.nn.AvgPool2d

差异对比

torch.nn.AvgPool3d

mindspore.nn.AvgPool3d

差异对比

torch.nn.BCELoss

mindspore.nn.BCELoss

一致

torch.nn.BCEWithLogitsLoss

mindspore.nn.BCEWithLogitsLoss

差异对比

torch.nn.BatchNorm1d

mindspore.nn.BatchNorm1d

差异对比

torch.nn.BatchNorm2d

mindspore.nn.BatchNorm2d

差异对比

torch.nn.BatchNorm3d

mindspore.nn.BatchNorm3d

差异对比

torch.nn.Bilinear

mindspore.nn.BiDense

差异对比

torch.nn.CeLU

mindspore.nn.CELU

一致

torch.nn.ChannelShuffle

mindspore.nn.ChannelShuffle

一致

torch.nn.CTCLoss

mindspore.nn.CTCLoss

一致

torch.nn.ConstantPad1d

mindspore.nn.ConstantPad1d

一致

torch.nn.ConstantPad2d

mindspore.nn.ConstantPad2d

一致

torch.nn.ConstantPad3d

mindspore.nn.ConstantPad3d

一致

torch.nn.Conv1d

mindspore.nn.Conv1d

差异对比

torch.nn.Conv2d

mindspore.nn.Conv2d

差异对比

torch.nn.Conv3d

mindspore.nn.Conv3d

差异对比

torch.nn.ConvTranspose1d

mindspore.nn.Conv1dTranspose

差异对比

torch.nn.ConvTranspose2d

mindspore.nn.Conv2dTranspose

差异对比

torch.nn.ConvTranspose3d

mindspore.nn.Conv3dTranspose

差异对比

torch.nn.CosineEmbeddingLoss

mindspore.nn.CosineEmbeddingLoss

一致

torch.nn.CrossEntropyLoss

mindspore.nn.CrossEntropyLoss

差异对比

torch.nn.Dropout

mindspore.nn.Dropout

差异对比

torch.nn.Dropout2d

mindspore.nn.Dropout2d

一致

torch.nn.Dropout3d

mindspore.nn.Dropout3d

一致

torch.nn.ELU

mindspore.nn.ELU

一致

torch.nn.Flatten

mindspore.nn.Flatten

一致

torch.nn.GaussianNLLLoss

mindspore.nn.GaussianNLLLoss

差异对比

torch.nn.GELU

mindspore.nn.GELU

差异对比

torch.nn.GRU

mindspore.nn.GRU

差异对比

torch.nn.GRUCell

mindspore.nn.GRUCell

差异对比

torch.nn.GroupNorm

mindspore.nn.GroupNorm

差异对比

torch.nn.Hardshrink

mindspore.nn.HShrink

差异对比

torch.nn.Hardsigmoid

mindspore.nn.Hsigmoid

一致

torch.nn.Hardswish

mindspore.nn.Hswish

一致

torch.nn.Hardtanh

mindspore.nn.Hardtanh

一致

torch.nn.HingeEmbeddingLoss

mindspore.nn.HingeEmbeddingLoss

一致

torch.nn.HuberLoss

mindspore.nn.HuberLoss

一致

torch.nn.Identity

mindspore.nn.Identity

功能一致,参数名不同

torch.nn.init.uniform_

mindspore.ops.uniform

差异对比

torch.nn.InstanceNorm1d

mindspore.nn.InstanceNorm1d

差异对比

torch.nn.InstanceNorm2d

mindspore.nn.InstanceNorm2d

差异对比

torch.nn.InstanceNorm3d

mindspore.nn.InstanceNorm3d

差异对比

torch.nn.KLDivLoss

mindspore.nn.KLDivLoss

一致

torch.nn.L1Loss

mindspore.nn.L1Loss

一致

torch.nn.LayerNorm

mindspore.nn.LayerNorm

差异对比

torch.nn.LeakyReLU

mindspore.nn.LeakyReLU

差异对比

torch.nn.LPPool1d

mindspore.nn.LPPool1d

一致

torch.nn.LPPool2d

mindspore.nn.LPPool2d

一致

torch.nn.LSTM

mindspore.nn.LSTM

差异对比

torch.nn.LSTMCell

mindspore.nn.LSTMCell

差异对比

torch.nn.Linear

mindspore.nn.Dense

差异对比

torch.nn.LocalResponseNorm

mindspore.nn.LRN

差异对比

torch.nn.LogSigmoid

mindspore.nn.LogSigmoid

一致

torch.nn.LogSoftMax

mindspore.nn.LogSoftMax

一致

torch.nn.MSELoss

mindspore.nn.MSELoss

一致

torch.nn.MarginRankingLoss

mindspore.nn.MarginRankingLoss

一致

torch.nn.MaxPool1d

mindspore.nn.MaxPool1d

差异对比

torch.nn.MaxPool2d

mindspore.nn.MaxPool2d

差异对比

torch.nn.MaxPool3d

mindspore.nn.MaxPool3d

差异对比

torch.nn.MaxUnpool1d

mindspore.nn.MaxUnpool1d

一致

torch.nn.MaxUnpool2d

mindspore.nn.MaxUnpool2d

一致

torch.nn.MaxUnpool3d

mindspore.nn.MaxUnpool3d

一致

torch.nn.ModuleDict

mindspore.nn.CellDict

差异对比

torch.nn.ModuleList

mindspore.nn.CellList

功能一致,参数名不同

torch.nn.MultiheadAttention

mindspore.nn.MultiheadAttention

差异对比

torch.nn.MultiLabelMarginLoss

mindspore.nn.MultiLabelMarginLoss

一致

torch.nn.MultiLabelSoftMarginLoss

mindspore.nn.MultiLabelSoftMarginLoss

一致

torch.nn.MultiMarginLoss

mindspore.nn.MultiMarginLoss

一致

torch.nn.NLLLoss

mindspore.nn.NLLLoss

差异对比

torch.nn.parameter.Parameter

mindspore.Parameter

差异对比

torch.nn.PReLU

mindspore.nn.PReLU

差异对比

torch.nn.PixelShuffle

mindspore.nn.PixelShuffle

一致

torch.nn.PixelUnshuffle

mindspore.nn.PixelUnshuffle

一致

torch.nn.PoissonNLLLoss

mindspore.nn.PoissonNLLLoss

一致

torch.nn.ReflectionPad1d

mindspore.nn.ReflectionPad1d

一致

torch.nn.ReflectionPad2d

mindspore.nn.ReflectionPad2d

一致

torch.nn.ReLU

mindspore.nn.ReLU

差异对比

torch.nn.ReLU6

mindspore.nn.ReLU6

一致

torch.nn.ReplicationPad1d

mindspore.nn.ReplicationPad1d

一致

torch.nn.ReplicationPad2d

mindspore.nn.ReplicationPad2d

一致

torch.nn.ReplicationPad3d

mindspore.nn.ReplicationPad3d

一致

torch.nn.RNN

mindspore.nn.RNN

差异对比

torch.nn.RNNCell

mindspore.nn.RNNCell

差异对比

torch.nn.RReLU

mindspore.nn.RReLU

一致

torch.nn.SeLU

mindspore.nn.SeLU

一致

torch.nn.Sequential

mindspore.nn.SequentialCell

差异对比

torch.nn.Sigmoid

mindspore.nn.Sigmoid

差异对比

torch.nn.SiLU

mindspore.nn.SiLU

一致

torch.nn.SmoothL1Loss

mindspore.nn.SmoothL1Loss

差异对比

torch.nn.SoftMarginLoss

mindspore.nn.SoftMarginLoss

一致

torch.nn.Softmax

mindspore.nn.Softmax

差异对比

torch.nn.Softmin

mindspore.nn.Softmin

差异对比

torch.nn.Softmax2d

mindspore.nn.Softmax2d

一致

torch.nn.Softshrink

mindspore.nn.SoftShrink

差异对比

torch.nn.Softsign

mindspore.nn.Softsign

一致

torch.nn.SyncBatchNorm

mindspore.nn.SyncBatchNorm

差异对比

torch.nn.Tanh

mindspore.nn.Tanh

差异对比

torch.nn.Tanhshrink

mindspore.nn.Tanhshrink

一致

torch.nn.Threshold

mindspore.nn.Threshold

一致

torch.nn.Transformer

mindspore.nn.Transformer

差异对比

torch.nn.TransformerDecoder

mindspore.nn.TransformerDecoder

差异对比

torch.nn.TransformerEncoder

mindspore.nn.TransformerEncoder

差异对比

torch.nn.TransformerDecoderLayer

mindspore.nn.TransformerDecoderLayer

差异对比

torch.nn.TransformerEncoderLayer

mindspore.nn.TransformerEncoderLayer

差异对比

torch.nn.TripletMarginLoss

mindspore.nn.TripletMarginLoss

功能一致,参数个数或顺序不一致

torch.nn.Unflatten

mindspore.nn.Unflatten

功能一致,参数名不同

torch.nn.Unfold

mindspore.nn.Unfold

差异对比

torch.nn.Upsample

mindspore.nn.Upsample

差异对比

torch.nn.ZeroPad2d

mindspore.nn.ZeroPad2d

一致

torch.nn.functional

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.nn.functional.adaptive_avg_pool1d

mindspore.ops.adaptive_avg_pool1d

差异对比

torch.nn.functional.adaptive_avg_pool2d

mindspore.ops.adaptive_avg_pool2d

一致

torch.nn.functional.adaptive_avg_pool3d

mindspore.ops.adaptive_avg_pool3d

一致

torch.nn.functional.adaptive_max_pool1d

mindspore.ops.adaptive_max_pool1d

差异对比

torch.nn.functional.adaptive_max_pool2d

mindspore.ops.adaptive_max_pool2d

一致

torch.nn.functional.affine_grid

mindspore.ops.affine_grid

一致

torch.nn.functional.avg_pool1d

mindspore.ops.avg_pool1d

差异对比

torch.nn.functional.avg_pool2d

mindspore.ops.avg_pool2d

差异对比

torch.nn.functional.avg_pool3d

mindspore.ops.avg_pool3d

差异对比

torch.nn.functional.batch_norm

mindspore.ops.batch_norm

功能一致,参数名不同

torch.nn.functional.bilinear

mindspore.ops.bidense

一致

torch.nn.functional.binary_cross_entropy

mindspore.ops.binary_cross_entropy

功能一致,参数名不同

torch.nn.functional.binary_cross_entropy_with_logits

mindspore.ops.binary_cross_entropy_with_logits

功能一致,参数名不同

torch.nn.functional.celu

mindspore.ops.celu

功能一致,参数名不同

torch.nn.functional.conv1d

mindspore.ops.conv1d

一致

torch.nn.functional.conv2d

mindspore.ops.conv2d

一致

torch.nn.functional.conv3d

mindspore.ops.conv3d

一致

torch.nn.functional.cosine_embedding_loss

mindspore.ops.cosine_embedding_loss

一致

torch.nn.functional.cosine_similarity

mindspore.ops.cosine_similarity

一致

torch.nn.functional.cross_entropy

mindspore.ops.cross_entropy

一致

torch.nn.functional.ctc_loss

mindspore.ops.ctc_loss

一致

torch.nn.functional.linear

mindspore.ops.dense

一致

torch.nn.functional.dropout

mindspore.ops.dropout

差异对比

torch.nn.functional.dropout2d

mindspore.ops.dropout2d

功能一致,参数数据类型不同

torch.nn.functional.dropout3d

mindspore.ops.dropout3d

功能一致,参数数据类型不同

torch.nn.functional.elu

mindspore.ops.elu

差异对比

torch.nn.functional.fold

mindspore.ops.fold

差异对比

torch.nn.functional.gelu

mindspore.ops.gelu

差异对比

torch.nn.functional.glu

mindspore.ops.glu

功能一致,参数名不同

torch.nn.functional.grid_sample

mindspore.ops.grid_sample

差异对比

torch.nn.functional.gumbel_softmax

mindspore.ops.gumbel_softmax

一致

torch.nn.functional.hardshrink

mindspore.ops.hardshrink

功能一致,参数名不同

torch.nn.functional.hardsigmoid

mindspore.ops.hardsigmoid

一致

torch.nn.functional.hardswish

mindspore.ops.hardswish

功能一致,参数名不同

torch.nn.functional.hardtanh

mindspore.ops.hardtanh

一致

torch.nn.functional.hinge_embedding_loss

mindspore.ops.hinge_embedding_loss

一致

torch.nn.functional.interpolate

mindspore.ops.interpolate

差异对比

torch.nn.functional.kl_div

mindspore.ops.kl_div

差异对比

torch.nn.functional.l1_loss

mindspore.ops.l1_loss

一致

torch.nn.functional.leaky_relu

mindspore.ops.leaky_relu

差异对比

torch.nn.functional.logsigmoid

mindspore.ops.logsigmoid

功能一致,参数名不同

torch.nn.functional.log_softmax

mindspore.ops.log_softmax

差异对比

torch.nn.functional.lp_pool1d

mindspore.ops.lp_pool1d

功能一致,参数名不同

torch.nn.functional.lp_pool2d

mindspore.ops.lp_pool2d

功能一致,参数名不同

torch.nn.functional.margin_ranking_loss

mindspore.ops.margin_ranking_loss

一致

torch.nn.functional.max_pool3d

mindspore.ops.max_pool3d

一致

torch.nn.functional.max_unpool1d

mindspore.ops.max_unpool1d

一致

torch.nn.functional.max_unpool2d

mindspore.ops.max_unpool2d

一致

torch.nn.functional.max_unpool3d

mindspore.ops.max_unpool3d

一致

torch.nn.functional.mse_loss

mindspore.ops.mse_loss

一致

torch.nn.functional.multi_margin_loss

mindspore.ops.multi_margin_loss

一致

torch.nn.functional.multilabel_margin_loss

mindspore.ops.multilabel_margin_loss

一致

torch.nn.functional.multilabel_soft_margin_loss

mindspore.ops.multilabel_soft_margin_loss

一致

torch.nn.functional.nll_loss

mindspore.ops.nll_loss

一致

torch.nn.functional.pad

mindspore.ops.pad

差异对比

torch.nn.functional.pdist

mindspore.ops.pdist

一致

torch.nn.functional.pixel_shuffle

mindspore.ops.pixel_shuffle

一致

torch.nn.functional.pixel_unshuffle

mindspore.ops.pixel_unshuffle

一致

torch.nn.functional.prelu

mindspore.ops.prelu

功能一致,参数名不同

torch.nn.functional.relu

mindspore.ops.relu

一致

torch.nn.functional.relu6

mindspore.ops.relu6

功能一致,参数名不同

torch.nn.functional.rrelu

mindspore.ops.rrelu

功能一致,参数名不同

torch.nn.functional.selu

mindspore.ops.selu

功能一致,参数名不同

torch.nn.functional.sigmoid

mindspore.ops.sigmoid

一致

torch.nn.functional.silu

mindspore.ops.silu

功能一致,参数名不同

torch.nn.functional.softmax

mindspore.ops.softmax

差异对比

torch.nn.functional.softmin

mindspore.ops.softmin

差异对比

torch.nn.functional.softsign

mindspore.ops.softsign

功能一致,参数名不同

torch.nn.functional.smooth_l1_loss

mindspore.ops.smooth_l1_loss

一致

torch.nn.functional.soft_margin_loss

mindspore.ops.soft_margin_loss

一致

torch.nn.functional.softshrink

mindspore.ops.softshrink

功能一致,参数名不同

torch.nn.functional.tanh

mindspore.ops.tanh

一致

torch.nn.functional.tanhshrink

mindspore.ops.tanhshrink

一致

torch.nn.functional.threshold

mindspore.ops.threshold

功能一致,参数名不同

torch.nn.functional.triplet_margin_loss

mindspore.ops.triplet_margin_loss

功能一致,参数个数或顺序不一致

torch.nn.functional.unfold

mindspore.ops.unfold

一致

torch.nn.functional.upsample

mindspore.ops.upsample

差异对比

torch.nn.Module

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.nn.Module.apply

mindspore.nn.Cell.apply

一致

torch.nn.utils

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.nn.utils.clip_grad_value_

mindspore.ops.clip_by_value

差异对比

torch.nn.utils.clip_grad_norm_

mindspore.ops.clip_by_norm

差异对比

torch.Tensor

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.Tensor.abs

mindspore.Tensor.abs

一致

torch.Tensor.absolute

mindspore.Tensor.absolute

一致

torch.Tensor.acos

mindspore.Tensor.acos

一致

torch.Tensor.acosh

mindspore.Tensor.acosh

一致

torch.Tensor.add

mindspore.Tensor.add

一致

torch.Tensor.addbmm

mindspore.Tensor.addbmm

一致

torch.Tensor.addcdiv

mindspore.Tensor.addcdiv

一致

torch.Tensor.addcmul

mindspore.Tensor.addcmul

一致

torch.Tensor.addmm

mindspore.Tensor.addmm

一致

torch.Tensor.addmv

mindspore.Tensor.addmv

功能一致,参数名不同

torch.Tensor.addr

mindspore.Tensor.addr

一致

torch.Tensor.all

mindspore.Tensor.all

差异对比

torch.Tensor.amax

mindspore.Tensor.amax

差异对比

torch.Tensor.amin

mindspore.Tensor.amin

差异对比

torch.Tensor.any

mindspore.Tensor.any

差异对比

torch.Tensor.arccos

mindspore.Tensor.arccos

一致

torch.Tensor.arccosh

mindspore.Tensor.arccosh

一致

torch.Tensor.argmax

mindspore.Tensor.argmax

功能一致,参数名不同

torch.Tensor.angle

mindspore.Tensor.angle

一致

torch.Tensor.arcsin

mindspore.Tensor.arcsin

一致

torch.Tensor.arcsinh

mindspore.Tensor.arcsinh

一致

torch.Tensor.arctan

mindspore.Tensor.arctan

一致

torch.Tensor.arctanh

mindspore.Tensor.arctanh

一致

torch.Tensor.argmin

mindspore.Tensor.argmin

差异对比

torch.Tensor.argsort

mindspore.Tensor.argsort

功能一致,参数名不同

torch.Tensor.asin

mindspore.Tensor.asin

一致

torch.Tensor.asinh

mindspore.Tensor.asinh

一致

torch.Tensor.atan

mindspore.Tensor.atan

一致

torch.Tensor.atan2

mindspore.Tensor.atan2

一致

torch.Tensor.atanh

mindspore.Tensor.atanh

一致

torch.Tensor.baddbmm

mindspore.Tensor.baddbmm

一致

torch.Tensor.bernoulli

mindspore.Tensor.bernoulli

功能一致,参数个数或顺序不一致

torch.Tensor.bincount

mindspore.Tensor.bincount

一致

torch.Tensor.bitwise_and

mindspore.Tensor.bitwise_and

一致

torch.Tensor.bitwise_or

mindspore.Tensor.bitwise_or

一致

torch.Tensor.bitwise_xor

mindspore.Tensor.bitwise_xor

一致

torch.Tensor.bmm

mindspore.Tensor.bmm

功能一致,参数名不同

torch.Tensor.bool

mindspore.Tensor.bool

功能一致,参数名不同

torch.Tensor.broadcast_to

mindspore.Tensor.broadcast_to

差异对比

torch.Tensor.cauchy_

mindspore.Tensor.cauchy

一致

torch.Tensor.ceil

mindspore.Tensor.ceil

一致

torch.Tensor.chunk

mindspore.Tensor.chunk

一致

torch.Tensor.cholesky

mindspore.Tensor.cholesky

一致

torch.Tensor.cholesky_solve

mindspore.Tensor.cholesky_solve

一致

torch.Tensor.clamp

mindspore.Tensor.clamp

一致

torch.Tensor.clip

mindspore.Tensor.clip

一致

torch.Tensor.conj

mindspore.Tensor.conj

一致

torch.Tensor.contiguous

mindspore.Tensor.contiguous

一致

torch.Tensor.copysign

mindspore.Tensor.copysign

一致

torch.Tensor.cos

mindspore.Tensor.cos

一致

torch.Tensor.cosh

mindspore.Tensor.cosh

一致

torch.Tensor.cross

mindspore.Tensor.cross

一致

torch.Tensor.cummax

mindspore.Tensor.cummax

功能一致,参数名不同

torch.Tensor.cummin

mindspore.Tensor.cummin

功能一致,参数名不同

torch.Tensor.cumprod

mindspore.Tensor.cumprod

一致

torch.Tensor.cumsum

mindspore.Tensor.cumsum

一致

torch.Tensor.deg2rad

mindspore.Tensor.deg2rad

一致

torch.Tensor.diag

mindspore.Tensor.diag

差异对比

torch.Tensor.diagonal

mindspore.Tensor.diagonal

一致

torch.Tensor.diagflat

mindspore.Tensor.diagflat

一致

torch.Tensor.diff

mindspore.Tensor.diff

功能一致,参数名不同

torch.Tensor.digamma

mindspore.Tensor.digamma

一致

torch.Tensor.dim

mindspore.Tensor.ndimension

一致

torch.Tensor.div

mindspore.Tensor.div

一致

torch.Tensor.divide

mindspore.Tensor.divide

一致

torch.Tensor.eq

mindspore.Tensor.equal

一致

torch.Tensor.erf

mindspore.Tensor.erf

一致

torch.Tensor.erfc

mindspore.Tensor.erfc

一致

torch.Tensor.erfinv

mindspore.Tensor.erfinv

一致

torch.Tensor.exp

mindspore.Tensor.exp

一致

torch.Tensor.expand

mindspore.Tensor.broadcast_to

差异对比

torch.Tensor.expand_as

mindspore.Tensor.expand_as

功能一致,参数名不同

torch.Tensor.expm1

mindspore.Tensor.expm1

一致

torch.Tensor.fill_diagonal_

mindspore.Tensor.fill_diagonal

一致

torch.Tensor.flip

mindspore.Tensor.flip

差异对比

torch.Tensor.fliplr

mindspore.Tensor.fliplr

一致

torch.Tensor.flipud

mindspore.Tensor.flipud

一致

torch.Tensor.float

mindspore.Tensor.float

一致

torch.Tensor.float_power

mindspore.Tensor.float_power

差异对比

torch.Tensor.floor

mindspore.Tensor.floor

一致

torch.Tensor.floor_divide

mindspore.Tensor.floor_divide

功能一致,参数名不同

torch.Tensor.fmax

mindspore.Tensor.fmax

一致

torch.Tensor.fmod

mindspore.Tensor.fmod

一致

torch.Tensor.frac

mindspore.Tensor.frac

功能一致,参数名不同

torch.Tensor.gather

mindspore.Tensor.gather_elements

一致

torch.Tensor.ge

mindspore.Tensor.ge

功能一致,参数名不同

torch.Tensor.geqrf

mindspore.Tensor.geqrf

一致

torch.Tensor.ger

mindspore.Tensor.ger

差异对比

torch.Tensor.greater

mindspore.Tensor.greater

一致

torch.Tensor.greater_equal

mindspore.Tensor.greater_equal

一致

torch.Tensor.gt

mindspore.Tensor.gt

功能一致,参数名不同

torch.Tensor.H

mindspore.Tensor.H

一致

torch.Tensor.half

mindspore.Tensor.half

一致

torch.Tensor.hardshrink

mindspore.Tensor.hardshrink

一致

torch.Tensor.heaviside

mindspore.Tensor.heaviside

一致

torch.Tensor.histc

mindspore.Tensor.histc

一致

torch.Tensor.hypot

mindspore.Tensor.hypot

一致

torch.Tensor.i0

mindspore.Tensor.i0

一致

torch.Tensor.igamma

mindspore.Tensor.igamma

一致

torch.Tensor.igammac

mindspore.Tensor.igammac

一致

torch.Tensor.imag

mindspore.Tensor.imag

一致

torch.Tensor.index_add

mindspore.Tensor.index_add

一致

torch.Tensor.index_fill

mindspore.Tensor.index_fill

一致

torch.Tensor.index_put

mindspore.Tensor.index_put

一致

torch.Tensor.index_select

mindspore.Tensor.index_select

功能一致,参数名不同

torch.Tensor.inner

mindspore.Tensor.inner

功能一致,参数名不同

torch.Tensor.int

mindspore.Tensor.int

一致

torch.Tensor.inverse

mindspore.Tensor.inverse

一致

torch.Tensor.isclose

mindspore.Tensor.isclose

功能一致,参数名不同

torch.Tensor.isfinite

mindspore.Tensor.isfinite

一致

torch.Tensor.isinf

mindspore.Tensor.isinf

一致

torch.Tensor.isnan

mindspore.Tensor.isnan

一致

torch.Tensor.is_complex

mindspore.Tensor.is_complex

一致

torch.Tensor.is_contiguous

mindspore.Tensor.is_contiguous

一致

torch.Tensor.is_floating_point

mindspore.Tensor.is_floating_point

一致

torch.Tensor.is_signed

mindspore.Tensor.is_signed

一致

torch.Tensor.isneginf

mindspore.Tensor.isneginf

一致

torch.Tensor.isposinf

mindspore.Tensor.isposinf

一致

torch.Tensor.isreal

mindspore.Tensor.isreal

一致

torch.Tensor.item

mindspore.Tensor.item

差异对比

torch.Tensor.lcm

mindspore.Tensor.lcm

一致

torch.Tensor.ldexp

mindspore.Tensor.ldexp

一致

torch.Tensor.le

mindspore.Tensor.le

一致

torch.Tensor.lerp

mindspore.Tensor.lerp

一致

torch.Tensor.less

mindspore.Tensor.less

一致

torch.Tensor.less_equal

mindspore.Tensor.less_equal

一致

torch.Tensor.log

mindspore.Tensor.log

一致

torch.Tensor.log_normal

mindspore.Tensor.log_normal

一致

torch.Tensor.log10

mindspore.Tensor.log10

一致

torch.Tensor.log1p

mindspore.Tensor.log1p

一致

torch.Tensor.log2

mindspore.Tensor.log2

一致

torch.Tensor.logaddexp

mindspore.Tensor.logaddexp

一致

torch.Tensor.logaddexp2

mindspore.Tensor.logaddexp2

一致

torch.Tensor.logcumsumexp

mindspore.Tensor.logcumsumexp

一致

torch.Tensor.logdet

mindspore.Tensor.logdet

一致

torch.Tensor.logical_and

mindspore.Tensor.logical_and

一致

torch.Tensor.logical_not

mindspore.Tensor.logical_not

一致

torch.Tensor.logical_or

mindspore.Tensor.logical_or

一致

torch.Tensor.logical_xor

mindspore.Tensor.logical_xor

一致

torch.Tensor.logit

mindspore.Tensor.logit

一致

torch.Tensor.logsumexp

mindspore.Tensor.logsumexp

功能一致,参数名不同

torch.Tensor.long

mindspore.Tensor.long

一致

torch.Tensor.lt

mindspore.Tensor.lt

一致

torch.Tensor.lu_solve

mindspore.Tensor.lu_solve

一致

torch.Tensor.masked_fill

mindspore.Tensor.masked_fill

一致

torch.Tensor.masked_scatter

mindspore.Tensor.masked_scatter

差异对比

torch.Tensor.masked_select

mindspore.Tensor.masked_select

一致

torch.Tensor.matmul

mindspore.Tensor.matmul

一致

torch.Tensor.max

mindspore.Tensor.max

差异对比

torch.Tensor.maximum

mindspore.Tensor.maximum

一致

torch.Tensor.mean

mindspore.Tensor.mean

功能一致,参数名不同

torch.Tensor.median

mindspore.Tensor.median

差异对比

torch.Tensor.mH

mindspore.Tensor.mH

一致

torch.Tensor.min

mindspore.Tensor.min

差异对比

torch.Tensor.minimum

mindspore.Tensor.minimum

一致

torch.Tensor.mm

mindspore.Tensor.mm

一致

torch.Tensor.moveaxis

mindspore.Tensor.moveaxis

功能一致

torch.Tensor.movedim

mindspore.Tensor.movedim

一致

torch.Tensor.msort

mindspore.Tensor.msort

一致

torch.Tensor.mT

mindspore.Tensor.mT

一致

torch.Tensor.mul

mindspore.Tensor.mul

一致

torch.Tensor.multinomial

mindspore.Tensor.multinomial

功能一致,参数默认值不一致

torch.Tensor.multiply

mindspore.Tensor.multiply

一致

torch.Tensor.mvlgamma

mindspore.Tensor.mvlgamma

一致

torch.Tensor.nan_to_num

mindspore.Tensor.nan_to_num

一致

torch.Tensor.nanmedian

mindspore.Tensor.nanmedian

一致

torch.Tensor.nansum

mindspore.Tensor.nansum

一致

torch.Tensor.narrow

mindspore.Tensor.narrow

功能一致,参数名不同

torch.Tensor.ndim

mindspore.Tensor.ndim

一致

torch.Tensor.ndimension

mindspore.Tensor.ndimension

一致

torch.Tensor.ne

mindspore.Tensor.ne

一致

torch.Tensor.neg

mindspore.Tensor.neg

一致

torch.Tensor.negative

mindspore.Tensor.negative

一致

torch.Tensor.nelement

mindspore.Tensor.nelement

一致

torch.Tensor.new_ones

mindspore.Tensor.new_ones

一致

torch.Tensor.new_zeros

mindspore.Tensor.new_zeros

一致

torch.Tensor.nextafter

mindspore.Tensor.nextafter

一致

torch.Tensor.norm

mindspore.Tensor.norm

torch.Tensor.norm即将弃用,mindspore.Tensor.norm对标torch.linalg.norm,功能完全一致

torch.Tensor.nonzero

mindspore.Tensor.nonzero

一致

torch.Tensor.not_equal

mindspore.Tensor.not_equal

一致

torch.Tensor.numel

mindspore.Tensor.numel

一致

torch.Tensor.numpy

mindspore.Tensor.asnumpy

一致

torch.Tensor.orgqr

mindspore.Tensor.orgqr

一致

torch.Tensor.ormqr

mindspore.Tensor.ormqr

一致

torch.Tensor.outer

mindspore.Tensor.outer

一致

torch.Tensor.permute

mindspore.Tensor.permute

一致

torch.Tensor.pow

mindspore.Tensor.pow

功能一致,参数名不同

torch.Tensor.prod

mindspore.Tensor.prod

差异对比

torch.Tensor.ravel

mindspore.Tensor.ravel

一致

torch.Tensor.real

mindspore.Tensor.real

一致

torch.Tensor.reciprocal

mindspore.Tensor.reciprocal

一致

torch.Tensor.remainder

mindspore.Tensor.remainder

一致

torch.Tensor.renorm

mindspore.Tensor.renorm

功能一致,参数数据类型不一致

torch.Tensor.rad2deg

mindspore.Tensor.rad2deg

一致

torch.Tensor.repeat

mindspore.Tensor.tile

差异对比

torch.Tensor.repeat_interleave

mindspore.Tensor.repeat_interleave

一致

torch.Tensor.reshape

mindspore.Tensor.reshape

一致

torch.Tensor.reshape_as

mindspore.Tensor.reshape_as

一致

torch.Tensor.round

mindspore.Tensor.round

一致

torch.Tensor.roll

mindspore.Tensor.roll

一致

torch.Tensor.rot90

mindspore.Tensor.rot90

一致

torch.Tensor.rsqrt

mindspore.Tensor.rsqrt

一致

torch.Tensor.scatter_

mindspore.ops.tensor_scatter_elements

差异对比

torch.Tensor.sum_to_size

mindspore.Tensor.sum_to_size

一致

torch.Tensor.scatter

mindspore.Tensor.scatter

差异对比

torch.Tensor.sgn

mindspore.Tensor.sgn

一致

torch.Tensor.shape

mindspore.Tensor.shape

一致

torch.Tensor.short

mindspore.Tensor.short

一致

torch.Tensor.sigmoid

mindspore.Tensor.sigmoid

一致

torch.Tensor.sign

mindspore.Tensor.sign

一致

torch.Tensor.signbit

mindspore.Tensor.signbit

一致

torch.Tensor.sin

mindspore.Tensor.sin

一致

torch.Tensor.sinc

mindspore.Tensor.sinc

一致

torch.Tensor.sinh

mindspore.Tensor.sinh

一致

torch.Tensor.size

mindspore.Tensor.shape

差异对比

torch.Tensor.slogdet

mindspore.Tensor.slogdet

一致

torch.Tensor.sort

mindspore.Tensor.sort

一致

torch.Tensor.split

mindspore.Tensor.split

功能一致,参数名不同

torch.Tensor.sqrt

mindspore.Tensor.sqrt

一致

torch.Tensor.square

mindspore.Tensor.square

一致

torch.Tensor.squeeze

mindspore.Tensor.squeeze

一致

torch.Tensor.std

mindspore.Tensor.std

差异对比

torch.Tensor.storage_offset

mindspore.Tensor.storage_offset

一致

torch.Tensor.stride

mindspore.Tensor.stride

一致

torch.Tensor.sub

mindspore.Tensor.subtract

一致

torch.Tensor.subtract

mindspore.Tensor.subtract

一致

torch.Tensor.sum

mindspore.Tensor.sum

功能一致,参数个数或顺序不一致

torch.Tensor.svd

mindspore.Tensor.svd

差异对比

torch.Tensor.swapaxes

mindspore.Tensor.swapaxes

一致

torch.Tensor.swapdims

mindspore.Tensor.swapdims

一致

torch.Tensor.T

mindspore.Tensor.T

一致

torch.Tensor.t

mindspore.Tensor.t

一致

torch.Tensor.take

mindspore.Tensor.take

差异对比

torch.Tensor.tan

mindspore.Tensor.tan

一致

torch.Tensor.tanh

mindspore.Tensor.tanh

一致

torch.Tensor.trace

mindspore.Tensor.trace

一致

torch.Tensor.transpose

mindspore.Tensor.swapaxes

一致

torch.Tensor.tile

mindspore.Tensor.tile

功能一致,参数名不同

torch.Tensor.to

mindspore.Tensor.to

差异对比

torch.Tensor.topk

mindspore.Tensor.topk

一致

torch.Tensor.triu

mindspore.Tensor.triu

功能一致,参数名不同

torch.Tensor.tril

mindspore.Tensor.tril

一致

torch.Tensor.tensor_split

mindspore.Tensor.tensor_split

功能一致,参数名不同

torch.Tensor.true_divide

mindspore.Tensor.true_divide

一致

torch.Tensor.trunc

mindspore.Tensor.trunc

一致

torch.Tensor.unbind

mindspore.Tensor.unbind

一致

torch.Tensor.unique_consecutive

mindspore.Tensor.unique_consecutive

功能一致,参数名不同

torch.Tensor.unsqueeze

mindspore.Tensor.unsqueeze

一致

torch.Tensor.var

mindspore.Tensor.var

差异对比

torch.Tensor.view

mindspore.Tensor.view

一致

torch.Tensor.view_as

mindspore.Tensor.view_as

一致

torch.Tensor.where

mindspore.Tensor.where

一致

torch.Tensor.xlogy

mindspore.Tensor.xlogy

功能一致,参数名不同

PyTorch 1.12 APIs

MindSpore APIs

说明

torch.Tensor.hsplit

mindspore.Tensor.hsplit

功能一致,参数名不同

torch.Tensor.vsplit

mindspore.Tensor.vsplit

功能一致,参数名不同

torch.optim

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.optim.Adadelta

mindspore.nn.Adadelta

一致

torch.optim.Adagrad

mindspore.nn.Adagrad

差异对比

torch.optim.Adam

mindspore.nn.Adam

差异对比

torch.optim.AdaMax

mindspore.nn.AdaMax

差异对比

torch.optim.AdamW

mindspore.nn.AdamWeightDecay

差异对比

torch.optim.ASGD

mindspore.nn.ASGD

一致

torch.optim.Optimizer

mindspore.nn.Optimizer

差异对比

torch.optim.SparseAdam

mindspore.nn.LazyAdam

差异对比

torch.optim.RMSProp

mindspore.nn.RMSProp

差异对比

torch.optim.Rprop

mindspore.nn.Rprop

差异对比

torch.optim.SGD

mindspore.nn.SGD

一致

torch.optim.lr_scheduler.CosineAnnealingLR

mindspore.nn.cosine_decay_lr

差异对比

torch.optim.lr_scheduler.ExponentialLR

mindspore.nn.exponential_decay_lr

差异对比

torch.optim.lr_scheduler.MultiStepLR

mindspore.nn.piecewise_constant_lr

差异对比

torch.optim.lr_scheduler.StepLR

mindspore.nn.piecewise_constant_lr

差异对比

torch.optim

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.optim.Adadelta

mindspore.experimental.optim.Adadelta

一致

torch.optim.Adagrad

mindspore.experimental.optim.Adagrad

一致

torch.optim.Adam

mindspore.experimental.optim.Adam

一致

torch.optim.Adamax

mindspore.experimental.optim.Adamax

一致

torch.optim.AdamW

mindspore.experimental.optim.AdamW

一致

torch.optim.ASGD

mindspore.experimental.optim.ASGD

一致

torch.optim.NAdam

mindspore.experimental.optim.NAdam

一致

torch.optim.RAdam

mindspore.experimental.optim.RAdam

一致

torch.optim.RMSprop

mindspore.experimental.optim.RMSprop

一致

torch.optim.Rprop

mindspore.experimental.optim.Rprop

一致

torch.optim.SGD

mindspore.experimental.optim.SGD

一致

torch.optim.lr_scheduler

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.optim.lr_scheduler.LRScheduler

mindspore.experimental.optim.lr_scheduler.LRScheduler

verbose 入参,其余功能一致

torch.optim.lr_scheduler.ConstantLR

mindspore.experimental.optim.lr_scheduler.ConstantLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.CosineAnnealingLR

mindspore.experimental.optim.lr_scheduler.CosineAnnealingLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.CosineAnnealingWarmRestarts

mindspore.experimental.optim.lr_scheduler.CosineAnnealingWarmRestarts

verbose 入参,其余功能一致

torch.optim.lr_scheduler.CyclicLR

mindspore.experimental.optim.lr_scheduler.CyclicLR

verbosemomentum 相关入参,其余功能一致

torch.optim.lr_scheduler.ExponentialLR

mindspore.experimental.optim.lr_scheduler.ExponentialLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.LambdaLR

mindspore.experimental.optim.lr_scheduler.LambdaLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.LinearLR

mindspore.experimental.optim.lr_scheduler.LinearLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.MultiplicativeLR

mindspore.experimental.optim.lr_scheduler.MultiplicativeLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.MultiStepLR

mindspore.experimental.optim.lr_scheduler.MultiStepLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.PolynomialLR

mindspore.experimental.optim.lr_scheduler.PolynomialLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.ReduceLROnPlateau

mindspore.experimental.optim.lr_scheduler.ReduceLROnPlateau

verbose 入参,其余功能一致

torch.optim.lr_scheduler.SequentialLR

mindspore.experimental.optim.lr_scheduler.SequentialLR

verbose 入参,其余功能一致

torch.optim.lr_scheduler.StepLR

mindspore.experimental.optim.lr_scheduler.StepLR

verbose 入参,其余功能一致

torch.utils

PyTorch 1.8.1 APIs

MindSpore APIs

说明

torch.utils.data.DataLoader

mindspore.dataset.GeneratorDataset

差异对比

torch.utils.data.distributed.DistributedSampler

mindspore.dataset.DistributedSampler

差异对比

torch.utils.data.RandomSampler

mindspore.dataset.RandomSampler

差异对比

torch.utils.data.SequentialSampler

mindspore.dataset.SequentialSampler

差异对比

torch.utils.data.SubsetRandomSampler

mindspore.dataset.SubsetRandomSampler

差异对比

torch.utils.data.WeightedRandomSampler

mindspore.dataset.WeightedRandomSampler

差异对比

torch.utils.checkpoint.checkpoint

mindspore.nn.Cell.recompute

差异对比

torchaudio

当前API映射表对应的PyTorch版本是1.8.1,Python版本不高于Python 3.9。

TorchAudio 0.8.1 APIs

MindSpore APIs

说明

torchaudio.datasets.CMUARCTIC

mindspore.dataset.CMUArcticDataset

差异对比

torchaudio.datasets.GTZAN

mindspore.dataset.GTZANDataset

差异对比

torchaudio.datasets.LIBRITTS

mindspore.dataset.LibriTTSDataset

差异对比

torchaudio.datasets.LJSPEECH

mindspore.dataset.LJSpeechDataset

差异对比

torchaudio.datasets.SPEECHCOMMANDS

mindspore.dataset.SpeechCommandsDataset

差异对比

torchaudio.datasets.TEDLIUM

mindspore.dataset.TedliumDataset

差异对比

torchaudio.datasets.YESNO

mindspore.dataset.YesNoDataset

差异对比

torchaudio.transforms.AmplitudeToDB

mindspore.dataset.audio.AmplitudeToDB

差异对比

torchaudio.transforms.ComplexNorm

mindspore.dataset.audio.ComplexNorm

一致

torchaudio.transforms.ComputeDeltas

mindspore.dataset.audio.ComputeDeltas

功能一致,参数名不同

torchaudio.transforms.Fade

mindspore.dataset.audio.Fade

一致

torchaudio.transforms.FrequencyMasking

mindspore.dataset.audio.FrequencyMasking

差异对比

torchaudio.transforms.GriffinLim

mindspore.dataset.audio.GriffinLim

差异对比

torchaudio.transforms.InverseMelScale

mindspore.dataset.audio.InverseMelScale

差异对比

torchaudio.transforms.MelScale

mindspore.dataset.audio.MelScale

差异对比

torchaudio.transforms.MelSpectrogram

mindspore.dataset.audio.MelSpectrogram

差异对比

torchaudio.transforms.MFCC

mindspore.dataset.audio.MFCC

一致

torchaudio.transforms.MuLawEncoding

mindspore.dataset.audio.MuLawEncoding

一致

torchaudio.transforms.MuLawDecoding

mindspore.dataset.audio.MuLawDecoding

一致

torchaudio.transforms.Resample

mindspore.dataset.audio.Resample

差异对比

torchaudio.transforms.SlidingWindowCmn

mindspore.dataset.audio.SlidingWindowCmn

一致

torchaudio.transforms.SpectralCentroid

mindspore.dataset.audio.SpectralCentroid

差异对比

torchaudio.transforms.Spectrogram

mindspore.dataset.audio.Spectrogram

差异对比

torchaudio.transforms.TimeMasking

mindspore.dataset.audio.TimeMasking

差异对比

torchaudio.transforms.TimeStretch

mindspore.dataset.audio.TimeStretch

一致

torchaudio.transforms.Vad

mindspore.dataset.audio.Vad

一致

torchaudio.transforms.Vol

mindspore.dataset.audio.Vol

一致

torchtext

当前API映射表对应的PyTorch版本是1.8.1,Python版本不高于Python 3.9。

TorchText 0.9.1 APIs

MindSpore APIs

说明

torchtext.data.functional.custom_replace

mindspore.dataset.text.RegexReplace

差异对比

torchtext.data.functional.load_sp_model

mindspore.dataset.text.SentencePieceTokenizer

差异对比

torchtext.data.functional.numericalize_tokens_from_iterator

mindspore.dataset.text.Lookup

差异对比

torchtext.data.functional.sentencepiece_numericalizer

mindspore.dataset.text.SentencePieceTokenizer

差异对比

torchtext.data.functional.sentencepiece_tokenizer

mindspore.dataset.text.SentencePieceTokenizer

差异对比

torchtext.data.functional.simple_space_split

mindspore.dataset.text.WhitespaceTokenizer

差异对比

torchtext.data.utils.ngrams_iterator

mindspore.dataset.text.Ngram

差异对比

torchtext.datasets.AG_NEWS

mindspore.dataset.AGNewsDataset

差异对比

torchtext.datasets.AmazonReviewFull

mindspore.dataset.AmazonReviewDataset

差异对比

torchtext.datasets.AmazonReviewPolarity

mindspore.dataset.AmazonReviewDataset

差异对比

torchtext.datasets.CoNLL2000Chunking

mindspore.dataset.CoNLL2000Dataset

差异对比

torchtext.datasets.DBpedia

mindspore.dataset.DBpediaDataset

差异对比

torchtext.datasets.IMDB

mindspore.dataset.IMDBDataset

差异对比

torchtext.datasets.IWSLT2016

mindspore.dataset.IWSLT2016Dataset

差异对比

torchtext.datasets.IWSLT2017

mindspore.dataset.IWSLT2017Dataset

差异对比

torchtext.datasets.PennTreebank

mindspore.dataset.PennTreebankDataset

差异对比

torchtext.datasets.SogouNews

mindspore.dataset.SogouNewsDataset

差异对比

torchtext.datasets.SQuAD1

mindspore.dataset.SQuADDataset

差异对比

torchtext.datasets.SQuAD2

mindspore.dataset.SQuADDataset

差异对比

torchtext.datasets.UDPOS

mindspore.dataset.UDPOSDataset

差异对比

torchtext.datasets.WikiText103

mindspore.dataset.WikiTextDataset

差异对比

torchtext.datasets.WikiText2

mindspore.dataset.WikiTextDataset

差异对比

torchtext.datasets.YahooAnswers

mindspore.dataset.YahooAnswersDataset

差异对比

torchtext.datasets.YelpReviewFull

mindspore.dataset.YelpReviewDataset

差异对比

torchtext.datasets.YelpReviewPolarity

mindspore.dataset.YelpReviewDataset

差异对比

torchvision

当前API映射表对应的PyTorch版本是1.8.1,Python版本不高于Python 3.9。

TorchVision 0.9.1 APIs

MindSpore APIs

说明

torchvision.datasets.CelebA

mindspore.dataset.CelebADataset

差异对比

torchvision.datasets.Cityscapes

mindspore.dataset.CityscapesDataset

差异对比

torchvision.datasets.CIFAR10

mindspore.dataset.Cifar10Dataset

差异对比

torchvision.datasets.CIFAR100

mindspore.dataset.Cifar100Dataset

差异对比

torchvision.datasets.CocoDetection

mindspore.dataset.CocoDataset

差异对比

torchvision.datasets.ImageFolder

mindspore.dataset.ImageFolderDataset

差异对比

torchvision.datasets.MNIST

mindspore.dataset.MnistDataset

差异对比

torchvision.datasets.VOCDetection

mindspore.dataset.VOCDataset

差异对比

torchvision.datasets.VOCSegmentation

mindspore.dataset.VOCDataset

差异对比

torchvision.ops.nms

mindspore.ops.NMSWithMask

差异对比

torchvision.ops.roi_align

mindspore.ops.ROIAlign

差异对比

torchvision.transforms.CenterCrop

mindspore.dataset.vision.CenterCrop

一致

torchvision.transforms.ColorJitter

mindspore.dataset.vision.RandomColorAdjust

一致

torchvision.transforms.Compose

mindspore.dataset.transforms.Compose

一致

torchvision.transforms.ConvertImageDtype

mindspore.dataset.transforms.TypeCast

差异对比

torchvision.transforms.FiveCrop

mindspore.dataset.vision.FiveCrop

一致

torchvision.transforms.GaussianBlur

mindspore.dataset.vision.GaussianBlur

一致

torchvision.transforms.Grayscale

mindspore.dataset.vision.Grayscale

一致

torchvision.transforms.LinearTransformation

mindspore.dataset.vision.LinearTransformation

一致

torchvision.transforms.Normalize

mindspore.dataset.vision.Normalize

差异对比

torchvision.transforms.Pad

mindspore.dataset.vision.Pad

功能一致,参数名不同

torchvision.transforms.RandomAffine

mindspore.dataset.vision.RandomAffine

差异对比

torchvision.transforms.RandomApply

mindspore.dataset.transforms.RandomApply

功能一致,参数名不同

torchvision.transforms.RandomChoice

mindspore.dataset.transforms.RandomChoice

一致

torchvision.transforms.RandomCrop

mindspore.dataset.vision.RandomCrop

功能一致,参数名不同

torchvision.transforms.RandomGrayscale

mindspore.dataset.vision.RandomGrayscale

功能一致,参数名不同

torchvision.transforms.RandomHorizontalFlip

mindspore.dataset.vision.RandomHorizontalFlip

功能一致,参数名不同

torchvision.transforms.RandomOrder

mindspore.dataset.transforms.RandomOrder

一致

torchvision.transforms.RandomPerspective

mindspore.dataset.vision.RandomPerspective

差异对比

torchvision.transforms.RandomResizedCrop

mindspore.dataset.vision.RandomResizedCrop

差异对比

torchvision.transforms.RandomRotation

mindspore.dataset.vision.RandomRotation

差异对比

torchvision.transforms.RandomVerticalFlip

mindspore.dataset.vision.RandomVerticalFlip

功能一致,参数名不同

torchvision.transforms.Resize

mindspore.dataset.vision.Resize

一致

torchvision.transforms.TenCrop

mindspore.dataset.vision.TenCrop

功能一致,参数名不同

torchvision.transforms.ToPILImage

mindspore.dataset.vision.ToPIL

差异对比

torchvision.transforms.ToTensor

mindspore.dataset.vision.ToTensor

差异对比

torchvision.ops.deform_conv2d

mindspore.ops.deformable_conv2d

差异对比