Skip to content

Commit

Permalink
[benchmark] split test of nonzero into two (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrongSpoon authored Sep 5, 2024
1 parent 38187f8 commit edb09f0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion benchmark/test_reduction_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,28 @@ def nonzero_args(dtype, batch, size):
op_name="nonzero",
torch_op=torch.nonzero,
arg_func=nonzero_args,
dtypes=FLOAT_DTYPES + INT_DTYPES + [torch.bool],
dtypes=FLOAT_DTYPES,
batch=REDUCTION_BATCH,
sizes=SIZES,
)
bench.run()


def test_perf_nonzero_int():
def nonzero_args(dtype, batch, size):
if dtype == torch.bool:
inp = torch.randint(0, 2, [batch, size], dtype=torch.int, device="cuda").to(
torch.bool
)
else:
inp = torch.randint(0, 2, [batch, size], dtype=dtype, device="cuda")
return (inp,)

bench = Benchmark(
op_name="nonzero_int",
torch_op=torch.nonzero,
arg_func=nonzero_args,
dtypes=INT_DTYPES,
batch=REDUCTION_BATCH,
sizes=SIZES,
)
Expand Down

0 comments on commit edb09f0

Please sign in to comment.