From 2cf2817f321f705cb0d97d2188c17067915507ea Mon Sep 17 00:00:00 2001 From: Mikolaj Konarski Date: Wed, 24 Dec 2025 19:31:38 +0100 Subject: 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. --- src/Data/Array/Strided/Orthotope.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Data/Array/Strided') 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) -- cgit v1.2.3-70-g09d2