FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-go/src/arrayfire/array.go at master · arrayfire/arrayfire-go · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
arrayfire
/
arrayfire-go
Public
Notifications
You must be signed in to change notification settings
Fork
7
Star
17
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
arrayfire-go
/
src
/
arrayfire
/
array.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
145 lines (113 loc) · 2.52 KB
Breadcrumbs
arrayfire-go
/
src
/
arrayfire
/
array.go
Copy path
File metadata and controls
145 lines (113 loc) · 2.52 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package
arrayfire
/*
#include <arrayfire.h>
#include <af/array.h>
*/
import
"C"
import
(
"runtime"
"unsafe"
)
type
(
DType
C.
af_dtype
Dim
C.
dim_t
)
type
array
struct
{
arr
C.
af_array
}
type
Array
*
array
func
release
(
a
Array
) (
e
error
) {
e
=
nil
if
a
.
arr
!=
nil
{
e
=
af_call
(
C
.
af_release_array
((
C
.
af_array
)(
a
.
arr
)))
a
.
arr
=
nil
}
return
}
func
register
(
in
array
) (
out
Array
) {
//TODO: Call runtime.GC() depending on how much memory is left on device
out
=
&
in
runtime
.
SetFinalizer
(
out
,
release
)
return
}
func
CreateArray
(
data
unsafe.
Pointer
,
ndims
uint
,
dims
[]
Dim
,
ty
DType
) (
out
Array
,
err
error
) {
out
=
nil
err
=
nil
var
a
array
err
=
af_call
(
C
.
af_create_array
(
&
a
.
arr
,
data
, (
C
.
uint
)(
ndims
),
(
*
C
.
dim_t
)(
&
dims
[
0
]), (
C
.
af_dtype
)(
ty
)))
out
=
register
(
a
)
return
}
func
CopyArray
(
in
Array
) (
out
Array
,
err
error
) {
out
=
nil
err
=
nil
var
a
array
err
=
af_call
(
C
.
af_copy_array
(
&
a
.
arr
,
in
.
arr
))
out
=
register
(
a
)
return
}
func
RetainArray
(
in
Array
) (
out
Array
,
err
error
) {
out
=
nil
err
=
nil
var
a
array
err
=
af_call
(
C
.
af_retain_array
(
&
a
.
arr
,
in
.
arr
))
out
=
register
(
a
)
return
}
/*
af_err af_create_handle(af_array *arr, const unsigned ndims, const dim_t * const dims, const af_dtype type)
{
return CALL(arr, ndims, dims, type);
}
af_err af_write_array(af_array arr, const void *data, const size_t bytes, af_source src)
{
return CALL(arr, data, bytes, src);
}
af_err af_get_data_ptr(void *data, const af_array arr)
{
return CALL(data, arr);
}
af_err af_get_data_ref_count(int *use_count, const af_array in)
{
return CALL(use_count, in);
}
af_err af_eval(af_array in)
{
return CALL(in);
}
af_err af_get_elements(dim_t *elems, const af_array arr)
{
return CALL(elems, arr);
}
af_err af_get_type(af_dtype *type, const af_array arr)
{
return CALL(type, arr);
}
af_err af_get_dims(dim_t *d0, dim_t *d1, dim_t *d2, dim_t *d3, const af_array arr)
{
return CALL(d0, d1, d2, d3, arr);
}
af_err af_get_numdims(unsigned *result, const af_array arr)
{
return CALL(result, arr);
}
#define ARRAY_HAPI_DEF(af_func) \
af_err af_func(bool *result, const af_array arr)\
{\
return CALL(result, arr);\
}
ARRAY_HAPI_DEF(af_is_empty)
ARRAY_HAPI_DEF(af_is_scalar)
ARRAY_HAPI_DEF(af_is_row)
ARRAY_HAPI_DEF(af_is_column)
ARRAY_HAPI_DEF(af_is_vector)
ARRAY_HAPI_DEF(af_is_complex)
ARRAY_HAPI_DEF(af_is_real)
ARRAY_HAPI_DEF(af_is_double)
ARRAY_HAPI_DEF(af_is_single)
ARRAY_HAPI_DEF(af_is_realfloating)
ARRAY_HAPI_DEF(af_is_floating)
ARRAY_HAPI_DEF(af_is_integer)
ARRAY_HAPI_DEF(af_is_bool)
*/
Back
|
FazBrowse Home
|
New Git URL