Jutho / TensorKit.jl

A Julia package for large-scale tensor computations, with a hint of category theory
MIT License
218 stars 38 forks source link

Update postprocessors.jl #114

Closed maartenvd closed 5 months ago

maartenvd commented 5 months ago

before:

julia> @macroexpand (@planar allocator=malloc out[-1 -2 -3;-4 -5] := l[-1 1;-4]*o[1 -2;-5 -3])
quote
    numout(l) == 2 && numin(l) == 1 || throw(TensorOperations.IndexError("Incorrect number of input-output indices for l: (2, 1) instead of ($((numout(l), numin(l))))."))
    numout(o) == 2 && numin(o) == 2 || throw(TensorOperations.IndexError("Incorrect number of input-output indices for o: (2, 2) instead of ($((numout(o), numin(o))))."))
    var"##T_##304#305" = TensorOperations.promote_contract(TensorOperations.scalartype(l), TensorOperations.scalartype(o))
    var"##304" = TensorOperations.tensoralloc_contract(var"##T_##304#305", ((2, 1), (4, 5, 3)), l, ((1, 3), (2,)), :N, o, ((1,), (2, 3, 4)), :N, false, TensorOperations.Backend{:malloc}())
    var"##304" = TensorKit._planarcontract!(var"##304", ((2, 1), (4, 5, 3)), l, ((1, 3), (2,)), o, ((1,), (2, 3, 4)), VectorInterface.One(), VectorInterface.Zero())
    var"##T_out#306" = TensorOperations.scalartype(var"##304")
    out = TensorOperations.tensoralloc_add(var"##T_out#306", ((2, 5, 4), (1, 3)), var"##304", :N, false, TensorOperations.Backend{:malloc}())
    out = TensorKit._planaradd!(out, ((2, 5, 4), (1, 3)), var"##304", VectorInterface.One(), VectorInterface.Zero())
    TensorOperations.tensorfree!(var"##304", TensorOperations.Backend{:malloc}())
    out
end

Now it correctly labels var"##304" as a temporary, and no longer segfaults.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.39%. Comparing base (fe3c9c2) to head (14f6e69).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #114 +/- ## ========================================== + Coverage 81.29% 81.39% +0.10% ========================================== Files 42 42 Lines 5575 5575 ========================================== + Hits 4532 4538 +6 + Misses 1043 1037 -6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

lkdvos commented 5 months ago

Nice, good catch!