Skip to content

Commit 1722fcb

Browse files
authored
feat: LinearAlgebra.dot (#1213)
1 parent 4e2977d commit 1722fcb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/stdlibs/LinearAlgebra.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,8 @@ end
452452

453453
#-------------
454454

455+
function LinearAlgebra.dot(x::AnyTracedRVector, y::AnyTracedRVector)
456+
return sum(materialize_traced_array(x) .* materialize_traced_array(y))
457+
end
458+
455459
end

test/integration/linear_algebra.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,12 @@ end
263263
@jit axpby!(α, x_ra, β, y_ra)
264264
@test y_ra axpby!(α, x, β, y)
265265
end
266+
267+
@testset "Dot" begin
268+
x = collect(Float32, 1:10)
269+
y = collect(Float32, 10:-1:1)
270+
x_ra = Reactant.to_rarray(x)
271+
y_ra = Reactant.to_rarray(y)
272+
273+
@test @jit(dot(x_ra, y_ra)) dot(x, y)
274+
end

0 commit comments

Comments
 (0)