Ticket #25 (closed defect: duplicate)

Opened 7 years ago

Last modified 7 years ago

fold produces incorrect result when a non-identity value is given as the default value

Reported by: seanl Owned by: tmcdonell
Priority: major Milestone:
Component: CUDA backend Version:
Keywords: Cc:


For example,

sum' :: Vector Word32 -> Acc (Scalar Word32)
sum' xs
  = let
      xs' = use xs
    fold (*) 1 xs'

main :: IO ()
main = do
  let input = fromList 10 [1..] :: Vector (Word32)
  putStrLn $ "reference: " ++ (show $ Interpreter.run $ sum' input)
  r <- CUDA.run $ sum'  input
  putStrLn $ "output:    " ++ (show r)


reference: Array () [56]
output:    Array () [311]

Change History

Changed 7 years ago by tmcdonell

Please clarify your example.

Your function is called 'sum', but actually computes the product. Your sample output matches the former, so I will assume that this is your intention. In that case, 1 is not the neutral element of addition, and so this ticket is invalid. This is stated as a precondition in the documentation, together with the requirement that the combining function be associative.

Changed 7 years ago by tmcdonell

  • status changed from new to closed
  • resolution set to duplicate

Merge with #23

Note: See TracTickets for help on using tickets.