[PyTorch] Remove the List/Dict move operations (#69370)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69370
These operations are likely slower than copying because they perform a heap allocation and reference count bump, whereas copying is just a reference count bump. This diff is up to see 1) if anything breaks 2) if we can measure any improvements.
ghstack-source-id: 146468907
Test Plan:
Ran //sigrid/lib/features/tests:pytorch_feature_conversion_benchmark before/after
```
swolchok@devbig032 ~/f/fbcode> for x in (seq 5); sudo scripts/bertrand/noise/denoise.sh /tmp/pytorch_feature_conversion_benchmark.Dec7Stable ; end
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.43us 410.68K
PyTorchFeatureConversionIdListBenchmark 3.74us 267.65K
PyTorchFeatureConversionIdScoreListBenchmark 4.98us 200.81K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.43us 410.75K
PyTorchFeatureConversionIdListBenchmark 3.75us 266.92K
PyTorchFeatureConversionIdScoreListBenchmark 4.98us 200.97K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.44us 410.43K
PyTorchFeatureConversionIdListBenchmark 3.75us 266.75K
PyTorchFeatureConversionIdScoreListBenchmark 5.04us 198.23K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.43us 411.17K
PyTorchFeatureConversionIdListBenchmark 3.74us 267.60K
PyTorchFeatureConversionIdScoreListBenchmark 5.00us 199.84K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.44us 410.19K
PyTorchFeatureConversionIdListBenchmark 3.73us 267.89K
PyTorchFeatureConversionIdScoreListBenchmark 4.96us 201.46K
============================================================================
swolchok@devbig032 ~/f/fbcode> for x in (seq 5); sudo scripts/bertrand/noise/denoise.sh /tmp/pytorch_feature_conversion_benchmark.Dec8RemoveListAndDictMove ; end
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.47us 405.12K
PyTorchFeatureConversionIdListBenchmark 3.60us 278.07K
PyTorchFeatureConversionIdScoreListBenchmark 4.87us 205.44K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.45us 407.39K
PyTorchFeatureConversionIdListBenchmark 3.63us 275.56K
PyTorchFeatureConversionIdScoreListBenchmark 4.95us 202.17K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.47us 405.49K
PyTorchFeatureConversionIdListBenchmark 3.63us 275.58K
PyTorchFeatureConversionIdScoreListBenchmark 4.88us 205.05K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.52us 396.13K
PyTorchFeatureConversionIdListBenchmark 3.59us 278.29K
PyTorchFeatureConversionIdScoreListBenchmark 4.88us 204.94K
============================================================================
============================================================================
sigrid/lib/features/tests/PyTorchFeatureConversionBenchmark.cpprelative time/iter iters/s
============================================================================
PyTorchFeatureConversionDenseBenchmark 2.46us 406.77K
PyTorchFeatureConversionIdListBenchmark 3.62us 276.17K
PyTorchFeatureConversionIdScoreListBenchmark 4.92us 203.07K
============================================================================
```
Reviewed By: suo, hlu1
Differential Revision: D32836701
fbshipit-source-id: 6e1c3d81f1b4ee13156320263dac17f5256c1462