Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added traversing of Replicate nodes

* Added a test for these
* Had to alter evaluation of Const expression nodes, so that type of "All" is not printed out
* Haven't used the SliceIndex argument for Replicate as there doesn't currently appear to be a need for it, but this may change in the future after more thorough testing
  • Loading branch information...
commit 5a1a3c45aeba30355dd2d6e4c5725c881f353927 1 parent 8cb6509
@blambo authored
Showing with 33 additions and 5 deletions.
  1. +15 −5 Data/Array/Accelerate/Repa/Evaluations.hs
  2. +18 −0 examples/Replicate.hs
View
20 Data/Array/Accelerate/Repa/Evaluations.hs
@@ -158,10 +158,13 @@ evalPreOpenAcc (Generate sh f) letLevel
<+> parens fun
---TODO
-evalPreOpenAcc (Replicate _sliceIndex _slix _acc) _letLevel
- = RepaAcc $ text "<ERROR:Replicate>"
+evalPreOpenAcc (Replicate sliceIndex slix acc) letLevel
+ = RepaAcc $ returnDoc
+ where
+ slixD = toDoc $ evalExp slix letLevel
+ RepaAcc arrD = evalOpenAcc acc letLevel
+ returnDoc = text "extend" <+> parens slixD <+> parens arrD
--TODO
evalPreOpenAcc (Index _sliceIndex _acc _slix) _letLevel
@@ -558,9 +561,16 @@ evalOpenExp var@(Var idx) lamL letL
typeD = expToString (var)
evalOpenExp (Const c) _ _
- = RepaExp $ val <+> colon <> colon <+> typeS
+ = RepaExp $ val
where
- val = text $ show ((Sugar.toElt c) :: a)
+ val = let val' = show ((Sugar.toElt c) :: a)
+ in case val' of
+ "All" -> text "All"
+ otherwise -> text val'
+ <+> colon
+ <> colon
+ <+> typeS
+
typeS = text $ (showsTypeRep $ typeOf ((Sugar.toElt c) :: a)) ""
evalOpenExp (Tuple tup) lamL letL
View
18 examples/Replicate.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE TypeOperators #-}
+import Data.Array.Accelerate as Acc
+import Data.Array.Accelerate.Repa as Repa
+import Prelude hiding (replicate)
+
+
+main = do
+-- putStrLn $ Repa.run $ replicate replicateShape
+-- $ generate (index0) (\x -> constant (1 :: Int))
+ putStrLn $ Repa.run $ replicate replicateShape'
+ $ generate (index1 4) (\x -> constant (2 :: Int))
+
+replicateShape :: Exp (Z :. Int)
+replicateShape = lift $ Z :. (3 :: Int)
+
+replicateShape' :: Exp (Z :. All :. Int)
+replicateShape' = lift $ Z :. All :. (3 :: Int)
+
Please sign in to comment.
Something went wrong with that request. Please try again.