pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/cupy/cupy/pull/9705

s.com/assets/global-87aa887446e37f5c.css" /> MAINT,ENH: Refactor kernel argument handling into `KernelArguments` class by seberg · Pull Request #9705 · cupy/cupy · GitHub
Skip to content

MAINT,ENH: Refactor kernel argument handling into KernelArguments class#9705

Open
seberg wants to merge 4 commits intocupy:mainfrom
seberg:args-refactor
Open

MAINT,ENH: Refactor kernel argument handling into KernelArguments class#9705
seberg wants to merge 4 commits intocupy:mainfrom
seberg:args-refactor

Conversation

@seberg
Copy link
Member

@seberg seberg commented Feb 17, 2026

This is a bit related to gh-9586 and the previous attempt on it in gh-2920. I.e. to make ElementWise kernels and ufuncs (and reductions) more similar one part of the old PR was also to introduce a new Args class to encapsulate kernel arguments.

This PR introduces a KernelArguments and merges the broadcasting logic into find_and_apply_shape().
There is still quite a bit of duplication, but it helps to make the main __call__ paths easier to follow, I think. I opted for .get_in(0) getters for many things, because I would like to hide a bit how the arguments are stored.


Should reduce overheads for simple ufuncs by around 5-10%, but for me it is more about helping with follow-ups on merging the ufunc/elementwise kernel code or just moving more things into KernelArguments.

Two concrete thoughts I have here is that KernelArguments could already create CArrays, which could give us a pretty big boost when broadcasting or reduce_dims() happens (avoid creating more ndarrays).
Another thought I have is to speed up ArgInfos a bit by merging them (the cache lookup takes quite a lot longer than it should).

@seberg seberg requested a review from a team as a code owner February 17, 2026 14:26
@seberg

This comment was marked as outdated.

1 similar comment
@seberg
Copy link
Member Author

seberg commented Feb 18, 2026

/test mini

@leofang leofang self-assigned this Feb 19, 2026
@seberg
Copy link
Member Author

seberg commented Feb 19, 2026

/test mini

This reorganizes kernel argument handling to package them into a
custom object.
That has small advantages:
1. It allows passing them around slightly more conveniently.
2. It gives us a place to centralize at least _some_ functionality.
3. Having a mutable owning object makes it cleaner and easier to
   mutate a single owner (could be a list) rather than juggle many.

This is already not bad, but some may actually go a bit too far in
this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy