Skip to content

Commit 8975b32

Browse files
authored
Fix nits in benchmark files (#2786)
1 parent 3b840c2 commit 8975b32

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

benchmark/test_act_quant.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import flag_gems
77
from flag_gems.utils.device_info import get_device_capability
88

9-
from .performance_utils import GenericBenchmark
9+
from . import base
1010

1111
M = [1, 40, 164, 512, 3454, 12027, 38594]
1212
N = [128, 896, 2048, 8192]
@@ -74,11 +74,11 @@ def torch_act_quant(
7474
return y, s
7575

7676

77-
class ActQuantBenchmark(GenericBenchmark):
77+
class ActQuantBenchmark(base.GenericBenchmark):
7878
# Only 2D shapes make sense for act_quant
7979
def set_more_shapes(self):
8080
self.shapes = SHAPES
81-
return None
81+
return []
8282

8383

8484
@pytest.mark.act_quant
@@ -97,7 +97,7 @@ def input_fn(shape, dtype, device):
9797
op_name="act_quant",
9898
torch_op=torch_act_quant,
9999
input_fn=input_fn,
100-
dtypes=[torch.bfloat16],
101100
gems_op=flag_gems.act_quant_triton,
101+
dtypes=[torch.bfloat16],
102102
)
103103
bench.run()

benchmark/test_avg_pool3d_perf.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import pytest
44
import torch
55

6-
from benchmark.attri_util import FLOAT_DTYPES, BenchLevel
7-
from benchmark.performance_utils import Config, GenericBenchmark, generate_tensor_input
6+
from . import base, consts, utils
87

98

109
def avg_pool3d_input_fn(shape, dtype, device):
11-
inp = generate_tensor_input(shape, dtype, device)
10+
inp = utils.generate_tensor_input(shape, dtype, device)
1211
# Common case
1312
yield inp, {
1413
"kernel_size": 3,
@@ -18,7 +17,7 @@ def avg_pool3d_input_fn(shape, dtype, device):
1817
"count_include_pad": True,
1918
"divisor_override": None,
2019
}
21-
if Config.bench_level == BenchLevel.COMPREHENSIVE:
20+
if base.Config.bench_level == consts.BenchLevel.COMPREHENSIVE:
2221
# With count_include_pad=False
2322
yield inp, {
2423
"kernel_size": 3,
@@ -49,8 +48,8 @@ def avg_pool3d_input_fn(shape, dtype, device):
4948
}
5049

5150

52-
class AvgPool3dBenchmark(GenericBenchmark):
53-
def get_input_iter(self, cur_dtype) -> Generator:
51+
class AvgPool3dBenchmark(base.GenericBenchmark):
52+
def get_input_iter(self, dtype) -> Generator:
5453
shapes_5d = [
5554
(4, 3, 16, 56, 56),
5655
(8, 64, 8, 28, 28),
@@ -59,7 +58,7 @@ def get_input_iter(self, cur_dtype) -> Generator:
5958
]
6059

6160
for shape in shapes_5d:
62-
yield from self.input_fn(shape, cur_dtype, self.device)
61+
yield from self.input_fn(shape, dtype, self.device)
6362

6463

6564
@pytest.mark.avg_pool3d
@@ -68,18 +67,18 @@ def test_perf_avg_pool3d():
6867
input_fn=avg_pool3d_input_fn,
6968
op_name="avg_pool3d",
7069
torch_op=torch.ops.aten.avg_pool3d,
71-
dtypes=FLOAT_DTYPES,
70+
dtypes=consts.FLOAT_DTYPES,
7271
)
7372
bench.run()
7473

7574

76-
@pytest.mark.avg_pool3d
75+
@pytest.mark.avg_pool3d_backward
7776
def test_perf_avg_pool3d_backward():
7877
bench = AvgPool3dBenchmark(
7978
input_fn=avg_pool3d_input_fn,
8079
op_name="avg_pool3d",
8180
torch_op=torch.ops.aten.avg_pool3d,
82-
dtypes=FLOAT_DTYPES,
81+
dtypes=consts.FLOAT_DTYPES,
8382
is_backward=True,
8483
)
8584
bench.run()

0 commit comments

Comments
 (0)