Skip to content

Commit aaf4f55

Browse files
authored
Continue renaming benchmark modules (flagos-ai#2719)
1 parent cbfe758 commit aaf4f55

45 files changed

Lines changed: 121 additions & 174 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmark/test_safe_softmax.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
import pytest
44
import torch
55

6-
from . import attri_util as attr_utils
7-
from . import performance_utils as utils
6+
from . import base, consts, utils
87

98

10-
class SafeSoftmaxBenchmark(utils.Benchmark):
11-
def get_input_iter(self, cur_dtype) -> Generator:
9+
class SafeSoftmaxBenchmark(base.Benchmark):
10+
def get_input_iter(self, dtype) -> Generator:
1211
for shape in self.shapes:
13-
inp = utils.generate_tensor_input(shape, cur_dtype, self.device)
12+
inp = utils.generate_tensor_input(shape, dtype, self.device)
1413
yield inp, -1, None
1514

1615

@@ -19,7 +18,7 @@ def test_safe_softmax():
1918
bench = SafeSoftmaxBenchmark(
2019
op_name="_safe_softmax",
2120
torch_op=torch.ops.aten._safe_softmax,
22-
dtypes=attr_utils.FLOAT_DTYPES,
21+
dtypes=consts.FLOAT_DTYPES,
2322
)
2423

2524
bench.run()

benchmark/test_scaled_dot_product_attention.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@
33

44
import flag_gems
55

6-
from .performance_utils import GenericBenchmark
6+
from . import base
77

88

9-
class AttentionBenchmark(GenericBenchmark):
10-
"""
11-
benchmark for attention
12-
"""
13-
9+
class AttentionBenchmark(base.GenericBenchmark):
1410
def set_more_shapes(self):
1511
# self.shapes is a list of tuples, each containing three elements:
1612
# (batch, num_heads, seq_len, head_size).
17-
return None
13+
return []
1814

1915

2016
@pytest.mark.scaled_dot_product_attention
2117
@pytest.mark.parametrize("dropout_p", [0.0])
2218
@pytest.mark.parametrize("is_causal", [True, False])
23-
def test_perf_scaled_dot_product_attention(monkeypatch, dropout_p, is_causal):
19+
def test_scaled_dot_product_attention(monkeypatch, dropout_p, is_causal):
2420
if flag_gems.vendor_name == "hygon":
2521
monkeypatch.setenv("TRITON_HIP_USE_NEW_STREAM_PIPELINE", "0")
2622

benchmark/test_scaled_softmax.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import flag_gems
77

8-
from . import performance_utils as base
9-
from . import utils
8+
from . import base, utils
109

1110
try:
1211
from transformer_engine.pytorch import cpp_extensions as tex

benchmark/test_scatter_add.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import flag_gems
55
from flag_gems.utils import shape_utils
66

7-
from . import attri_util as attr_utils
8-
from . import performance_utils as utils
7+
from . import base, consts
98

109

11-
class TensorSelectBenchmark(utils.GenericBenchmark2DOnly):
10+
class TensorSelectBenchmark(base.GenericBenchmark2DOnly):
1211
def set_more_metrics(self):
1312
return ["gbps"]
1413

@@ -62,6 +61,6 @@ def scatter_input_fn(shape, dtype, device):
6261
torch_op=torch.Tensor.scatter_add_,
6362
input_fn=scatter_input_fn,
6463
get_gbps=_get_gbps,
65-
dtypes=attr_utils.FLOAT_DTYPES,
64+
dtypes=consts.FLOAT_DTYPES,
6665
)
6766
bench.run()

benchmark/test_scatter_reduce.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import flag_gems
55
from flag_gems.utils import shape_utils
66

7-
from . import performance_utils as utils
7+
from . import base
88

99

10-
class TensorSelectBenchmark(utils.GenericBenchmark2DOnly):
10+
class TensorSelectBenchmark(base.GenericBenchmark2DOnly):
1111
def set_more_metrics(self):
1212
return ["gbps"]
1313

benchmark/test_scatter_src.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import flag_gems
55
from flag_gems.utils import shape_utils
66

7-
from . import attri_util as attr_utils
8-
from . import performance_utils as utils
7+
from . import base, consts
98

109

11-
class TensorSelectBenchmark(utils.GenericBenchmark2DOnly):
10+
class TensorSelectBenchmark(base.GenericBenchmark2DOnly):
1211
def set_more_metrics(self):
1312
return ["gbps"]
1413

