[PyTorch] Specialize `list_element_from` for `IValue` to avoid extra move/copy (#50124)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50124
This patch makes `list_element_from` avoid extra `IValue`
move/copies for `List<IValue>` by just forwarding the reference
argument.
We take advantage of this in `listConstruct` by using `push_back`
(which hits the `ListElementFrom` path) instead of `
ghstack-source-id: 119478962
Test Plan:
Inspected generated assembly for vararg_functions.cpp in
optimized build. Rather than a call to `vector::emplace_back` and an extra
move, `vector::push_back` gets inlined.
Reviewed By: ezyang
Differential Revision: D25794277
fbshipit-source-id: 2354d8c08e0a0d6be2db3f0d0d6c90c3a455d8bd