From 2fad94b1549bcf2ca3ac5a0571e37e3d5b08ca96 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 23 May 2024 23:09:54 +0200 Subject: Bugfix in wrapper for C reduce op --- src/Data/Array/Nested/Internal/Arith.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Data') 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 = -- cgit v1.2.3-70-g09d2