Fix lite interpreter record function issue. (#47457)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47457
This fixes two issues.
1. lite interpreter record_function is intended to be used only for root op
profiling. At the moment if RECORD_FUNCTION is enabled via Dispatcher then it
logs not just root ops but all ops.
2. Because interpreter sets op index that later gets picked up elsewhere
(decoupled design), op index that is set in lite interpreter ends up getting
used by all the record function calls not just root op. Thus we dont really get
correct per op profiling. This diff also fixes this issue.
Reviewed By: ilia-cher
Differential Revision: D24763689
fbshipit-source-id: 6c1f8bcaec9fb5ebacb2743a5dcf7090ceb176b9