mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
can't infer device on benchmarked function with no args or kwargs (#133290)
when we call benchmarker.benchmark(fn, (), {}) it attempts to infer the device from the args and kwargs, which are both empty. in this case the default behavior is to assume CPU, since `is_cpu_device` is implemented as `all([x.device == "cpu" for x in ... if x is Tensor])`, and `all([]) == True`. I've added a PR that makes this raise an error, but we should just fix this one callsite first Pull Request resolved: https://github.com/pytorch/pytorch/pull/133290 Approved by: https://github.com/eellison
This commit is contained in:
committed by
PyTorch MergeBot
parent
dfc7c860e4
commit
fa7ae6cdbc
@ -21,7 +21,7 @@ class TestBench(TestCase):
|
||||
cls._bench_fn = functools.partial(torch.nn.functional.linear, x, w)
|
||||
|
||||
def test_benchmarker(self):
|
||||
res = benchmarker.benchmark(self._bench_fn, (), {})
|
||||
res = benchmarker.benchmark_gpu(self._bench_fn)
|
||||
log.warning("do_bench result: %s", res)
|
||||
self.assertGreater(res, 0)
|
||||
|
||||
|
Reference in New Issue
Block a user