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

+ is not correctly recorded #17

Open
Roger-luo opened this issue Apr 1, 2020 · 2 comments
Open

+ is not correctly recorded #17

Roger-luo opened this issue Apr 1, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@Roger-luo
Copy link
Collaborator

I find this while writing documentation, it's strange since it seems not because of the BLACK_LIST

julia> A, B = (rand(100, 100) for _ in 1:2)
Base.Generator{UnitRange{Int64},var"#3#4"}(var"#3#4"(), 1:2)

julia> record_allocations(+, A, B)
(value = [1.0495016055493258 1.3273418213359485  0.5963185747522923 1.1503808755746068; 0.3158719236919174 1.5157179087539658  1.5485087164398046 0.4956053992013334;  ; 0.8055821535049874 1.0735544173517684  0.8744412783135622 0.9502501256860647; 1.1511881175529912 0.3931796416314606  1.2724735635978146 0.4405171223405957], allocation_record = AutoPreallocation.AllocationRecord(
    [],
    []
))

in principle this should record one Array, but it didn't, however, it works fine on broadcast, and the broadcast_preserving_zero_d(+, A, Bs...) that +(A, B) uses

julia> record_allocations(broadcast, +, A, B)
(value = [1.0495016055493258 1.3273418213359485  0.5963185747522923 1.1503808755746068; 0.3158719236919174 1.5157179087539658  1.5485087164398046 0.4956053992013334;  ; 0.8055821535049874 1.0735544173517684  0.8744412783135622 0.9502501256860647; 1.1511881175529912 0.3931796416314606  1.2724735635978146 0.4405171223405957], allocation_record = AutoPreallocation.AllocationRecord(
    [Array{Float64,2}(undef, (100, 100))],
    [(100, 100)]
))
julia> record_allocations(Base.broadcast_preserving_zero_d, +, A, B)
(value = [1.0495016055493258 1.3273418213359485  0.5963185747522923 1.1503808755746068; 0.3158719236919174 1.5157179087539658  1.5485087164398046 0.4956053992013334;  ; 0.8055821535049874 1.0735544173517684  0.8744412783135622 0.9502501256860647; 1.1511881175529912 0.3931796416314606  1.2724735635978146 0.4405171223405957], allocation_record = AutoPreallocation.AllocationRecord(
    [Array{Float64,2}(undef, (100, 100))],
    [(100, 100)]
))

I guess this might be caused by splitting?

@Roger-luo Roger-luo added the bug Something isn't working label Apr 1, 2020
@oxinabox
Copy link
Owner

oxinabox commented Apr 1, 2020

oh weird, weird weird. Maybe there is a nother way to construct an Array that we are missing?

@Roger-luo
Copy link
Collaborator Author

I mean in principal one could workaround this by using .+ instead of +, but this is very strange indeed. I suspect this is due to the call of splatting that make Cassette escape that call? Not sure how to debug this however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants