torch 接口支持列表

通用约束

  • 暂不支持layout, device, requires_grad, memory_format参数的配置功能。

  • Generator相关功能正在开发。

  • 不支持七维及以上的计算。

  • 复数和bfloat16类型的支持正在完善。

  • Ascend上对float64类型的输入支持受限,部分接口无法处理float64类型入参,需转换为float32或float16类型之后输入。

  • Ascend上目前不支持输入为nan和inf的场景,如果输入包含nan或inf值,计算结果可能存在错误。

  • Tensor与numpy对象不共享内存,可能会导致一些支持Tensor类型作为输入的接口,不能天然地兼容以numpy格式作为输入。

  • 在Ascend和GPU上,部分数据类型(如int16和int32)在溢出的场景下,不同框架处理的结果存在差异。因此请谨慎处理临界值的赋值和转换,以免获得预期之外的结果。

  • 优化器相关通用约束请参见优化器统一约束lr_scheduler统一约束

  • Storage相关接口并未实现存储区控制功能,通用约束请参见Storage统一约束

  • Hook相关功能(如nn.Module.register_forward_hook, nn.utils.weight_norm, LazyLinear等)仅限在PyNative模式(默认模式)下使用。

  • 下表中存在”功能存在限制“标注的接口,请查看接口约束列表,获取详细信息。

  • view/squeeze/transpose等涉及返回视图张量的接口在静态图模式下输出张量不与输入张量共享内存,在动态图模式下输出张量与输入张量共享内存,但暂不支持原地修改张量内容。

torch

MindTorch接口 状态 约束
torch.is_tensor 支持
torch.is_floating_point 支持
torch.arange 支持
torch.cat 支持
torch.tensor 支持
torch.as_tensor 支持
torch.from_numpy 支持
torch.frombuffer 部分支持 功能存在限制
torch.permute 支持
torch.bitwise_left_shift 支持
torch.bitwise_right_shift 支持
torch.nan_to_num 支持
torch.range 支持
torch.linspace 支持
torch.logspace 部分支持 功能存在限制
torch.eye 支持
torch.empty 支持
torch.empty_like 支持
torch.eig 部分支持 暂不支持GPU后端
torch.full 支持
torch.full_like 支持
torch.polar 支持
torch.concat 支持
torch.column_stack 支持
torch.gather 支持
torch.is_complex 支持
torch.hstack 支持
torch.index_select 支持
torch.masked_select 支持
torch.movedim 支持
torch.moveaxis 支持
torch.narrow 支持
torch.nonzero 支持
torch.numel 支持
torch.reshape 支持
torch.row_stack 支持
torch.select 支持
torch.zeros 支持
torch.squeeze 支持
torch.stack 支持
torch.swapaxes 支持
torch.swapdims 支持
torch.zeros_like 支持
torch.take 支持
torch.ones 支持
torch.tile 支持
torch.transpose 支持
torch.unbind 支持
torch.unsqueeze 支持
torch.ones_like 支持
torch.vstack 支持
torch.heaviside 支持
torch.seed 支持
torch.initial_seed 支持
torch.rand 支持
torch.randn 支持
torch.abs 支持
torch.absolute 支持
torch.acos 支持
torch.adjoint 支持
torch.acosh 支持
torch.arccosh 支持
torch.add 部分支持 功能存在限制
torch.addcdiv 支持
torch.addcmul 支持
torch.dsplit 支持
torch.asin 支持
torch.arcsin 支持
torch.asinh 支持
torch.arcsinh 支持
torch.atan 支持
torch.arctan 支持
torch.atanh 支持
torch.arctanh 支持
torch.atan2 支持
torch.arctan2 支持
torch.bitwise_not 支持
torch.bitwise_and 支持
torch.bitwise_or 支持
torch.bitwise_xor 支持
torch.hsplit 支持
torch.split 支持
torch.ceil 支持
torch.t 支持
torch.tensor_split 支持
torch.conj_physical 支持
torch.copysign 支持
torch.cos 支持
torch.cosh 支持
torch.deg2rad 支持
torch.device 支持
torch.div 支持
torch.divide 支持
torch.erf 支持
torch.erfc 支持
torch.erfinv 支持
torch.exp 支持
torch.exp2 支持
torch.expm1 支持
torch.fix 支持
torch.vsplit 支持
torch.floor 支持
torch.floor_divide 支持
torch.where 支持
torch.frac 支持
torch.frexp 支持
torch.finfo 支持
torch.iinfo 支持
torch.ldexp 支持
torch.lerp 支持
torch.arccos 支持
torch.log 支持
torch.angle 支持
torch.log1p 支持
torch.clamp 支持
torch.logaddexp 支持
torch.logaddexp2 支持
torch.logical_not 支持
torch.logical_or 支持
torch.logit 支持
torch.clip 支持
torch.float_power 部分支持 输入参数有限制
torch.igammac 支持
torch.mul 部分支持 功能存在限制
torch.fmod 支持
torch.lgamma 部分支持 输入参数有限制
torch.neg 支持
torch.log10 支持
torch.nextafter 部分支持 输入参数有限制
torch.positive 支持
torch.pow 支持
torch.rad2deg 支持
torch.log2 支持
torch.hypot 支持
torch.remainder 支持
torch.round 支持
torch.sigmoid 支持
torch.multiply 支持
torch.negative 支持
torch.sin 支持
torch.reciprocal 支持
torch.sinh 支持
torch.sqrt 支持
torch.roll 支持
torch.rot90 支持
torch.square 支持
torch.sub 支持
torch.rsqrt 支持
torch.tan 支持
torch.tanh 支持
torch.sign 支持
torch.trunc 支持
torch.xlogy 部分支持 功能存在限制
torch.amax 支持
torch.amin 支持
torch.aminmax 支持
torch.all 支持
torch.any 支持
torch.min 支持
torch.dist 支持
torch.logsumexp 支持
torch.nanmean 支持
torch.nansum 支持
torch.prod 支持
torch.qr 支持
torch.std 支持
torch.sgn 部分支持 功能存在限制
torch.unique_consecutive 支持
torch.var 支持
torch.count_nonzero 支持
torch.allclose 支持
torch.signbit 支持
torch.eq 支持
torch.equal 支持
torch.ge 支持
torch.greater_equal 支持
torch.gt 支持
torch.greater 支持
torch.isclose 部分支持 功能存在限制
torch.isfinite 支持
torch.isin 支持
torch.isinf 支持
torch.isposinf 支持
torch.isneginf 支持
torch.isnan 支持
torch.isreal 支持
torch.is_nonzero 支持
torch.le 支持
torch.less_equal 支持
torch.lt 支持
torch.less 支持
torch.lu 部分支持 功能存在限制
torch.lu_solve 支持
torch.lu_unpack 部分支持 暂不支持Ascend后端
torch.maximum 支持
torch.minimum 支持
torch.ne 支持
torch.sinc 支持
torch.subtract 支持
torch.topk 支持
torch.true_divide 支持
torch.atleast_1d 支持
torch.atleast_2d 支持
torch.atleast_3d 支持
torch.block_diag 支持
torch.broadcast_to 支持
torch.cdist 支持
torch.corrcoef 部分支持 功能存在限制
torch.cov 支持
torch.cummin 支持
torch.cumprod 支持
torch.cumsum 支持
torch.diag 支持
torch.diagflat 支持
torch.diagonal 支持
torch.diff 部分支持 功能存在限制
torch.flatten 支持
torch.flip 支持
torch.flipud 支持
torch.histc 支持
torch.meshgrid 支持
torch.ravel 支持
torch.not_equal 支持
torch.trace 支持
torch.tril 支持
torch.triu 支持
torch.sort 部分支持 功能存在限制
torch.msort 支持
torch.addmv 支持
torch.addr 支持
torch.bincount 支持
torch.bmm 支持
torch.cholesky 支持
torch.cholesky_inverse 部分支持 暂不支持GPU后端
torch.cholesky_solve 支持
torch.dot 支持
torch.repeat_interleave 部分支持 功能存在限制
torch.addbmm 支持
torch.det 支持
torch.addmm 支持
torch.matmul 支持
torch.mv 支持
torch.orgqr 支持
torch.outer 支持
torch.vdot 支持
torch._assert 支持
torch.inner 支持
torch.logdet 支持
torch.lstsq 部分支持 功能存在限制
torch.mm 支持
torch.ByteTensor 支持
torch.CharTensor 支持
torch.IntTensor 支持
torch.HalfTensor 支持
torch.FloatTensor 支持
torch.DoubleTensor 支持
torch.ShortTensor 支持
torch.LongTensor 支持
torch.BoolTensor 支持
torch.as_strided 支持
torch.view_as_real 支持
torch.scatter 部分支持 功能存在限制
torch.manual_seed 支持
torch.matrix_exp 不支持
torch.bernoulli 部分支持 功能存在限制
torch.multinomial 部分支持 功能存在限制
torch.randint 部分支持 功能存在限制
torch.randperm 部分支持 功能存在限制
torch.digamma 部分支持 输入参数有限制
torch.fft 部分支持 功能存在限制
torch.gradient 部分支持 功能存在限制
torch.imag 部分支持 功能存在限制
torch.logical_and 支持
torch.logical_xor 支持
torch.igamma 支持
torch.mvlgamma 支持
torch.i0 部分支持 功能存在限制
torch.real 支持
torch.argmax 支持
torch.argmin 支持
torch.max 部分支持 功能存在限制
torch.mean 支持
torch.median 支持
torch.norm 部分支持 功能存在限制
torch.normal 部分支持 功能存在限制
torch.unique 部分支持 功能存在限制
torch.bartlett_window 支持
torch.sum 支持
torch.hann_window 支持
torch.argsort 部分支持 功能存在限制
torch.cross 部分支持 暂不支持GPU后端
torch.cummax 部分支持 暂不支持Ascend后端
torch.einsum 部分支持 只支持GPU后端
torch.fliplr 支持
torch.hamming_window 支持
torch.svd 部分支持 功能存在限制
torch.searchsorted 支持
torch.fmax 部分支持 功能存在限制
torch.fmin 部分支持 功能存在限制
torch.inverse 部分支持 暂不支持Ascend后端
torch.poisson 部分支持 功能存在限制
torch.polygamma 部分支持 功能存在限制
torch.matrix_power 部分支持 功能存在限制
torch.vander 支持
torch.renorm 支持
torch.is_conj 部分支持 暂不支持图模式
torch.resolve_conj 部分支持 暂不支持图模式
torch.index_add 部分支持 功能存在限制
torch.scatter_reduce 部分支持 功能存在限制
torch.scatter_add 部分支持 功能存在限制
torch.index_copy 部分支持 功能存在限制
torch.histogramdd 支持
torch.diag_embed 支持
torch.resolve_neg 部分支持 暂不支持图模式
torch.pinverse 部分支持 暂不支持Ascend后端
torch.asarray 部分支持 功能存在限制
torch.symeig 部分支持 功能存在限制
torch.result_type 支持
torch.logcumsumexp 支持
torch.complex 部分支持 功能存在限制
torch.blackman_window 支持
torch.kaiser_window 支持
torch.bucketize 支持
torch.cartesian_prod 支持
torch.clone 支持
torch.combinations 支持
torch.kron 部分支持 功能存在限制
torch.gcd 支持
torch.histogram 支持
torch.lcm 支持
torch.tensordot 部分支持 功能存在限制
torch.tril_indices 支持
torch.triu_indices 支持
torch.geqrf 部分支持 功能存在限制
torch.trapz 支持
torch.trapezoid 支持
torch.kthvalue 支持
torch.slice_scatter 支持
torch.select_scatter 支持
torch.take_along_dim 支持
torch.broadcast_shapes 支持
torch.broadcast_tensors 支持
torch.index_reduce 部分支持 功能存在限制
torch.chain_matmul 支持
torch.view_as_complex 支持
torch.empty_strided 支持
torch.cumulative_trapezoid 支持
torch.can_cast 支持
torch.diagonal_scatter 支持
torch.no_grad 部分支持 不支持图模式
torch.nanmedian 部分支持 暂不支持Ascend和GPU后端
torch.promote_types 支持
torch.ormqr 部分支持 暂不支持Ascend和CPU后端
torch.matrix_rank 部分支持 功能存在限制
torch.enable_grad 部分支持 不支持图模式
torch.set_grad_enable 部分支持 不支持图模式
torch.is_grad_enable 部分支持 不支持图模式
torch.inference_mode 部分支持 功能存在限制
torch.triangular_solve 部分支持 暂不支持Ascend后端
torch.save 部分支持 暂不支持保存模型结构
torch.load 部分支持 暂不支持加载模型结构
torch.std_mean 支持
torch.is_storage 支持
torch.set_default_dtype 部分支持 不支持图模式
torch.get_default_dtype 支持
torch.set_default_tensor_type 部分支持 不支持图模式
torch.BFloat16Tensor 支持
torch.var_mean 部分支持 不支持图模式
torch.slogdet 支持
torch.ger 支持
torch.baddbmm 支持
torch.set_deterministic_debug_mode 部分支持 功能存在限制
torch.are_deterministic_algorithms_enabled 支持
torch.is_deterministic_algorithms_warn_only_enabled 部分支持 机制差异,结果恒为False
torch.get_deterministic_debug_mode 支持
torch.randn_like 支持
torch.randint_like 支持
torch.rand_like 支持
torch.is_inference_mode_enabled 部分支持 功能存在限制
torch.dstack 支持
torch.conj 支持
torch.chunk 支持
torch.argwhere 支持
torch._assert 支持
torch.set_grad_enabled 部分支持 不支持图模式
torch.set_default_device 部分支持 设置设备暂不生效
torch.get_num_thread 部分支持 不支持图模式
torch.set_num_threads 部分支持 功能存在限制
torch.get_num_interop_threads 部分支持 不支持图模式
torch.set_num_interop_threads 部分支持 功能存在限制

