[caffe2] Refactor out common util functions from tvm_transformer (#34652)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34652
Split from D20006007 because it needs to synced to open source and also for easy testing & landing.
Test Plan:
```
buck test caffe2/caffe2/fb/tvm:test_tvm_transform
```
CI
Reviewed By: yinghai
Differential Revision: D20414037
fbshipit-source-id: 6e17dd9f8cffe87bc59c6e3cc6fd1f8d8def926b