Optional out parameter for np.dot()#14
Closed
luispedro wants to merge 15 commits intonumpy:masterfrom
luispedro:master
Closed
Optional out parameter for np.dot()#14luispedro wants to merge 15 commits intonumpy:masterfrom luispedro:master
luispedro wants to merge 15 commits intonumpy:masterfrom
luispedro:master
Conversation
Member
|
Looks close, but I think it need work. |
Contributor
Author
|
Thanks for your feedback. I'll improve it and resubmit. |
Member
|
Member
|
The signature of Relevant fixes here: https://github.com/pv/numpy/commits/bug/luispedro-dot-out |
Contributor
Author
|
Thank you for your work. I am just working out the last details and will issue a pull request on numpy/numpy soon. |
This avoids the memory allocation. It is very strict in checking that the types are correct, but since it is intended as an optimisation, it should only be used when the user knows what they are doing.
Using the toy example in the test as a benchmark, I clocked 63ms with
an `out` parameter, versus 91ms without. Here is the full
benchmark (requires ipython)::
import numpy as np
np.random.seed(22)
f = np.random.rand(1024*128, 16)
v = np.random.rand(16,32)
r = np.empty((1024*128, 32))
_ip.magic("timeit np.dot(f,v,r)")
_ip.magic("timeit np.dot(f,v)")
(Pointed out by pv on github)
This allows `np.dot(a, b, out=r)`. Suggested by pv.
…ture in PyArray_MatrixProduct2
This indicates that the function takes 3 arguments
This was referenced Oct 19, 2012
bashtage
referenced
this pull request
in bashtage/numpy
Apr 16, 2019
ENH: Add fast path for randint broadcasting
prototype99
referenced
this pull request
in prototype99/numpy
Jan 4, 2021
lithomas1
added a commit
to lithomas1/numpy
that referenced
this pull request
Nov 18, 2021
# This is the 1st commit message: Add Windows config to GHA # This is the commit message numpy#2: update script [wheel build] # This is the commit message numpy#3: typo [wheel build] # This is the commit message numpy#4: fix typo? [wheel build] # This is the commit message numpy#5: fix linux builds? [wheel build] # This is the commit message numpy#6: typo [wheel build] # This is the commit message numpy#7: add license and pin to windows 2016 # This is the commit message numpy#8: skip tests [wheel build] # This is the commit message numpy#9: pin to windows 2019 instead [wheel build] # This is the commit message numpy#10: try to find out the error on windows [wheel build] # This is the commit message numpy#11: maybe fix? [wheel build] # This is the commit message numpy#12: maybe fix? [wheel build] # This is the commit message numpy#13: fix? [wheel build] # This is the commit message numpy#14: cleanup [wheel build]
lithomas1
added a commit
to lithomas1/numpy
that referenced
this pull request
Nov 18, 2021
commit 30228578ac65ec6b90961700a5783c23d8e1b879
Author: Thomas Li <47963215+lithomas1@users.noreply.github.com>
Date: Wed Nov 17 16:21:27 2021 -0800
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
commit 4bd12df
Author: Thomas Li <47963215+lithomas1@users.noreply.github.com>
Date: Mon Nov 15 17:28:47 2021 -0800
# This is a combination of 14 commits.
# This is the 1st commit message:
Add Windows config to GHA
# This is the commit message numpy#2:
update script [wheel build]
# This is the commit message numpy#3:
typo [wheel build]
# This is the commit message numpy#4:
fix typo? [wheel build]
# This is the commit message numpy#5:
fix linux builds? [wheel build]
# This is the commit message numpy#6:
typo [wheel build]
# This is the commit message numpy#7:
add license and pin to windows 2016
# This is the commit message numpy#8:
skip tests [wheel build]
# This is the commit message numpy#9:
pin to windows 2019 instead [wheel build]
# This is the commit message numpy#10:
try to find out the error on windows [wheel build]
# This is the commit message numpy#11:
maybe fix? [wheel build]
# This is the commit message numpy#12:
maybe fix? [wheel build]
# This is the commit message numpy#13:
fix? [wheel build]
# This is the commit message numpy#14:
cleanup [wheel build]
commit 444a721
Merge: 376ad69 22448b4
Author: Charles Harris <charlesr.harris@gmail.com>
Date: Mon Nov 15 17:47:23 2021 -0700
Merge pull request numpy#20274 from h-vetinari/fix_15179
TST: Some fixes & refactoring around glibc-dependent skips in test_umath.py
commit 376ad69
Merge: b75fe57 546c47a
Author: Charles Harris <charlesr.harris@gmail.com>
Date: Mon Nov 15 17:31:41 2021 -0700
Merge pull request numpy#20327 from seberg/rename-interpolation
BUG,DEP: Fixup quantile/percentile and rename interpolation->method
commit 546c47a
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Mon Nov 15 16:13:50 2021 -0600
DOC: Fixups for interpolation rename comments from review
Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
commit b75fe57
Merge: 7310c09 cbc25d2
Author: Warren Weckesser <warren.weckesser@gmail.com>
Date: Mon Nov 15 17:27:08 2021 -0500
Merge pull request numpy#20369 from bilderbuchi/missing_diagnostics_newlines
MAINT: Fix newlines in diagnostics output of numpy.f2py.
commit cbc25d2
Author: Christoph Buchner <bilderbuchi@phononoia.at>
Date: Sun Nov 14 08:36:03 2021 +0100
MAINT: Fix newlines in diagnostics output of numpy.f2py.
Linebreaks were not consistently added to errmess/outmess
arguments, which led to very long lines and wrong
concatenation with compiler messages in f2py console output.
commit be15716
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Fri Nov 12 12:10:20 2021 -0600
DOC: Add release not for quantile `interpolation` rename
Also updates the old release note to include the info (and generally
tweaks it a bit)
commit 7d8a8e7
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Fri Nov 12 11:57:22 2021 -0600
DOC: Update percentile/quantile docs
Mainly fixes the method list slightly, tones down the warning a
bit and fixes the link to the paper (I did not realize that the
link failed to work due only because the reference was missing
from nanquantile/nanpercentile).
commit 5bd71fb
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Tue Nov 9 09:48:59 2021 -0600
DOC: Add ticks to quantile interpolation/method error
Co-authored-by: abel <aoun@cerfacs.fr>
commit 0d5fb81
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Mon Nov 8 20:39:50 2021 -0600
DOC: Remove reference to paper from quantile `method` kwarg
Apparently, sphinx does not resolve references to footnotes from
parameter descriptions.
commit 8437663
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Mon Nov 8 18:25:37 2021 -0600
MAINT: Rename interpolation to method in percentile stubs
commit 8cfb6b5
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Mon Nov 8 16:47:27 2021 -0600
TST: Add deprecation testcase for quantile interpolation rename
commit a5ac5a5
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Mon Nov 8 16:41:24 2021 -0600
DOC: Fixup the percentile methods plot
commit 85f3dda
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Mon Nov 8 16:37:41 2021 -0600
BUG: quantile discrete methods ended up using -1 as index sometimes
Also, the closest-observation did not correctly support multiple
quantiles calculated at the same time (broadcasting error).
commit 3993408
Author: Sebastian Berg <sebastian@sipsolutions.net>
Date: Mon Nov 8 15:38:30 2021 -0600
API,DEP: Rename percentile/quantile `interpolation=` to `method=`
commit 22448b4
Author: H. Vetinari <h.vetinari@gmx.com>
Date: Tue Nov 2 16:51:59 2021 +1100
TST: parametrize glibc-version check in test_umath.py
commit 12923c2
Author: H. Vetinari <h.vetinari@gmx.com>
Date: Tue Nov 2 14:21:01 2021 +1100
TST: skip coverage of large elements in sincos_float32 for ancient glibc
Fixes numpy#15179
commit 56268d5
Author: H. Vetinari <h.vetinari@gmx.com>
Date: Tue Nov 2 14:19:24 2021 +1100
TST: use existence of glibc-version to clean up a test
commit 01443e8
Author: H. Vetinari <h.vetinari@gmx.com>
Date: Tue Nov 2 14:18:52 2021 +1100
TST: turn glibc_older_than_2.17 into boolean instead of xfail
this anticipates reuse of this boolean within the test module
lithomas1
added a commit
to lithomas1/numpy
that referenced
this pull request
Nov 18, 2021
commit 9c833bed5879d77e625556260690c349de18b433
Author: Thomas Li <47963215+lithomas1@users.noreply.github.com>
Date: Wed Nov 17 16:21:27 2021 -0800
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
Update cibw_test_command.sh
commit 4bd12df
Author: Thomas Li <47963215+lithomas1@users.noreply.github.com>
Date: Mon Nov 15 17:28:47 2021 -0800
# This is a combination of 14 commits.
# This is the 1st commit message:
Add Windows config to GHA
# This is the commit message numpy#2:
update script [wheel build]
# This is the commit message numpy#3:
typo [wheel build]
# This is the commit message numpy#4:
fix typo? [wheel build]
# This is the commit message numpy#5:
fix linux builds? [wheel build]
# This is the commit message numpy#6:
typo [wheel build]
# This is the commit message numpy#7:
add license and pin to windows 2016
# This is the commit message numpy#8:
skip tests [wheel build]
# This is the commit message numpy#9:
pin to windows 2019 instead [wheel build]
# This is the commit message numpy#10:
try to find out the error on windows [wheel build]
# This is the commit message numpy#11:
maybe fix? [wheel build]
# This is the commit message numpy#12:
maybe fix? [wheel build]
# This is the commit message numpy#13:
fix? [wheel build]
# This is the commit message numpy#14:
cleanup [wheel build]
lithomas1
added a commit
to lithomas1/numpy
that referenced
this pull request
Nov 18, 2021
commit 9c833bed5879d77e625556260690c349de18b433
Author: Thomas Li <47963215+lithomas1@users.noreply.github.com>
Date: Wed Nov 17 16:21:27 2021 -0800
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
Add Windows config to GHA
update script [wheel build]
typo [wheel build]
fix typo? [wheel build]
fix linux builds? [wheel build]
typo [wheel build]
add license and pin to windows 2016
skip tests [wheel build]
pin to windows 2019 instead [wheel build]
try to find out the error on windows [wheel build]
maybe fix? [wheel build]
maybe fix? [wheel build]
fix? [wheel build]
cleanup [wheel build]
Update LICENSE_win32.txt
Update LICENSE_win32.txt
Update cibw_test_command.sh
commit 4bd12df
Author: Thomas Li <47963215+lithomas1@users.noreply.github.com>
Date: Mon Nov 15 17:28:47 2021 -0800
# This is a combination of 14 commits.
# This is the 1st commit message:
Add Windows config to GHA
# This is the commit message numpy#2:
update script [wheel build]
# This is the commit message numpy#3:
typo [wheel build]
# This is the commit message numpy#4:
fix typo? [wheel build]
# This is the commit message numpy#5:
fix linux builds? [wheel build]
# This is the commit message numpy#6:
typo [wheel build]
# This is the commit message numpy#7:
add license and pin to windows 2016
# This is the commit message numpy#8:
skip tests [wheel build]
# This is the commit message numpy#9:
pin to windows 2019 instead [wheel build]
# This is the commit message numpy#10:
try to find out the error on windows [wheel build]
# This is the commit message numpy#11:
maybe fix? [wheel build]
# This is the commit message numpy#12:
maybe fix? [wheel build]
# This is the commit message numpy#13:
fix? [wheel build]
# This is the commit message numpy#14:
cleanup [wheel build]
fangerer
referenced
this pull request
in hpyproject/numpy-hpy
Jul 7, 2022
Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from ss/array_array2 to labs-hpy-port * commit 'bebf094010c275b747e1115881d67fa85a9f6751': Remove dtypemeta_dealloc, visit the new HPyFields in DTypeMeta_traverse_impl Fix more C API usages in HPyArray_AssignArray Last C API usage removed from HPyArray_CheckCastSafety NPY_DType_Slots.within_dtype_castingimpl is HPyField NPY_DType_Slots.castingimpls is HPyField HPyArray_CheckCastSafety (partial port)
luyahan
referenced
this pull request
in plctlab/numpy
Apr 25, 2024
refactor: Refactor to register-based algorithm
amane-ame
added a commit
to amane-ame/numpy
that referenced
this pull request
Jun 19, 2025
…ighway (numpy#14) * ENH, SIMD: Initial implementation of Highway wrapper A thin wrapper over Google's Highway SIMD library to simplify its interface. This commit provides the implementation of that wrapper, consisting of: - simd.hpp: Main header defining the SIMD namespaces and configuration - simd.inc.hpp: Template header included multiple times with different namespaces The wrapper eliminates Highway's class tags by: - Using lane types directly which can be deduced from arguments - Leveraging namespaces (np::simd and np::simd128) for different register widths A README is included to guide usage and document design decisions. * SIMD: Update wrapper with improved docs and type support - Fix hardware/platform terminology in documentation for clarity - Add support for long double in template specializations - Add kMaxLanes constant to expose maximum vector width information - Follows clang formatting style for consistency with NumPy codebase. * SIMD: Improve isolation and constexpr handling in wrapper - Add anonymous namespace around implementation to ensure each translation unit gets its own constants based on local flags - Use HWY_LANES_CONSTEXPR for Lanes function to ensure proper constexpr evaluation across platforms * Update Highway submodule to latest master * SIMD: Fix compile error by using MaxLanes instead of Lanes for array size Replace hn::Lanes(f64) with hn::MaxLanes(f64) when defining the index array size to fix error C2131: "expression did not evaluate to a constant". This error occurs because Lanes() isn't always constexpr compatible, especially with scalable vector extensions. MaxLanes() provides a compile-time constant value suitable for static array allocation and should be used with non-scalable SIMD extensions when defining fixed-size arrays. * Convert unary_complex to highway. --------- Co-authored-by: Sayed Adel <seiko@imavr.com>
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
This adds an optional out array for np.dot(). I measured it to be faster, but mostly it is easier to not always reallocate memory if you are manipulating large matrices.
I would appreciate a review as I am not an expert in this code.
Thank you,
Luis