[PyTorch] Avoid no-op shared_ptr dtor when constructing tuple (#69337)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69337
See note in code.
ghstack-source-id: 144657751
Test Plan:
Ran PyTorchFeatureConversionBenchmark 5x before/after:
```
swolchok@devbig032 ~/f/fbcode> for x in (seq 5); sudo scripts/bertrand/noise/denoise.sh /tmp/pytorch_feature_conversion_benchmark.Dec2CacheTupleTypes ; end (pytorch-ort-bert)
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.39us 418.75K
PyTorchFeatureConversionIdListBenchmark 3.59us 278.91K
PyTorchFeatureConversionIdScoreListBenchmark 5.01us 199.51K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.42us 413.80K
PyTorchFeatureConversionIdListBenchmark 3.56us 280.60K
PyTorchFeatureConversionIdScoreListBenchmark 5.05us 198.15K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.41us 414.25K
PyTorchFeatureConversionIdListBenchmark 3.55us 281.59K
PyTorchFeatureConversionIdScoreListBenchmark 5.02us 199.09K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.39us 417.68K
PyTorchFeatureConversionIdListBenchmark 3.55us 281.65K
PyTorchFeatureConversionIdScoreListBenchmark 5.05us 198.06K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.39us 417.54K
PyTorchFeatureConversionIdListBenchmark 3.56us 281.03K
PyTorchFeatureConversionIdScoreListBenchmark 5.05us 198.13K
============================================================================
swolchok@devbig032 ~/f/fbcode> for x in (seq 5); sudo scripts/bertrand/noise/denoise.sh /tmp/pytorch_feature_conversion_benchmark.Dec2TupleConstruction ; end (pytorch-ort-bert)
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.38us 420.38K
PyTorchFeatureConversionIdListBenchmark 3.53us 282.90K
PyTorchFeatureConversionIdScoreListBenchmark 4.99us 200.41K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.37us 421.54K
PyTorchFeatureConversionIdListBenchmark 3.54us 282.27K
PyTorchFeatureConversionIdScoreListBenchmark 4.99us 200.28K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.38us 420.99K
PyTorchFeatureConversionIdListBenchmark 3.56us 280.56K
PyTorchFeatureConversionIdScoreListBenchmark 5.08us 196.91K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.37us 421.48K
PyTorchFeatureConversionIdListBenchmark 3.54us 282.87K
PyTorchFeatureConversionIdScoreListBenchmark 5.00us 199.88K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.38us 419.69K
PyTorchFeatureConversionIdListBenchmark 3.56us 280.68K
PyTorchFeatureConversionIdScoreListBenchmark 4.97us 201.23K
============================================================================
```
Looks like maybe around 1% faster?
Reviewed By: hlu1
Differential Revision: D32817592
fbshipit-source-id: 4b015dc993b26a92e45a3673e14fde32105a34fa