diff options
| author | Raghuveer Devulapalli <raghuveer.devulapalli@intel.com> | 2021-04-16 13:36:15 -0700 |
|---|---|---|
| committer | Raghuveer Devulapalli <raghuveer.devulapalli@intel.com> | 2021-07-16 15:39:56 -0700 |
| commit | 41b14b16cd75ad2d3cb2fb1409dc152de5c32cd2 (patch) | |
| tree | 9e6bf083a044735c7bfc5d92f84a6d3d01b4ed9f | |
| parent | b5e3361b7164de2cf7376a7ea42fef988455da7b (diff) | |
| download | numpy-41b14b16cd75ad2d3cb2fb1409dc152de5c32cd2.tar.gz | |
BENCH: Add benchmarking for ufuncs using SVML implementations
| -rw-r--r-- | benchmarks/benchmarks/bench_ufunc_strides.py | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/benchmarks/benchmarks/bench_ufunc_strides.py b/benchmarks/benchmarks/bench_ufunc_strides.py index 213ff0020..75aa510a6 100644 --- a/benchmarks/benchmarks/bench_ufunc_strides.py +++ b/benchmarks/benchmarks/bench_ufunc_strides.py @@ -2,41 +2,31 @@ from .common import Benchmark import numpy as np -unary_ufuncs = ['sin', - 'cos', - 'exp', - 'log', - 'sqrt', - 'absolute', - 'reciprocal', - 'square', - 'rint', - 'floor', - 'ceil' , - 'trunc', - 'frexp', - 'isnan', - 'isfinite', - 'isinf', - 'signbit'] +UNARY_UFUNCS = [obj for obj in np.core.umath.__dict__.values() if + isinstance(obj, np.ufunc)] +UNARY_OBJECT_UFUNCS = [uf for uf in UNARY_UFUNCS if "O->O" in uf.types] +UNARY_OBJECT_UFUNCS.remove(getattr(np, 'invert')) + stride = [1, 2, 4] stride_out = [1, 2, 4] dtype = ['f', 'd'] class Unary(Benchmark): - params = [unary_ufuncs, stride, stride_out, dtype] + params = [UNARY_OBJECT_UFUNCS, stride, stride_out, dtype] param_names = ['ufunc', 'stride_in', 'stride_out', 'dtype'] timeout = 10 def setup(self, ufuncname, stride, stride_out, dtype): np.seterr(all='ignore') try: - self.f = getattr(np, ufuncname) + self.f = ufuncname except AttributeError: raise NotImplementedError(f"No ufunc {ufuncname} found") from None - N = 10000 - self.arr = np.ones(stride*N, dtype) + N = 100000 self.arr_out = np.empty(stride_out*N, dtype) + self.arr = np.random.rand(stride*N).astype(dtype) + if (ufuncname.__name__ == 'arccosh'): + self.arr = 1.0 + self.arr def time_ufunc(self, ufuncname, stride, stride_out, dtype): self.f(self.arr[::stride], self.arr_out[::stride_out]) |
