Skip to content

Commit 3bba4a0

Browse files
authored
Basic Array API Support. Changes in core AF API (#5)
* Add backend setup * Add backend helpers * Remove c_backend constants * Rename dirs * Fix typings. Fix tests and array_api initialization * Change dtypes structure * Change project structure * Refactor to avoid misunderstanding with import * * Remove pointer source from array init * Operations refactoring * Add random. Add data * Fix tests. Add utils * Add typings from 3.10 * Add reduction operations. Add array methods * Fix the bug with the sum method. Add some test cases * Fix typing * On-call changes. Added vanilla sync, get_device * Hotfixes * Minor changes in str notes
1 parent 1889394 commit 3bba4a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+7387
-961
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- master
1414

1515
env:
16-
DEFAULT_PYTHON_VERSION: "3.8"
16+
DEFAULT_PYTHON_VERSION: "3.10"
1717

1818
defaults:
1919
run:

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[settings]
22
line_length = 119
3-
multi_line_output = 4
3+
profile = black

arrayfire/__init__.py

100644100755
Lines changed: 222 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,236 @@
1-
__all__ = [
2-
# array objects
3-
"Array",
4-
# dtypes
1+
# flake8: noqa
2+
from .version import ARRAYFIRE_VERSION, VERSION
3+
4+
__all__ = ["__version__"]
5+
__version__ = VERSION
6+
7+
__all__ += ["__arrayfire_version__"]
8+
__arrayfire_version__ = ARRAYFIRE_VERSION
9+
10+
__all__ += ["Array"]
11+
from .array_object import Array
12+
13+
__all__ += [
14+
"int8",
515
"int16",
616
"int32",
717
"int64",
818
"uint8",
919
"uint16",
1020
"uint32",
1121
"uint64",
22+
"float16",
1223
"float32",
1324
"float64",
1425
"complex64",
1526
"complex128",
1627
"bool",
1728
]
1829

19-
from .dtypes import bool, complex64, complex128, float32, float64, int16, int32, int64, uint8, uint16, uint32, uint64
20-
from .library.array_object import Array
30+
from .dtypes import (
31+
bool,
32+
complex64,
33+
complex128,
34+
float16,
35+
float32,
36+
float64,
37+
int8,
38+
int16,
39+
int32,
40+
int64,
41+
uint8,
42+
uint16,
43+
uint32,
44+
uint64,
45+
)
46+
47+
__all__ += [
48+
"get_backend",
49+
"get_active_backend", # DeprecationWarning
50+
"get_array_backend_name",
51+
"get_array_device_id",
52+
"get_available_backends", # DeprecationWarning
53+
"get_backend_count",
54+
"get_backend_id", # DeprecationWarning
55+
"get_device_id", # DeprecationWarning
56+
"get_dtype_size",
57+
"get_size_of", # DeprecationWarning
58+
"set_backend",
59+
]
60+
61+
from .backend._backend import get_backend
62+
from .backend._backend_functions import (
63+
get_active_backend,
64+
get_array_backend_name,
65+
get_array_device_id,
66+
get_available_backends,
67+
get_backend_count,
68+
get_backend_id,
69+
get_device_id,
70+
get_dtype_size,
71+
get_size_of,
72+
set_backend,
73+
)
74+
75+
__all__ += [
76+
"add",
77+
"sub",
78+
"mul",
79+
"div",
80+
"mod",
81+
"pow",
82+
"bitnot",
83+
"bitand",
84+
"bitor",
85+
"bitxor",
86+
"bitshiftl",
87+
"bitshiftr",
88+
"lt",
89+
"le",
90+
"gt",
91+
"ge",
92+
"eq",
93+
"neq",
94+
"sin",
95+
"cos",
96+
"tan",
97+
"asin",
98+
"acos",
99+
"atan",
100+
"atan2",
101+
"sinh",
102+
"cosh",
103+
"tanh",
104+
"asinh",
105+
"acosh",
106+
"atanh",
107+
"exp",
108+
"expm1",
109+
"log",
110+
"log1p",
111+
"log2",
112+
"log10",
113+
"sqrt",
114+
"cbrt",
115+
"hypot",
116+
"erf",
117+
"erfc",
118+
"tgamma",
119+
"lgamma",
120+
"pow2",
121+
"sign",
122+
"abs",
123+
"ceil",
124+
"floor",
125+
"round",
126+
"trunc",
127+
"isinf",
128+
"isnan",
129+
"iszero",
130+
"isinf",
131+
"isnan",
132+
"iszero",
133+
"isinf",
134+
"isnan",
135+
"clamp",
136+
"arg",
137+
"conjg",
138+
"cplx",
139+
"imag",
140+
"factorial",
141+
"maxof",
142+
"minof",
143+
"real",
144+
"rem",
145+
"root",
146+
"rsqrt",
147+
"sigmoid",
148+
"land",
149+
"lor",
150+
"lnot",
151+
]
152+
153+
154+
from .library.operators import (
155+
abs,
156+
acos,
157+
acosh,
158+
add,
159+
arg,
160+
asin,
161+
asinh,
162+
atan,
163+
atan2,
164+
atanh,
165+
bitand,
166+
bitnot,
167+
bitor,
168+
bitshiftl,
169+
bitshiftr,
170+
bitxor,
171+
cbrt,
172+
ceil,
173+
conjg,
174+
cos,
175+
cosh,
176+
cplx,
177+
div,
178+
eq,
179+
erf,
180+
erfc,
181+
exp,
182+
expm1,
183+
factorial,
184+
floor,
185+
ge,
186+
gt,
187+
hypot,
188+
imag,
189+
isinf,
190+
isnan,
191+
iszero,
192+
land,
193+
le,
194+
lgamma,
195+
lnot,
196+
log,
197+
log1p,
198+
log2,
199+
log10,
200+
lor,
201+
lt,
202+
maxof,
203+
minof,
204+
mod,
205+
mul,
206+
neq,
207+
pow,
208+
pow2,
209+
real,
210+
rem,
211+
root,
212+
round,
213+
rsqrt,
214+
sigmoid,
215+
sign,
216+
sin,
217+
sinh,
218+
sqrt,
219+
sub,
220+
tan,
221+
tanh,
222+
tgamma,
223+
trunc,
224+
)
225+
226+
__all__ += ["constant", "range", "identity", "flat"]
227+
228+
from arrayfire.library.data import constant, flat, identity, range
229+
230+
__all__ += ["randu"]
231+
232+
from arrayfire.library.random import randu
233+
234+
__all__ += ["all_true", "any_true"]
235+
236+
from arrayfire.library.vector_algorithms import all_true, any_true

arrayfire/array_api/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# flake8: noqa
2+
3+
__array_api_version__ = "2022.12"
4+
5+
__all__ = ["__array_api_version__"]
6+
7+
from ._constants import Device
8+
9+
__all__ += ["Device"]
10+
11+
from ._creation_function import asarray
12+
13+
__all__ += ["asarray"]
14+
15+
from ._dtypes import (
16+
bool,
17+
complex64,
18+
complex128,
19+
float32,
20+
float64,
21+
int8,
22+
int16,
23+
int32,
24+
int64,
25+
uint8,
26+
uint16,
27+
uint32,
28+
uint64,
29+
)
30+
31+
__all__ += [
32+
"int8",
33+
"int16",
34+
"int32",
35+
"int64",
36+
"uint8",
37+
"uint16",
38+
"uint32",
39+
"uint64",
40+
"float32",
41+
"float64",
42+
"bool",
43+
]

0 commit comments

Comments
 (0)