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

Add repartition(!)(::AbstractTensorMap) #116

Merged
merged 5 commits into from
Apr 11, 2024
Merged

Add repartition(!)(::AbstractTensorMap) #116

merged 5 commits into from
Apr 11, 2024

Conversation

lkdvos
Copy link
Collaborator

@lkdvos lkdvos commented Apr 9, 2024

No description provided.

@lkdvos
Copy link
Collaborator Author

lkdvos commented Apr 10, 2024

@Jutho, I am not actually sure how to make repartition(t, N1, N2 inferrable. I've tried Base.@constprop :aggressive, which does not seem to help, and without resorting to val(N) type things, I don't think I can make it work. So maybe the next question is, does it matter? In principle, this is just a wrapper around transpose, so in important cases you can use that instead?

@Jutho
Copy link
Owner

Jutho commented Apr 10, 2024

Can you try with @constinferred repartition(t, $k) (but maybe first locally)? Constant propagation can only work if the argument is really a constant. So either you need to explicitly have @constinferred repartition(t, 3) or something, or you need to splice in the value using $k.

@lkdvos
Copy link
Collaborator Author

lkdvos commented Apr 10, 2024

Can you try with @constinferred repartition(t, $k) (but maybe first locally)? Constant propagation can only work if the argument is really a constant. So either you need to explicitly have @constinferred repartition(t, 3) or something, or you need to splice in the value using $k.

Thanks! Indeed, combining the @constprop and the corrected @constinferred fixes everything, at least on my machine. I can't seem to find a way of doing this in julia v1.6 though...

@lkdvos
Copy link
Collaborator Author

lkdvos commented Apr 10, 2024

So now, for Julia v1.6, there is a slight type-instability for repartition, but everything else should be fine. I think if the tests pass, this is ready to go.

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.46%. Comparing base (fe3c9c2) to head (4dc1fd0).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #116      +/-   ##
==========================================
+ Coverage   81.29%   81.46%   +0.16%     
==========================================
  Files          42       42              
  Lines        5575     5588      +13     
==========================================
+ Hits         4532     4552      +20     
+ Misses       1043     1036       -7     

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

@Jutho
Copy link
Owner

Jutho commented Apr 11, 2024

Ok I will merge. Given that this is an addition to the public interface, I guess this should become TensorKit v0.13? Let's hope this doesn't bring bad luck :-).

@lkdvos
Copy link
Collaborator Author

lkdvos commented Apr 11, 2024

We might want to tag the latest version (v0.12.3) before this then, I think this didn't happen yet.

for k in 0:5
for p in permutations(1:5)
p1 = ntuple(n -> p[n], k)
p2 = ntuple(n -> p[k + n], 5 - k)
t2 = permute(t, (p1, p2))
a2 = convert(Array, t2)
@test a2 ≈ permutedims(convert(Array, t), (p1..., p2...))
@test a2 ≈ permutedims(a, (p1..., p2...))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice improvement!

@Jutho Jutho merged commit 370dd92 into master Apr 11, 2024
14 checks passed
@lkdvos lkdvos deleted the ld-repartition branch April 11, 2024 15:33
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