diff --git a/accelerate-tensorflow-lite/test/nofib/Data/Array/Accelerate/Test/NoFib/Unit.hs b/accelerate-tensorflow-lite/test/nofib/Data/Array/Accelerate/Test/NoFib/Unit.hs index e9060bd..533a4bc 100644 --- a/accelerate-tensorflow-lite/test/nofib/Data/Array/Accelerate/Test/NoFib/Unit.hs +++ b/accelerate-tensorflow-lite/test/nofib/Data/Array/Accelerate/Test/NoFib/Unit.hs @@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} -- | -- Module : Data.Array.Accelerate.Test.NoFib.Prelude.Map -- Copyright : [2022] The Accelerate Team @@ -40,6 +41,7 @@ test_unit tc = testGroup "unit" [ testProperty "sum_generate_2" $ prop_sum_generate_2 tc , testProperty "generate_2" $ prop_generate_2 tc + , tree_sum3mod4 tc ] prop_sum_generate_2 :: TestContext -> Property @@ -68,3 +70,46 @@ prop_generate_2 tc = property $ do xs2 <- forAll (array ForInput sh f32) let f a b = A.generate (A.constant sh) (\i -> a ! i + b ! i) tpuTestCase tc f (P.zipWith (\a b -> a :-> b :-> Result sh) dat1 dat2) xs1 xs2 + +tree_sum3mod4 :: TestContext -> TestTree +tree_sum3mod4 tc = + localOption (HedgehogTestLimit (Just 1)) $ + testGroup "sum3mod4" $ + concat [[testDim3 2 2 2] + ,[testDim3 1 1 n | n <- [1..20]] + ,[testDim3 2 1 n | n <- [1..20]] + ,[testDim3 3 1 n | n <- [1..20]] + ,[testDim3 4 1 n | n <- [1..20]] + ,[testDim3 5 1 n | n <- [1..20]] + ,[testDim3 3 2 n | n <- [1..20]] + ,[testDim3 1 1 n | n <- [1..20]] + ,[testDim3 1 2 n | n <- [1..20]] + ,[testDim3 1 3 n | n <- [1..20]] + ,[testDim2 1 n | n <- [1..20]] + ,[testDim2 2 n | n <- [1..20]] + ,[testDim2 3 n | n <- [1..20]] + ] + where + testDim2 :: Int -> Int -> TestTree + testDim2 a b = + testProperty (show a P.++ " " P.++ show b) $ + prop_sum (return (Z :. a :. b)) f32 + + testDim3 :: Int -> Int -> Int -> TestTree + testDim3 a b c = + testProperty (show a P.++ " " P.++ show b P.++ " " P.++ show c) $ + prop_sum (return (Z :. a :. b :. c)) f32 + + prop_sum + :: (P.Eq sh, Show sh, Shape sh, A.Num e, Show e, Similar e) + => Gen (sh :. Int) + -> (WhichData -> Gen e) + -> Property + prop_sum dim e = + property $ do + sh@(shtail :. _) <- forAll dim + ndat <- forAll (Gen.int (Range.linear 10 16)) + dat <- forAll (do arrs <- Gen.list (Range.singleton ndat) (array ForSample sh e) + return [arr :-> Result shtail | arr <- arrs]) + xs <- forAll (array ForInput sh e) + tpuTestCase tc A.sum dat xs