Tensor

MindTorch接口 状态 约束
Tensor.mm 支持
Tensor.msort 支持
Tensor.abs 支持
Tensor.absolute 支持
Tensor.acos 支持
Tensor.acosh 支持
Tensor.new 支持
Tensor.new_tensor 支持
Tensor.new_full 部分支持 功能存在限制
Tensor.new_empty 支持
Tensor.new_ones 支持
Tensor.new_zeros 部分支持 功能存在限制
Tensor.is_cuda 支持
Tensor.ndim 支持
Tensor.add 部分支持 功能存在限制
Tensor.addbmm 支持
Tensor.addcdiv 支持
Tensor.addcmul 支持
Tensor.addmm 支持
Tensor.addmv 支持
Tensor.addr 支持
Tensor.all 支持
Tensor.allclose 支持
Tensor.amax 支持
Tensor.amin 支持
Tensor.aminmax 支持
Tensor.any 支持
Tensor.arccos 支持
Tensor.arccosh 支持
Tensor.arcsin 支持
Tensor.arcsinh 支持
Tensor.arctan 支持
Tensor.arctan2 支持
Tensor.arctanh 支持
Tensor.asin 支持
Tensor.asinh 支持
Tensor.atan 支持
Tensor.atan2 支持
Tensor.atanh 支持
Tensor.baddbmm 支持
Tensor.bincount 支持
Tensor.bitwise_and 支持
Tensor.bitwise_left_shift 支持
Tensor.bitwise_not 支持
Tensor.bitwise_or 支持
Tensor.bitwise_right_shift 支持
Tensor.bitwise_xor 支持
Tensor.bmm 支持
Tensor.bool 部分支持 功能存在限制
Tensor.broadcast_to 支持
Tensor.byte 部分支持 功能存在限制
Tensor.ceil 支持
Tensor.char 部分支持 功能存在限制
Tensor.cholesky 支持
Tensor.cholesky_inverse 部分支持 暂不支持GPU后端
Tensor.cholesky_solve 支持
Tensor.clamp 支持
Tensor.clip 支持
Tensor.clone 支持
Tensor.conj 支持
Tensor.copysign 支持
Tensor.cos 支持
Tensor.cosh 支持
Tensor.count_nonzero 支持
Tensor.cpu 支持
Tensor.cummax 部分支持 暂不支持Ascend后端
Tensor.cummin 支持
Tensor.cumprod 支持
Tensor.cumsum 支持
Tensor.data 支持
Tensor.deg2rad 支持
Tensor.diag 支持
Tensor.diagflat 支持
Tensor.diagonal 支持
Tensor.diff 部分支持 功能存在限制
Tensor.dim 支持
Tensor.dist 支持
Tensor.divide 支持
Tensor.dot 支持
Tensor.double 部分支持 功能存在限制
Tensor.dsplit 支持
Tensor.eig 部分支持 暂不支持GPU后端
Tensor.eq 支持
Tensor.equal 支持
Tensor.erf 支持
Tensor.erfc 支持
Tensor.erfinv 支持
Tensor.exp 支持
Tensor.expand_as 支持
Tensor.expm1 支持
Tensor.fix 支持
Tensor.flatten 支持
Tensor.flip 支持
Tensor.flipud 支持
Tensor.float_power 支持
Tensor.floor 支持
Tensor.fmod 支持
Tensor.gather 支持
Tensor.ge 支持
Tensor.ger 支持
Tensor.greater 支持
Tensor.greater_equal 支持
Tensor.gt 支持
Tensor.half 部分支持 功能存在限制
Tensor.hardshrink 支持
Tensor.heaviside 支持
Tensor.hsplit 支持
Tensor.hypot 支持
Tensor.index_select 支持
Tensor.int 部分支持 功能存在限制
Tensor.is_complex 支持
Tensor.isclose 部分支持 功能存在限制
Tensor.isfinite 支持
Tensor.isinf 支持
Tensor.isnan 支持
Tensor.isneginf 支持
Tensor.isposinf 支持
Tensor.isreal 支持
Tensor.item 支持
Tensor.le 支持
Tensor.less 支持
Tensor.less_equal 支持
Tensor.log 支持
Tensor.log10 支持
Tensor.log1p 支持
Tensor.log2 支持
Tensor.logaddexp 支持
Tensor.logdet 支持
Tensor.logical_not 支持
Tensor.logical_or 支持
Tensor.logical_xor 支持
Tensor.logsumexp 支持
Tensor.long 部分支持 功能存在限制
Tensor.lt 支持
Tensor.lu 部分支持 功能存在限制
Tensor.lu_solve 支持
Tensor.lstsq 部分支持 功能存在限制
Tensor.masked_fill 支持
Tensor.matmul 支持
Tensor.max 支持
Tensor.maximum 支持
Tensor.mean 支持
Tensor.min 支持
Tensor.fmax 部分支持 功能存在限制
Tensor.fmin 部分支持 功能存在限制
Tensor.histc 支持
Tensor.minimum 支持
Tensor.moveaxis 支持
Tensor.movedim 支持
Tensor.mul 部分支持 功能存在限制
Tensor.multiply 支持
Tensor.mvlgamma 支持
Tensor.nanmean 支持
Tensor.nansum 支持
Tensor.narrow 支持
Tensor.narrow_copy 支持
Tensor.ndimension 支持
Tensor.ne 支持
Tensor.neg 部分支持 功能存在限制
Tensor.negative 支持
Tensor.nonzero 支持
Tensor.not_equal 支持
Tensor.numel 支持
Tensor.numpy 支持
Tensor.orgqr 支持
Tensor.permute 支持
Tensor.pow 支持
Tensor.prod 支持
Tensor.qr 支持
Tensor.rad2deg 支持
Tensor.ravel 支持
Tensor.random_ 支持
Tensor.reciprocal 支持
Tensor.remainder 支持
Tensor.renorm 支持
Tensor.repeat 支持
Tensor.repeat_interleave 部分支持 功能存在限制
Tensor.reshape 支持
Tensor.reshape_as 支持
Tensor.resize_as_ 部分支持 暂不支持图模式
Tensor.round 支持
Tensor.roll 支持
Tensor.rot90 支持
Tensor.rsqrt_ 部分支持 暂不支持图模式
Tensor.rsqrt 支持
Tensor.select 支持
Tensor.short 部分支持 功能存在限制
Tensor.sigmoid 支持
Tensor.sign 支持
Tensor.signbit 支持
Tensor.sin 支持
Tensor.sinc 支持
Tensor.sinh 支持
Tensor.size 支持
Tensor.sort 支持
Tensor.split 支持
Tensor.sqrt 支持
Tensor.square 支持
Tensor.squeeze 支持
Tensor.stride 支持
Tensor.sub 支持
Tensor.subtract 支持
Tensor.sum 支持
Tensor.swapaxes 支持
Tensor.swapdims 支持
Tensor.T 支持
Tensor.t 支持
Tensor.t_ 部分支持 暂不支持图模式
Tensor.H 支持
Tensor.take 支持
Tensor.tan 支持
Tensor.tanh 支持
Tensor.tensor_split 支持
Tensor.tile 支持
Tensor.tolist 支持
Tensor.topk 支持
Tensor.trace 支持
Tensor.transpose 支持
Tensor.tril 支持
Tensor.tril_ 部分支持 暂不支持图模式
Tensor.triu 支持
Tensor.triu_ 部分支持 暂不支持图模式
Tensor.true_divide 支持
Tensor.true_divide_ 部分支持 暂不支持图模式
Tensor.trunc 支持
Tensor.type 支持
Tensor.type_as 支持
Tensor.unbind 支持
Tensor.uniform_ 部分支持 暂不支持图模式
Tensor.unique_consecutive 支持
Tensor.unsqueeze 支持
Tensor.var 支持
Tensor.vdot 支持
Tensor.view_as 支持
Tensor.vsplit 支持
Tensor.xlogy_ 部分支持 暂不支持图模式
Tensor.argmin 支持
Tensor.argsort 支持
Tensor.as_strided 支持
Tensor.bernoulli 部分支持 功能存在限制
Tensor.bernoulli_ 部分支持 功能存在限制
Tensor.cauchy_ 部分支持 暂不支持图模式,暂不支持GPU后端
Tensor.chunk 支持
Tensor.contiguous 部分支持 暂不支持图模式
Tensor.cross 部分支持 暂不支持GPU后端
Tensor.cuda 部分支持 输入参数有限制
Tensor.det 支持
Tensor.digamma 部分支持 输入参数有限制
Tensor.div 支持
Tensor.expand 部分支持 功能存在限制
Tensor.fliplr 部分支持 暂不支持Ascend后端
Tensor.float 部分支持 功能存在限制
Tensor.index_fill 支持
Tensor.inverse 部分支持 暂不支持Ascend后端
Tensor.is_floating_point 支持
Tensor.norm 部分支持 功能存在限制
Tensor.real 支持
Tensor.scatter_ 部分支持 暂不支持图模式
Tensor.scatter 部分支持 功能存在限制
Tensor.std 部分支持 功能存在限制
Tensor.svd 部分支持 功能存在限制
Tensor.to 部分支持 功能存在限制
Tensor.unique 部分支持 功能存在限制
Tensor.view 支持
Tensor.where 支持
Tensor.xlogy 部分支持 功能存在限制
Tensor.abs_ 部分支持 暂不支持图模式
Tensor.absolute_ 部分支持 暂不支持图模式
Tensor.acos_ 部分支持 暂不支持图模式
Tensor.arccos_ 部分支持 暂不支持图模式
Tensor.add_ 部分支持 暂不支持图模式
Tensor.addbmm_ 部分支持 暂不支持图模式
Tensor.addcdiv_ 部分支持 暂不支持图模式
Tensor.addcmul_ 部分支持 暂不支持图模式
Tensor.addmm_ 部分支持 暂不支持图模式
Tensor.addmv_ 部分支持 暂不支持图模式
Tensor.addr_ 部分支持 暂不支持图模式
Tensor.asin_ 部分支持 暂不支持图模式
Tensor.arcsin_ 部分支持 暂不支持图模式
Tensor.atan_ 部分支持 暂不支持图模式
Tensor.arctan_ 部分支持 暂不支持图模式
Tensor.atan2_ 部分支持 暂不支持图模式
Tensor.arctan2_ 部分支持 暂不支持图模式
Tensor.baddbmm_ 部分支持 暂不支持图模式
Tensor.bitwise_not_ 部分支持 暂不支持图模式
Tensor.bitwise_and_ 部分支持 暂不支持图模式
Tensor.bitwise_or_ 部分支持 暂不支持图模式
Tensor.bitwise_xor_ 部分支持 暂不支持图模式
Tensor.clamp_ 部分支持 暂不支持图模式
Tensor.clip_ 部分支持 暂不支持图模式
Tensor.copy_ 部分支持 暂不支持图模式
Tensor.copysign_ 部分支持 暂不支持图模式
Tensor.acosh_ 部分支持 暂不支持图模式
Tensor.arccosh_ 部分支持 暂不支持图模式
Tensor.cumprod_ 部分支持 暂不支持图模式
Tensor.div_ 部分支持 暂不支持图模式
Tensor.divide_ 部分支持 暂不支持图模式
Tensor.eq_ 部分支持 暂不支持图模式
Tensor.expm1_ 部分支持 暂不支持图模式
Tensor.fix_ 部分支持 暂不支持图模式
Tensor.fill_ 部分支持 暂不支持图模式
Tensor.float_power_ 部分支持 暂不支持图模式
Tensor.floor_ 部分支持 暂不支持图模式
Tensor.fmod_ 部分支持 暂不支持图模式
Tensor.ge_ 部分支持 暂不支持图模式
Tensor.greater_equal_ 部分支持 暂不支持图模式
Tensor.gt_ 部分支持 暂不支持图模式
Tensor.greater_ 部分支持 暂不支持图模式
Tensor.hypot_ 部分支持 暂不支持图模式
Tensor.le_ 部分支持 暂不支持图模式
Tensor.less_equal_ 部分支持 暂不支持图模式
Tensor.lgamma_ 部分支持 暂不支持图模式
Tensor.logical_xor_ 部分支持 暂不支持图模式
Tensor.lt_ 部分支持 暂不支持图模式
Tensor.less_ 部分支持 暂不支持图模式
Tensor.mul_ 部分支持 暂不支持图模式
Tensor.multiply_ 部分支持 暂不支持图模式
Tensor.mvlgamma_ 部分支持 暂不支持图模式
Tensor.ne_ 部分支持 暂不支持图模式
Tensor.not_equal_ 部分支持 暂不支持图模式
Tensor.neg_ 部分支持 暂不支持图模式
Tensor.negative_ 部分支持 暂不支持图模式
Tensor.pow_ 部分支持 暂不支持图模式
Tensor.reciprocal_ 部分支持 暂不支持图模式
Tensor.renorm_ 部分支持 暂不支持图模式
Tensor.resize_ 部分支持 暂不支持图模式
Tensor.round_ 部分支持 暂不支持图模式
Tensor.sigmoid_ 部分支持 暂不支持图模式
Tensor.sign_ 部分支持 暂不支持图模式
Tensor.sin_ 部分支持 暂不支持图模式
Tensor.sinc_ 部分支持 暂不支持图模式
Tensor.sinh_ 部分支持 暂不支持图模式
Tensor.asinh_ 部分支持 暂不支持图模式
Tensor.square_ 部分支持 暂不支持图模式
Tensor.sqrt_ 部分支持 暂不支持图模式
Tensor.squeeze_ 部分支持 暂不支持图模式
Tensor.sub_ 部分支持 暂不支持图模式
Tensor.tan_ 部分支持 暂不支持图模式
Tensor.tanh_ 部分支持 暂不支持图模式
Tensor.atanh_ 部分支持 暂不支持图模式
Tensor.arctanh_ 部分支持 暂不支持图模式
Tensor.transpose_ 部分支持 暂不支持图模式
Tensor.trunc_ 部分支持 暂不支持图模式
Tensor.unsqueeze_ 部分支持 暂不支持图模式
Tensor.zero_ 部分支持 暂不支持图模式
Tensor.is_conj 部分支持 暂不支持图模式
Tensor.resolve_conj 部分支持 暂不支持图模式
Tensor.i0 部分支持 功能存在限制
Tensor.nextafter 部分支持 功能存在限制
Tensor.logit 支持
Tensor.matrix_power 部分支持 功能存在限制
Tensor.index_fill_ 部分支持 暂不支持图模式
Tensor.index_add 部分支持 功能存在限制
Tensor.index_add_ 部分支持 暂不支持图模式
Tensor.scatter_add 部分支持 功能存在限制
Tensor.scatter_add_ 部分支持 功能存在限制
Tensor.index_copy 支持
Tensor.index_copy_ 部分支持 暂不支持图模式
Tensor.diag_embed 支持
Tensor.resolve_neg 部分支持 暂不支持图模式
Tensor.i0_ 部分支持 暂不支持图模式
Tensor.logit_ 部分支持 暂不支持图模式
Tensor.pinverse 部分支持 暂不支持Ascend后端
Tensor.symeig 部分支持 功能存在限制
Tensor.put_ 部分支持 暂不支持图模式
Tensor.nan_to_num 支持
Tensor.nan_to_num_ 部分支持 暂不支持图模式
Tensor.unfold 支持
Tensor.logcumsumexp 支持
Tensor.nextafter_ 部分支持 输入参数有限制
Tensor.lgamma 部分支持 输入参数有限制
Tensor.log2_ 部分支持 暂不支持图模式
Tensor.logaddexp2 支持
Tensor.logical_and 支持
Tensor.logical_and_ 部分支持 暂不支持图模式
Tensor.logical_not_ 部分支持 暂不支持图模式
Tensor.logical_or_ 部分支持 暂不支持图模式
Tensor.igamma 支持
Tensor.igamma_ 部分支持 暂不支持图模式
Tensor.igammac 支持
Tensor.igammac_ 部分支持 暂不支持图模式
Tensor.positive 支持
Tensor.remainder_ 部分支持 暂不支持图模式
Tensor.sgn 部分支持 功能存在限制
Tensor.sgn_ 部分支持 暂不支持图模式
Tensor.subtract_ 部分支持 暂不支持图模式
Tensor.argmax 支持
Tensor.gcd 支持
Tensor.histogram 支持
Tensor.lcm 支持
Tensor.geqrf 部分支持 功能存在限制
Tensor.inner 支持
Tensor.kthvalue 支持
Tensor.adjoint 支持
Tensor.angle 支持
Tensor.argwhere 支持
Tensor.cov 支持
Tensor.element_size 支持
Tensor.is_signed 支持
Tensor.masked_select 支持
Tensor.median 支持
Tensor.mv 支持
Tensor.multinomial 支持
Tensor.nelement 支持
Tensor.outer 支持
Tensor.slice_scatter 支持
Tensor.select_scatter 支持
Tensor.slogdet 支持
Tensor.sum_to_size 支持
Tensor.take_along_dim 支持
Tensor.unflatten 支持
Tensor.conj_physical 支持
Tensor.conj_physical_ 部分支持 暂不支持图模式
Tensor.arcsinh_ 部分支持 暂不支持图模式
Tensor.bitwise_right_shift_ 部分支持 暂不支持图模式
Tensor.ceil_ 部分支持 暂不支持图模式
Tensor.cos_ 部分支持 暂不支持图模式
Tensor.cosh_ 部分支持 暂不支持图模式
Tensor.cumsum_ 部分支持 暂不支持图模式
Tensor.digamma_ 部分支持 暂不支持图模式
Tensor.erf_ 部分支持 暂不支持图模式
Tensor.erfc_ 部分支持 暂不支持图模式
Tensor.erfinv_ 部分支持 暂不支持图模式
Tensor.exp_ 部分支持 暂不支持图模式
Tensor.fill_diagonal_ 部分支持 暂不支持图模式
Tensor.floor_divide 支持
Tensor.floor_divide_ 部分支持 暂不支持图模式
Tensor.frac 支持
Tensor.frac_ 部分支持 暂不支持图模式
Tensor.gcd_ 部分支持 暂不支持图模式
Tensor.lcm_ 部分支持 暂不支持图模式
Tensor.imag 部分支持 功能存在限制
Tensor.ldexp 支持
Tensor.ldexp_ 部分支持 暂不支持图模式
Tensor.log_ 部分支持 暂不支持图模式
Tensor.log10_ 部分支持 暂不支持图模式
Tensor.log1p_ 部分支持 暂不支持图模式
Tensor.masked_fill_ 部分支持 暂不支持图模式
Tensor.normal_ 部分支持 暂不支持图模式
Tensor.scatter_reduce 部分支持 功能存在限制
Tensor.scatter_reduce_ 部分支持 功能存在限制
Tensor.exponential_ 部分支持 功能存在限制
Tensor.index_reduce 部分支持 功能存在限制
Tensor.index_reduce_ 部分支持 功能存在限制
Tensor.masked_scatter 部分支持 功能存在限制
Tensor.masked_scatter_ 部分支持 暂不支持图模式和GPU后端
Tensor.index_put 部分支持 功能存在限制
Tensor.index_put_ 部分支持 功能存在限制
Tensor.corrcoef 部分支持 功能存在限制
Tensor.geometric_ 部分支持 功能存在限制
Tensor.log_normal_ 部分支持 功能存在限制
Tensor.map_ 部分支持 暂不支持图模式
Tensor.diagonal_scatter 支持
Tensor.apply_ 部分支持 暂不支持图模式
Tensor.nanmedian 部分支持 暂不支持Ascend和GPU后端
Tensor.frexp 支持
Tensor.ormqr 部分支持 暂不支持Ascend和CPU后端
Tensor.triangular_solve 部分支持 暂不支持Ascend后端
Tensor.storage 部分支持 暂不支持图模式
Tensor.storage_type 部分支持 暂不支持图模式
Tensor.storage_offset 部分支持 暂不支持图模式
Tensor.cfloat 支持
Tensor.cdouble 支持
Tensor.is_contiguous 支持
Tensor.is_pinned 部分支持 机制差异,结果恒为False
Tensor.is_set_to 部分支持 暂不支持严格图模式
Tensor.is_shared 部分支持 机制差异,结果恒为False
Tensor.is_sparse 部分支持 机制差异,结果恒为False
Tensor.is_quantized 部分支持 机制差异,结果恒为False
Tensor.pin_memory 部分支持 机制差异,拷贝至锁页内存动作不生效
Tensor.bfloat16 部分支持 暂不支持Ascend和GPU后端
Tensor.cfloat 支持
Tensor.cdouble 支持
Tensor.polygamma 部分支持 暂不支持Ascend后端
Tensor.polygamma_ 部分支持 暂不支持Ascend后端,暂不支持图模式
Tensor.mT 支持
Tensor.mH 支持
Tensor.lerp 支持
Tensor.lerp_ 部分支持 暂不支持图模式
Tensor.data_ptr 部分支持 功能存在限制
Tensor.device 部分支持 功能存在限制
Tensor.get_device 部分支持 暂不支持图模式
Tensor.set_ 部分支持 功能存在限制
Tensor.requires_grad 部分支持 功能存在限制
Tensor.requires_grad_ 部分支持 功能存在限制
Tensor.backward 部分支持 功能存在限制
Tensor.detach 部分支持 功能存在限制
Tensor.detach_ 部分支持 功能存在限制
Tensor.retain_grad 部分支持 功能存在限制
Tensor.retains_grad 部分支持 功能存在限制
Tensor.grad 部分支持 功能存在限制
Tensor.is_leaf 部分支持 功能存在限制

