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 Hcat * Vcat special case #50

Merged
merged 1 commit into from
Aug 16, 2019
Merged

Add Hcat * Vcat special case #50

merged 1 commit into from
Aug 16, 2019

Conversation

dlfivefifty
Copy link
Member

Starts to address #48

@antoine-levitt This should give an idea on what to do. At this point just overloading

materialize!(::MatMulMatAdd{<:VcatLayout,<:HcatLayout})

should suffice.

@antoine-levitt
Copy link

Thanks! I was just looking at this.

@antoine-levitt
Copy link

I assume we also need something to support products of cats and regular matrices? Or is that magically covered?

@dlfivefifty
Copy link
Member Author

It will fall back to the slow default, but something like the following should be fast for Hcat * Strided (e.g. Hcat * Vector):

function materialize!(M::MatMulVecAdd{<:HcatLayout})
    α,A,B,β,C =  M.α,M.A,M.B,M.β,M.C
    T = eltype(C)
    _fill_lmul!(β,C) # this is temporary until strong β = false is supported
    ind = 0
    for a in A.arrays
        jr = ind+1:ind+size(a,2)
        b = view(B, jr, :) 
        materialize!(MulAdd(α,a,b,one(T),C))
        ind = last(jr)
    end
    C
 end

@antoine-levitt
Copy link

OK, thanks! Will try to do the 3^2 combinations with Hcat,Vcat and dense.

@dlfivefifty
Copy link
Member Author

I think you only need 4, not 3^2: Hcat * Vcat, Vcat * Hcat, Vcat * any, Hcat * any. This is because I don’t think Vcat * Vcat or Hcat * Hcat are that useful....

(Ok each will need to be done three times, once for matrix * matrix, matrix * vector and vector * matrix...)

@dlfivefifty dlfivefifty merged commit 138014d into master Aug 16, 2019
@dlfivefifty dlfivefifty deleted the dl/hcatmul branch August 16, 2019 14:09
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