[JIT] Add aten::slice optimization (#63049)
authorMike Iovine <mikeiovine@fb.com>
Fri, 27 Aug 2021 17:10:48 +0000 (10:10 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 27 Aug 2021 17:12:45 +0000 (10:12 -0700)
commitbabd4499783abc699faf36f3a72a9fc491e0e572
treedd0490212c59198b79cf9b8d5bcecd49ffae2fa2
parent3abb6060910186f38fc1eef2a2169639533f0c54
[JIT] Add aten::slice optimization (#63049)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63049

Given a graph produced from a function like this:
```
def foo():
    li = [1, 2, 3, 4, 5, 6]
    return li[0:2]
```
This pass produces a graph like this:
```
def foo():
    li = [1, 2]
    return li
```

These changes are mostly adapted from https://github.com/pytorch/pytorch/pull/62297/

Test Plan: `buck test //caffe2/test:jit -- TestPeephole`

Reviewed By: eellison

Differential Revision: D30231044

fbshipit-source-id: d12ee39f68289a574f533041a5adb38b2f000dd5
test/jit/test_peephole.py
torch/csrc/jit/passes/peephole_list_idioms.cpp
torch/csrc/jit/passes/peephole_list_idioms.h