Torch.nn

MindTorch接口 状态 约束
nn.ModuleDict 部分支持 暂不支持图模式
nn.Parameter 支持
nn.UninitializedParameter 部分支持 暂不支持图模式
nn.UninitializedBuffer 部分支持 暂不支持图模式
nn.ParameterList 部分支持 暂不支持图模式
nn.ParameterDict 部分支持 暂不支持图模式
nn.Unfold 支持
nn.Fold 支持
nn.MaxPool1d 支持
nn.MaxPool2d 支持
nn.MaxPool3d 支持
nn.AvgPool1d 支持
nn.AvgPool2d 支持
nn.AvgPool3d 支持
nn.FractionalMaxPool2d 支持
nn.FractionalMaxPool3d 支持
nn.LPPool1d 部分支持 功能存在限制
nn.LPPool2d 部分支持 功能存在限制
nn.AdaptiveMaxPool1d 部分支持 功能存在限制
nn.AdaptiveMaxPool2d 部分支持 功能存在限制
nn.AdaptiveMaxPool3d 支持
nn.AdaptiveAvgPool1d 支持
nn.AdaptiveAvgPool2d 支持
nn.AdaptiveAvgPool3d 支持
nn.ReflectionPad1d 支持
nn.ReflectionPad2d 支持
nn.ReflectionPad3d 部分支持 功能存在限制
nn.ReplicationPad1d 支持
nn.ReplicationPad2d 支持
nn.ReplicationPad3d 支持
nn.ZeroPad2d 支持
nn.ConstantPad1d 支持
nn.ConstantPad2d 支持
nn.ConstantPad3d 支持
nn.ELU 部分支持 功能存在限制
nn.Hardshrink 部分支持 功能存在限制
nn.Hardsigmoid 支持
nn.Hardtanh 部分支持 功能存在限制
nn.Hardswish 部分支持 功能存在限制
nn.LeakyReLU 部分支持 功能存在限制
nn.LogSigmoid 支持
nn.PReLU 部分支持 功能存在限制
nn.ReLU 支持
nn.ReLU6 部分支持 功能存在限制
nn.RReLU 部分支持 inplace不支持图模式
nn.SELU 部分支持 inplace不支持图模式
nn.CELU 部分支持 inplace不支持图模式
nn.GELU 支持
nn.Sigmoid 支持
nn.SiLU 支持
nn.Mish 部分支持 功能存在限制
nn.Softplus 支持
nn.Softshrink 部分支持 功能存在限制
nn.Softsign 支持
nn.Tanh 支持
nn.Tanhshrink 支持
nn.Threshold 部分支持 inplace不支持图模式
nn.GLU 支持
nn.Softmin 支持
nn.Softmax 支持
nn.Softmax2d 支持
nn.LogSoftmax 部分支持 功能存在限制
nn.BatchNorm1d 支持
nn.BatchNorm2d 支持
nn.BatchNorm3d 支持
nn.GroupNorm 支持
nn.LayerNorm 支持
nn.LocalResponseNorm 支持
nn.RNNBase 支持
nn.RNN 部分支持 功能存在限制
nn.RNNCell 支持
nn.LSTMCell 支持
nn.GRUCell 支持
nn.Identity 支持
nn.Linear 部分支持 功能存在限制
nn.Bilinear 支持
nn.Dropout 部分支持 inplace不支持图模式
nn.Dropout1d 部分支持 inplace不支持图模式
nn.Dropout2d 部分支持 inplace不支持图模式
nn.Dropout3d 部分支持 inplace不支持图模式
nn.AlphaDropout 部分支持 inplace不支持图模式
nn.FeatureAlphaDropout 部分支持 inplace不支持图模式
nn.CosineSimilarity 支持
nn.PairwiseDistance 支持
nn.L1Loss 支持
nn.MSELoss 支持
nn.CrossEntropyLoss 部分支持 功能存在限制
nn.CTCLoss 支持
nn.NLLLoss 支持
nn.PoissonNLLLoss 支持
nn.GaussianNLLLoss 支持
nn.BCELoss 支持
nn.BCEWithLogitsLoss 支持
nn.MarginRankingLoss 支持
nn.HingeEmbeddingLoss 支持
nn.HuberLoss 支持
nn.SmoothL1Loss 支持
nn.SoftMarginLoss 部分支持 暂不支持CPU后端
nn.MultiLabelSoftMarginLoss 支持
nn.CosineEmbeddingLoss 支持
nn.TripletMarginWithDistanceLoss 支持
nn.PixelShuffle 支持
nn.PixelUnshuffle 支持
nn.Upsample 部分支持 功能存在限制
nn.UpsamplingNearest2d 部分支持 功能存在限制
nn.UpsamplingBilinear2d 支持
nn.ChannelShuffle 支持
nn.Flatten 支持
nn.Unflatten 支持
nn.Module 部分支持 功能存在限制
nn.Sequential 支持
nn.ModuleList 部分支持 功能存在限制
nn.Conv1d 部分支持 功能存在限制
nn.Conv2d 部分支持 功能存在限制
nn.Conv3d 部分支持 功能存在限制
nn.ConvTranspose1d 部分支持 功能存在限制
nn.ConvTranspose2d 部分支持 功能存在限制
nn.ConvTranspose3d 支持
nn.MaxUnpool1d 支持
nn.MaxUnpool2d 支持
nn.MaxUnpool3d 支持
nn.MultiheadAttention 部分支持 功能存在限制
nn.AdaptiveLogSoftmaxWithLoss 部分支持 暂不支持图模式
nn.SyncBatchNorm 部分支持 仅支持Ascend后端
nn.InstanceNorm1d 部分支持 仅支持GPU后端
nn.InstanceNorm2d 部分支持 仅支持GPU后端
nn.InstanceNorm3d 部分支持 仅支持GPU后端
nn.LSTM 部分支持 功能存在限制
nn.GRU 部分支持 功能存在限制
nn.Embedding 部分支持 功能存在限制
nn.KLDivLoss 支持
nn.MultiLabelMarginLoss 部分支持 暂不支持CPU后端
nn.MultiMarginLoss 支持
nn.TripletMarginLoss 支持
nn.Transformer 部分支持 功能存在限制
nn.TransformerEncoder 部分支持 功能存在限制
nn.TransformerDecoder 部分支持 功能存在限制
nn.TransformerEncoderLayer 部分支持 功能存在限制
nn.TransformerDecoderLayer 部分支持 功能存在限制
nn.LazyConv1d 支持
nn.LazyConv2d 支持
nn.LazyConv3d 支持
nn.LazyConvTranspose1d 支持
nn.LazyConvTranspose2d 支持
nn.LazyConvTranspose3d 支持
nn.LazyBatchNorm1d 支持
nn.LazyBatchNorm2d 支持
nn.LazyBatchNorm3d 支持
nn.LazyInstanceNorm1d 支持
nn.LazyInstanceNorm2d 支持
nn.LazyInstanceNorm3d 支持
nn.LazyLinear 支持
nn.modules.lazy.LazyModuleMixin 支持
nn.utils.rnn.pad_sequence 支持
nn.utils.rnn.pack_padded_sequence 支持
nn.utils.rnn.PackedSequence 支持
nn.utils.rnn.pad_packed_sequence 支持
nn.utils.rnn.pack_sequence 支持
nn.parallel.DistributedDataParallel 部分支持 功能存在限制
nn.utils.clip_grad_norm_ 部分支持 功能存在限制
nn.utils.clip_grad_value_ 部分支持 功能存在限制
nn.utils.parameters_to_vector 支持
nn.utils.vector_to_parameters 部分支持 暂不支持图模式
nn.utils.weight_norm 支持
nn.utils.remove_weight_norm 支持
nn.utils.spectral_norm 支持
nn.utils.remove_spectral_norm 支持
nn.utils.skip_init 支持
nn.utils.parametrizations.orthogonal 部分支持 功能存在限制
nn.utils.parametrizations.spectral_norm 部分支持 暂不支持图模式
nn.utils.parametrize.register_parametrization 部分支持 暂不支持图模式
nn.utils.parametrize.remove_parametrizations 部分支持 暂不支持图模式
nn.utils.parametrize.cached 部分支持 暂不支持图模式
nn.utils.parametrize.is_parametrized 部分支持 暂不支持图模式
nn.utils.parametrize.ParametrizationList 部分支持 暂不支持图模式
nn.utils.stateless.functional_call 部分支持 暂不支持图模式
nn.quantized.FloatFunctional 支持
nn.quantized.FXFloatFunctional 支持
nn.Module.add_module 支持
nn.Module.apply 支持
nn.Module.bfloat16 部分支持 暂不支持Ascend和GPU后端
nn.Module.buffers 支持
nn.Module.children 支持
nn.Module.double 支持
nn.Module.eval 支持
nn.Module.extra_repr 支持
nn.Module.float 支持
nn.Module.get_parameter 支持
nn.Module.get_submodule 支持
nn.Module.half 支持
nn.Module.load_state_dict 支持
nn.Module.modules 支持
nn.Module.named_buffers 支持
nn.Module.named_children 支持
nn.Module.named_modules 支持
nn.Module.named_parameters 支持
nn.Module.register_buffer 支持
nn.Module.register_module 支持
nn.Module.requires_grad_ 支持
nn.Module.register_parameter 支持
nn.Module.state_dict 支持
nn.Module.to 部分支持 功能存在限制
nn.Module.to_empty 支持
nn.Module.train 支持
nn.Module.type 支持
nn.Module.zero_grad 支持
nn.Module.share_memory 部分支持 功能存在限制
nn.Module.cpu 支持
nn.Module.cuda 支持
nn.Module.forward 支持
nn.Module.get_buffer 支持
nn.Module.get_extra_state 支持
nn.Module.set_extra_state 支持
nn.Module.parameters 支持
nn.Module.register_load_state_dict_post_hook 支持
nn.Module.register_forward_pre_hook 支持
nn.Module.register_forward_hook 支持
nn.Module.register_backward_hook 部分支持 功能存在限制
nn.Module.register_full_backward_hook 部分支持 功能存在限制
nn.modules.module.register_module_forward_pre_hook 支持
nn.modules.module.register_module_forward_hook 支持
nn.modules.module.register_module_backward_hook 部分支持 功能存在限制
nn.modules.module.register_module_full_backward_hook 部分支持 功能存在限制

