-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for BLAS.dot, BLAS.dotc, and BLAS.dotu (#842)
* Add tests for BLAS rules * Make checks approximate * Fix approx check for tuples * Apply suggestion * Add EnzymeTestUtils as test dependency * Refactor to use EnzymeTestUtils Also removes checks for consistency with 2-arg dot and pointer tests, since these should be covered by the base case. * Make sure dev version of EnzymeTestUtils used in testing * Move blas.jl to test dir * Update path * Try to fix deving of EnzymeTestUtils * Dev EnzymeTestUtils while running tests * Remove EnzymeTestUtils as test dep * Load Pkg * Remove workaround in CI --------- Co-authored-by: William S. Moses <gh@wsmoses.com>
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Enzyme | ||
using EnzymeTestUtils | ||
using LinearAlgebra | ||
using Test | ||
|
||
@testset "BLAS rules" begin | ||
RTs = (Float32, Float64) | ||
RCs = (ComplexF32, ComplexF64) | ||
n = 10 | ||
|
||
@testset for fun in (BLAS.dot, BLAS.dotu, BLAS.dotc) | ||
@testset "forward" begin | ||
@testset for Tret in ( | ||
Const, | ||
Duplicated, | ||
DuplicatedNoNeed, | ||
BatchDuplicated, | ||
BatchDuplicatedNoNeed, | ||
), | ||
Tx in (Const, Duplicated, BatchDuplicated), | ||
Ty in (Const, Duplicated, BatchDuplicated), | ||
T in (fun == BLAS.dot ? RTs : RCs), | ||
(sz, inc) in ((10, 1), ((2, 20), -2)) | ||
|
||
are_activities_compatible(Tret, Tx, Ty) || continue | ||
|
||
x = randn(T, sz) | ||
y = randn(T, sz) | ||
atol = rtol = sqrt(eps(real(T))) | ||
test_forward(fun, Tret, n, (x, Tx), inc, (y, Ty), inc; atol, rtol) | ||
end | ||
end | ||
|
||
@testset "reverse" begin | ||
@testset for Tret in (Const, Active), | ||
Tx in (Const, Duplicated, BatchDuplicated), | ||
Ty in (Const, Duplicated, BatchDuplicated), | ||
T in (fun == BLAS.dot ? RTs : RCs), | ||
(sz, inc) in ((10, 1), ((2, 20), -2)) | ||
|
||
are_activities_compatible(Tret, Tx, Ty) || continue | ||
|
||
x = randn(T, sz) | ||
y = randn(T, sz) | ||
atol = rtol = sqrt(eps(real(T))) | ||
test_reverse(fun, Tret, n, (x, Tx), inc, (y, Ty), inc; atol, rtol) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters