Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH, SIMD: improve argmax/argmin performance #20846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe overkill? Is there any real difference between argmax and argmin? I guess there might slight differences since they are different loops

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