Skip to content

Commit 60b7d58

Browse files
factnntengqm
andauthored
Apply suggestions from code review
Co-authored-by: Qiming Teng <tengqm@outlook.com> Signed-off-by: Zang Peiyu <166481866+factnn@users.noreply.github.com>
1 parent 288c926 commit 60b7d58

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

benchmark/test_einsum_perf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def einsum_matmul_op(A, B):
3131

3232

3333
@pytest.mark.einsum
34-
def test_einsum_matmul_benchmark():
34+
def test_einsum_matmul():
3535
bench = EinsumMatmulBenchmark(
3636
input_fn=None,
3737
op_name="einsum_matmul",
@@ -58,7 +58,7 @@ def einsum_bmm_op(A, B):
5858

5959

6060
@pytest.mark.einsum
61-
def test_einsum_bmm_benchmark():
61+
def test_einsum_bmm():
6262
bench = EinsumBmmBenchmark(
6363
input_fn=None,
6464
op_name="einsum_bmm",

tests/test_einsum.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@pytest.mark.einsum
3232
@pytest.mark.parametrize("M, K, N", EINSUM_SHAPES["matmul"])
3333
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
34-
def test_accuracy_einsum_matmul(M, K, N, dtype):
34+
def test_einsum_matmul(M, K, N, dtype):
3535
inp1 = torch.randn((M, K), dtype=dtype, device=flag_gems.device)
3636
inp2 = torch.randn((K, N), dtype=dtype, device=flag_gems.device)
3737
ref_inp1 = to_reference(inp1, True)
@@ -45,7 +45,7 @@ def test_accuracy_einsum_matmul(M, K, N, dtype):
4545
@pytest.mark.einsum
4646
@pytest.mark.parametrize("B, M, K, N", EINSUM_SHAPES["bmm"])
4747
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
48-
def test_accuracy_einsum_bmm(B, M, K, N, dtype):
48+
def test_einsum_bmm(B, M, K, N, dtype):
4949
inp1 = torch.randn((B, M, K), dtype=dtype, device=flag_gems.device)
5050
inp2 = torch.randn((B, K, N), dtype=dtype, device=flag_gems.device)
5151
ref_inp1 = to_reference(inp1, True)
@@ -59,7 +59,7 @@ def test_accuracy_einsum_bmm(B, M, K, N, dtype):
5959
@pytest.mark.einsum
6060
@pytest.mark.parametrize("size", EINSUM_SHAPES["dot"])
6161
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
62-
def test_accuracy_einsum_dot(size, dtype):
62+
def test_einsum_dot(size, dtype):
6363
inp1 = torch.randn(size, dtype=dtype, device=flag_gems.device)
6464
inp2 = torch.randn(size, dtype=dtype, device=flag_gems.device)
6565
ref_inp1 = to_reference(inp1, True)
@@ -73,7 +73,7 @@ def test_accuracy_einsum_dot(size, dtype):
7373
@pytest.mark.einsum
7474
@pytest.mark.parametrize("M, N", EINSUM_SHAPES["outer"])
7575
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
76-
def test_accuracy_einsum_outer(M, N, dtype):
76+
def test_einsum_outer(M, N, dtype):
7777
inp1 = torch.randn(M, dtype=dtype, device=flag_gems.device)
7878
inp2 = torch.randn(N, dtype=dtype, device=flag_gems.device)
7979
ref_inp1 = to_reference(inp1, True)
@@ -87,7 +87,7 @@ def test_accuracy_einsum_outer(M, N, dtype):
8787
@pytest.mark.einsum
8888
@pytest.mark.parametrize("size", EINSUM_SHAPES["trace"])
8989
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
90-
def test_accuracy_einsum_trace(size, dtype):
90+
def test_einsum_trace(size, dtype):
9191
inp = torch.randn((size, size), dtype=dtype, device=flag_gems.device)
9292
ref_inp = to_reference(inp, True)
9393
ref_out = torch.einsum("ii->", ref_inp)
@@ -99,7 +99,7 @@ def test_accuracy_einsum_trace(size, dtype):
9999
@pytest.mark.einsum
100100
@pytest.mark.parametrize("size", EINSUM_SHAPES["trace"])
101101
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
102-
def test_accuracy_einsum_diagonal(size, dtype):
102+
def test_einsum_diagonal(size, dtype):
103103
inp = torch.randn((size, size), dtype=dtype, device=flag_gems.device)
104104
ref_inp = to_reference(inp, True)
105105
ref_out = torch.einsum("ii->i", ref_inp)
@@ -111,7 +111,7 @@ def test_accuracy_einsum_diagonal(size, dtype):
111111
@pytest.mark.einsum
112112
@pytest.mark.parametrize("shape", EINSUM_SHAPES["transpose"])
113113
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
114-
def test_accuracy_einsum_transpose(shape, dtype):
114+
def test_einsum_transpose(shape, dtype):
115115
inp = torch.randn(shape, dtype=dtype, device=flag_gems.device)
116116
ref_inp = to_reference(inp, True)
117117
if len(shape) == 2:
@@ -128,7 +128,7 @@ def test_accuracy_einsum_transpose(shape, dtype):
128128
@pytest.mark.einsum
129129
@pytest.mark.parametrize("shape", EINSUM_SHAPES["sum"])
130130
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
131-
def test_accuracy_einsum_sum_all(shape, dtype):
131+
def test_einsum_sum_all(shape, dtype):
132132
inp = torch.randn(shape, dtype=dtype, device=flag_gems.device)
133133
ref_inp = to_reference(inp, True)
134134
ref_out = torch.einsum("ijk->", ref_inp)
@@ -141,7 +141,7 @@ def test_accuracy_einsum_sum_all(shape, dtype):
141141
@pytest.mark.einsum
142142
@pytest.mark.parametrize("shape", EINSUM_SHAPES["sum"])
143143
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
144-
def test_accuracy_einsum_sum_dim(shape, dtype):
144+
def test_einsum_sum_dim(shape, dtype):
145145
inp = torch.randn(shape, dtype=dtype, device=flag_gems.device)
146146
ref_inp = to_reference(inp, True)
147147
ref_out = torch.einsum("ijk->j", ref_inp)
@@ -153,7 +153,7 @@ def test_accuracy_einsum_sum_dim(shape, dtype):
153153

154154
@pytest.mark.einsum
155155
@pytest.mark.parametrize("dtype", FLOAT_DTYPES)
156-
def test_accuracy_einsum_ellipsis(dtype):
156+
def test_einsum_ellipsis(dtype):
157157
shape1 = (2, 3, 32, 64)
158158
shape2 = (2, 3, 64, 128)
159159
inp1 = torch.randn(shape1, dtype=dtype, device=flag_gems.device)

0 commit comments

Comments
 (0)