FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-python/tests/simple/device.py at master · arrayfire/arrayfire-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
arrayfire
/
arrayfire-python
Public
Notifications
You must be signed in to change notification settings
Fork
64
Star
422
Code
Issues
57
Pull requests
3
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
arrayfire-python
/
tests
/
simple
/
device.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
77 lines (59 loc) · 1.91 KB
Breadcrumbs
arrayfire-python
/
tests
/
simple
/
device.py
Copy path
File metadata and controls
77 lines (59 loc) · 1.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
#######################################################
# Copyright (c) 2015, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
import
arrayfire
as
af
from
.
import
_util
def
simple_device
(
verbose
=
False
):
display_func
=
_util
.
display_func
(
verbose
)
print_func
=
_util
.
print_func
(
verbose
)
print_func
(
af
.
device_info
())
print_func
(
af
.
get_device_count
())
print_func
(
af
.
is_dbl_supported
())
af
.
sync
()
curr_dev
=
af
.
get_device
()
print_func
(
curr_dev
)
for
k
in
range
(
af
.
get_device_count
()):
af
.
set_device
(
k
)
dev
=
af
.
get_device
()
assert
(
k
==
dev
)
print_func
(
af
.
is_dbl_supported
(
k
))
af
.
device_gc
()
mem_info_old
=
af
.
device_mem_info
()
a
=
af
.
randu
(
100
,
100
)
af
.
sync
(
dev
)
mem_info
=
af
.
device_mem_info
()
assert
(
mem_info
[
"alloc"
][
"buffers"
]
==
1
+
mem_info_old
[
"alloc"
][
"buffers"
])
assert
(
mem_info
[
"lock"
][
"buffers"
]
==
1
+
mem_info_old
[
"lock"
][
"buffers"
])
af
.
set_device
(
curr_dev
)
a
=
af
.
randu
(
10
,
10
)
display_func
(
a
)
dev_ptr
=
af
.
get_device_ptr
(
a
)
print_func
(
dev_ptr
)
b
=
af
.
Array
(
src
=
dev_ptr
,
dims
=
a
.
dims
(),
dtype
=
a
.
dtype
(),
is_device
=
True
)
display_func
(
b
)
c
=
af
.
randu
(
10
,
10
)
af
.
lock_array
(
c
)
af
.
unlock_array
(
c
)
a
=
af
.
constant
(
1
,
3
,
3
)
b
=
af
.
constant
(
2
,
3
,
3
)
af
.
eval
(
a
)
af
.
eval
(
b
)
print_func
(
a
)
print_func
(
b
)
c
=
a
+
b
d
=
a
-
b
af
.
eval
(
c
,
d
)
print_func
(
c
)
print_func
(
d
)
print_func
(
af
.
set_manual_eval_flag
(
True
))
assert
(
af
.
get_manual_eval_flag
())
print_func
(
af
.
set_manual_eval_flag
(
False
))
assert
(
not
af
.
get_manual_eval_flag
())
display_func
(
af
.
is_locked_array
(
a
))
_util
.
tests
[
"device"
]
=
simple_device
Back
|
FazBrowse Home
|
New Git URL