aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Strided
diff options
context:
space:
mode:
authorMikolaj Konarski <mikolaj.konarski@funktory.com>2025-12-24 19:31:38 +0100
committerMikolaj Konarski <mikolaj.konarski@funktory.com>2025-12-24 19:31:40 +0100
commit2cf2817f321f705cb0d97d2188c17067915507ea (patch)
tree72791846df14707f3db65025056260c74101ab4b /src/Data/Array/Strided
parent9abd9c73ec53250dec5783a188229712639aaa94 (diff)
Inline most lifting wrappers
This results in only marginal performance gain, probably because they are already small enough to be specialized and/or inlined automatically, but these pragmas ensure it remains so regardless of changes in GHC heuristics.
Diffstat (limited to 'src/Data/Array/Strided')
-rw-r--r--src/Data/Array/Strided/Orthotope.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Data/Array/Strided/Orthotope.hs b/src/Data/Array/Strided/Orthotope.hs
index 5c38d14..e2cd17c 100644
--- a/src/Data/Array/Strided/Orthotope.hs
+++ b/src/Data/Array/Strided/Orthotope.hs
@@ -24,14 +24,19 @@ fromO (RS.A (RG.A sh (OI.T strides offset vec))) = AS.Array sh strides offset ve
toO :: AS.Array n a -> RS.Array n a
toO (AS.Array sh strides offset vec) = RS.A (RG.A sh (OI.T strides offset vec))
+{-# INLINE liftO1 #-}
liftO1 :: (AS.Array n a -> AS.Array n' b)
-> RS.Array n a -> RS.Array n' b
liftO1 f = toO . f . fromO
+{-# INLINE liftO2 #-}
liftO2 :: (AS.Array n a -> AS.Array n1 b -> AS.Array n2 c)
-> RS.Array n a -> RS.Array n1 b -> RS.Array n2 c
liftO2 f x y = toO (f (fromO x) (fromO y))
+-- We don't inline this lifting function, because its code is not just
+-- a wrapper, being relatively long and expensive.
+{-# INLINEABLE liftVEltwise1 #-}
liftVEltwise1 :: (Storable a, Storable b)
=> SNat n
-> (VS.Vector a -> VS.Vector b)