torch.nn

torch.nn

表1 torch.nn

序号

API名称

是否支持

1

Parameter

Containers

表2 Containers

序号

API名称

是否支持

1

Module

2

ModuleDict

3

ModuleList

4

ParameterDict

5

ParameterList

6

Sequential

Convolution Layers

表3 Convolution Layers

序号

API名称

是否支持

1

nn.Conv1d

2

nn.Conv2d

3

nn.Conv3d

4

nn.ConvTranspose1d

5

nn.ConvTranspose2d

6

nn.ConvTranspose3d

7

nn.Fold

8

nn.Unfold

Pooling layers

表4 Pooling layers

序号

API名称

是否支持

1

nn.AdaptiveAvgPool1d

2

nn.AdaptiveAvgPool2d

3

nn.AdaptiveAvgPool3d

是,仅支持D=1,H=1,W=1场景

4

nn.AdaptiveMaxPool1d

5

nn.AdaptiveMaxPool2d

6

nn.AdaptiveMaxPool3d

7

nn.AvgPool1d

8

nn.AvgPool2d

9

nn.AvgPool3d

10

nn.FractionalMaxPool2d

11

nn.LPPool1d

12

nn.LPPool2d

13

nn.MaxPool1d

14

nn.MaxPool2d

15

nn.MaxPool3d

16

nn.MaxUnpool1d

17

nn.MaxUnpool2d

18

nn.MaxUnpool3d

Padding Layers

表5 Padding Layers

序号

API名称

是否支持

1

nn.ConstantPad1d

2

nn.ConstantPad2d

3

nn.ConstantPad3d

4

nn.ReflectionPad1d

5

nn.ReflectionPad2d

6

nn.ReplicationPad1d

7

nn.ReplicationPad2d

8

nn.ReplicationPad3d

9

nn.ZeroPad2d

Non-linear Activations (weighted sum, nonlinearity)

表6 Non-linear Activations

序号

API名称

是否支持

1

nn.CELU

2

nn.ELU

3

nn.GELU

4

nn.Hardshrink

5

nn.Hardtanh

6

nn.LeakyReLU

7

nn.LogSigmoid

8

nn.MultiheadAttention

9

nn.PReLU

10

nn.ReLU

11

nn.ReLU6

12

nn.RReLU

13

nn.SELU

14

nn.Sigmoid

15

nn.Softplus

16

nn.Softshrink

17

nn.Softsign

18

nn.Tanh

19

nn.Tanhshrink

20

nn.Threshold

Non-linear Activations (other)

表7 Normalization Layers

序号

API名称

是否支持

1

nn.AdaptiveLogSoftmaxWithLoss

2

nn.LogSoftmax

3

nn.Softmax

4

nn.Softmax2d

5

nn.Softmin

Normalization Layers

表8 Non-linear Activations

序号

API名称

是否支持

1

nn.BatchNorm1d

2

nn.BatchNorm2d

3

nn.BatchNorm3d

4

nn.GroupNorm

5

nn.InstanceNorm1d

6

nn.InstanceNorm2d

7

nn.InstanceNorm3d

8

nn.LayerNorm

9

nn.LocalResponseNorm

10

nn.SyncBatchNorm

Recurrent Layers

表9 Recurrent Layers

序号

API名称

是否支持

1

nn.GRU

2

nn.GRUCell

3

nn.LSTM

4

nn.LSTMCell

是,非16对齐场景暂不支持

5

nn.RNN

6

nn.RNNBase

7

nn.RNNCell

Transformer Layers

表10 Transformer Layers

序号

API名称

是否支持

1

nn.Transformer

2

nn.TransformerDecoder

3

nn.TransformerDecoderLayer

4

nn.TransformerEncoder

5

nn.TransformerEncoderLayer

Linear Layers

表11 Linear Layers

序号

API名称

是否支持

1

nn.Bilinear

2

nn.Identity

3

nn.LazyLinear

4

nn.Linear

Dropout Layers

表12 Dropout Layers

序号

API名称

是否支持

1

nn.AlphaDropout

2

nn.Dropout

3

nn.Dropout2d

4

nn.Dropout3d

Sparse Layers

表13 Sparse Layers

序号

API名称

是否支持

1

nn.Embedding

2

nn.EmbeddingBag

Distance Functions

表14 Distance Functions

序号

API名称

是否支持

1

nn.CosineSimilarity

2

nn.PairwiseDistance

Loss Functions

表15 Loss Functions

序号

API名称

是否支持

1

nn.BCELoss

2

nn.BCEWithLogitsLoss

3

nn.CosineEmbeddingLoss

4

nn.CrossEntropyLoss

5

nn.CTCLoss

6

nn.HingeEmbeddingLoss

7

nn.KLDivLoss

8

nn.L1Loss

9

nn.MarginRankingLoss

10

nn.MSELoss

11

nn.MultiLabelMarginLoss

12

nn.MultiLabelSoftMarginLoss

13

nn.MultiMarginLoss

14

nn.NLLLoss

15

nn.PoissonNLLLoss

16

nn.SmoothL1Loss

17

nn.SoftMarginLoss

18

nn.TripletMarginLoss

Vision Layers

表16 Vision Layers

序号

API名称

是否支持

1

nn.PixelShuffle

2

nn.Upsample

3

nn.UpsamplingBilinear2d

4

nn.UpsamplingNearest2d

DataParallel Layers (multi-GPU, distributed)

表17 DataParallel Layers

序号

API名称

是否支持

1

nn.DataParallel

2

nn.parallel.DistributedDataParallel

Utilities

表18 Utilities

序号

API名称

是否支持

1

clip_grad_norm_

2

clip_grad_value_

3

nn.Flatten

4

nn.utils.rnn.pack_padded_sequence

5

nn.utils.rnn.pack_sequence

6

nn.utils.rnn.PackedSequence

7

nn.utils.rnn.pad_packed_sequence

8

nn.utils.rnn.pad_sequence

9

parameters_to_vector

10

prune.BasePruningMethod

11

prune.custom_from_mask

12

prune.CustomFromMask

13

prune.global_unstructured

14

prune.Identity

15

prune.identity

16

prune.is_pruned

17

prune.l1_unstructured

18

prune.L1Unstructured

19

prune.ln_structured

20

prune.LnStructured

21

prune.PruningContainer

22

prune.random_structured

23

prune.random_unstructured

24

prune.RandomStructured

25

prune.RandomUnstructured

26

prune.remove

27

remove_spectral_norm

28

remove_weight_norm

29

spectral_norm

30

vector_to_parameters

31

weight_norm