add labels and kwargs'
@@ -33,14 +33,16 @@ class _PerfCaseResult(object):
def to_str(self, show_gpu=False):
ts = self._ts if show_gpu else self._ts[[0]]
+ devices = ["CPU", "GPU"]
return '{:<20s}:{}'.format(
- self.name, ' '.join([self._to_str_per_item(t) for t in ts]))
+ self.name, ' '.join([devices[i] + ": "
+ + self._to_str_per_item(ts[i]) for i in range(len(ts))]))
def __str__(self):
return self.to_str(show_gpu=True)
-def repeat(func, args=(), n=10000, *, name=None, n_warmup=10):
+def repeat(func, args=(), kwargs={}, n=10000, *, name=None, n_warmup=10):
util.experimental('cupyx.time.repeat')
if name is None:
name = func.__name__
@@ -49,6 +51,8 @@ def repeat(func, args=(), n=10000, *, name=None, n_warmup=10):
raise ValueError('`func` should be a callable object.')
if not isinstance(args, tuple):
raise ValueError('`args` should be of tuple type.')
+ if not isinstance(kwargs, dict):
+ raise ValueError('`args` should be of tuple type.')
if not isinstance(n, int):
raise ValueError('`n` should be an integer.')
if not isinstance(name, str):
@@ -61,7 +65,7 @@ def repeat(func, args=(), n=10000, *, name=None, n_warmup=10):
ev2 = cupy.cuda.stream.Event()
for i in range(n_warmup):
- func(*args)
+ func(*args, **kwargs)
ev1.record()
ev1.synchronize()
@@ -70,7 +74,7 @@ def repeat(func, args=(), n=10000, *, name=None, n_warmup=10):
ev1.record()
t1 = time.perf_counter()
- func(*args)
+ func(*args, **kwargs)
t2 = time.perf_counter()
ev2.record()
