diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-07-21 18:58:33 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-07-21 18:59:50 +0200 |
commit | f42b2b139ed8377bcf63d7a28db237350d3cb773 (patch) | |
tree | f8918a50bacdf96a7a490c69befca8a111c0a2ee /src/Data/Array/Mixed/Internal/Arith.hs | |
parent | 774730c3b2742c59bea532e32f43fa12397a3a15 (diff) |
arith: Respect offsets in dotprodinner
Diffstat (limited to 'src/Data/Array/Mixed/Internal/Arith.hs')
-rw-r--r-- | src/Data/Array/Mixed/Internal/Arith.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Data/Array/Mixed/Internal/Arith.hs b/src/Data/Array/Mixed/Internal/Arith.hs index fc26633..0ee6708 100644 --- a/src/Data/Array/Mixed/Internal/Arith.hs +++ b/src/Data/Array/Mixed/Internal/Arith.hs @@ -23,7 +23,7 @@ import Data.Vector.Storable.Mutable qualified as VSM import Foreign.C.Types import Foreign.Marshal.Alloc (alloca) import Foreign.Ptr -import Foreign.Storable (Storable, peek, poke) +import Foreign.Storable (Storable(sizeOf), peek, poke) import GHC.TypeLits import GHC.TypeNats qualified as TypeNats import Language.Haskell.TH @@ -341,7 +341,9 @@ vectorDotprodInnerOp sn@SNat valconv ptrconv fmul fscale fred fdotinner VS.unsafeWith vec1 $ \pvec1 -> VS.unsafeWith (VS.fromListN inrank (map fromIntegral strides2)) $ \pstrides2 -> VS.unsafeWith vec2 $ \pvec2 -> - fdotinner (fromIntegral @Int @Int64 inrank) psh (ptrconv poutv) pstrides1 (ptrconv pvec1) pstrides2 (ptrconv pvec2) + fdotinner (fromIntegral @Int @Int64 inrank) psh (ptrconv poutv) + pstrides1 (ptrconv pvec1 `plusPtr` (sizeOf (undefined :: a) * offset1)) + pstrides2 (ptrconv pvec2 `plusPtr` (sizeOf (undefined :: a) * offset2)) RS.fromVector @_ @n (init sh1) <$> VS.unsafeFreeze outv {-# NOINLINE dotScalarVector #-} |