Implement batching rules for some view ops (#42248)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/42248
Including:
- torch.diagonal
- torch.t
- torch.select
- Tensor.expand_as
- Tensor slicing.
Please let me know in the future if it would be easier to review these
separately (I put five operators into this PR because each
implementation is relatively simple).
Test Plan:
- new tests in `test/test_vmap.py`.
- I would like to have a more structured/automated way of testing but
my previous attempts at making something resulted in something very
complicated.
Reviewed By: ezyang
Differential Revision: D22846273
Pulled By: zou3519
fbshipit-source-id: 8e45ebe11174512110faf1ee0fdc317a25e8b7ac