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

Use TransmuteDims #31

Merged
merged 13 commits into from
Feb 21, 2021
Merged

Use TransmuteDims #31

merged 13 commits into from
Feb 21, 2021

Conversation

mcabbott
Copy link
Owner

@mcabbott mcabbott commented Feb 4, 2021

This replaces orient, rview (which reshaped), dropdims, and permutedims with transmute from https://github.com/mcabbott/TransmuteDims.jl

Known problems:

  • @strided may not work with this yet. I think this is fixed.
  • tracking of lazy/not is broken, |= & nolazy Maybe fixed, too.

@mcabbott
Copy link
Owner Author

mcabbott commented Feb 4, 2021

The examples of #28 will become:

julia> @pretty @reduce C[a,b,d] := sum(c) A[a,b,c] * B[a,c,d] # Fast
begin
    local ram = transmute(B, (1, nothing, 2, 3))               # reshape
    C = transmute(sum(@__dot__(A * ram), dims = 3), (1, 2, 4)) # reshape
end

julia> @pretty @reduce C[b,a,d] := sum(c) A[a,b,c] * B[a,c,d] # Not fast
begin
    local ram = transmute(A, (2, 1, nothing, 3))    # one wrapper
    local tapir = transmute(B, (nothing, 1, 3, 2))  # one wrapper
    C = transmute(sum(@__dot__(ram * tapir), dims = 4), (1, 2, 3)) # reshape
end

and that of #25:

julia> @pretty @reduce D[m,a] := sum(p) C[p,a] + L[p,m]
begin
    local octopus = transmute(C, (nothing, 2, 1))
    local deer = transmute(L, (2, nothing, 1))
    D = transmute(sum(@__dot__(octopus + deer), dims = 3), (1, 2))
end

Both of these benefit from avoiding needing wrappers of wrappers, as their reshape(PermutedDimsArray(... can be one lazy transmute.

@mcabbott mcabbott merged commit 1edb9c7 into master Feb 21, 2021
@mcabbott mcabbott deleted the transmute branch February 21, 2021 18:37
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.

1 participant