forked from arrayfire/arrayfire-binary-python-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinclusive_scan_operations.py
41 lines (32 loc) · 1.47 KB
/
inclusive_scan_operations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import ctypes
from arrayfire_wrapper.defines import AFArray
from arrayfire_wrapper.lib._constants import BinaryOperator
from arrayfire_wrapper.lib._utility import call_from_clib
def accum(arr: AFArray, dim: int, /) -> AFArray:
"""
source: https://arrayfire.org/docs/group__scan__func__accum.htm#ga50d499e844e0b63e338cb3ea50439629
"""
out = AFArray.create_null_pointer()
call_from_clib(accum.__name__, ctypes.pointer(out), arr, ctypes.c_int(dim))
return out
def scan(arr: AFArray, dim: int, op: BinaryOperator, inclusive_scan: bool, /) -> AFArray:
"""
source: https://arrayfire.org/docs/group__scan__func__scan.htm#ga1c864e22826f61bec2e9b6c61aa93fce
"""
out = AFArray.create_null_pointer()
call_from_clib(scan.__name__, ctypes.pointer(out), arr, dim, op.value, inclusive_scan)
return out
def scan_by_key(key: AFArray, arr: AFArray, dim: int, op: BinaryOperator, inclusive_scan: bool, /) -> AFArray:
"""
source: https://arrayfire.org/docs/group__scan__func__scanbykey.htm#gaaae150e0f197782782f45340d137b027
"""
out = AFArray.create_null_pointer()
call_from_clib(scan_by_key.__name__, ctypes.pointer(out), key, arr, dim, op.value, inclusive_scan)
return out
def where(arr: AFArray, /) -> AFArray:
"""
source: https://arrayfire.org/docs/group__scan__func__where.htm#gafda59a3d25d35238592dd09907be9d07
"""
out = AFArray.create_null_pointer()
call_from_clib(where.__name__, ctypes.pointer(out), arr)
return out