[PyTorch] Reduce code size of register_prim_ops.cpp (#61494)
authorScott Wolchok <swolchok@fb.com>
Fri, 27 Aug 2021 19:55:26 +0000 (12:55 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 27 Aug 2021 19:56:35 +0000 (12:56 -0700)
commit8fc1064b7f562ec5b5c6a5e6a0b59069101e6c87
treebb0a318fce9085a2676d10331b58f6f249c26182
parent6a76ee04de5f10b76cc8f97cc254da43905d170b
[PyTorch] Reduce code size of register_prim_ops.cpp (#61494)

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

Creating a constexpr array and then looping over it is much cheaper than emitting a function call per item.
ghstack-source-id: 136639302

Test Plan:
fitsships

Buildsizebot some mobile apps to check size impact.

Reviewed By: dhruvbird, iseeyuan

Differential Revision: D29646977

fbshipit-source-id: 6144999f6acfc4e5dcd659845859702051344d88
torch/csrc/jit/runtime/custom_operator.h
torch/csrc/jit/runtime/operator.h
torch/csrc/jit/runtime/register_ops_utils.h
torch/csrc/jit/runtime/register_prim_ops.cpp