Skip to content

Commit 63b9f7e

Browse files
committed
Revert "Remove BLAS.asum(x) rules"
This reverts commit 3fe59b4.
1 parent 61b425b commit 63b9f7e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/rulesets/LinearAlgebra/blas.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ end
6767
##### `BLAS.asum`
6868
#####
6969

70+
function frule(::typeof(BLAS.asum), x, _, Δx)
71+
return BLAS.asum(x), sum(zip(x, Δx)) do xs
72+
x, Δx = xs
73+
return sign(x) * Δx
74+
end
75+
end
76+
77+
function rrule(::typeof(BLAS.asum), x)
78+
function asum_pullback(ΔΩ)
79+
return (NO_FIELDS, @thunk(ΔΩ * sign.(x)))
80+
end
81+
return BLAS.asum(x), asum_pullback
82+
end
83+
7084
function rrule(::typeof(BLAS.asum), n, X, incx)
7185
Ω = BLAS.asum(n, X, incx)
7286
function asum_pullback(ΔΩ)

0 commit comments

Comments
 (0)