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>2026-02-12 10:16:29 +0100
commit653ad3cb2cb84ff30eb33b3d3832852a419981a7 (patch)
treef2abdba982e6857ed5203e55eaa833439c1ed5d2 /src/Data/Array/Strided
parent44d15b0b38d00df5dece3cba0a9dc749371aceb0 (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)