Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions benchmark/test_addcdiv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
import torch

from . import attri_util as attrs
from . import performance_utils as base


def _input_fn(shape, cur_dtype, device):
inp1 = base.generate_tensor_input(shape, cur_dtype, device)
inp2 = base.generate_tensor_input(shape, cur_dtype, device)
inp3 = base.generate_tensor_input(shape, cur_dtype, device)

yield inp1, inp2, inp3, {"value": 0.5}


@pytest.mark.addcdiv
def test_addcdiv():
bench = base.GenericBenchmark(
op_name="addcdiv",
input_fn=_input_fn,
torch_op=torch.addcdiv,
dtypes=attrs.FLOAT_DTYPES,
)
bench.run()
24 changes: 24 additions & 0 deletions benchmark/test_addcmul.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
import torch

from . import attri_util as attrs
from . import performance_utils as base


def _input_fn(shape, cur_dtype, device):
inp1 = base.generate_tensor_input(shape, cur_dtype, device)
inp2 = base.generate_tensor_input(shape, cur_dtype, device)
inp3 = base.generate_tensor_input(shape, cur_dtype, device)

yield inp1, inp2, inp3, {"value": 0.5}


@pytest.mark.addcmul
def test_addcmul():
bench = base.GenericBenchmark(
op_name="addcmul",
input_fn=_input_fn,
torch_op=torch.addcmul,
dtypes=attrs.FLOAT_DTYPES,
)
bench.run()
41 changes: 41 additions & 0 deletions benchmark/test_clamp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pytest
import torch

from . import attri_util as attrs
from . import performance_utils as base


def _input_fn(shape, cur_dtype, device):
inp1 = base.generate_tensor_input(shape, cur_dtype, device)
inp2 = base.generate_tensor_input(shape, cur_dtype, device)
inp3 = base.generate_tensor_input(shape, cur_dtype, device)

yield inp1, inp2, inp3

if base.Config.bench_level == base.BenchLevel.COMPREHENSIVE:
# scalar or None situation
yield inp1, inp2, None
yield inp1, None, 3.14


@pytest.mark.clamp
def test_clamp():
bench = base.GenericBenchmark(
op_name="clamp",
input_fn=_input_fn,
torch_op=torch.clamp,
dtypes=attrs.FLOAT_DTYPES,
)
bench.run()


@pytest.mark.clamp_
def test_clamp_inplace():
bench = base.GenericBenchmark(
input_fn=_input_fn,
op_name="clamp_",
torch_op=torch.clamp_,
dtypes=attrs.FLOAT_DTYPES,
is_inplace=True,
)
bench.run()
39 changes: 39 additions & 0 deletions benchmark/test_clamp_min.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest
import torch

from . import attri_util as attrs
from . import performance_utils as base


def _input_fn(shape, cur_dtype, device):
inp1 = base.generate_tensor_input(shape, cur_dtype, device)
inp2 = base.generate_tensor_input(shape, cur_dtype, device)

yield inp1, inp2

if base.Config.bench_level == attrs.BenchLevel.COMPREHENSIVE:
# scalar situation
yield inp1, 3.14


@pytest.mark.clamp_min
def test_clamp_min():
bench = base.GenericBenchmark(
op_name="clamp_min",
input_fn=_input_fn,
torch_op=torch.clamp_min,
dtypes=attrs.FLOAT_DTYPES,
)
bench.run()


@pytest.mark.clamp_min_
def test_clamp_min_inplace():
bench = base.GenericBenchmark(
input_fn=_input_fn,
op_name="clamp_min_",
torch_op=torch.clamp_min_,
dtypes=attrs.FLOAT_DTYPES,
is_inplace=True,
)
bench.run()
24 changes: 24 additions & 0 deletions benchmark/test_flip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
import torch

from . import attri_util as attrs
from . import performance_utils as base


def _input_fn(shape, cur_dtype, device):
inp = base.generate_tensor_input(shape, cur_dtype, device)
if len(shape) > 1:
yield inp, {"dims": (0, 1)}
else:
yield inp, {"dims": (0,)}


@pytest.mark.flip
def test_flip():
bench = base.GenericBenchmark(
op_name="flip",
input_fn=_input_fn,
torch_op=torch.flip,
dtypes=attrs.FLOAT_DTYPES + attrs.INT_DTYPES,
)
bench.run()
219 changes: 0 additions & 219 deletions benchmark/test_generic_pointwise_perf.py

This file was deleted.

Loading
Loading