Skip to content

Commit

Permalink
Some formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsmeding committed Oct 12, 2020
1 parent 3f7cc56 commit ede16d3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Data/Array/Accelerate/Trafo/AD/Translate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ reduceConvert :: D.ReduceSpec spec red full -> ReduceConvert red full
reduceConvert spec
| let spec' = untypeifySpec spec
sortedSpec = sort spec'
-- These two lines are the core transformation implemented here. Nothing more.
sortedFullIndices = map snd (sortBy (comparing fst) (zip spec' [0..]))
fullSortedIndices = invertPermutation sortedFullIndices
, SomeReduceSpec sortedSpec' tagval <- typeifySpec sortedSpec
Expand Down Expand Up @@ -337,11 +338,11 @@ reduceConvert spec
specSameRed :: D.ReduceSpec spec red full
-> D.ReduceSpec spec' red' full'
-> Maybe (red :~: red')
specSameRed D.RSpecNil D.RSpecNil = Just Refl
specSameRed (D.RSpecKeep s1) (D.RSpecKeep s2) | Just Refl <- specSameRed s1 s2 = Just Refl
specSameRed (D.RSpecReduce s1) s2 | Just Refl <- specSameRed s1 s2 = Just Refl
specSameRed s1 (D.RSpecReduce s2) | Just Refl <- specSameRed s1 s2 = Just Refl
specSameRed _ _ = Nothing
specSameRed D.RSpecNil D.RSpecNil = Just Refl
specSameRed (D.RSpecKeep s1) (D.RSpecKeep s2) | Just Refl <- specSameRed s1 s2 = Just Refl
specSameRed (D.RSpecReduce s1) s2 | Just Refl <- specSameRed s1 s2 = Just Refl
specSameRed s1 (D.RSpecReduce s2) | Just Refl <- specSameRed s1 s2 = Just Refl
specSameRed _ _ = Nothing

invertPermutation :: [Int] -> [Int]
invertPermutation l = map snd (sortBy (comparing fst) (zip l [0..]))
Expand Down

0 comments on commit ede16d3

Please sign in to comment.