FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
array-api-comparison/scripts/array_api.js at main · data-apis/array-api-comparison · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
data-apis
/
array-api-comparison
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
56
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
array-api-comparison
/
scripts
/
array_api.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
162 lines (148 loc) · 4.01 KB
Breadcrumbs
array-api-comparison
/
scripts
/
array_api.js
Copy path
File metadata and controls
162 lines (148 loc) · 4.01 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env node
/**
*
@license
MIT
*
* Copyright (c) 2021 Python Data APIs Consortium.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
'use strict'
;
// MODULES //
var
join
=
require
(
'path'
)
.
join
;
var
readJSON
=
require
(
'@stdlib/fs/read-json'
)
.
sync
;
var
contains
=
require
(
'@stdlib/assert/contains'
)
;
var
ARRAY_API
=
require
(
'./../data/raw/array_api.json'
)
;
// VARIABLES //
var
TORCH_LINALG
=
[
'torch.linalg.cholesky'
,
'torch.linalg.cond'
,
'torch.linalg.det'
,
'torch.linalg.slogdet'
,
'torch.linalg.eigh'
,
'torch.linalg.eigvalsh'
,
'torch.linalg.matrix_rank'
,
'torch.linalg.norm'
,
'torch.linalg.pinv'
,
'torch.linalg.svd'
,
'torch.linalg.solve'
,
'torch.linalg.tensorinv'
,
'torch.linalg.tensorsolve'
,
'torch.linalg.inv'
,
'torch.linalg.qr'
]
;
var
LIBRARIES
=
[
'numpy'
,
'cupy'
,
'dask'
,
'jax'
,
'mxnet'
,
'pytorch'
,
'sparse'
,
'tensorflow'
]
;
var
PREFIXES
=
{
'numpy'
:
'numpy._array_api.'
,
// 'numpy.',
'cupy'
:
'cupy.'
,
'dask'
:
''
,
'jax'
:
''
,
'mxnet'
:
'mxnet.ndarray.'
,
'pytorch'
:
'torch.'
,
'sparse'
:
''
,
'tensorflow'
:
'tf.'
}
;
var
FOPTS
=
{
'encoding'
:
'utf8'
}
;
// MAIN //
/**
* Main execution sequence.
*
*
@private
*/
function
main
(
)
{
var
counts
;
var
fpath
;
var
alias
;
var
name
;
var
data
;
var
out
;
var
tmp
;
var
key
;
var
fcn
;
var
o
;
var
i
;
var
j
;
var
k
;
counts
=
{
'name'
:
'Total APIs: '
+
ARRAY_API
.
length
}
;
for
(
j
=
0
;
j
<
LIBRARIES
.
length
;
j
++
)
{
key
=
LIBRARIES
[
j
]
;
// TODO: remove once https://github.com/numpy/numpy/pull/18585 is merged; here, we mark with an asterisk to indicate that this is in-progress...
if
(
key
===
'numpy'
)
{
key
+=
'<sup>*</sup>'
;
}
counts
[
key
]
=
0
;
}
out
=
[
]
;
for
(
i
=
0
;
i
<
ARRAY_API
.
length
;
i
++
)
{
name
=
ARRAY_API
[
i
]
;
tmp
=
{
'name'
:
name
}
;
for
(
j
=
0
;
j
<
LIBRARIES
.
length
;
j
++
)
{
key
=
LIBRARIES
[
j
]
;
if
(
key
===
'numpy'
)
{
// For NumPy, we base the data off a WIP PR: https://github.com/numpy/numpy/pull/18585
fpath
=
join
(
__dirname
,
'..'
,
'data'
,
'raw'
,
key
+
'_array_api.json'
)
;
}
else
{
fpath
=
join
(
__dirname
,
'..'
,
'data'
,
'raw'
,
key
+
'.json'
)
;
}
data
=
readJSON
(
fpath
,
FOPTS
)
;
if
(
data
instanceof
Error
)
{
throw
data
;
}
alias
=
PREFIXES
[
key
]
+
name
;
for
(
k
=
0
;
k
<
data
.
length
;
k
++
)
{
o
=
data
[
k
]
;
if
(
o
.
name
===
alias
||
(
key
===
'pytorch'
&&
contains
(
TORCH_LINALG
,
alias
)
)
)
{
// TODO: remove once https://github.com/numpy/numpy/pull/18585 is merged; here, we mark with an asterisk to indicate that this is in-progress...
if
(
key
===
'numpy'
)
{
key
+=
'<sup>*</sup>'
;
}
tmp
[
key
]
=
'🚀'
;
// '🙌'; // '🐍'; // '👍';
counts
[
key
]
+=
1
;
break
;
}
}
if
(
k
===
data
.
length
)
{
// TODO: remove once WIP PR https://github.com/numpy/numpy/pull/18585 is merged:
if
(
key
===
'numpy'
)
{
key
+=
'<sup>*</sup>'
;
}
tmp
[
key
]
=
''
;
}
}
out
.
push
(
tmp
)
;
}
out
.
push
(
counts
)
;
// Print the data as JSON to stdout:
console
.
log
(
JSON
.
stringify
(
out
,
null
,
2
)
)
;
}
main
(
)
;
Back
|
FazBrowse Home
|
New Git URL