Repository: pytorch
Issue: [v1.5] Python/C++ API parity master tracking task
Labels: module: cpp,triaged

Achieving API parity between our Python and C++ frontend is crucial for broadening the number of language communities PyTorch can address. By the PyTorch 1.5 release, we will provide the following improvements to the PyTorch C++ frontend:

**Python/C++ API Parity:**
- [x] torch.nn modules and functional (tracking issue: https://github.com/pytorch/pytorch/issues/25883)
  - [x] RNN (https://github.com/pytorch/pytorch/pull/34322)
  - [x] LSTM (https://github.com/pytorch/pytorch/pull/34322)
  - [x] GRU (https://github.com/pytorch/pytorch/pull/34322)
  - [x] RNNCell (https://github.com/pytorch/pytorch/pull/34400)
  - [x] LSTMCell (https://github.com/pytorch/pytorch/pull/34400)
  - [x] GRUCell (https://github.com/pytorch/pytorch/pull/34400)
  - [x] AdaptiveLogSoftmaxWithLoss (https://github.com/pytorch/pytorch/pull/29076)
  - [x] PackedSequence (https://github.com/pytorch/pytorch/pull/33652)
  - [x] pack_padded_sequence (https://github.com/pytorch/pytorch/pull/33652)
  - [x] pad_packed_sequence (https://github.com/pytorch/pytorch/pull/33652)
  - [x] pad_sequence (https://github.com/pytorch/pytorch/pull/33652)
  - [x] pack_sequence (https://github.com/pytorch/pytorch/pull/33652)
- [ ] Python/C++ API parity test for torch.nn modules and functional
  - [x] Fix AdaptiveAvgPool{2,3}d and AdaptiveMaxPool{2,3}d implementation (https://github.com/pytorch/pytorch/pull/35022)
  - [x] Fix Conv and ConvTranspose implementation (https://github.com/pytorch/pytorch/pull/35023)
  - [x] Fix fractional_max_pool3d_with_indices implementation (https://github.com/pytorch/pytorch/pull/35024)
  - [x] Fix F::interpolate and torch::nn::Upsample implementation (https://github.com/pytorch/pytorch/pull/35025)
  - [x] Add inplace tests for several torch::nn modules / functionals (#35147)
  - [x] Renaming: MultiLabelMarginLossFuncOptions -> MultilabelMarginLossFuncOptions, MultiLabelSoftMarginLossFuncOptions -> MultilabelSoftMarginLossFuncOptions (#35163)
  - [ ] Turn on parity test (https://github.com/pytorch/pytorch/pull/35189, https://github.com/pytorch/pytorch/pull/35190)
- [ ] torch.optim optimizers (tracking issue: https://github.com/pytorch/pytorch/issues/28440, make sure to test that the new design doesn't break serialization BC)
- [x] tensor multi-dim indexing API
  - [x] https://github.com/pytorch/pytorch/pull/32841
  - [x] https://github.com/pytorch/pytorch/pull/30426
  - [x] https://github.com/pytorch/pytorch/pull/30427
- [x] C++ tensor autograd API (tracking issue: https://github.com/pytorch/pytorch/issues/25874). Remaining items:
  - [x] grad_fn (https://github.com/pytorch/pytorch/pull/28287)
  - [x] register_hook (https://github.com/pytorch/pytorch/pull/28287)
  - [x] retain_grad (https://github.com/pytorch/pytorch/pull/33349)
  - [x] _base (https://github.com/pytorch/pytorch/pull/33316)

**Deprecation**
- [x] Remove deprecated torch::nn::BatchNorm / FeatureDropout / modules_ordered_dict and torch::nn::init::Nonlinearity / FanMode (https://github.com/pytorch/pytorch/pull/34508)

**Bug fixes:**
- [x] Allow skipping default arguments in module's forward method when module is used in Sequential (PR: https://github.com/pytorch/pytorch/pull/33027)
- [x] ModuleList compile error: error: 'begin' was not declared in this scope (Issue: https://github.com/pytorch/pytorch/issues/32414, PR: https://github.com/pytorch/pytorch/pull/34463)
- [x] C++ nn::FractionalMaxPool2d/3d output_ratio option is integer, should be double (Issue: https://github.com/pytorch/pytorch/issues/33240, PR: https://github.com/pytorch/pytorch/pull/33304)
- [x] Remove `using namespace torch::autograd` from header files (Issue: https://github.com/pytorch/pytorch/issues/34371. PR: https://github.com/pytorch/pytorch/pull/34423)

**Docs:**
- [x] For each `torch::nn` layer, document how to use `*Options` to specify options (ideally right above `torch::nn` layer doc) (https://github.com/pytorch/pytorch/pull/34522)
- [x] For each `torch::nn` functional, document how to use `*Options` to specify options (ideally right above `torch::nn` functional doc) (https://github.com/pytorch/pytorch/pull/34688) (https://github.com/pytorch/pytorch/pull/34752) (ETA: 3/13)
- [x] Fix torch::Tensor doc generation (Issue: https://github.com/pytorch/pytorch/issues/25845. PR: https://github.com/pytorch/pytorch/pull/34467)
- [ ] How to use C++ tensor multi-dim indexing (ETA: 4/3)
  - [ ] Maybe a table to show the translation between two languages

**Tutorials:**
- [ ] Autograd in C++ (ETA: 4/3)
  - [ ] Basic autograd operations (https://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html, https://pytorch.org/tutorials/beginner/examples_autograd/two_layer_net_autograd.html?highlight=autograd)
  - [ ] How to use C++ custom autograd function (https://pytorch.org/docs/stable/notes/extending.html#extending-torch-autograd)
  - [ ] How to use `at::Tensor::register_hook`
  - [ ] How to compute higher-order gradients in C++ (e.g. issue: https://github.com/pytorch/pytorch/issues/18173)

**Blog post:**
- [ ] C++ frontend revamp (ETA: 4/3)



cc @yf225 @gchanan