diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-05-23 23:09:54 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-05-23 23:09:54 +0200 |
commit | 2fad94b1549bcf2ca3ac5a0571e37e3d5b08ca96 (patch) | |
tree | db416c070383723fbed81b78f4c4d94ea1cc45ce /src/Data/Array/Nested/Internal | |
parent | c231637529ce7fc5b321c24a24320b505df51e91 (diff) |
Bugfix in wrapper for C reduce op
Diffstat (limited to 'src/Data/Array/Nested/Internal')
-rw-r--r-- | src/Data/Array/Nested/Internal/Arith.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Data/Array/Nested/Internal/Arith.hs b/src/Data/Array/Nested/Internal/Arith.hs index bd582b7..4bfc043 100644 --- a/src/Data/Array/Nested/Internal/Arith.hs +++ b/src/Data/Array/Nested/Internal/Arith.hs @@ -144,7 +144,8 @@ vectorRedInnerOp :: forall a b n. (Num a, Storable a) -> RS.Array (n + 1) a -> RS.Array n a vectorRedInnerOp sn@SNat valconv ptrconv fscale fred (RS.A (RG.A sh (OI.T strides offset vec))) | null sh = error "unreachable" - | any (<= 0) sh = RS.A (RG.A (init sh) (OI.T (map (const 0) (init strides)) 0 VS.empty)) + | last sh <= 0 = RS.stretch (init sh) (RS.fromList (map (const 1) (init sh)) [0]) + | any (<= 0) (init sh) = RS.A (RG.A (init sh) (OI.T (map (const 0) (init strides)) 0 VS.empty)) -- now the input array is nonempty | last sh == 1 = RS.A (RG.A (init sh) (OI.T (init strides) offset vec)) | last strides == 0 = |