Skip to content

Commit bb715a9

Browse files
authored
Merge branch 'master' into split-reduction-bm
Signed-off-by: Qiming Teng <tengqm@outlook.com>
2 parents a27f872 + 30f1962 commit bb715a9

6 files changed

Lines changed: 95 additions & 70 deletions

File tree

benchmark/test_bernoulli.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
import torch
3+
4+
from . import attri_util as attr_utils
5+
from . import performance_utils as utils
6+
7+
8+
def input_fn(shape, cur_dtype, device):
9+
self = torch.randn(shape, dtype=cur_dtype, device=device)
10+
p = 0.5
11+
yield self, p
12+
13+
14+
@pytest.mark.bernoulli_
15+
def test_bernoulli_inplace():
16+
bench = utils.GenericBenchmark(
17+
op_name="bernoulli_",
18+
input_fn=input_fn,
19+
torch_op=torch.Tensor.bernoulli_,
20+
dtypes=attr_utils.FLOAT_DTYPES,
21+
)
22+
bench.run()

benchmark/test_distribution_perf.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

benchmark/test_exponential.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
import torch
3+
4+
from . import attri_util as attr_utils
5+
from . import performance_utils as utils
6+
7+
8+
@pytest.mark.exponential_
9+
def test_exponential_inplace():
10+
bench = utils.GenericBenchmark(
11+
op_name="exponential_",
12+
input_fn=utils.unary_input_fn,
13+
torch_op=torch.Tensor.exponential_,
14+
dtypes=attr_utils.FLOAT_DTYPES,
15+
)
16+
bench.run()

benchmark/test_normal.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
import torch
3+
4+
from . import attri_util as attr_utils
5+
from . import performance_utils as utils
6+
7+
8+
def normal_input_fn(shape, cur_dtype, device):
9+
loc = torch.full(shape, fill_value=3.0, dtype=cur_dtype, device=device)
10+
scale = torch.full(shape, fill_value=10.0, dtype=cur_dtype, device=device)
11+
yield loc, scale
12+
13+
14+
@pytest.mark.normal
15+
def test_normal():
16+
bench = utils.GenericBenchmark(
17+
input_fn=normal_input_fn,
18+
op_name="normal",
19+
torch_op=torch.normal,
20+
dtypes=attr_utils.FLOAT_DTYPES,
21+
)
22+
bench.run()
23+
24+
25+
def normal_inplace_input_fn(shape, cur_dtype, device):
26+
self = torch.randn(shape, dtype=cur_dtype, device=device)
27+
loc = 3.0
28+
scale = 10.0
29+
yield self, loc, scale
30+
31+
32+
@pytest.mark.normal_
33+
def test_normal_inplace():
34+
bench = utils.GenericBenchmark(
35+
input_fn=normal_inplace_input_fn,
36+
op_name="normal_",
37+
torch_op=torch.Tensor.normal_,
38+
dtypes=attr_utils.FLOAT_DTYPES,
39+
)
40+
bench.run()

benchmark/test_uniform.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
import torch
3+
4+
from . import attri_util as attr_utils
5+
from . import performance_utils as utils
6+
7+
8+
@pytest.mark.uniform_
9+
def test_uniform_inplace():
10+
bench = utils.GenericBenchmark(
11+
input_fn=utils.unary_input_fn,
12+
op_name="uniform_",
13+
torch_op=torch.Tensor.uniform_,
14+
dtypes=attr_utils.FLOAT_DTYPES,
15+
)
16+
bench.run()

tools/test-op.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ done
9090
# Run benchmark test if necessary
9191
for item in "${PERF_TEST_CASES[@]}"; do
9292
echo "Running benchmark tests for ${item}"
93-
echo "pytest -s --level core --record log ${item}"
93+
echo "pytest -s ${item} --level core --record log"
9494
pytest -s ${item} --level core --record log
9595
done
9696

0 commit comments

Comments
 (0)