Skip to content

Commit c44d1f7

Browse files
committed
Bump version, NOINLINE.
1 parent 723c64a commit c44d1f7

8 files changed

Lines changed: 34 additions & 11 deletions

File tree

arrayfire.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 3.0
22
name: arrayfire
3-
version: 0.7.1.0
3+
version: 0.8.0.0
44
synopsis: Haskell bindings to the ArrayFire general-purpose GPU library
55
homepage: https://github.com/arrayfire/arrayfire-haskell
66
license: BSD-3-Clause

src/ArrayFire/Algorithm.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,11 @@ setIntersect a1 a2 (fromIntegral . fromEnum -> b) =
667667
--
668668
-- >>> sumByKey (vector @Int 5 [1,1,2,2,2]) (vector @Double 5 [10,20,1,2,3]) 0
669669
-- (ArrayFire Array
670-
-- [3 1 1 1]
671-
-- 1 2 3,
670+
-- [2 1 1 1]
671+
-- 1 2,
672672
-- ArrayFire Array
673-
-- [3 1 1 1]
674-
-- 30.0000 6.0000 ...)
673+
-- [2 1 1 1]
674+
-- 30.0000 6.0000)
675675
sumByKey
676676
:: AFType a
677677
=> Array Int

src/ArrayFire/Array.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ isSparse a = toEnum . fromIntegral $ (a `infoFromArray` af_is_sparse)
479479
-- >>> toVector (vector @Double 10 [1..])
480480
-- [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0]
481481
toVector :: forall a . AFType a => Array a -> Vector a
482-
toVector arr@(Array fptr) = do
482+
{-# NOINLINE toVector #-}
483+
toVector arr@(Array fptr) =
483484
unsafePerformIO . mask_ . withForeignPtr fptr $ \arrPtr -> do
484485
let len = getElements arr
485486
size = len * getSizeOf (Proxy @a)
@@ -500,6 +501,7 @@ toList = V.toList . toVector
500501
-- >>> getScalar (scalar @Double 22.0) :: Double
501502
-- 22.0
502503
getScalar :: forall a b . (Storable a, AFType b) => Array b -> a
504+
{-# NOINLINE getScalar #-}
503505
getScalar (Array fptr) =
504506
unsafePerformIO . mask_ . withForeignPtr fptr $ \arrPtr -> do
505507
alloca $ \ptr -> do

src/ArrayFire/Data.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ constant
6363
-> a
6464
-- ^ Scalar value
6565
-> Array a
66+
{-# NOINLINE constant #-}
6667
constant dims val =
6768
case dtyp of
6869
x | x == c64 ->
@@ -210,8 +211,9 @@ range
210211
=> [Int]
211212
-> Int
212213
-> Array a
213-
range dims (fromIntegral -> k) = unsafePerformIO $ do
214-
ptr <- alloca $ \ptrPtr -> mask_ $ do
214+
{-# NOINLINE range #-}
215+
range dims (fromIntegral -> k) = unsafePerformIO . mask_ $ do
216+
ptr <- alloca $ \ptrPtr -> do
215217
withArray (fromIntegral <$> dims) $ \dimArray -> do
216218
throwAFError =<< af_range ptrPtr n dimArray k typ
217219
peek ptrPtr
@@ -252,10 +254,11 @@ iota
252254
-- ^ is array containing the number of repetitions of the unit dimensions
253255
-> Array a
254256
-- ^ is the generated array
255-
iota dims tdims = unsafePerformIO $ do
257+
{-# NOINLINE iota #-}
258+
iota dims tdims = unsafePerformIO . mask_ $ do
256259
let dims' = take 4 (dims ++ repeat 1)
257260
tdims' = take 4 (tdims ++ repeat 1)
258-
ptr <- alloca $ \ptrPtr -> mask_ $ do
261+
ptr <- alloca $ \ptrPtr -> do
259262
zeroOutArray ptrPtr
260263
withArray (fromIntegral <$> dims') $ \dimArray ->
261264
withArray (fromIntegral <$> tdims') $ \tdimArray -> do
@@ -280,6 +283,7 @@ identity
280283
=> [Int]
281284
-- ^ Dimensions
282285
-> Array a
286+
{-# NOINLINE identity #-}
283287
identity dims = unsafePerformIO . mask_ $ do
284288
let dims' = take 4 (dims ++ repeat 1)
285289
ptr <- alloca $ \ptrPtr -> mask_ $ do
@@ -357,6 +361,7 @@ joinMany
357361
:: Int
358362
-> [Array a]
359363
-> Array a
364+
{-# NOINLINE joinMany #-}
360365
joinMany (fromIntegral -> n) (fmap (\(Array fp) -> fp) -> arrays) = unsafePerformIO . mask_ $ do
361366
newPtr <- alloca $ \aPtr -> do
362367
zeroOutArray aPtr
@@ -444,6 +449,7 @@ moddims
444449
:: Array a
445450
-> [Int]
446451
-> Array a
452+
{-# NOINLINE moddims #-}
447453
moddims (Array fptr) dims =
448454
unsafePerformIO . mask_ . withForeignPtr fptr $ \ptr -> do
449455
newPtr <- alloca $ \aPtr -> do

src/ArrayFire/Features.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
--------------------------------------------------------------------------------
1818
module ArrayFire.Features where
1919

20+
import Control.Exception (mask_)
2021
import Foreign.Marshal
2122
import Foreign.Storable
2223
import Foreign.ForeignPtr
@@ -34,8 +35,9 @@ import ArrayFire.Exception
3435
createFeatures
3536
:: Int
3637
-> Features
38+
{-# NOINLINE createFeatures #-}
3739
createFeatures (fromIntegral -> n) =
38-
unsafePerformIO $ do
40+
unsafePerformIO . mask_ $ do
3941
ptr <-
4042
alloca $ \ptrInput -> do
4143
throwAFError =<< ptrInput `af_create_features` n

src/ArrayFire/Index.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ index
2929
-> [Seq]
3030
-- ^ 'Seq' to use for indexing
3131
-> Array a
32+
{-# NOINLINE index #-}
3233
index (Array fptr) seqs =
3334
unsafePerformIO . mask_ . withForeignPtr fptr $ \ptr -> do
3435
alloca $ \aptr ->
@@ -66,6 +67,7 @@ assignSeq
6667
-- ^ Source array
6768
-> Array a
6869
-- ^ Result with values written at the specified indices
70+
{-# NOINLINE assignSeq #-}
6971
assignSeq (Array fptr) seqs (Array rhsFptr) =
7072
unsafePerformIO . mask_ $
7173
withForeignPtr fptr $ \ptr ->
@@ -90,6 +92,7 @@ indexGen
9092
-- ^ List of 'Index' values (one per dimension)
9193
-> Array a
9294
-- ^ Indexed result
95+
{-# NOINLINE indexGen #-}
9396
indexGen (Array fptr) indices =
9497
unsafePerformIO . mask_ $
9598
withForeignPtr fptr $ \ptr -> do
@@ -120,6 +123,7 @@ assignGen
120123
-- ^ Source array
121124
-> Array a
122125
-- ^ Result with values written at the specified indices
126+
{-# NOINLINE assignGen #-}
123127
assignGen (Array fptr) indices (Array rhsFptr) =
124128
unsafePerformIO . mask_ $
125129
withForeignPtr fptr $ \ptr ->

src/ArrayFire/Util.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ arrayToString
258258
-- ^ If 'True', performs takes the transpose before rendering to 'String'
259259
-> String
260260
-- ^ 'Array' rendered to 'String'
261+
{-# NOINLINE arrayToString #-}
261262
arrayToString expr (Array fptr) (fromIntegral -> prec) (fromIntegral . fromEnum -> trans) =
262263
unsafePerformIO . mask_ . withForeignPtr fptr $ \aptr ->
263264
withCString expr $ \expCstr ->
@@ -279,6 +280,7 @@ getSizeOf
279280
-- ^ Witness of Haskell type that mirrors ArrayFire type.
280281
-> Int
281282
-- ^ Size of ArrayFire type
283+
{-# NOINLINE getSizeOf #-}
282284
getSizeOf proxy =
283285
unsafePerformIO . mask_ . alloca $ \csize -> do
284286
throwAFError =<< af_get_size_of csize (afType proxy)

src/ArrayFire/Vision.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fast
5050
-- ^ Is the length of the edges in the image to be discarded by FAST (minimum is 3, as the radius of the circle)
5151
-> Features
5252
-- ^ Struct containing arrays for x and y coordinates and score, while array orientation is set to 0 as FAST does not compute orientation, and size is set to 1 as FAST does not compute multiple scales
53+
{-# NOINLINE fast #-}
5354
fast (Array fptr) thr (fromIntegral -> arc) (fromIntegral . fromEnum -> non) ratio (fromIntegral -> edge)
5455
= unsafePerformIO . mask_ . withForeignPtr fptr $ \aptr ->
5556
do feat <- alloca $ \ptr -> do
@@ -78,6 +79,7 @@ harris
7879
-> Float
7980
-- ^ struct containing arrays for x and y coordinates and score (Harris response), while arrays orientation and size are set to 0 and 1, respectively, because Harris does not compute that information
8081
-> Features
82+
{-# NOINLINE harris #-}
8183
harris (Array fptr) (fromIntegral -> maxc) minresp sigma (fromIntegral -> bs) thr
8284
= unsafePerformIO . mask_ . withForeignPtr fptr $ \aptr ->
8385
do feat <- alloca $ \ptr -> do
@@ -107,6 +109,7 @@ orb
107109
-- ^ blur image with a Gaussian filter with sigma=2 before computing descriptors to increase robustness against noise if true
108110
-> (Features, Array a)
109111
-- ^ 'Features' struct composed of arrays for x and y coordinates, score, orientation and size of selected features
112+
{-# NOINLINE orb #-}
110113
orb (Array fptr) thr (fromIntegral -> feat) scl (fromIntegral -> levels) (fromIntegral . fromEnum -> blur)
111114
= unsafePerformIO . mask_ . withForeignPtr fptr $ \inptr ->
112115
do (feature, arr) <-
@@ -144,6 +147,7 @@ sift
144147
-> (Features, Array a)
145148
-- ^ Features object composed of arrays for x and y coordinates, score, orientation and size of selected features
146149
-- Nx128 array containing extracted descriptors, where N is the number of features found by SIFT
150+
{-# NOINLINE sift #-}
147151
sift (Array fptr) (fromIntegral -> a) b c d (fromIntegral . fromEnum -> e) f g
148152
= unsafePerformIO . mask_ . withForeignPtr fptr $ \inptr ->
149153
do (feat, arr) <-
@@ -181,6 +185,7 @@ gloh
181185
-> (Features, Array a)
182186
-- ^ 'Features' object composed of arrays for x and y coordinates, score, orientation and size of selected features
183187
-- ^ Nx272 array containing extracted GLOH descriptors, where N is the number of features found by SIFT
188+
{-# NOINLINE gloh #-}
184189
gloh (Array fptr) (fromIntegral -> a) b c d (fromIntegral . fromEnum -> e) f g
185190
= unsafePerformIO . mask_ . withForeignPtr fptr $ \inptr ->
186191
do (feat, arr) <-
@@ -274,6 +279,7 @@ susan
274279
-> Int
275280
-- ^ indicates how many pixels width area should be skipped for corner detection
276281
-> Features
282+
{-# NOINLINE susan #-}
277283
susan (Array fptr) (fromIntegral -> a) b c d (fromIntegral -> e)
278284
= unsafePerformIO . mask_ . withForeignPtr fptr $ \inptr ->
279285
do feat <-
@@ -329,6 +335,7 @@ homography
329335
-> (Int, Array a)
330336
-- ^ is a 3x3 array containing the estimated homography.
331337
-- is the number of inliers that the homography was estimated to comprise, in the case that htype is AF_HOMOGRAPHY_RANSAC, a higher inlier_thr value will increase the estimated inliers. Note that if the number of inliers is too low, it is likely that a bad homography will be returned.
338+
{-# NOINLINE homography #-}
332339
homography
333340
(Array a)
334341
(Array b)

0 commit comments

Comments
 (0)