Skip to content
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

[NDTensors] Optimize permutedims #1288

Merged
merged 3 commits into from Dec 16, 2023
Merged

Conversation

mtfishman
Copy link
Member

This fixes a few performance issues in permutedims.

Inspired by this discourse question.

@kmp5VT

@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a00ef70) 84.05% compared to head (938a168) 53.94%.

❗ Current head 938a168 differs from pull request most recent head a9c355c. Consider uploading reports for the commit a9c355c to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1288       +/-   ##
===========================================
- Coverage   84.05%   53.94%   -30.12%     
===========================================
  Files         100       99        -1     
  Lines        8542     8489       -53     
===========================================
- Hits         7180     4579     -2601     
- Misses       1362     3910     +2548     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kmp5VT
Copy link
Collaborator

kmp5VT commented Dec 15, 2023

It looks like there is an error with Strided and Base.ReshpaedArray. Heres the example

y = reshape(randn(elt, 8)', 2, 4)
x = Base.ReshapedArray(randn(elt, 8, 8)'[1:8], (2, 4), ())
y .= y .* x
# works 
@strided x .= x .* x

# stack overflow
@strided y .= y .* x
@strided x .= x .* y
@strided y .= y .* y

so I suggest we make a fix like

function permutedims(Edest::Exposed{<:Array, <:Base.ReshpaedArray}, Esrc::Exposed{<:Array}, perm, f) 
  adest = unexpose(Edest)
  asrc = unexpose(Esrc)
  adest .= f.(adest, permutedims(asrc, perm))
  return adest
end

and I can make an issue in Strided with my example above

@mtfishman
Copy link
Member Author

That issue should be fixed by Jutho/StridedViews.jl#5.

@mtfishman mtfishman merged commit faa0357 into main Dec 16, 2023
8 of 9 checks passed
@mtfishman mtfishman deleted the NDTensors_optimize_permutedims branch December 16, 2023 19:25
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.

None yet

3 participants