torch.nn.init

MindTorch接口 状态 约束
nn.init.calculate_gain 支持
nn.init.uniform_ 部分支持 暂不支持图模式
nn.init.normal_ 部分支持 暂不支持图模式
nn.init.constant_ 部分支持 暂不支持图模式
nn.init.ones_ 部分支持 暂不支持图模式
nn.init.zeros_ 部分支持 暂不支持图模式
nn.init.eye_ 部分支持 暂不支持图模式
nn.init.dirac_ 部分支持 暂不支持图模式
nn.init.xavier_uniform_ 部分支持 暂不支持图模式
nn.init.xavier_normal_ 部分支持 暂不支持图模式
nn.init.kaiming_uniform_ 部分支持 暂不支持图模式
nn.init.kaiming_normal_ 部分支持 暂不支持图模式
nn.init.trunc_normal_ 部分支持 暂不支持图模式
nn.init.orthogonal_ 部分支持 暂不支持图模式
nn.init.sparse_ 部分支持 暂不支持图模式

nn.functional

MindTorch接口 状态 约束
functional.max_pool2d 支持
functional.max_pool3d 支持
functional.conv_transpose2d 部分支持 功能存在限制
functional.conv_transpose3d 支持
functional.avg_pool2d 支持
functional.avg_pool3d 支持
functional.max_pool1d 支持
functional.max_unpool1d 支持
functional.max_unpool2d 支持
functional.max_unpool3d 支持
functional.lp_pool1d 部分支持 功能存在限制
functional.lp_pool2d 部分支持 功能存在限制
functional.adaptive_max_pool1d 部分支持 功能存在限制
functional.adaptive_max_pool2d 部分支持 功能存在限制
functional.adaptive_avg_pool1d 支持
functional.fractional_max_pool2d 支持
functional.fractional_max_pool3d 支持
functional.threshold 支持
functional.threshold_ 部分支持 暂不支持图模式
functional.relu 支持
functional.relu_ 部分支持 暂不支持图模式
functional.hardtanh 支持
functional.hardtanh_ 部分支持 暂不支持图模式
functional.hardswish 支持
functional.relu6 支持
functional.elu 支持
functional.elu_ 部分支持 暂不支持图模式
functional.selu 部分支持 功能存在限制
functional.celu 部分支持 功能存在限制
functional.leaky_relu 支持
functional.leaky_relu_ 部分支持 暂不支持图模式
functional.prelu 部分支持 功能存在限制
functional.rrelu 部分支持 功能存在限制
functional.rrelu_ 部分支持 暂不支持图模式
functional.glu 支持
functional.gelu 支持
functional.logsigmoid 支持
functional.hardshrink 支持
functional.tanhshrink 支持
functional.softsign 支持
functional.softplus 支持
functional.softmin 支持
functional.softmax 支持
functional.softshrink 部分支持 功能存在限制
functional.gumbel_softmax 支持
functional.log_softmax 部分支持 功能存在限制
functional.tanh 支持
functional.sigmoid 支持
functional.hardsigmoid 支持
functional.silu 支持
functional.mish 部分支持 功能存在限制
functional.batch_norm 部分支持 功能存在限制
functional.group_norm 支持
functional.instance_norm 部分支持 功能存在限制
functional.layer_norm 支持
functional.local_response_norm 支持
functional.normalize 支持
functional.linear 支持
functional.bilinear 支持
functional.dropout 支持
functional.alpha_dropout 部分支持 inplace不支持图模式
functional.feature_alpha_dropout 部分支持 inplace不支持图模式
functional.dropout1d 部分支持 inplace不支持图模式
functional.dropout2d 部分支持 inplace不支持图模式
functional.dropout3d 部分支持 inplace不支持图模式
functional.one_hot 支持
functional.pairwise_distance 支持
functional.cosine_similarity 支持
functional.pdist 支持
functional.binary_cross_entropy 支持
functional.binary_cross_entropy_with_logits 支持
functional.poisson_nll_loss 支持
functional.cosine_embedding_loss 支持
functional.cross_entropy 部分支持 功能存在限制
functional.gaussian_nll_loss 支持
functional.hinge_embedding_loss 支持
functional.l1_loss 支持
functional.mse_loss 支持
functional.margin_ranking_loss 支持
functional.multilabel_soft_margin_loss 支持
functional.nll_loss 支持
functional.smooth_l1_loss 支持
functional.soft_margin_loss 部分支持 暂不支持CPU后端
functional.triplet_margin_loss 支持
functional.triplet_margin_with_distance_loss 支持
functional.pixel_shuffle 支持
functional.pixel_unshuffle 支持
functional.grid_sample 部分支持 功能存在限制
functional.huber_loss 支持
functional.conv1d 部分支持 功能存在限制
functional.conv2d 部分支持 功能存在限制
functional.conv3d 部分支持 功能存在限制
functional.conv_transpose1d 部分支持 功能存在限制
functional.unfold 支持
functional.fold 支持
functional.adaptive_max_pool3d 支持
functional.adaptive_avg_pool2d 支持
functional.adaptive_avg_pool3d 支持
functional.embedding 部分支持 功能存在限制
functional.ctc_loss 部分支持 功能存在限制
functional.kl_div 支持
functional.multilabel_margin_loss 部分支持 暂不支持CPU后端
functional.multi_margin_loss 支持
functional.interpolate 部分支持 功能存在限制
functional.upsample 部分支持 功能存在限制
functional.upsample_nearest 支持
functional.upsample_bilinear 部分支持 功能存在限制
functional.affine_grid 支持
functional.avg_pool1d 支持
functional.scaled_dot_product_attention 支持
functional.pad 部分支持 1. 暂不支持图模式 2. 功能存在限制

