Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
jessegrabowski wants to merge1 commit intopymc-devs:main
base:main
Choose a base branch
Loading
fromjessegrabowski:sparse-structured

Conversation

@jessegrabowski
Copy link
Member

@jessegrabowskijessegrabowski commentedNov 18, 2025
edited
Loading

Description

For elemwise functions that are idempotent at 0 such that f(0) = 0, it is safe to always use astructured_ function, rather than converting back to dense.

Such functions aresinh,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.T returned a sparse, butsparse.transpose returned a dense, which is baffling.

copy seems 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

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

Comment on lines 203 to +204
deftranspose(self):
raiseNotImplementedError
returnself.T
Copy link
Member

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
Copy link
Member

ricardoV94 commentedNov 18, 2025
edited
Loading

Re: copy is identity function, we can make it returnViewOp()(self).

One thing with these Elemwise operations is that they box the sparse part like:sparse.data -> f(data) -> sparse_again. If we have multiple Elemwise in succession they won't get fused. We may need a rewrite (not a blocker for this PR ofc).

In general I'm not a big fan of this eager implementation. I would rather do it as a rewrite:elemwise(x.todense()) -> trick used here. Again not a blocker, specially because I haven't thought about all the ramifications

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ricardoV94ricardoV94ricardoV94 approved these changes

Assignees

No one assigned

Labels

enhancementNew feature or requestsparse variables

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@jessegrabowski@ricardoV94

[8]ページ先頭

©2009-2025 Movatter.jp