From fad10d5a218f935d47e8b9dc41256a30b4ec540d Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 12 Dec 2024 11:44:16 +0100 Subject: Add sparse test --- test/Main.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/Main.hs b/test/Main.hs index 5db7ea0..b234aa2 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -237,6 +237,15 @@ term_pairs = fromNamed $ lambda #x $ lambda #y $ body $ let_ #q (pair (snd_ #p * fst_ #p + #y) #x) $ fst_ #q * #x + snd_ #q * fst_ #p +term_sparse :: Ex '[TArr N1 (TScal TF64)] (TScal TF64) +term_sparse = fromNamed $ lambda #inp $ body $ + let_ #n (snd_ (shape #inp)) $ + let_ #arr (build1 #n (#i :-> #inp ! pair nil #i)) $ + let_ #a (build1 #n (#i :-> #arr ! pair nil 2)) $ + let_ #b (build1 #n (#i :-> #arr ! pair nil 3)) $ + let_ #c (build1 #n (#i :-> #arr ! pair nil 4)) $ + idx0 (sum1i #a) + idx0 (sum1i #b) + idx0 (sum1i #c) + tests :: IO Bool tests = checkParallel $ Group "AD" [("id", adTest $ fromNamed $ lambda #x $ body $ #x) @@ -275,6 +284,8 @@ tests = checkParallel $ Group "AD" let_ #a (build1 (snd_ (shape #x)) (#i :-> #x ! pair nil #i)) $ 42) + ,("sparse", adTestTp (C "" 5) term_sparse) + ,("neural", adTestGen Example.neural genNeural) ,("neural-unMonoid", adTestGen (unMonoid (simplifyFix Example.neural)) genNeural) -- cgit v1.2.3-70-g09d2