torch.linalg

MindTorch接口 状态 约束
norm 部分支持 功能存在限制
vector_norm 部分支持 功能存在限制
matrix_norm 部分支持 功能存在限制
diagonal 部分支持 功能存在限制
det 支持
slogdet 支持
cond 部分支持 功能存在限制
matrix_rank 部分支持 功能存在限制
cholesky 部分支持 功能存在限制
lu 部分支持 功能存在限制
lu_factor 部分支持 功能存在限制
lu_factor_ex 部分支持 功能存在限制
lu_solve 部分支持 功能存在限制
eig 部分支持 暂不支持GPU后端
eigvals 部分支持 功能存在限制
eigh 部分支持 功能存在限制
eigvalsh 部分支持 功能存在限制
svd 部分支持 功能存在限制
svdvals 部分支持 功能存在限制
solve 部分支持 功能存在限制
solve_triangular 部分支持 功能存在限制
lstsq 部分支持 功能存在限制
inv 部分支持 功能存在限制
pinv 部分支持 暂不支持Ascend后端
qr 支持
matrix_exp 不支持
matrix_power 部分支持 功能存在限制
cross 部分支持 暂不支持GPU后端
matmul 支持
vecdot 不支持
multi_dot 支持
householder_product 支持
tensorinv 不支持
tensorsolve 不支持
vander 支持
cholesky_ex 部分支持 功能存在限制
inv_ex 部分支持 功能存在限制
solve_ex 不支持
lu_factor_ex 不支持
ldl_factor 不支持
ldl_factor_ex 不支持
ldl_solve 不支持

