- Notifications
You must be signed in to change notification settings - Fork151
Use sparse structured methods where possible#1727
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| deftranspose(self): | ||
| raiseNotImplementedError | ||
| returnself.T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Do you want to add themT property as well? Will make code that works with tensors more likely to work with sparse variables as well
ricardoV94 commentedNov 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Re: copy is identity function, we can make it return One thing with these Elemwise operations is that they box the sparse part like: In general I'm not a big fan of this eager implementation. I would rather do it as a rewrite: |
Uh oh!
There was an error while loading.Please reload this page.
Description
For elemwise functions that are idempotent at 0 such that f(0) = 0, it is safe to always use a
structured_function, rather than converting back to dense.Such functions are
sinh,tanh,arcsin,arctan,arcsinh,deg2rad,rad2deg,expm1, andlog1p.I also removed the dense_override on
.transpose, which now callsself.T. I think this is fine for now, since we're only supporting sparse matrices, not general sparse arrays. Previously,sparse.Treturned a sparse, butsparse.transposereturned a dense, which is baffling.copyseems like another low-hanging fruit, but I'm leaving it for another time because it was slightly harder to reason about than the functions in this PR.Related Issue
Checklist
Type of change