Skip to content

Commit

Permalink
[Benchmark] Benchmark to(device) (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens authored May 18, 2023
1 parent da83c3b commit a84add9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions benchmarks/common/common_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ def exec_select():
benchmark.pedantic(exec_select, iterations=100, rounds=100)


@pytest.mark.skipif(not torch.cuda.device_count(), reason="No cuda device")
def test_to(benchmark, td):
benchmark.pedantic(td.to, args=("cuda:0",), iterations=100, rounds=1000)


@pytest.mark.skipif(not torch.cuda.device_count(), reason="No cuda device")
def test_to_nonblocking(benchmark, td):
benchmark.pedantic(
td.to,
args=("cuda:0",),
kwargs={"non_blocking", True},
iterations=100,
rounds=1000,
)


def main():
# creation
td = TensorDict({}, [3, 4])
Expand Down

0 comments on commit a84add9

Please sign in to comment.