torch.optim

优化器限制与约束:

MindTorch优化器基于MindSpore.experimental.optim目录下的优化器封装,可满足大部分功能的对标。但由于MindSpore与PyTorch存在机制差异,会存在以下的限制和约束:

PyNative:

  1. param_groups中的学习率默认类型是MindSpore的Parameter,非number类型,与PyTorch不同。

  2. optimizer.state已定义,但未实际使用,所以该变量值为空值。状态保存在对应的ParameterTuple中(该行为从MindSpore优化器继承过来)。

  3. optimizer.step(),需要使用optimizer.step(grads)的方式将梯度从入参传入(微分机制不同,梯度不能存储在每个Parameter中,只能从外部传入)。grads可由MindSpore微分接口mindspore.grad或者mindspore.value_and_grad计算获得。

可能造成的影响:

  1. 修改、查看学习率需要转换类型。

  2. 查看state时,可能发现是空值。

  3. step函数新增入参,使用行为发生改变。

Graph:

  1. 只支持修改param_groups中的学习率。修改时,需要使用mindspore.ops.assign的方式进行修改。

  2. 编译step函数时,请使用mindspore.jit的方式,set_context(mindspore.GRAPH_MODE)的方式不生效。

自定义优化器:

  1. 暂不支持静态图模式。

  2. step函数需要扩展支持grads入参。

