Skip to content

Commit

Permalink
Revert "Remove BLAS.asum(x) rules"
Browse files Browse the repository at this point in the history
This reverts commit 3fe59b4.
  • Loading branch information
YingboMa committed Jan 12, 2020
1 parent 61b425b commit 63b9f7e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rulesets/LinearAlgebra/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ end
##### `BLAS.asum`
#####

function frule(::typeof(BLAS.asum), x, _, Δx)
return BLAS.asum(x), sum(zip(x, Δx)) do xs
x, Δx = xs
return sign(x) * Δx
end
end

function rrule(::typeof(BLAS.asum), x)
function asum_pullback(ΔΩ)
return (NO_FIELDS, @thunk(ΔΩ * sign.(x)))
end
return BLAS.asum(x), asum_pullback
end

function rrule(::typeof(BLAS.asum), n, X, incx)
Ω = BLAS.asum(n, X, incx)
function asum_pullback(ΔΩ)
Expand Down

0 comments on commit 63b9f7e

Please sign in to comment.