ChainRules.jl icon indicating copy to clipboard operation
ChainRules.jl copied to clipboard

Smarter conjugation for inplace BLAS rules

Open oxinabox opened this issue 5 years ago • 0 comments

@sethaxen wrote in https://github.com/JuliaDiff/ChainRules.jl/pull/279#pullrequestreview-506908830

not allocate new conjugated matrices in the BLAS rules? e.g. in

https://github.com/JuliaDiff/ChainRules.jl/blob/c877550430a3cb0f657f43ccbf4e64b13b7177a7/src/rulesets/LinearAlgebra/blas.jl#L134-L137 , we allocate a new matrix A, which I think can be made faster by allocating a new vector instead and then conjugating a vector in-place:

             ∂x = InplaceableThunk( 
                 @thunk(gemv('N', α', conj(A), ȳ)), 
                 x̄ -> conj!(gemv!('N', α, A, conj(ȳ), one(T), conj!(x̄)))
             ) 

Definately worth benchmarking

oxinabox avatar Oct 12 '20 21:10 oxinabox