Skip to content

Commit

Permalink
Merge pull request numpy#20846 from seiko2plus/simd_argmaxmin
Browse files Browse the repository at this point in the history
ENH, SIMD: improve argmax/argmin performance
  • Loading branch information
mattip authored Feb 13, 2022
2 parents 344a3cb + 52787cc commit 7fe5d7f
Show file tree
Hide file tree
Showing 6 changed files with 601 additions and 114 deletions.
14 changes: 13 additions & 1 deletion benchmarks/benchmarks/bench_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def time_max(self, dtype):
np.fmax.reduce(self.d)

class ArgMax(Benchmark):
params = [np.float32, np.float64, bool]
params = [np.int8, np.uint8, np.int16, np.uint16, np.int32, np.uint32,
np.int64, np.uint64, np.float32, np.float64, bool]
param_names = ['dtype']

def setup(self, dtype):
Expand All @@ -82,6 +83,17 @@ def setup(self, dtype):
def time_argmax(self, dtype):
np.argmax(self.d)

class ArgMin(Benchmark):
params = [np.int8, np.uint8, np.int16, np.uint16, np.int32, np.uint32,
np.int64, np.uint64, np.float32, np.float64, bool]
param_names = ['dtype']

def setup(self, dtype):
self.d = np.ones(200000, dtype=dtype)

def time_argmin(self, dtype):
np.argmin(self.d)

class SmallReduction(Benchmark):
def setup(self):
self.d = np.ones(100, dtype=np.float32)
Expand Down
4 changes: 3 additions & 1 deletion numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ def gl_if_msvc(build_cmd):
multiarray_deps = [
join('src', 'multiarray', 'abstractdtypes.h'),
join('src', 'multiarray', 'arrayobject.h'),
join('src', 'multiarray', 'arraytypes.h'),
join('src', 'multiarray', 'arraytypes.h.src'),
join('src', 'multiarray', 'arrayfunction_override.h'),
join('src', 'multiarray', 'array_coercion.h'),
join('src', 'multiarray', 'array_method.h'),
Expand Down Expand Up @@ -892,7 +892,9 @@ def gl_if_msvc(build_cmd):
join('src', 'multiarray', 'abstractdtypes.c'),
join('src', 'multiarray', 'alloc.c'),
join('src', 'multiarray', 'arrayobject.c'),
join('src', 'multiarray', 'arraytypes.h.src'),
join('src', 'multiarray', 'arraytypes.c.src'),
join('src', 'multiarray', 'argfunc.dispatch.c.src'),
join('src', 'multiarray', 'array_coercion.c'),
join('src', 'multiarray', 'array_method.c'),
join('src', 'multiarray', 'array_assign_scalar.c'),
Expand Down
Loading

0 comments on commit 7fe5d7f

Please sign in to comment.