Skip to content

Commit ad974b1

Browse files
committedNov 23, 2021
max_pool3d bench 52828
1 parent 6fc4ee3 commit ad974b1

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
 

‎max-pool3d-bench-52828/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pkl

‎max-pool3d-bench-52828/52211.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import torch
2+
3+
x = torch.randn(70, 32, 100, 100, 100, dtype=torch.half, device='cuda')
4+
5+
y = torch.nn.functional.max_pool3d(x, 5)
6+
7+
torch.cuda.synchronize()

‎max-pool3d-bench-52828/b.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import torch
2+
import torch.utils.benchmark as benchmark
3+
import pickle
4+
5+
fuzzer = benchmark.Fuzzer(parameters=[
6+
benchmark.FuzzedParameter('n', minval=4, maxval=16, distribution='uniform'),
7+
benchmark.FuzzedParameter('c', minval=4, maxval=256, distribution='uniform'),
8+
benchmark.FuzzedParameter('d', minval=8, maxval=256, distribution='uniform'),
9+
benchmark.FuzzedParameter('h', minval=8, maxval=256, distribution='uniform'),
10+
benchmark.FuzzedParameter('w', minval=8, maxval=256, distribution='uniform'),
11+
],
12+
tensors=[
13+
benchmark.FuzzedTensor('x',
14+
size='ncdhw',
15+
min_elements=12,
16+
max_elements=10000000,
17+
cuda=True,
18+
dtype=torch.half,
19+
max_allocation_bytes=1_000_000_000)
20+
],
21+
seed=42)
22+
23+
res = []
24+
25+
for kernel_size in [2, 3, 5]:
26+
for tensors, tensor_params, params in fuzzer.take(20):
27+
sub_label = str(tensors['x'].size())
28+
res.append(
29+
benchmark.Timer(stmt=f'torch.nn.functional.max_pool3d(x, {kernel_size})',
30+
setup='',
31+
globals=tensors,
32+
label=f'max_pool3d, {kernel_size=}',
33+
sub_label=sub_label,
34+
description=f'{torch.__version__}').blocked_autorange(min_run_time=0.1))
35+
36+
torch_ver = str(torch.__version__)
37+
torch_git_ver = torch_ver[torch_ver.index('+') + 1:]
38+
39+
with open(f'{torch_git_ver}.pkl', 'wb') as f:
40+
pickle.dump(res, f)
41+
42+
compare = benchmark.Compare(res)
43+
# compare.colorize()
44+
compare.print()

‎max-pool3d-bench-52828/c.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import torch.utils.benchmark as benchmark
2+
import glob
3+
import pickle
4+
5+
res = []
6+
7+
for pkl in glob.glob('./*.pkl'):
8+
with open(pkl, 'rb') as f:
9+
res += pickle.load(f)
10+
11+
compare = benchmark.Compare(res)
12+
compare.print()

0 commit comments

Comments
 (0)
Please sign in to comment.