lstmForward :: Int -> S.Vector Double -> S.Vector Double -> S.Vector Double ->
               (S.Vector Double, S.Vector Double, S.Vector Double)
lstmForward n ps hs xs = unsafePerformIO $ do target_hs <- M.replicate n 0 :: IO (M.IOVector Double)
                                              target_ys <- M.replicate n 0 :: IO (M.IOVector Double)
                                              target_store <- M.replicate (8*n) 0 :: IO (M.IOVector Double)
                                              S.unsafeWith hs $ \hbuf -> do
                                                S.unsafeWith ps $ \pbuf -> do
                                                  S.unsafeWith xs $ \xbuf -> do
                                                    M.unsafeWith target_hs $ \thbuf -> do
                                                      M.unsafeWith target_ys $ \tybuf -> do
                                                        M.unsafeWith target_store $ \tsbuf -> do
                                                          lstmForwardFFI (fromIntegral n) pbuf hbuf xbuf thbuf tybuf tsbuf
                                              new_hs <- V.unsafeFreeze target_hs
                                              new_ys <- V.unsafeFreeze target_ys
                                              store <- V.unsafeFreeze target_store
                                              return (new_hs, new_ys, store)


lstmForward :: Int -> S.Vector Double -> S.Vector Double -> S.Vector Double ->
               (S.Vector Double, S.Vector Double, S.Vector Double)
lstmForward n ps hs xs = unsafePerformIO $ do target_hs <- M.replicate n 0 :: IO (M.IOVector Double)
                                              target_ys <- M.replicate n 0 :: IO (M.IOVector Double)
                                              target_store <- M.replicate (8*n) 0 :: IO (M.IOVector Double)
                                              S.unsafeWith hs $ \hbuf -> do
                                                S.unsafeWith ps $ \pbuf -> do
                                                  S.unsafeWith xs $ \xbuf -> do
                                                    M.unsafeWith target_hs $ \thbuf -> do
                                                      M.unsafeWith target_ys $ \tybuf -> do
                                                        M.unsafeWith target_store $ \tsbuf -> do
                                                          lstmForwardFFI (fromIntegral n) pbuf hbuf xbuf thbuf tybuf tsbuf
                                              new_hs <- V.unsafeFreeze target_hs
                                              new_ys <- V.unsafeFreeze target_ys
                                              store <- V.unsafeFreeze target_store
                                              return (new_hs, new_ys, store)


lstmForward n ps hs xs = unsafePerformIO $ do target_hs <- M.replicate n 0 :: IO (M.IOVector Double)
                                              target_ys <- M.replicate n 0 :: IO (M.IOVector Double)
                                              target_store <- M.replicate (8*n) 0 :: IO (M.IOVector Double)
                                              S.unsafeWith hs $ \hbuf -> do
                                                S.unsafeWith ps $ \pbuf -> do
                                                  S.unsafeWith xs $ \xbuf -> do
                                                    M.unsafeWith target_hs $ \thbuf -> do
                                                      M.unsafeWith target_ys $ \tybuf -> do
                                                        M.unsafeWith target_store $ \tsbuf -> do
                                                          lstmForwardFFI (fromIntegral n) pbuf hbuf xbuf thbuf tybuf tsbuf
                                              new_hs <- V.unsafeFreeze target_hs
                                              new_ys <- V.unsafeFreeze target_ys
                                              store <- V.unsafeFreeze target_store
                                              return (new_hs, new_ys, store)

