Currently, PyTorch C++ API is missing many torch::nn
layers that are available in the Python API. As part of the Python/C++ API parity project, we would like to add all of the following layers to C++:
Containers
- [ ] ModuleDict
- [ ] ParameterList
- [ ] ParameterDict
Convolution layers
- [ ] ConvTranspose1d
- [ ] ConvTranspose2d
- [ ] ConvTranspose3d
- [ ] Unfold
Pooling layers
- [ ] MaxUnpool1d
- [ ] MaxUnpool2d
- [ ] MaxUnpool3d
- [ ] FractionalMaxPool2d
- [ ] LPPool1d
- [ ] LPPool2d
- [ ] AdaptiveMaxPool1d
- [ ] AdaptiveMaxPool2d
- [ ] AdaptiveMaxPool3d
- [ ] AdaptiveAvgPool1d
- [ ] AdaptiveAvgPool2d
- [ ] AdaptiveAvgPool3d
Padding layers
- [ ] ReflectionPad1d
- [ ] ReflectionPad2d
- [ ] ReplicationPad1d
- [ ] ReplicationPad2d
- [ ] ReplicationPad3d
- [ ] ZeroPad2d
- [ ] ConstantPad1d
- [ ] ConstantPad2d
- [ ] ConstantPad3d
Non-linear activations (weighted sum, nonlinearity)
- [ ] ELU
- [ ] Hardshrink
- [ ] Hardtanh
- [ ] LeakyReLU
- [ ] LogSigmoid
- [ ] MultiheadAttention
- [ ] PReLU
- [ ] ReLU
- [ ] ReLU6
- [ ] RReLU
- [ ] SELU
- [ ] CELU
- [ ] Sigmoid
- [ ] Softplus
- [ ] Softshrink
- [ ] Softsign
- [ ] Tanh
- [ ] Tanhshrink
- [ ] Threshold
Non-linear activations (other)
- [ ] Softmin
- [ ] Softmax
- [ ] Softmax2d
- [ ] LogSoftmax
- [ ] AdaptiveLogSoftmaxWithLoss
Normalization layers
- [ ] GroupNorm
- [ ] SyncBatchNorm
- [ ] InstanceNorm1d
- [ ] InstanceNorm2d
- [ ] InstanceNorm3d
- [ ] LocalResponseNorm
Linear layers
- [ ] Identity
- [ ] Bilinear
- [ ] Flatten
Dropout layers
- [ ] AlphaDropout
Distance functions
- [ ] CosineSimilarity
- [ ] PairwiseDistance
Vision layers
- [ ] PixelShuffle
- [ ] Upsample
- [ ] UpsamplingNearest2d
- [ ] UpsamplingBilinear2d
DataParallel layers (multi-GPU, distributed)
- [ ] DataParallel
- [ ] DistributedDataParallel
Utilities
- [ ] clip_grad_norm_
- [ ] clip_grad_value_
- [ ] parameters_to_vector
- [ ] vector_to_parameters
- [ ] weight_norm
- [ ] remove_weight_norm
- [ ] spectral_norm
- [ ] remove_spectral_norm
- [ ] PackedSequence
- [ ] pack_padded_sequence
- [ ] pad_packed_sequence
- [ ] pad_sequence
- [ ] pack_sequence
If you see any layers in the list that you are interested in using, please let me know whether you would also be interested in contributing to its implementation in C++ API. Most layers would just call the corresponding ATen functions internally (e.g. C++ MaxPoolNd module: https://github.com/pytorch/pytorch/pull/24860/files, thanks @ShahriarSS for the contribution! ) and doesn’t require in-depth knowledge about how the layer performs computation, so the barrier to entry should be considerably low for C++ developers of all levels.
Thanks!