Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 02d098f

Browse files
committed
Conv ops to check
1 parent 3e6e8d9 commit 02d098f

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

dl_bench/cli/launcher.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from dl_bench.mlp import MlpBenchmark
77
from dl_bench.cnn import CnnBenchmark
88
from dl_bench.llm import LlmBenchmark
9+
from dl_bench.ops import OpsBenchmark
910
from dl_bench.mlp_basic import MlpBasicBenchmark
1011
from dl_bench.report.report import BenchmarkDb
1112
from dl_bench.utils import Backend
@@ -16,6 +17,7 @@
1617
"mlp": MlpBenchmark,
1718
"cnn": CnnBenchmark,
1819
"llm": LlmBenchmark,
20+
"ops": OpsBenchmark,
1921
}
2022

2123

dl_bench/ops.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from dl_bench.utils import Benchmark, RandomInfDataset
2+
3+
import torch
4+
5+
class Conv2dNoPaddingModule(torch.nn.Module):
6+
7+
def __init__(self):
8+
super().__init__()
9+
torch.manual_seed(0)
10+
self.conv = torch.nn.Conv2d(2, 10, 3, bias=False)
11+
self.train(False)
12+
13+
def forward(self, x):
14+
return self.conv(x)
15+
16+
def get_op(name):
17+
18+
name2model = {
19+
"conv210": Conv2dNoPaddingModule,
20+
}
21+
if name in name2model:
22+
return name2model[name]()
23+
else:
24+
raise ValueError(f"Unknown name {name}")
25+
26+
27+
class OpsBenchmark(Benchmark):
28+
def __init__(self, params) -> None:
29+
batch_size = int(params.get("batch_size", 1024))
30+
31+
in_shape = (2, 10, 20)
32+
min_batches = 10
33+
DATASET_SIZE = max(10_240, batch_size * min_batches)
34+
dataset = RandomInfDataset(DATASET_SIZE, in_shape)
35+
36+
name = params.get("name", "conv210")
37+
net = get_op(name=name)
38+
39+
super().__init__(
40+
net=net, in_shape=in_shape, dataset=dataset, batch_size=batch_size
41+
)

ops.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
export ONEDNN_VERBOSE=0
6+
7+
if [[ -z "${DL_BENCH_ARGS}" ]]; then
8+
echo "Please, provide DL_BENCH_ARGS environment variable"
9+
exit 1
10+
fi
11+
12+
CNNS=(conv210)
13+
for BS in 0001 0032 0128
14+
do
15+
for name in "${CNNS[@]}"
16+
do
17+
echo "Benchmark $name"
18+
benchmark-run -b ops -p "name='${name}',batch_size='$BS'" --benchmark_desc "${name}_bs$BS" ${DL_BENCH_ARGS} || echo Failed
19+
done
20+
done

0 commit comments

Comments
 (0)