MSAdapter接口 状态 约束
Optimizer 支持
Adadelta 支持
Adagrad 支持
Adam 支持
AdamW 支持
SparseAdam 不支持
Adamax 支持
ASGD 支持
LBFGS 不支持
NAdam 支持
RAdam 支持
RMSprop 支持
Rprop 支持
SGD 支持

优化器性能正在持续优化,如果当前期望使用性能更高的优化器,可以尝试MindSpore存量的优化器,但用法和算法上可能有一定差异。

lr_scheduler的约束限制:

动态图模式:

  1. 需要搭配MindTorch的优化器或者继承optim.LRScheduler作为父类的自定义优化器。

  2. verbose参数暂不支持。

  3. base_lrs_last_lr为Parameter类型。

静态图模式:

  1. 需要使用mindspore.ops.assign的方式修改优化器的学习率。

自定义学习率调整器:

  1. 暂不支持静态图模式。

  2. 状态保存(state_dict)/恢复(load_state_dict),需要对base_lrs_last_lr进行类型转换。

MSAdapter接口 状态 约束
lr_scheduler.LRScheduler 支持
lr_scheduler._LRScheduler 支持
lr_scheduler.LambdaLR 支持 不支持verbose
lr_scheduler.MultiplicativeLR 支持 不支持verbose
lr_scheduler.StepLR 支持 不支持verbose
lr_scheduler.MultiStepLR 支持 不支持verbose
lr_scheduler.ConstantLR 支持 不支持verbose
lr_scheduler.LinearLR 支持 不支持verbose
lr_scheduler.ExponentialLR 支持 不支持verbose
lr_scheduler.PolynomialLR 支持 不支持verbose
lr_scheduler.CosineAnnealingLR 支持 不支持verbose
lr_scheduler.ChainedScheduler 不支持
lr_scheduler.SequentialLR 支持 不支持verbose
lr_scheduler.ReduceLROnPlateau 支持 不支持verbose
lr_scheduler.CyclicLR 支持 不支持verbose, cycle_momentum
lr_scheduler.OneCycleLR 支持 不支持verbose
lr_scheduler.CosineAnnealingWarmRestarts 支持 不支持verbose