@@ -85,7 +84,7 @@ def test_scatter_src():
8584
torch_op=torch.scatter,
8685
input_fn=scatter_input_fn_factory(),
8786
get_gbps=gather_scatter_gbps,
88-
dtypes=attr_utils.FLOAT_DTYPES,
87+
dtypes=consts.FLOAT_DTYPES,
8988
)
9089
bench.run()
9190

@@ -97,7 +96,7 @@ def test_scatter_src_inplace():
9796
torch_op=torch.Tensor.scatter_,
9897
input_fn=scatter_inplace_input_fn_factory(),
9998
get_gbps=gather_scatter_gbps,
100-
dtypes=attr_utils.FLOAT_DTYPES,
99+
dtypes=consts.FLOAT_DTYPES,
101100
is_inplace=True,
102101
)
103102

benchmark/test_select_scatter.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import flag_gems
77
from flag_gems.utils import shape_utils
88

9-
from . import attri_util as attr_utils
10-
from . import performance_utils as utils
9+
from . import base, consts
1110

1211

13-
class TensorSelectBenchmark(utils.GenericBenchmark2DOnly):
12+
class TensorSelectBenchmark(base.GenericBenchmark2DOnly):
1413
def set_more_metrics(self):
1514
return ["gbps"]
1615

@@ -55,7 +54,7 @@ def test_select_scatter():
5554
op_name="select_scatter",
5655
torch_op=torch.select_scatter,
5756
input_fn=_input_fn,
58-
dtypes=attr_utils.FLOAT_DTYPES,
57+
dtypes=consts.FLOAT_DTYPES,
5958
get_gbps=_get_gbps,
6059
)
6160

benchmark/test_selu.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import pytest
22
import torch
33

4-
from . import attri_util as attrs
5-
from . import performance_utils as base
4+
from . import base, consts
65

76

87
@pytest.mark.selu
98
def test_selu():
109
bench = base.UnaryPointwiseBenchmark(
11-
op_name="selu", torch_op=torch.nn.functional.selu, dtypes=attrs.FLOAT_DTYPES
10+
op_name="selu", torch_op=torch.nn.functional.selu, dtypes=consts.FLOAT_DTYPES
1211
)
1312
bench.run()
1413

@@ -18,7 +17,7 @@ def test_selu_inplace():
1817
bench = base.UnaryPointwiseBenchmark(
1918
op_name="selu_",
2019
torch_op=torch.ops.aten.selu_,
21-
dtypes=attrs.FLOAT_DTYPES,
20+
dtypes=consts.FLOAT_DTYPES,
2221
is_inplace=True,
2322
)
2423
bench.run()

benchmark/test_sgn.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import pytest
22

3-
from . import attri_util as attrs
4-
from . import performance_utils as base
3+
from . import base, consts
54

65

76
@pytest.mark.sgn_
87
def test_sgn_inplace():
98
bench = base.UnaryPointwiseBenchmark(
109
op_name="atan_",
1110
torch_op=lambda a: a.sgn_(),
12-
dtypes=attrs.FLOAT_DTYPES,
11+
dtypes=consts.FLOAT_DTYPES,
1312
is_inplace=True,
1413
)
1514
bench.run()

benchmark/test_sigmoid.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import pytest
22
import torch
33

4-
from . import attri_util as attrs
5-
from . import performance_utils as base
4+
from . import base, consts
65

76

87
@pytest.mark.sigmoid
98
def test_sigmoid():
109
bench = base.UnaryPointwiseBenchmark(
11-
op_name="sigmoid", torch_op=torch.sigmoid, dtypes=attrs.FLOAT_DTYPES
10+
op_name="sigmoid", torch_op=torch.sigmoid, dtypes=consts.FLOAT_DTYPES
1211
)
1312
bench.run()
1413

@@ -18,7 +17,7 @@ def test_sigmoid_inplace():
1817
bench = base.UnaryPointwiseBenchmark(
1918
op_name="sigmoid_",
2019
torch_op=torch.sigmoid_,
21-
dtypes=attrs.FLOAT_DTYPES,
20+
dtypes=consts.FLOAT_DTYPES,
2221
is_inplace=True,
2322
)
2423
bench.run()

0 commit comments

Comments
 (0)