Skip to content

Commit 53cea80

Browse files
committed
initial v34 api additions to python wrapper
1 parent af9854a commit 53cea80

File tree

4 files changed

+110
-0
lines changed

4 files changed

+110
-0
lines changed

arrayfire/algorithm.py

+57
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,63 @@ def accum(a, dim=0):
299299
"""
300300
return _parallel_dim(a, dim, backend.get().af_accum)
301301

302+
def scan(a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
303+
"""
304+
Generalized scan of an array.
305+
306+
Parameters
307+
----------
308+
a : af.Array
309+
Multi dimensional arrayfire array.
310+
311+
dim : optional: int. default: 0
312+
Dimension along which the scan is performed.
313+
314+
op : optional: af.BINARYOP. default: af.BINARYOP.BINARY_ADD.
315+
- Interpolation method used for resizing.
316+
317+
inclusive_scan: optional: bool. default: True
318+
Specifies if the scan is inclusive
319+
320+
Returns
321+
---------
322+
out : af.Array
323+
- will contain scan of input.
324+
"""
325+
out = Array()
326+
safe_call(backend.get().af_scan(ct.pointer(out.arr), a.arr, dim, op, inclusive_scan))
327+
return out
328+
329+
def scanByKey(key, a, dim=0, op=BINARYOP.BINARY_ADD, inclusive_scan=True):
330+
"""
331+
Generalized scan by key of an array.
332+
333+
Parameters
334+
----------
335+
key : af.Array
336+
key array.
337+
338+
a : af.Array
339+
Multi dimensional arrayfire array.
340+
341+
dim : optional: int. default: 0
342+
Dimension along which the scan is performed.
343+
344+
op : optional: af.BINARYOP. default: af.BINARYOP.BINARY_ADD.
345+
- Interpolation method used for resizing.
346+
347+
inclusive_scan: optional: bool. default: True
348+
Specifies if the scan is inclusive
349+
350+
Returns
351+
---------
352+
out : af.Array
353+
- will contain scan of input.
354+
"""
355+
out = Array()
356+
safe_call(backend.get().af_scan(ct.pointer(out.arr), key.arr, a.arr, dim, op, inclusive_scan))
357+
return out
358+
302359
def where(a):
303360
"""
304361
Find the indices of non zero elements

arrayfire/image.py

+22
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,28 @@ def rgb2ycbcr(image, standard=YCC_STD.BT_601):
11981198
safe_call(backend.get().af_rgb2ycbcr(ct.pointer(out.arr), image.arr, standard.value))
11991199
return out
12001200

1201+
def moments(image, moment = MOMENT.MOMENT_FIRST_ORDER):
1202+
"""
1203+
Calculate image moments.
1204+
1205+
Parameters
1206+
----------
1207+
image : af.Array
1208+
- A 2 D arrayfire array representing an image, or
1209+
- A multi dimensional array representing batch of images.
1210+
1211+
moment : optional: af.MOMENT. default: af.MOMENT.MOMENT_FIRST_ORDER.
1212+
- Moment(s) to calculate
1213+
1214+
Returns
1215+
---------
1216+
out : af.Array
1217+
- array containing requested moment(s) of each image
1218+
"""
1219+
output = Array()
1220+
safe_call(backend.get().af_moments(ct.pointer(output.arr), image.arr, moment.value))
1221+
return output
1222+
12011223
def is_image_io_available():
12021224
"""
12031225
Function to check if the arrayfire library was built with Image IO support.

arrayfire/library.py

+19
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,25 @@ class MARKER(_Enum):
349349
PLUS = _Enum_Type(6)
350350
STAR = _Enum_Type(7)
351351

352+
class MOMENT(_Enum):
353+
"""
354+
Image Moments
355+
"""
356+
MOMENT_M00 = _Enum_Type(1)
357+
MOMENT_M01 = _Enum_Type(2)
358+
MOMENT_M10 = _Enum_Type(4)
359+
MOMENT_M11 = _Enum_Type(8)
360+
MOMENT_FIRST_ORDER = _Enum_Type(15)
361+
362+
class BINARYOP(_Enum):
363+
"""
364+
Binary Operators
365+
"""
366+
BINARY_ADD = _Enum_Type(0)
367+
BINARY_MUL = _Enum_Type(1)
368+
BINARY_MIN = _Enum_Type(2)
369+
BINARY_MAX = _Enum_Type(3)
370+
352371
def _setup():
353372
import platform
354373
import os

arrayfire/signal.py

+12
Original file line numberDiff line numberDiff line change
@@ -1264,3 +1264,15 @@ def iir(B, A, X):
12641264
Y = Array()
12651265
safe_call(backend.get().af_iir(ct.pointer(Y.arr), B.arr, A.arr, X.arr))
12661266
return Y
1267+
1268+
def set_fft_plan_cache_size(cache_size):
1269+
"""
1270+
Sets plan cache size.
1271+
1272+
Parameters
1273+
----------
1274+
1275+
cache_size : scalar
1276+
the number of plans that shall be cached
1277+
"""
1278+
safe_call(backend.get().af_set_fft_plan_cache_size(ct.c_size_t(cache_size)))

0 commit comments

Comments
 (0)