torch.utils.data

MindTorch接口 状态 约束
DataLoader 支持 功能存在限制
Dataset 支持
IterableDataset 支持
TensorDataset 支持
ConcatDataset 支持
ChainDataset 支持
Subset 支持
default_collate 支持
default_convert 支持
get_worker_info 支持
random_split 支持 功能存在限制
Sampler 支持
SequentialSampler 支持
RandomSampler 支持 功能存在限制
SubsetRandomSampler 支持 功能存在限制
WeightedRandomSampler 支持 功能存在限制
BatchSampler 支持
distributed.DistributedSampler 支持

torch.utils.model_zoo

MindTorch接口 状态 约束
load_url 支持

torch.hub

MindTorch接口 状态 约束
download_url_to_file 支持
get_dir 支持
load_state_dict_from_url 支持
set_dir 支持
list 支持
help 支持
load 支持

torch.Storage

Storage统一约束:

  • 由于存储机制差异,无法支持share_memory_,pin_memory等涉及数据存储区控制的功能,暂不支持两个Tensor配置同一个Storage对象的相关场景,详见FAQ示例。

  • 当前基于Numpy实现,性能存在较大优化空间,不建议频繁调用。

  • Storage相关接口为实验性API,后续可能修改或删除。

MindTorch接口 状态 约束
torch.DoubleStorage 部分支持 暂不支持图模式
torch.FloatStorage 部分支持 暂不支持图模式
torch.HalfStorage 部分支持 暂不支持图模式
torch.LongStorage 部分支持 暂不支持图模式
torch.IntStorage 部分支持 暂不支持图模式
torch.ShortStorage 部分支持 暂不支持图模式
torch.CharStorage 部分支持 暂不支持图模式
torch.ByteStorage 部分支持 暂不支持图模式
torch.BoolStorage 部分支持 暂不支持图模式
torch.BFloat16Storage 部分支持 暂不支持图模式
torch.ComplexFloatStorage 部分支持 暂不支持图模式
torch.ComplexDoubleStorage 部分支持 暂不支持图模式

torch.autograd

MindTorch接口 状态 约束
torch.autograd.functional.vjp 部分支持 功能存在限制
torch.autograd.functional.jvp 部分支持 功能存在限制
torch.autograd.functional.jacobian 部分支持 功能存在限制

torch.fft

MindTorch接口 状态 约束
torch.fft.rfft Partly supported Function is constrained

torch.cuda

MindTorch接口 状态 约束
torch.cuda.is_available 支持
torch.cuda.amp.GradScalar 部分支持 功能存在限制
torch.cuda.ByteTensor 支持
torch.cuda.CharTensor 支持
torch.cuda.ShortTensor 支持
torch.cuda.IntTensor 支持
torch.cuda.LongTensor 支持
torch.cuda.BoolTensor 支持
torch.cuda.FloatTensor 支持
torch.cuda.DoubleTensor 支持
torch.cuda.BFloat16Tensor 支持
torch.cuda.HalfTensor 支持
torch.cuda.Event 部分支持 功能存在限制
torch.cuda.Stream 部分支持 功能存在限制
torch.cuda.current_stream 部分支持 功能存在限制
torch.cuda.default_stream 部分支持 功能存在限制
torch.cuda.synchronize 部分支持 功能存在限制
torch.cuda.is_initialized 支持
torch.cuda.is_available 支持
torch.cuda.empty_cache 不支持
torch.cuda.set_device 部分支持 设置设备暂不生效
torch.cuda.device_count 支持
torch.cuda.current_device 支持
torch.cuda.get_device_capability 部分支持 Ascend上返回固定的版本号
torch.cuda.get_deivce_properties 支持
torch.cuda.get_device_name 支持
torch.cuda.get_arch_list 部分支持 Ascend上不支持

torch.distributed

分布式接口总体支持情况如下:

  1. 仅支持动态图(PyNative)模式。

  2. 仅支持GPU/Ascend后端。

  3. 启动方式当前仅支持MindSpore原生的启动方式。

  4. 通信接口不支持异步通信(async_op等),不支持超时检测机制(timeout等)。

MindTorch接口 状态 约束
torch.distributed.is_available 支持
torch.distributed.init_process_group 部分支持 功能存在限制
torch.distributed.is_initialized 支持
torch.distributed.is_mpi_available 支持
torch.distributed.is_nccl_available 支持
torch.distributed.get_backend 支持
torch.distributed.Backend 部分支持 仅支持'mccl','hccl','nccl'后端
torch.distributed.get_rank 支持
torch.distributed.get_world_size 支持
torch.distributed.new_group 部分支持 功能存在限制
torch.distributed.send 支持
torch.distributed.recv 部分支持 src不支持为None
torch.distributed.broadcast 支持
torch.distributed.all_reduce 部分支持 op仅支持ReduceOp.SUM/PROD/MIN/MAX
torch.distributed.reduce 支持
torch.distributed.all_gather 支持
torch.distributed.all_gather_into_tensor 支持
torch.distributed.gather 部分支持 仅支持Ascend后端
torch.distributed.scatter 部分支持 仅支持Ascend后端
torch.distributed.reduce_scatter 支持
torch.distributed.ReduceOp 部分支持 仅支持SUM/PRODUCT/MIN/MAX模式
torch.distributed.barrier 部分支持 不支持device_ids入参
torch.distributed.get_global_rank 部分支持 功能存在限制
torch.distributed.destroy_process_group 部分支持 不支持删除全局通信组
torch.distributed.get_process_group_ranks 部分支持 功能存在限制

其他接口

MindTorch接口 状态 约束
torch.__version__ 部分支持 功能存在限制