Caffe2 Concat operator benchmark (#50449)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50449
Port caffe2 operator benchmark from torch.cat to caffe2 concat to measure the difference in performance.
previous diff abandoned to rerun github CI tests. D25738076
Test Plan:
Tested on devbig by running both pt and c2 benchmarks. Compiled with mode/opt
Inputs:
```
size, number of inputs, cat dimension, device
----------------------------------------------------
(1, 1, 1), N: 2, dim: 0, device: cpu
(512, 512, 2), N: 2, dim: 1, device: cpu
(128, 1024, 2), N: 2, dim: 1, device: cpu
(1024, 1024, 2), N: 2, dim: 0, device: cpu
(1025, 1023, 2), N: 2, dim: 1, device: cpu
(1024, 1024, 2), N: 2, dim: 2, device: cpu
[<function <lambda> at 0x7f922718e8c0>, 111, 65], N: 5, dim: 0, device: cpu
[96, <function <lambda> at 0x7f9226dad710>, 64], N: 5, dim: 1, device: cpu
[128, 64, <function <lambda> at 0x7f91a3625ef0>], N: 5, dim: 2, device: cpu
[<function <lambda> at 0x7f91a3625f80>, 32, 64], N: 50, dim: 0, device: cpu
[32, <function <lambda> at 0x7f91a3621050>, 64], N: 50, dim: 1, device: cpu
[33, 65, <function <lambda> at 0x7f91a36210e0>], N: 50, dim: 2, device: cpu
(64, 32, 4, 16, 32), N: 2, dim: 2, device: cpu
(16, 32, 4, 16, 32), N: 8, dim: 2, device: cpu
(9, 31, 5, 15, 33), N: 17, dim: 4, device: cpu
[<function <lambda> at 0x7f91a3621170>], N: 100, dim: 0, device: cpu
[<function <lambda> at 0x7f91a3621200>], N: 1000, dim: 0, device: cpu
[<function <lambda> at 0x7f91a3621290>], N: 2000, dim: 0, device: cpu
[<function <lambda> at 0x7f91a3621320>], N: 3000, dim: 0, device: cpu
```
```
pytorch: MKL_NUM_THREADS=1 OMP_NUM_THREADS=1 buck-out/gen/caffe2/benchmarks/operator_benchmark/pt/cat_test.par --tag_filter=all
caffe2: MKL_NUM_THREADS=1 OMP_NUM_THREADS=1 buck-out/gen/caffe2/benchmarks/operator_benchmark/c2/concat_test.par --tag_filter=all
```
```
Metric: Forward Execution Time (us)
pytorch | caffe2
--------------------------------
4.066 | 0.312
351.507 | 584.033
184.649 | 292.157
9482.895 | 6845.112
9558.988 | 6847.511
13730.016 | 14118.505
6324.371 | 4840.883
4613.497 | 3702.213
7504.718 | 7889.751
9882.978 | 7364.350
10087.076 | 7483.178
16849.556 | 18092.295
19181.075 | 13363.742
19296.508 | 13466.863
34157.449 | 56320.073
176.483 | 267.106
322.247 | 352.782
480.064 | 460.214
607.381 | 476.908
```
Reviewed By: hlu1
Differential Revision: D25890595
fbshipit-source-id: f53e125c0680bc2ebf722d1da5ec964bec585fdd
Author
Marat Subkhankulov