## torch 接口功能约束说明 - [Torch](#jump2) - [Tensor](#jump3) - [Torch.nn](#jump4) - [nn.functional](#jump5) - [torch.linalg](#jump6) - [torch.utils.data](#jump7) - [torch.distributed](#jump8) ### torch | MindTorch接口 | 约束条件 | | ------------- | -------------- | | torch.frombuffer | require_grad暂不支持 | | torch.multinomial | 暂不支持传入Generator | | torch.randint | 暂不支持传入Generator | | torch.randperm | 暂不支持传入Generator | | torch.imag | 暂不支持图模式 | | torch.max | 不支持other,不支持图模式 | | torch.lu | 暂不支持图模式, `get_infos=True`场景下,暂不支持错误扫描; 暂不支持`pivot=False`入参, 仅支持二维方阵输入,不支持(*, M, N)形式输入 | | torch.lstsq | 暂时不支持返回第二个参数QR,暂不支持图模式,反向梯度暂不支持 | | torch.svd | Ascend上暂不支持图模式,Ascend上反向梯度暂不支持 | | torch.nextafter | CPU上暂不支持float32输入 | | torch.matrix_power | GPU上暂不支持参数`n`小于0 | | torch.i0 | Ascend上暂不支持反向梯度, 暂不支持图模式 | | torch.index_add | 暂不支持二维以上的`input`或`dim`>=1,暂不支持图模式 | | torch.index_copy | 暂不支持二维以上的`input`或`dim`>=1,暂不支持图模式 | | torch.scatter_reduce | 暂不支持`reduce`="mean", Ascend上暂不支持`reduction='prod'`同时`dim`>0 | | torch.asarray | 1.暂不支持输入`device`和 `copy`参数配置功能; 2.`requires_grad`仅当环境变量`ENABLE_BACKWARD=1`时生效,且不支持图模式; | | torch.complex | 暂不支持float16类型输入 | | torch.fmin | 暂不支持反向梯度, 暂不支持图模式 | | torch.kron | 暂不支持入参是不同复数类型 | | torch.sort | 暂不支持`stable`入参 | | torch.float_power | 不支持复数输入 | | torch.add | 暂不支持当两个输入都为bool类型时, 返回bool类型 | | torch.polygamma | 1.暂不支持Ascend后端;2.当入参`n`为0时,结果可能不正确 | | torch.geqrf | 暂不支持大于2维的输入 | | torch.repeat_interleave | 暂不支持`output_size`入参 | | torch.index_reduce | 暂不支持`reduce`="mean" | | torch.corrcoef | 暂不支持复数类型入参 | | torch.symeig | 暂不支持反向梯度, 暂不支持图模式 | | torch.fmax | GPU和Ascend上暂不支持反向梯度, 暂不支持图模式 | | torch.fft | 暂不支持反向梯度, 暂不支持图模式 | | torch.norm | 1.当`p`为0/1/-1/-2时,矩阵范数不支持;2.不支持`p`为inf/-inf/0/1/-1/2/-2之外的int/float类型; 3.`dim`最多只支持指定两个维度;4.该接口使用mindspore.ops.norm实现,支持功能也可以参考[链接](https://www.mindspore.cn/docs/zh-CN/r2.1/api_python/ops/mindspore.ops.norm.html)| | torch.poisson | Ascend上暂不支持反向梯度,暂不支持图模式 | | torch.xlogy | Ascend 上当前只支持float16 和float32输入 | | torch.digamma | Ascend上仅支持float16和float32类型入参 | | torch.lgamma | Ascend上仅支持float16和float32类型入参 | | torch.logspace | 暂不支持float型`base`入参,GPU上暂不支持 | | torch.sgn | Ascend暂上不支持int16类型入参 | | torch.mm | GPU上暂不支持int类型输入 | | torch.inner | Ascend上暂不支持int类型输入 | | torch.isclose | Ascend上, 暂不支持equal_nan=False | | torch.matrix_rank | 暂不支持图模式,暂不支持复数类型输入,Ascend上不支持反向梯度 | | torch.inference_mode | 当前只支持相当于no_grad的功能 | | torch.tensordot | GPU上暂不支持int类型输入 | | torch.scatter_add | Ascend上仅支持 updates_shape = indices_shape + input_x_shape[1:]形式的入参 | | torch.diff | 复数输入仅在输入参数`n=1`时支持 | | torch.scatter | 不支持reduce='mutiply', Ascend不支持reduce='add', 不支持indices.shape != src.shape | | torch.set_deterministic_debug_mode | 机制差异,debug_mode配置不生效 | | torch.is_inference_mode_enabled | 1.只能判断反向是否使能,等同于is_grad_enable,暂不具备判断其他推理功能是否使能的功能;2.不支持图模式 | | torch.unique | 暂不支持sorted=True和return_inverse=True场景 | | torch.argsort | 暂不支持`stable`入参 | | torch.gradient | 入参`edge_order`暂时只支持配置为1 | | torch.normal | 暂不支持float64输入 | | torch.index_copy | 1.不支持input超过二维; 2.不支持dim>=1; 3.不支持图模式 | | torch.bernoulli | 暂不支持传入Generator | | torch.mul | 暂不支持两个入参均为bool类型 | | torch.set_num_threads | 1.暂不支持图模式; 2.该函数仅支持在程序执行操作之前调用; 3.此函数等效于`setnum_interopthreads` | | torch.set_num_interop_threads | 1.暂不支持图模式; 2.该函数仅支持在程序执行操作之前调用; | ### Tensor | MindTorch接口 | 约束条件 | | --------------- | -------------- | | Tensor.bool | 不支持`memory_format` | | Tensor.expand | 类型限制,只支持Tensor[Float16], Tensor[Float32], Tensor[Int32], Tensor[Int8], Tensor[UInt8] | | Tensor.float | 不支持`memory_format` | | Tensor.scatter | 不支持reduce='mutiply', Ascend不支持reduce='add', 不支持indices.shape != src.shape | | Tensor.std | 不支持复数和float64输入 | | Tensor.xlogy | Ascend 上当前只支持float16 和float32输入 | | Tensor.abs_ | 暂不支持图模式 | | Tensor.absolute_ | 暂不支持图模式 | | Tensor.acos_ | 暂不支持图模式 | | Tensor.arccos_ | 暂不支持图模式 | | Tensor.addr_ | 暂不支持图模式 | | 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.lu | 暂不支持图模式,入参`get_infos=True`时暂不支持扫描错误信息, 暂不支持`pivot=False`,仅支持二维方阵输入,不支持(*, M, N)形式输入 | | Tensor.lstsq | 暂时不支持返回第二个参数QR, 暂不支持图模式,反向梯度暂不支持 | | 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.svd | Ascend上暂不支持图模式,Ascend上反向梯度暂不支持 | | Tensor.nextafter | CPU上暂不支持float32输入 | | Tensor.matrix_power | GPU上暂不支持参数`n`小于0 | | Tensor.i0 | Ascend上暂不支持反向梯度, 暂不支持图模式 | | Tensor.index_add | 暂不支持二维以上的`input`或`dim`为1 | | Tensor.nextafter_ | CPU上暂不支持float32输入 | | Tensor.fmin | 暂不支持反向梯度, 暂不支持图模式 | | Tensor.imag | 暂不支持图模式 | | Tensor.scatter_reduce | 暂不支持`reduce`="mean", Ascend上暂不支持`reduction='prod'`同时`dim`>0 | | Tensor.scatter_reduce_ | 暂不支持`reduce`="mean"和图模式, Ascend上暂不支持`reduction='prod'`同时`dim`>0 | | Tensor.neg | 暂不支持uint32, uint64输入 | | Tensor.add | 暂不支持当两个输入都为bool类型时, 返回bool类型 | | Tensor.polygamma | 当入参`n`为0时,结果可能不正确 | | Tensor.geqrf | 暂不支持大于2维的输入 | | Tensor.repeat_interleave | 暂不支持`output_size`入参 | | Tensor.index_reduce | 暂不支持`reduce`="mean" | | Tensor.index_reduce_ | 暂不支持`reduce`="mean"和图模式 | | Tensor.masked_scatter | 暂不支持`input`广播到`mask`和GPU后端 | | Tensor.index_put | Ascend上暂不支持`accumulate`=False | | Tensor.index_put_ | Ascend上暂不支持`accumulate`=False,暂不支持图模式 | | Tensor.corrcoef | 暂不支持复数类型入参 | | Tensor.exponential_ | 暂不支持反向梯度, 暂不支持图模式 | | Tensor.geometric_ | 暂不支持反向梯度, 暂不支持图模式 | | Tensor.log_normal_ | 暂不支持反向梯度, 暂不支持图模式 | | Tensor.symeig | 暂不支持反向梯度, 暂不支持图模式 | | Tensor.fmax | GPU和Ascend上暂不支持反向梯度, 暂不支持图模式 | | Tensor.norm | 1.当`p`为0/1/-1/-2时,矩阵范数不支持;2.不支持`p`为inf/-inf/0/1/-1/2/-2之外的int/float类型; 3.`dim`最多只支持指定两个维度;4.该接口使用mindspore.ops.norm实现,支持功能也可以参考[链接](https://www.mindspore.cn/docs/zh-CN/r2.1/api_python/ops/mindspore.ops.norm.html)。| | Tensor.digamma | Ascend上仅支持float16和float32类型入参 | | Tensor.lgamma | Ascend上仅支持float16和float32类型入参 | | Tensor.arcsinh_ | 暂不支持图模式 | | Tensor.long | 不支持`memory_format` | | Tensor.half | 不支持`memory_format` | | Tensor.int | 不支持`memory_format` | | Tensor.double | 不支持`memory_format` | | Tensor.char | 不支持`memory_format` | | Tensor.byte | 不支持`memory_format` | | Tensor.short | 不支持`memory_format` | | Tensor.new_full | 1.暂不支持`device`; 2.`requires_grad`仅当环境变量`ENABLE_BACKWARD=1`时生效,且不支持图模式; 3.暂不支持`layout`; 4.暂不支持`pin_memory`; | | Tensor.new_zeros | 1.暂不支持`device`; 2.`requires_grad`仅当环境变量`ENABLE_BACKWARD=1`时生效,且不支持图模式; | | Tensor.sgn | Ascend暂上不支持int16类型入参 | | Tensor.mm | GPU上暂不支持int类型输入 | | Tensor.inner | Ascend上暂不支持int类型输入 | | Tensor.scatter_add | Ascend上仅支持 updates_shape = indices_shape + input_x_shape[1:]形式的入参 | | Tensor.scatter_add_ | Ascend上仅支持 updates_shape = indices_shape + input_x_shape[1:]形式的入参,暂不支持图模式 | | Tensor.diff | 复数输入仅在输入参数`n=1`时支持 | | Tensor.data_ptr | 1.机制差异,返回numpy数据的指针,不支持原地修改指针指向的数据;2.暂不支持图模式 | | Tensor.device | 机制差异,不支持对将单个张量指定执行硬件,无实际效果; | | Tensor.isclose | Ascend上, 暂不支持equal_nan=False | | Tensor.unique | 暂不支持sorted=True和return_inverse=True场景 | | Tensor.to | 仅支持修改类型的功能,其他入参不生效 | | Tensor.cuda | 机制差异,不改变张量存储内存位置 | | Tensor.bernoulli | 暂不支持传入Generator | | Tensor.bernoulli_ | 1.暂不支持传入Generator;2.暂不支持图模式 | | Tensor.mul | 暂不支持两个入参均为bool类型 | | Tensor.set_ | 1.暂不支持图模式; 2.暂不支持指定`storage_offset`, `size` 和 `stride`; | | Tensor.requires_grad | 1.仅当环境变量`ENABLE_BACKWARD=1`时生效,否则非叶子结点返回结果恒为False; 2. 不支持图模式; | | Tensor.requires_grad_ | 1.仅当环境变量`ENABLE_BACKWARD=1`时生效,否则赋值对微分结果无影响; 2. 不支持图模式; | | Tensor.backward | 1.不支持图模式; 2.仅当环境变量`ENABLE_BACKWARD=1`时生效,否则请使用mindspore的微分接口ms.grad(https://www.mindspore.cn/docs/zh-CN/r2.0/api_python/mindspore/mindspore.grad.html)或者 ms.value_and_grad(https://www.mindspore.cn/docs/zh-CN/r2.0/api_python/mindspore/mindspore.value_and_grad.html) 进行求导。实际网络用法可参考mobilenet_v2例子(https://openi.pcl.ac.cn/OpenI/MSAdapterModelZoo/src/branch/master/official/cv/mobilenet_v2/mobilenet_v2_adapter.py)| | Tensor.detach | 1.返回的tensor和原始tensor并不共享内存; | | Tensor.detach_ | 1.返回的tensor和原始tensor并不共享内存; 2. 不支持图模式; | | Tensor.retain_grad | 1.仅当环境变量`ENABLE_BACKWARD=1`时生效; 2. 不支持图模式; | | Tensor.retains_grad | 1.仅当环境变量`ENABLE_BACKWARD=1`时生效,否则默认返回False; 2. 不支持图模式; | | Tensor.grad | 1.仅当环境变量`ENABLE_BACKWARD=1`时生效,否则默认返回None; 2. 不支持图模式; | | Tensor.is_leaf | 1.仅当环境变量`ENABLE_BACKWARD=1`时生效; 2. 不支持图模式; | ### Torch.nn | MindTorch接口 | 约束条件 | | --------------- | -------------- | | nn.LPPool1d | Ascend上不支持float64 | | nn.LPPool2d | Ascend上不支持float64 | | nn.ELU | Alpha仅支持1.0 | | nn.Hardshrink | 不支持float64 | | nn.Hardtanh | 不支持float64 | | nn.Hardswish | 不支持float64 | | nn.LeakyReLU | 不支持float64 | | nn.PReLU | 不支持float64 | | nn.ReLU6 | 不支持float64 | | nn.RReLU | inplace不支持图模式 | | nn.SELU | inplace不支持图模式 | | nn.CELU | inplace不支持图模式 | | nn.Mish | 1.`inplace`不支持图模式;2.不支持float64 | | nn.Threshold | inplace不支持图模式 | | nn.Softshrink | 不支持float64 | | nn.LogSoftmax | 不支持float64,不支持8维及以上 | | nn.Linear | device, dtype参数不支持 | | nn.UpsamplingNearest2d | 不支持size为none | | nn.Conv1d | Ascend上,`groups`只支持1或者与`in_channels`相等 | | nn.Conv2d | Ascend上,`groups`只支持1或者与`in_channels`相等 | | nn.Conv3d | 1.不支持复数;2.`padding_mode`不支持`reflect`模式;3.Ascend上`groups`, `dialtion`参数只支持为1 | | nn.ConvTranspose1d | 1.`output_padding`,`output_size`不支持; 2.Ascend上`groups`只支持1或者与`in_channels`相等 | | nn.ConvTranspose2d | 1.`output_padding`,`output_size`不支持; 2.Ascend上`groups`只支持1或者与`in_channels`相等 | | nn.AdaptiveLogSoftmaxWithLoss | 不支持图模式 | | nn.LSTM | 在图模式下,`input`不支持PackedSequence类型 | | nn.ReflectionPad3d | `padding`参数不支持负数取值 | | nn.Transformer | 不支持空tensor输入 | | nn.TransformerEncoder | 不支持空tensor输入 | | nn.TransformerDecoder | 不支持空tensor输入 | | nn.TransformerEncoderLayer | 不支持空tensor输入 | | nn.TransformerDecoderLayer | 不支持空tensor输入 | | nn.AdaptiveMaxPool1d | Ascend上不支持`return_indices` | | nn.AdaptiveMaxPool2d | Ascend上不支持`return_indices` | | nn.Embedding | 1.`scale_grad_by_freq`, `sparse`不支持; 2.`norm_type`只能为2 | | nn.Upsample | 不支持`recompute_scale_factor` | | nn.RNN | 在图模式下,`input`不支持PackedSequence类型 | | nn.GRU | 在图模式下,`input`不支持PackedSequence类型 | | nn.CrossEntropyLoss | `target`类型为int64时,有溢出风险 | | nn.parallel.DistributedDataParallel | 不支持`device_ids`, `output_device`, `dim`, `find_unused_parameters`, `check_reduction`, `gradient_as_bucket_view`, `static_graph` | | nn.MultiheadAttention | 图模式下暂不支持入参使用键值对赋值 | | nn.ModuleList | 图模式下只支持list相关操作,暂不支持module相关的功能 | | nn.Module | nn.Module及其子类声明方法及属性时不能使用[以下名字](https://www.mindspore.cn/docs/zh-CN/r2.1/api_python/nn/mindspore.nn.Cell.html)。原因是nn.Module是继承mindspore.nn.Cell实现的, 所以也继承了它的成员变量, 存在重复名字时会导致方法及变量无法正常调用。| | | nn.utils.clip_grad_norm_ | 1.`norm_type`只支持2.0,`error_if_nonfinite`和`foreach`不支持;2.由于微分机制不同,入参需要额外传入梯度`grads`。| | nn.utils.clip_grad_value_ | 1.`foreach`不支持;2.由于微分机制不同,入参需要额外传入梯度`grads`。| | nn.utils.parametrizations.orthogonal | 1.不支持图模式;2.不支持CPU/GPU后端;3.当`orthogonal_map`为`cayley`或`householder`时不支持反向。| | nn.Module.register_backward_hook | 1.不支持求高阶导;2.hook内不能对Module进行修改。 | | nn.Module.register_full_backward_hook | 1.不支持求高阶导;2.hook内不能对Module进行修改。 | | nn.modules.module.register_module_backward_hook | 1.不支持求高阶导;2.hook内不能对Module进行修改。 | | nn.modules.module.register_module_full_backward_hook | 1.不支持求高阶导;2.hook内不能对Module进行修改。 | | nn.Module.share_memory | 机制差异,不改变张量存储内存位置 | | nn.Module.to | 仅支持修改类型的功能,其他入参不生效 | ### nn.functional | MindTorch接口 | 约束条件 | | --------------- | -------------- | | functional.lp_pool1d | Ascend上不支持float64 | | functional.lp_pool2d | Ascend上不支持float64 | | functional.prelu | 不支持float64 | | functional.rrelu | 1.inplace不支持图模式; 2.`training`入参不支持 | | functional.softshrink | 不支持float64 | | functional.log_softmax | 不支持float64 | | functional.dropout1d | inplace不支持图模式 | | functional.dropout2d | inplace不支持图模式 | | functional.dropout3d | inplace不支持图模式 | | functional.conv3d | Ascend上`groups`, `dialtion`参数只支持1 | | functional.upsample_bilinear | 输入张量必须是4维 | | functional.interpolate | `recompute_scale_factor` 及 `antialias` 入参不支持。`bicubic`模式仅支持`align_corners=True`, GPU上暂不支持`nearest-exact`模式,各模式参数和维度限制参考[mindspore.ops.interpolate](https://www.mindspore.cn/docs/zh-CN/master/api_python/ops/mindspore.ops.interpolate.html?highlight=interpolate#mindspore.ops.interpolate) | | functional.conv1d | Ascend上,`groups`只支持1或者与`input`的通道数相等 | | functional.conv2d | Ascend上,`groups`只支持1或者与`input`的通道数相等 | | functional.conv_transpose1d | 1.`output_padding`暂不支持; 2.Ascend上`groups`只支持1或者与`input`的通道数相等 | | functional.conv_transpose2d | 1.`output_padding`暂不支持; 2.Ascend上`groups`只支持1或者与`input`的通道数相等 | | functional.adaptive_max_pool1d | Ascend上不支持`return_indices` | | functional.adaptive_max_pool2d | Ascend上不支持`return_indices` | | functional.instance_norm | 图模式下,训练模式时, 暂不支持`running_mean`和`running_var` | | functional.batch_norm | 图模式下,训练模式时, 暂不支持`running_mean`及`running_var` | | functional.embedding | 1.`scale_grad_by_freq`, `sparse`不支持; 2.`norm_type`只能为2 | | functional.mish | 1.`inplace`不支持图模式;2.不支持float64 | | functional.selu | `inplace`不支持图模式 | | functional.celu | 1.`inplace`不支持图模式;2.不支持float64 | | functional.grid_sample | 不支持`mode='bicubic'` | | functional.cross_entropy | `target`类型为int64时,有溢出风险 | | functional.pad | 当`padding_mode`为'reflect'时,不支持填充最后三维 | | functional.upsample | `mode`仅支持`linear`、`bilinear`、`nearest` | | functional.ctc_loss | 入參`input_lengths` 和 `target_lengths` 不支持tuple类型 | ### torch.linalg | MindTorch接口 | 约束条件 | | --------------- | -------------- | | lu | 暂不支持图模式,暂不支持入参`pivot=False`, 仅支持二维方阵输入,不支持(*, M, N)形式输入 | | lu_solve | 暂不支持图模式,入参`left=False`不支持,入参`LU`不支持三维输入 | | lu_factor | 暂不支持图模式,仅支持二维方阵输入,不支持(*, M, N)形式输入 | | lu_factor_ex | 暂不支持图模式,入参`get_infos=True`时暂不支持扫描错误信息, 暂不支持`pivot=False`,仅支持二维方阵输入,不支持(*, M, N)形式输入 | | lstsq| 暂不支持图模式,反向梯度暂不支持 | | eigvals | 暂不支持图模式,反向梯度暂不支持 | | svd | `driver`参数只支持None, Ascend上不支持反向梯度, Ascend上暂不支持图模式 | | svdvals | `driver`参数只支持None,Ascend上不支持反向梯度, Ascend上暂不支持图模式 | | norm | 暂不支持复数输入, `ord`参数暂不支持浮点型输入, Ascend上暂不支持ord为nuc模式、float(`inf`)模式和整形数输入 | | vector_norm | 暂不支持复数输入, `ord`参数暂不支持浮点型输入 | | matrix_power | GPU上暂不支持参数`n`小于0 | | eigvalsh | 暂不支持图模式,反向梯度暂不支持 | | eigh | 暂不支持图模式,反向梯度暂不支持 | | solve | 暂不支持图模式,反向梯度暂不支持 | | cholesky | GPU上暂不支持int类型输入 | | cholesky_ex | 入参`check_errors=True`时暂不支持扫描错误信息,GPU上暂不支持int类型输入 | | inv_ex | 入参`check_errors=True`时暂不支持扫描错误信息 | | matrix_norm | Ascend上暂不支持`ord`为nuc模式和+2/-2模式,暂不支持复数输入 | | matrix_rank | 暂不支持图模式,暂不支持复数类型输入,Ascend上不支持反向梯度 | | solve_triangular | Ascend上暂不支持, 暂不支持`left=False` | | cond | 仅支持二维方阵输入,Ascend上暂不支持complex输入,float32类型输入仅支持`p=1/-1/'fro'/'inf'/'-inf'`,float64类型输入仅支持`p='fro'`;GPU和CPU上complex128类型输入仅支持`p=2/-2`, complex64类型输入仅支持`p='fro'/'nuc'` | | diagonal | 当 offset != 0 时不支持float64 | ### torch.utils.data | MindTorch接口 | 约束条件 | | --------------- |---------------------------------------------------------------------------------------------| | DataLoader | pin_memory仅支持False,worker_init_fn不支持自定义初始化,不支持generator来控制随机状态,不支持指定pin_memory_device | | random_split | 暂不支持传入Generator | | RandomSampler | 暂不支持传入Generator| | SubsetRandomSampler | 暂不支持传入Generator| | WeightedRandomSampler | 暂不支持传入Generator| ### torch.distributed | MindTorch接口 | 约束条件 | | --------------- |-----------------------------------------------------------------------------------------| | torch.distributed.init_process_group | 不支持`timeout`, `rank`, `store`, `group_name`, `pg_options`。`init_method`仅支持“env://”或者None | | torch.distributed.new_group | 不支持`timeout`, `pg_options`,`backend`仅支持“nccl”或“hccl” | | torch.distributed.get_global_rank | 如果当前进程不属于输入的通信组,不支持获取rank信息,返回None | | torch.distributed.get_process_group_ranks | 如果当前进程不属于输入的通信组,不支持获取rank信息,返回空的列表 | ### torch.cuda | MindTorch接口 | 约束条件 | | --------------- |-----------------------------------------------------------------------------------------| | torch.cuda.amp.GradScaler | 1.unscale方法需要传入对应的梯度: unscale_(optimizer, grads); 2.step方法需要传入对应的梯度: step(optimizer, grads); 3.unscale_ 方法不支持图模式 | | torch.cuda.current_stream | 1.不支持图模式;2.不支持`device`| | torch.cuda.default_stream | 1.不支持图模式;2.不支持`device`| | torch.cuda.synchronize | 1.不支持图模式;2.不支持`device`| | torch.cuda.Event | 1.不支持图模式;2.不支持`interprocess`; 3.成员`from_ipc_handle`,`ipc_handle`不支持| | torch.cuda.Stream | 1.不支持图模式;2.不支持`device`; 3.在Ascend 910B,`priority`只支持0 | ### torch.autograd | MindTorch接口 | 约束条件 | | --------------- |-----------------------------------------------------------------------------------------| | torch.autograd.functional.vjp | `create_graph`, `strict`不支持 | | torch.autograd.functional.jvp | `create_graph`, `strict`不支持 | | torch.autograd.functional.jacobian | `create_graph`, `strict`不支持 | ### torch.fft | MindTorch接口 | 约束条件 | | --------------- |-----------------------------------------------------------------------------------------| | torch.fft.rfft | 暂不支持反向梯度, 暂不支持图模式 | ### torch.\_\_version\_\_ | MindTorch接口 | 约束条件 | | --------------- |-----------------------------------------------------------------------------------------| | torch.\_\_version\_\_ | 图模式下,需要在图外(`ms.jit`作用域之外或者`nn.module.forward`之外)使用。|