Skip to content

Commit b8855e7

Browse files
jainapurvapytorchmergebot
authored andcommitted
Add conv ops to operator microbenchmark (pytorch#166331)
Adding `conv` (conv1d, conv2d, conv3d) to the list of operator microbenchmarks run in the CI script (`.ci/pytorch/test.sh`), ensuring convolution operators are now benchmarked alongside existing ones. Pull Request resolved: pytorch#166331 Approved by: https://github.com/huydhn, https://github.com/jbschlosser
1 parent 6725ee8 commit b8855e7

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.ci/pytorch/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ test_operator_microbenchmark() {
16531653

16541654
cd "${TEST_DIR}"/benchmarks/operator_benchmark
16551655

1656-
for OP_BENCHMARK_TESTS in matmul mm addmm bmm; do
1656+
for OP_BENCHMARK_TESTS in matmul mm addmm bmm conv; do
16571657
$TASKSET python -m pt.${OP_BENCHMARK_TESTS}_test --tag-filter long \
16581658
--output-json-for-dashboard "${TEST_REPORTS_DIR}/operator_microbenchmark_${OP_BENCHMARK_TESTS}_compile.json" \
16591659
--benchmark-name "PyTorch operator microbenchmark" --use-compile

benchmarks/operator_benchmark/pt/configs.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def remove_cuda(config_list):
1111
return [config for config in config_list if cuda_config not in config]
1212

1313

14+
def remove_cpu(config_list):
15+
cpu_config = {"device": "cpu"}
16+
return [config for config in config_list if cpu_config not in config]
17+
18+
1419
# Configs for conv-1d ops
1520
conv_1d_configs_short = op_bench.config_list(
1621
attr_names=["IC", "OC", "kernel", "stride", "N", "L"],
@@ -127,6 +132,18 @@ def remove_cuda(config_list):
127132
},
128133
tags=["short"],
129134
)
135+
conv_3d_configs_long = op_bench.cross_product_configs(
136+
IC=[16, 32],
137+
OC=[32, 64],
138+
kernel=[3, 5],
139+
stride=[1, 2],
140+
N=[1],
141+
D=[128],
142+
H=[128],
143+
W=[128],
144+
device=["cpu", "cuda"],
145+
tags=["long"],
146+
)
130147

131148
linear_configs_short = op_bench.config_list(
132149
attr_names=["N", "IN", "OUT"],

benchmarks/operator_benchmark/pt/conv_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def forward(self, input):
3838
op_bench.generate_pt_test(
3939
configs.conv_1d_configs_short + configs.conv_1d_configs_long, Conv1dBenchmark
4040
)
41+
op_bench.generate_pt_gradient_test(
42+
configs.remove_cpu(configs.conv_1d_configs_short + configs.conv_1d_configs_long),
43+
Conv1dBenchmark,
44+
)
4145

4246

4347
if not torch.backends.mkldnn.is_acl_available():
@@ -103,6 +107,20 @@ def forward(self, input):
103107
configs.conv_2d_pw_configs_short + configs.conv_2d_pw_configs_long,
104108
Conv2dPointwiseBenchmark,
105109
)
110+
op_bench.generate_pt_gradient_test(
111+
configs.remove_cpu(configs.conv_2d_configs_short + configs.conv_2d_configs_long),
112+
Conv2dBenchmark,
113+
)
114+
op_bench.generate_pt_gradient_test(
115+
configs.remove_cpu(configs.conv_2d_configs_short + configs.conv_2d_configs_long),
116+
ConvTranspose2dBenchmark,
117+
)
118+
op_bench.generate_pt_gradient_test(
119+
configs.remove_cpu(
120+
configs.conv_2d_pw_configs_short + configs.conv_2d_pw_configs_long
121+
),
122+
Conv2dPointwiseBenchmark,
123+
)
106124

107125

108126
"""
@@ -134,6 +152,12 @@ def forward(self, input):
134152

135153
op_bench.generate_pt_test(configs.conv_3d_configs_short, Conv3dBenchmark)
136154
op_bench.generate_pt_test(configs.conv_3d_configs_short, ConvTranspose3dBenchmark)
155+
op_bench.generate_pt_gradient_test(
156+
configs.remove_cpu(configs.conv_3d_configs_long), Conv3dBenchmark
157+
)
158+
op_bench.generate_pt_gradient_test(
159+
configs.remove_cpu(configs.conv_3d_configs_long), ConvTranspose3dBenchmark
160+
)
137161

138162

139163
if __name__ == "__main__":

0 commit comments

Comments
 (0)