AccelerateHS / AccelerateHS/accelerate

Batched mapAccumL and mapAccumR

未关闭
#215 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
language new feature
主要语言
Haskell
星标
1k
派生
135
PR 合并指标
30 天内没有已合并 PR

描述

I have an array of band matrices and want to perform a batched Cholesky decomposition. I know statically the band-width and thus I can e.g. represent a symmetric 50x50 matrix with band-width 5
not only as 50x3 array of `Double`, but even more strict as 50-element array of `(Double,Double,Double)`.
The Cholesky decomposition then becomes a `mapAccumL`. Here is the running code implemented for Haskell lists:

```
cholesky3 :: (Fractional a) => [(a,a,a)] -> [(a,(a,a))]
cholesky3 =
snd .
mapAccumL
(\((d1,l31), (d2,(l32,l42))) (a33,a43,a53) ->
let d3 = a33 - l31^2 * d1 - l32^2 * d2
l43 = (a43 - l42*l32*d2) / d3
l53 = a53 / d3
c3 = (d3,(l43,l53))
in (((d2,l42), c3), c3))
((0,0), (0,(0,0)))
```

The input list contains the diagonal and sub-diagonal non-zero elements of each column and the output list contains the diagonal elements of the diagonal matrices and the sub-diagonal elements column by column.

Now I like to port that to Accelerate. Unfortunately Accelerate's variants of `scan` all require associative accumulator functions in order to get parallelization from splitting the scan. In contrast to that, I like to perform the `mapAccumL` sequentially and I want to obtain parallisation by running it on hundreds of matrices in parallel. That is, what I need is a function like this one:

```
mapAccumL ::
(Exp acc -> Exp x -> (Exp acc, Exp y)) ->
Exp acc ->
Acc (Array (ix :. Int) x) ->
Acc (Array (ix :. Int) y)
```

See the according post to the Accelerate mailing list: https://groups.google.com/forum/#!topic/accelerate-haskell/BoSWpm0FeJ4

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。