[easy][PTE] Reduce unnecessary ref count bumps in callstack debug (#72547)

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

toTuple() returns a  new intrusive pointer that bumps its underlying ref count. Whereas, toTupeRef returns a reference. We can save an unnecessary ref count bump.

Based on https://fb.workplace.com/groups/pytorch.edge.team/permalink/1021780808376658/

similar to D34047666 (85d7e73a8a)
ghstack-source-id: 148665193

Test Plan:
```
> Executing task: buck: buck test //xplat/caffe2:test_lite_interpreter  --config client.id=nuclide <

Executing in directory: /data/users/pavithran/fbsource
buck test //xplat/caffe2:test_lite_interpreter  --config client.id=nuclide

clang-9: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]

Parsing buck files: finished in 2.1 sec
Creating action graph: finished in 0.5 sec
[RE] Metadata: Session ID=[reSessionID-66858379-0761-4966-a933-bc7f0d0add95]
[RE] Waiting on 0 remote actions. Completed 523 actions remotely, action cache hit rate: 0.00%.
Downloaded 3947/5089 artifacts, 20.92 Mbytes, 12.5% cache miss (for updated rules)
Building: finished in 01:04.0 min (100%) 5438/5438 jobs, 5192/5438 updated
  Total time: 01:06.6 min
Testing: finished in 06:53.7 min (71 PASS/0 FAIL)
BUILD SUCCEEDED
RESULTS FOR //xplat/caffe2:test_lite_interpreter
PASS    406.0s 71 Passed   0 Skipped   0 Failed   //xplat/caffe2:test_lite_interpreter
TESTS PASSED

Terminal will be reused by tasks, press any key to close it.
```

Reviewed By: kimishpatel

Differential Revision: D34082609

fbshipit-source-id: 4bcbdb2d11dd4c3bc392010487dccd2270278222
(cherry picked from commit dd64eb386d)
This commit is contained in:
Pavithran Ramachandran 2022-02-16 08:54:24 -08:00 committed by PyTorch MergeBot
parent 5343cfe949
commit d79aec91f7

View File

@ -222,7 +222,7 @@ ska::flat_hash_map<int64_t, DebugInfoTuple> CallStackDebugInfoUnpickler::
{},
c10::parseType);
ska::flat_hash_map<int64_t, DebugInfoTuple> callstack_ptrs;
auto ivalues = std::move(*std::move(ival).toTuple()).elements();
const auto& ivalues = ival.toTupleRef().elements();
for (auto& val : ivalues) {
const auto& tup_elems = val.toTupleRef().elements();
TORCH_CHECK(