flopscope 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- benchmarks/__init__.py +1 -0
- benchmarks/__main__.py +6 -0
- benchmarks/_baseline.py +171 -0
- benchmarks/_bitwise.py +231 -0
- benchmarks/_complex.py +176 -0
- benchmarks/_contractions.py +291 -0
- benchmarks/_fft.py +198 -0
- benchmarks/_impl_urls.py +139 -0
- benchmarks/_linalg.py +197 -0
- benchmarks/_linalg_delegates.py +407 -0
- benchmarks/_metadata.py +141 -0
- benchmarks/_misc.py +653 -0
- benchmarks/_perf.py +321 -0
- benchmarks/_perm_group_calibration.py +175 -0
- benchmarks/_pointwise.py +372 -0
- benchmarks/_polynomial.py +193 -0
- benchmarks/_random.py +209 -0
- benchmarks/_reductions.py +136 -0
- benchmarks/_sorting.py +289 -0
- benchmarks/_stats.py +137 -0
- benchmarks/_window.py +92 -0
- benchmarks/accumulation/__init__.py +0 -0
- benchmarks/accumulation/bench_cost_compute.py +138 -0
- benchmarks/dashboard.py +312 -0
- benchmarks/runner.py +636 -0
- flopscope/__init__.py +273 -0
- flopscope/_accumulation/__init__.py +13 -0
- flopscope/_accumulation/_bipartite.py +121 -0
- flopscope/_accumulation/_burnside.py +51 -0
- flopscope/_accumulation/_cache.py +146 -0
- flopscope/_accumulation/_components.py +153 -0
- flopscope/_accumulation/_cost.py +1414 -0
- flopscope/_accumulation/_cost_descriptions.py +63 -0
- flopscope/_accumulation/_detection.py +318 -0
- flopscope/_accumulation/_ladder.py +191 -0
- flopscope/_accumulation/_output_orbit.py +104 -0
- flopscope/_accumulation/_partition.py +290 -0
- flopscope/_accumulation/_path_info.py +211 -0
- flopscope/_accumulation/_public.py +169 -0
- flopscope/_accumulation/_reduction.py +310 -0
- flopscope/_accumulation/_regimes.py +303 -0
- flopscope/_accumulation/_shape.py +33 -0
- flopscope/_accumulation/_wreath.py +209 -0
- flopscope/_budget.py +1027 -0
- flopscope/_config.py +118 -0
- flopscope/_counting_ops.py +451 -0
- flopscope/_display.py +478 -0
- flopscope/_docstrings.py +59 -0
- flopscope/_dtypes.py +20 -0
- flopscope/_einsum.py +717 -0
- flopscope/_errstate.py +25 -0
- flopscope/_flops.py +282 -0
- flopscope/_free_ops.py +2654 -0
- flopscope/_ndarray.py +1126 -0
- flopscope/_opt_einsum/LICENSE +21 -0
- flopscope/_opt_einsum/NOTICE +59 -0
- flopscope/_opt_einsum/__init__.py +209 -0
- flopscope/_opt_einsum/_contract.py +1478 -0
- flopscope/_opt_einsum/_helpers.py +164 -0
- flopscope/_opt_einsum/_hsluv.py +273 -0
- flopscope/_opt_einsum/_path_random.py +462 -0
- flopscope/_opt_einsum/_paths.py +1653 -0
- flopscope/_opt_einsum/_subgraph_symmetry.py +544 -0
- flopscope/_opt_einsum/_symmetry.py +140 -0
- flopscope/_opt_einsum/_typing.py +37 -0
- flopscope/_perm_group.py +717 -0
- flopscope/_pointwise.py +2522 -0
- flopscope/_polynomial.py +278 -0
- flopscope/_registry.py +3216 -0
- flopscope/_sorting_ops.py +571 -0
- flopscope/_symmetric.py +812 -0
- flopscope/_symmetry_transport.py +510 -0
- flopscope/_symmetry_utils.py +669 -0
- flopscope/_type_info.py +12 -0
- flopscope/_unwrap.py +70 -0
- flopscope/_validation.py +83 -0
- flopscope/_version_check.py +46 -0
- flopscope/_weights.py +195 -0
- flopscope/_window.py +177 -0
- flopscope/accounting.py +565 -0
- flopscope/data/default_weights.json +462 -0
- flopscope/data/weights.csv +509 -0
- flopscope/errors.py +197 -0
- flopscope/numpy/__init__.py +878 -0
- flopscope/numpy/fft/__init__.py +55 -0
- flopscope/numpy/fft/_free.py +51 -0
- flopscope/numpy/fft/_transforms.py +695 -0
- flopscope/numpy/linalg/__init__.py +105 -0
- flopscope/numpy/linalg/_aliases.py +126 -0
- flopscope/numpy/linalg/_compound.py +161 -0
- flopscope/numpy/linalg/_decompositions.py +353 -0
- flopscope/numpy/linalg/_properties.py +533 -0
- flopscope/numpy/linalg/_solvers.py +444 -0
- flopscope/numpy/linalg/_svd.py +122 -0
- flopscope/numpy/random/__init__.py +684 -0
- flopscope/numpy/random/_cost_formulas.py +115 -0
- flopscope/numpy/random/_counted_classes.py +241 -0
- flopscope/numpy/testing/__init__.py +13 -0
- flopscope/numpy/typing/__init__.py +30 -0
- flopscope/py.typed +0 -0
- flopscope/stats/__init__.py +84 -0
- flopscope/stats/_base.py +77 -0
- flopscope/stats/_cauchy.py +146 -0
- flopscope/stats/_erf.py +190 -0
- flopscope/stats/_expon.py +146 -0
- flopscope/stats/_laplace.py +150 -0
- flopscope/stats/_logistic.py +148 -0
- flopscope/stats/_lognorm.py +160 -0
- flopscope/stats/_ndtri.py +133 -0
- flopscope/stats/_norm.py +149 -0
- flopscope/stats/_truncnorm.py +186 -0
- flopscope/stats/_uniform.py +141 -0
- flopscope-0.2.0.dist-info/METADATA +23 -0
- flopscope-0.2.0.dist-info/RECORD +115 -0
- flopscope-0.2.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
"""flopscope.numpy — counted drop-in for numpy (JAX-style).
|
|
2
|
+
|
|
3
|
+
Usage::
|
|
4
|
+
|
|
5
|
+
import flopscope.numpy as fnp
|
|
6
|
+
|
|
7
|
+
a = fnp.array([1, 2, 3])
|
|
8
|
+
b = fnp.einsum('ij,j->i', W, x)
|
|
9
|
+
u, s, vt = fnp.linalg.svd(M)
|
|
10
|
+
|
|
11
|
+
All operations exposed here are counted against the currently active
|
|
12
|
+
:class:`~flopscope.BudgetContext`. Accessing an attribute that flopscope
|
|
13
|
+
does not implement raises :class:`AttributeError` — there is no
|
|
14
|
+
transparent fallback to ``numpy``. This is deliberate: silently exposing
|
|
15
|
+
uncounted numpy operations would defeat the purpose of FLOP accounting.
|
|
16
|
+
If you need a raw numpy operation, import ``numpy`` directly.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import importlib as _importlib
|
|
20
|
+
|
|
21
|
+
import numpy as _np
|
|
22
|
+
|
|
23
|
+
# --- Counting, histogram & generation ops (counted) ---
|
|
24
|
+
from flopscope._counting_ops import ( # noqa: F401
|
|
25
|
+
allclose,
|
|
26
|
+
apply_along_axis,
|
|
27
|
+
apply_over_axes,
|
|
28
|
+
array_equal,
|
|
29
|
+
array_equiv,
|
|
30
|
+
bincount,
|
|
31
|
+
geomspace,
|
|
32
|
+
histogram,
|
|
33
|
+
histogram2d,
|
|
34
|
+
histogram_bin_edges,
|
|
35
|
+
histogramdd,
|
|
36
|
+
logspace,
|
|
37
|
+
piecewise,
|
|
38
|
+
trace,
|
|
39
|
+
vander,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# --- dtype utilities ---
|
|
43
|
+
from flopscope._dtypes import ( # noqa: F401
|
|
44
|
+
dtype,
|
|
45
|
+
floating,
|
|
46
|
+
integer,
|
|
47
|
+
number,
|
|
48
|
+
uint16,
|
|
49
|
+
uint32,
|
|
50
|
+
uint64,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# --- Einsum ---
|
|
54
|
+
from flopscope._einsum import ( # noqa: F401
|
|
55
|
+
clear_einsum_cache,
|
|
56
|
+
einsum,
|
|
57
|
+
einsum_cache_info,
|
|
58
|
+
einsum_path,
|
|
59
|
+
)
|
|
60
|
+
from flopscope._errstate import ( # noqa: F401
|
|
61
|
+
broadcast,
|
|
62
|
+
errstate,
|
|
63
|
+
get_printoptions,
|
|
64
|
+
geterr,
|
|
65
|
+
ndenumerate,
|
|
66
|
+
ndindex,
|
|
67
|
+
nditer,
|
|
68
|
+
printoptions,
|
|
69
|
+
set_printoptions,
|
|
70
|
+
seterr,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# --- Free ops ---
|
|
74
|
+
from flopscope._free_ops import ( # noqa: F401
|
|
75
|
+
append,
|
|
76
|
+
arange,
|
|
77
|
+
argwhere,
|
|
78
|
+
array,
|
|
79
|
+
array_split,
|
|
80
|
+
asarray,
|
|
81
|
+
asarray_chkfinite,
|
|
82
|
+
astype,
|
|
83
|
+
atleast_1d,
|
|
84
|
+
atleast_2d,
|
|
85
|
+
atleast_3d,
|
|
86
|
+
base_repr,
|
|
87
|
+
binary_repr,
|
|
88
|
+
block,
|
|
89
|
+
bmat,
|
|
90
|
+
broadcast_arrays,
|
|
91
|
+
broadcast_shapes,
|
|
92
|
+
broadcast_to,
|
|
93
|
+
can_cast,
|
|
94
|
+
choose,
|
|
95
|
+
column_stack,
|
|
96
|
+
common_type,
|
|
97
|
+
compress,
|
|
98
|
+
concat,
|
|
99
|
+
concatenate,
|
|
100
|
+
copy,
|
|
101
|
+
copyto,
|
|
102
|
+
delete,
|
|
103
|
+
diag,
|
|
104
|
+
diag_indices,
|
|
105
|
+
diag_indices_from,
|
|
106
|
+
diagflat,
|
|
107
|
+
diagonal,
|
|
108
|
+
dsplit,
|
|
109
|
+
dstack,
|
|
110
|
+
empty,
|
|
111
|
+
empty_like,
|
|
112
|
+
expand_dims,
|
|
113
|
+
extract,
|
|
114
|
+
eye,
|
|
115
|
+
fill_diagonal,
|
|
116
|
+
flatnonzero,
|
|
117
|
+
flip,
|
|
118
|
+
fliplr,
|
|
119
|
+
flipud,
|
|
120
|
+
from_dlpack,
|
|
121
|
+
frombuffer,
|
|
122
|
+
fromfile,
|
|
123
|
+
fromfunction,
|
|
124
|
+
fromiter,
|
|
125
|
+
fromregex,
|
|
126
|
+
fromstring,
|
|
127
|
+
full,
|
|
128
|
+
full_like,
|
|
129
|
+
hsplit,
|
|
130
|
+
hstack,
|
|
131
|
+
identity,
|
|
132
|
+
indices,
|
|
133
|
+
insert,
|
|
134
|
+
isdtype,
|
|
135
|
+
isfinite,
|
|
136
|
+
isfortran,
|
|
137
|
+
isinf,
|
|
138
|
+
isnan,
|
|
139
|
+
isscalar,
|
|
140
|
+
issubdtype,
|
|
141
|
+
iterable,
|
|
142
|
+
ix_,
|
|
143
|
+
linspace,
|
|
144
|
+
mask_indices,
|
|
145
|
+
matrix_transpose,
|
|
146
|
+
may_share_memory,
|
|
147
|
+
meshgrid,
|
|
148
|
+
min_scalar_type,
|
|
149
|
+
mintypecode,
|
|
150
|
+
moveaxis,
|
|
151
|
+
ndim,
|
|
152
|
+
nonzero,
|
|
153
|
+
ones,
|
|
154
|
+
ones_like,
|
|
155
|
+
packbits,
|
|
156
|
+
pad,
|
|
157
|
+
permute_dims,
|
|
158
|
+
place,
|
|
159
|
+
promote_types,
|
|
160
|
+
put,
|
|
161
|
+
put_along_axis,
|
|
162
|
+
putmask,
|
|
163
|
+
ravel,
|
|
164
|
+
ravel_multi_index,
|
|
165
|
+
repeat,
|
|
166
|
+
require,
|
|
167
|
+
reshape,
|
|
168
|
+
resize,
|
|
169
|
+
result_type,
|
|
170
|
+
roll,
|
|
171
|
+
rollaxis,
|
|
172
|
+
rot90,
|
|
173
|
+
row_stack,
|
|
174
|
+
select,
|
|
175
|
+
shape,
|
|
176
|
+
shares_memory,
|
|
177
|
+
size,
|
|
178
|
+
split,
|
|
179
|
+
squeeze,
|
|
180
|
+
stack,
|
|
181
|
+
swapaxes,
|
|
182
|
+
take,
|
|
183
|
+
take_along_axis,
|
|
184
|
+
tile,
|
|
185
|
+
transpose,
|
|
186
|
+
tri,
|
|
187
|
+
tril,
|
|
188
|
+
tril_indices,
|
|
189
|
+
tril_indices_from,
|
|
190
|
+
trim_zeros,
|
|
191
|
+
triu,
|
|
192
|
+
triu_indices,
|
|
193
|
+
triu_indices_from,
|
|
194
|
+
typename,
|
|
195
|
+
unpackbits,
|
|
196
|
+
unravel_index,
|
|
197
|
+
unstack,
|
|
198
|
+
vsplit,
|
|
199
|
+
vstack,
|
|
200
|
+
where,
|
|
201
|
+
zeros,
|
|
202
|
+
zeros_like,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# --- Flopscope array type, re-exposed under the numpy-shaped name ---
|
|
206
|
+
from flopscope._ndarray import FlopscopeArray as ndarray # noqa: F401
|
|
207
|
+
|
|
208
|
+
# --- Pointwise (counted) ---
|
|
209
|
+
from flopscope._pointwise import ( # noqa: F401
|
|
210
|
+
abs,
|
|
211
|
+
absolute,
|
|
212
|
+
acos,
|
|
213
|
+
acosh,
|
|
214
|
+
add,
|
|
215
|
+
all,
|
|
216
|
+
amax,
|
|
217
|
+
amin,
|
|
218
|
+
angle,
|
|
219
|
+
any,
|
|
220
|
+
arccos,
|
|
221
|
+
arccosh,
|
|
222
|
+
arcsin,
|
|
223
|
+
arcsinh,
|
|
224
|
+
arctan,
|
|
225
|
+
arctan2,
|
|
226
|
+
arctanh,
|
|
227
|
+
argmax,
|
|
228
|
+
argmin,
|
|
229
|
+
around,
|
|
230
|
+
asin,
|
|
231
|
+
asinh,
|
|
232
|
+
atan,
|
|
233
|
+
atan2,
|
|
234
|
+
atanh,
|
|
235
|
+
average,
|
|
236
|
+
bitwise_and,
|
|
237
|
+
bitwise_count,
|
|
238
|
+
bitwise_invert,
|
|
239
|
+
bitwise_left_shift,
|
|
240
|
+
bitwise_not,
|
|
241
|
+
bitwise_or,
|
|
242
|
+
bitwise_right_shift,
|
|
243
|
+
bitwise_xor,
|
|
244
|
+
cbrt,
|
|
245
|
+
ceil,
|
|
246
|
+
clip,
|
|
247
|
+
conj,
|
|
248
|
+
conjugate,
|
|
249
|
+
convolve,
|
|
250
|
+
copysign,
|
|
251
|
+
corrcoef,
|
|
252
|
+
correlate,
|
|
253
|
+
cos,
|
|
254
|
+
cosh,
|
|
255
|
+
count_nonzero,
|
|
256
|
+
cov,
|
|
257
|
+
cross,
|
|
258
|
+
cumprod,
|
|
259
|
+
cumsum,
|
|
260
|
+
cumulative_prod,
|
|
261
|
+
cumulative_sum,
|
|
262
|
+
deg2rad,
|
|
263
|
+
degrees,
|
|
264
|
+
diff,
|
|
265
|
+
divide,
|
|
266
|
+
divmod,
|
|
267
|
+
dot,
|
|
268
|
+
ediff1d,
|
|
269
|
+
equal,
|
|
270
|
+
exp,
|
|
271
|
+
exp2,
|
|
272
|
+
expm1,
|
|
273
|
+
fabs,
|
|
274
|
+
fix,
|
|
275
|
+
float_power,
|
|
276
|
+
floor,
|
|
277
|
+
floor_divide,
|
|
278
|
+
fmax,
|
|
279
|
+
fmin,
|
|
280
|
+
fmod,
|
|
281
|
+
frexp,
|
|
282
|
+
gcd,
|
|
283
|
+
gradient,
|
|
284
|
+
greater,
|
|
285
|
+
greater_equal,
|
|
286
|
+
heaviside,
|
|
287
|
+
hypot,
|
|
288
|
+
i0,
|
|
289
|
+
imag,
|
|
290
|
+
inner,
|
|
291
|
+
interp,
|
|
292
|
+
invert,
|
|
293
|
+
isclose,
|
|
294
|
+
iscomplex,
|
|
295
|
+
iscomplexobj,
|
|
296
|
+
isnat,
|
|
297
|
+
isneginf,
|
|
298
|
+
isposinf,
|
|
299
|
+
isreal,
|
|
300
|
+
isrealobj,
|
|
301
|
+
kron,
|
|
302
|
+
lcm,
|
|
303
|
+
ldexp,
|
|
304
|
+
left_shift,
|
|
305
|
+
less,
|
|
306
|
+
less_equal,
|
|
307
|
+
log,
|
|
308
|
+
log1p,
|
|
309
|
+
log2,
|
|
310
|
+
log10,
|
|
311
|
+
logaddexp,
|
|
312
|
+
logaddexp2,
|
|
313
|
+
logical_and,
|
|
314
|
+
logical_not,
|
|
315
|
+
logical_or,
|
|
316
|
+
logical_xor,
|
|
317
|
+
matmul,
|
|
318
|
+
matvec,
|
|
319
|
+
max,
|
|
320
|
+
maximum,
|
|
321
|
+
mean,
|
|
322
|
+
median,
|
|
323
|
+
min,
|
|
324
|
+
minimum,
|
|
325
|
+
mod,
|
|
326
|
+
modf,
|
|
327
|
+
multiply,
|
|
328
|
+
nan_to_num,
|
|
329
|
+
nanargmax,
|
|
330
|
+
nanargmin,
|
|
331
|
+
nancumprod,
|
|
332
|
+
nancumsum,
|
|
333
|
+
nanmax,
|
|
334
|
+
nanmean,
|
|
335
|
+
nanmedian,
|
|
336
|
+
nanmin,
|
|
337
|
+
nanpercentile,
|
|
338
|
+
nanprod,
|
|
339
|
+
nanquantile,
|
|
340
|
+
nanstd,
|
|
341
|
+
nansum,
|
|
342
|
+
nanvar,
|
|
343
|
+
negative,
|
|
344
|
+
nextafter,
|
|
345
|
+
not_equal,
|
|
346
|
+
outer,
|
|
347
|
+
percentile,
|
|
348
|
+
positive,
|
|
349
|
+
pow,
|
|
350
|
+
power,
|
|
351
|
+
prod,
|
|
352
|
+
ptp,
|
|
353
|
+
quantile,
|
|
354
|
+
rad2deg,
|
|
355
|
+
radians,
|
|
356
|
+
real,
|
|
357
|
+
real_if_close,
|
|
358
|
+
reciprocal,
|
|
359
|
+
remainder,
|
|
360
|
+
right_shift,
|
|
361
|
+
rint,
|
|
362
|
+
round,
|
|
363
|
+
sign,
|
|
364
|
+
signbit,
|
|
365
|
+
sin,
|
|
366
|
+
sinc,
|
|
367
|
+
sinh,
|
|
368
|
+
sort_complex,
|
|
369
|
+
spacing,
|
|
370
|
+
sqrt,
|
|
371
|
+
square,
|
|
372
|
+
std,
|
|
373
|
+
subtract,
|
|
374
|
+
sum,
|
|
375
|
+
tan,
|
|
376
|
+
tanh,
|
|
377
|
+
tensordot,
|
|
378
|
+
trapezoid,
|
|
379
|
+
trapz,
|
|
380
|
+
true_divide,
|
|
381
|
+
trunc,
|
|
382
|
+
var,
|
|
383
|
+
vdot,
|
|
384
|
+
vecdot,
|
|
385
|
+
vecmat,
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
# --- Polynomial (counted) ---
|
|
389
|
+
from flopscope._polynomial import ( # noqa: F401
|
|
390
|
+
poly,
|
|
391
|
+
polyadd,
|
|
392
|
+
polyder,
|
|
393
|
+
polydiv,
|
|
394
|
+
polyfit,
|
|
395
|
+
polyint,
|
|
396
|
+
polymul,
|
|
397
|
+
polysub,
|
|
398
|
+
polyval,
|
|
399
|
+
roots,
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
# --- Sorting, search & set ops (counted) ---
|
|
403
|
+
from flopscope._sorting_ops import ( # noqa: F401
|
|
404
|
+
argpartition,
|
|
405
|
+
argsort,
|
|
406
|
+
digitize,
|
|
407
|
+
in1d,
|
|
408
|
+
intersect1d,
|
|
409
|
+
isin,
|
|
410
|
+
lexsort,
|
|
411
|
+
partition,
|
|
412
|
+
searchsorted,
|
|
413
|
+
setdiff1d,
|
|
414
|
+
setxor1d,
|
|
415
|
+
sort,
|
|
416
|
+
union1d,
|
|
417
|
+
unique,
|
|
418
|
+
unique_all,
|
|
419
|
+
unique_counts,
|
|
420
|
+
unique_inverse,
|
|
421
|
+
unique_values,
|
|
422
|
+
)
|
|
423
|
+
from flopscope._type_info import finfo, iinfo # noqa: F401
|
|
424
|
+
|
|
425
|
+
# --- Unwrap (counted) ---
|
|
426
|
+
from flopscope._unwrap import unwrap # noqa: F401
|
|
427
|
+
|
|
428
|
+
# --- Window functions (counted) ---
|
|
429
|
+
from flopscope._window import ( # noqa: F401
|
|
430
|
+
bartlett,
|
|
431
|
+
blackman,
|
|
432
|
+
hamming,
|
|
433
|
+
hanning,
|
|
434
|
+
kaiser,
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
# --- Numpy constants ---
|
|
438
|
+
pi = _np.pi
|
|
439
|
+
e = _np.e
|
|
440
|
+
inf = _np.inf
|
|
441
|
+
nan = _np.nan
|
|
442
|
+
newaxis = _np.newaxis
|
|
443
|
+
|
|
444
|
+
float16 = _np.float16
|
|
445
|
+
float32 = _np.float32
|
|
446
|
+
float64 = _np.float64
|
|
447
|
+
int8 = _np.int8
|
|
448
|
+
int16 = _np.int16
|
|
449
|
+
int32 = _np.int32
|
|
450
|
+
int64 = _np.int64
|
|
451
|
+
uint8 = _np.uint8
|
|
452
|
+
bool_ = _np.bool_
|
|
453
|
+
complex64 = _np.complex64
|
|
454
|
+
complex128 = _np.complex128
|
|
455
|
+
|
|
456
|
+
# --- Registry-aware __getattr__ ---
|
|
457
|
+
# Strict policy: any name not explicitly implemented above (and not in the
|
|
458
|
+
# registry as a known-classified op) raises AttributeError. We intentionally
|
|
459
|
+
# do NOT fall through to ``numpy`` — silently exposing uncounted numpy ops
|
|
460
|
+
# would defeat the purpose of FLOP accounting.
|
|
461
|
+
# fmt: off
|
|
462
|
+
# ruff: noqa: E402, I001
|
|
463
|
+
from flopscope._registry import make_module_getattr as _make_module_getattr
|
|
464
|
+
# fmt: on
|
|
465
|
+
|
|
466
|
+
_LAZY_SUBMODULES = frozenset({"linalg", "fft", "random", "testing", "typing"})
|
|
467
|
+
_registry_getattr = _make_module_getattr(
|
|
468
|
+
module_prefix="", module_label="flopscope.numpy"
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
__all__ = [
|
|
473
|
+
"abs",
|
|
474
|
+
"absolute",
|
|
475
|
+
"acos",
|
|
476
|
+
"acosh",
|
|
477
|
+
"add",
|
|
478
|
+
"all",
|
|
479
|
+
"allclose",
|
|
480
|
+
"amax",
|
|
481
|
+
"amin",
|
|
482
|
+
"angle",
|
|
483
|
+
"any",
|
|
484
|
+
"append",
|
|
485
|
+
"apply_along_axis",
|
|
486
|
+
"apply_over_axes",
|
|
487
|
+
"arange",
|
|
488
|
+
"arccos",
|
|
489
|
+
"arccosh",
|
|
490
|
+
"arcsin",
|
|
491
|
+
"arcsinh",
|
|
492
|
+
"arctan",
|
|
493
|
+
"arctan2",
|
|
494
|
+
"arctanh",
|
|
495
|
+
"argmax",
|
|
496
|
+
"argmin",
|
|
497
|
+
"argpartition",
|
|
498
|
+
"argsort",
|
|
499
|
+
"argwhere",
|
|
500
|
+
"around",
|
|
501
|
+
"array",
|
|
502
|
+
"array_equal",
|
|
503
|
+
"array_equiv",
|
|
504
|
+
"array_split",
|
|
505
|
+
"asarray",
|
|
506
|
+
"asarray_chkfinite",
|
|
507
|
+
"asin",
|
|
508
|
+
"asinh",
|
|
509
|
+
"astype",
|
|
510
|
+
"atan",
|
|
511
|
+
"atan2",
|
|
512
|
+
"atanh",
|
|
513
|
+
"atleast_1d",
|
|
514
|
+
"atleast_2d",
|
|
515
|
+
"atleast_3d",
|
|
516
|
+
"average",
|
|
517
|
+
"bartlett",
|
|
518
|
+
"base_repr",
|
|
519
|
+
"binary_repr",
|
|
520
|
+
"bincount",
|
|
521
|
+
"bitwise_and",
|
|
522
|
+
"bitwise_count",
|
|
523
|
+
"bitwise_invert",
|
|
524
|
+
"bitwise_left_shift",
|
|
525
|
+
"bitwise_not",
|
|
526
|
+
"bitwise_or",
|
|
527
|
+
"bitwise_right_shift",
|
|
528
|
+
"bitwise_xor",
|
|
529
|
+
"blackman",
|
|
530
|
+
"block",
|
|
531
|
+
"bmat",
|
|
532
|
+
"bool_",
|
|
533
|
+
"broadcast",
|
|
534
|
+
"broadcast_arrays",
|
|
535
|
+
"broadcast_shapes",
|
|
536
|
+
"broadcast_to",
|
|
537
|
+
"can_cast",
|
|
538
|
+
"cbrt",
|
|
539
|
+
"ceil",
|
|
540
|
+
"choose",
|
|
541
|
+
"clear_einsum_cache",
|
|
542
|
+
"clip",
|
|
543
|
+
"column_stack",
|
|
544
|
+
"common_type",
|
|
545
|
+
"complex64",
|
|
546
|
+
"complex128",
|
|
547
|
+
"compress",
|
|
548
|
+
"concat",
|
|
549
|
+
"concatenate",
|
|
550
|
+
"conj",
|
|
551
|
+
"conjugate",
|
|
552
|
+
"convolve",
|
|
553
|
+
"copy",
|
|
554
|
+
"copysign",
|
|
555
|
+
"copyto",
|
|
556
|
+
"corrcoef",
|
|
557
|
+
"correlate",
|
|
558
|
+
"cos",
|
|
559
|
+
"cosh",
|
|
560
|
+
"count_nonzero",
|
|
561
|
+
"cov",
|
|
562
|
+
"cross",
|
|
563
|
+
"cumprod",
|
|
564
|
+
"cumsum",
|
|
565
|
+
"cumulative_prod",
|
|
566
|
+
"cumulative_sum",
|
|
567
|
+
"deg2rad",
|
|
568
|
+
"degrees",
|
|
569
|
+
"delete",
|
|
570
|
+
"diag",
|
|
571
|
+
"diag_indices",
|
|
572
|
+
"diag_indices_from",
|
|
573
|
+
"diagflat",
|
|
574
|
+
"diagonal",
|
|
575
|
+
"diff",
|
|
576
|
+
"digitize",
|
|
577
|
+
"divide",
|
|
578
|
+
"divmod",
|
|
579
|
+
"dot",
|
|
580
|
+
"dsplit",
|
|
581
|
+
"dstack",
|
|
582
|
+
"dtype",
|
|
583
|
+
"e",
|
|
584
|
+
"ediff1d",
|
|
585
|
+
"einsum",
|
|
586
|
+
"einsum_cache_info",
|
|
587
|
+
"einsum_path",
|
|
588
|
+
"empty",
|
|
589
|
+
"empty_like",
|
|
590
|
+
"equal",
|
|
591
|
+
"errstate",
|
|
592
|
+
"exp",
|
|
593
|
+
"exp2",
|
|
594
|
+
"expand_dims",
|
|
595
|
+
"expm1",
|
|
596
|
+
"extract",
|
|
597
|
+
"eye",
|
|
598
|
+
"fabs",
|
|
599
|
+
"finfo",
|
|
600
|
+
"fill_diagonal",
|
|
601
|
+
"fix",
|
|
602
|
+
"flatnonzero",
|
|
603
|
+
"flip",
|
|
604
|
+
"fliplr",
|
|
605
|
+
"flipud",
|
|
606
|
+
"float16",
|
|
607
|
+
"float32",
|
|
608
|
+
"float64",
|
|
609
|
+
"float_power",
|
|
610
|
+
"floor",
|
|
611
|
+
"floor_divide",
|
|
612
|
+
"floating",
|
|
613
|
+
"fmax",
|
|
614
|
+
"fmin",
|
|
615
|
+
"fmod",
|
|
616
|
+
"frexp",
|
|
617
|
+
"from_dlpack",
|
|
618
|
+
"frombuffer",
|
|
619
|
+
"fromfile",
|
|
620
|
+
"fromfunction",
|
|
621
|
+
"fromiter",
|
|
622
|
+
"fromregex",
|
|
623
|
+
"fromstring",
|
|
624
|
+
"full",
|
|
625
|
+
"full_like",
|
|
626
|
+
"gcd",
|
|
627
|
+
"geomspace",
|
|
628
|
+
"get_printoptions",
|
|
629
|
+
"geterr",
|
|
630
|
+
"gradient",
|
|
631
|
+
"greater",
|
|
632
|
+
"greater_equal",
|
|
633
|
+
"hamming",
|
|
634
|
+
"hanning",
|
|
635
|
+
"heaviside",
|
|
636
|
+
"histogram",
|
|
637
|
+
"histogram2d",
|
|
638
|
+
"histogram_bin_edges",
|
|
639
|
+
"histogramdd",
|
|
640
|
+
"hsplit",
|
|
641
|
+
"hstack",
|
|
642
|
+
"hypot",
|
|
643
|
+
"i0",
|
|
644
|
+
"identity",
|
|
645
|
+
"iinfo",
|
|
646
|
+
"imag",
|
|
647
|
+
"in1d",
|
|
648
|
+
"indices",
|
|
649
|
+
"inf",
|
|
650
|
+
"inner",
|
|
651
|
+
"insert",
|
|
652
|
+
"int8",
|
|
653
|
+
"int16",
|
|
654
|
+
"int32",
|
|
655
|
+
"int64",
|
|
656
|
+
"integer",
|
|
657
|
+
"interp",
|
|
658
|
+
"intersect1d",
|
|
659
|
+
"invert",
|
|
660
|
+
"isclose",
|
|
661
|
+
"iscomplex",
|
|
662
|
+
"iscomplexobj",
|
|
663
|
+
"isdtype",
|
|
664
|
+
"isfinite",
|
|
665
|
+
"isfortran",
|
|
666
|
+
"isin",
|
|
667
|
+
"isinf",
|
|
668
|
+
"isnan",
|
|
669
|
+
"isnat",
|
|
670
|
+
"isneginf",
|
|
671
|
+
"isposinf",
|
|
672
|
+
"isreal",
|
|
673
|
+
"isrealobj",
|
|
674
|
+
"isscalar",
|
|
675
|
+
"issubdtype",
|
|
676
|
+
"iterable",
|
|
677
|
+
"ix_",
|
|
678
|
+
"kaiser",
|
|
679
|
+
"kron",
|
|
680
|
+
"lcm",
|
|
681
|
+
"ldexp",
|
|
682
|
+
"left_shift",
|
|
683
|
+
"less",
|
|
684
|
+
"less_equal",
|
|
685
|
+
"lexsort",
|
|
686
|
+
"linspace",
|
|
687
|
+
"log",
|
|
688
|
+
"log10",
|
|
689
|
+
"log1p",
|
|
690
|
+
"log2",
|
|
691
|
+
"logaddexp",
|
|
692
|
+
"logaddexp2",
|
|
693
|
+
"logical_and",
|
|
694
|
+
"logical_not",
|
|
695
|
+
"logical_or",
|
|
696
|
+
"logical_xor",
|
|
697
|
+
"logspace",
|
|
698
|
+
"mask_indices",
|
|
699
|
+
"matmul",
|
|
700
|
+
"matrix_transpose",
|
|
701
|
+
"matvec",
|
|
702
|
+
"max",
|
|
703
|
+
"maximum",
|
|
704
|
+
"may_share_memory",
|
|
705
|
+
"mean",
|
|
706
|
+
"median",
|
|
707
|
+
"meshgrid",
|
|
708
|
+
"min",
|
|
709
|
+
"min_scalar_type",
|
|
710
|
+
"minimum",
|
|
711
|
+
"mintypecode",
|
|
712
|
+
"mod",
|
|
713
|
+
"modf",
|
|
714
|
+
"moveaxis",
|
|
715
|
+
"multiply",
|
|
716
|
+
"nan",
|
|
717
|
+
"nan_to_num",
|
|
718
|
+
"nanargmax",
|
|
719
|
+
"nanargmin",
|
|
720
|
+
"nancumprod",
|
|
721
|
+
"nancumsum",
|
|
722
|
+
"nanmax",
|
|
723
|
+
"nanmean",
|
|
724
|
+
"nanmedian",
|
|
725
|
+
"nanmin",
|
|
726
|
+
"nanpercentile",
|
|
727
|
+
"nanprod",
|
|
728
|
+
"nanquantile",
|
|
729
|
+
"nanstd",
|
|
730
|
+
"nansum",
|
|
731
|
+
"nanvar",
|
|
732
|
+
"ndarray",
|
|
733
|
+
"ndenumerate",
|
|
734
|
+
"ndim",
|
|
735
|
+
"ndindex",
|
|
736
|
+
"nditer",
|
|
737
|
+
"negative",
|
|
738
|
+
"newaxis",
|
|
739
|
+
"nextafter",
|
|
740
|
+
"nonzero",
|
|
741
|
+
"not_equal",
|
|
742
|
+
"number",
|
|
743
|
+
"ones",
|
|
744
|
+
"ones_like",
|
|
745
|
+
"outer",
|
|
746
|
+
"packbits",
|
|
747
|
+
"pad",
|
|
748
|
+
"partition",
|
|
749
|
+
"percentile",
|
|
750
|
+
"permute_dims",
|
|
751
|
+
"pi",
|
|
752
|
+
"piecewise",
|
|
753
|
+
"place",
|
|
754
|
+
"poly",
|
|
755
|
+
"polyadd",
|
|
756
|
+
"polyder",
|
|
757
|
+
"polydiv",
|
|
758
|
+
"polyfit",
|
|
759
|
+
"polyint",
|
|
760
|
+
"polymul",
|
|
761
|
+
"polysub",
|
|
762
|
+
"polyval",
|
|
763
|
+
"positive",
|
|
764
|
+
"pow",
|
|
765
|
+
"power",
|
|
766
|
+
"printoptions",
|
|
767
|
+
"prod",
|
|
768
|
+
"promote_types",
|
|
769
|
+
"ptp",
|
|
770
|
+
"put",
|
|
771
|
+
"put_along_axis",
|
|
772
|
+
"putmask",
|
|
773
|
+
"quantile",
|
|
774
|
+
"rad2deg",
|
|
775
|
+
"radians",
|
|
776
|
+
"ravel",
|
|
777
|
+
"ravel_multi_index",
|
|
778
|
+
"real",
|
|
779
|
+
"real_if_close",
|
|
780
|
+
"reciprocal",
|
|
781
|
+
"remainder",
|
|
782
|
+
"repeat",
|
|
783
|
+
"require",
|
|
784
|
+
"reshape",
|
|
785
|
+
"resize",
|
|
786
|
+
"result_type",
|
|
787
|
+
"right_shift",
|
|
788
|
+
"rint",
|
|
789
|
+
"roll",
|
|
790
|
+
"rollaxis",
|
|
791
|
+
"roots",
|
|
792
|
+
"rot90",
|
|
793
|
+
"round",
|
|
794
|
+
"row_stack",
|
|
795
|
+
"searchsorted",
|
|
796
|
+
"select",
|
|
797
|
+
"set_printoptions",
|
|
798
|
+
"setdiff1d",
|
|
799
|
+
"seterr",
|
|
800
|
+
"setxor1d",
|
|
801
|
+
"shape",
|
|
802
|
+
"shares_memory",
|
|
803
|
+
"sign",
|
|
804
|
+
"signbit",
|
|
805
|
+
"sin",
|
|
806
|
+
"sinc",
|
|
807
|
+
"sinh",
|
|
808
|
+
"size",
|
|
809
|
+
"sort",
|
|
810
|
+
"sort_complex",
|
|
811
|
+
"spacing",
|
|
812
|
+
"split",
|
|
813
|
+
"sqrt",
|
|
814
|
+
"square",
|
|
815
|
+
"squeeze",
|
|
816
|
+
"stack",
|
|
817
|
+
"std",
|
|
818
|
+
"subtract",
|
|
819
|
+
"sum",
|
|
820
|
+
"swapaxes",
|
|
821
|
+
"take",
|
|
822
|
+
"take_along_axis",
|
|
823
|
+
"tan",
|
|
824
|
+
"tanh",
|
|
825
|
+
"tensordot",
|
|
826
|
+
"tile",
|
|
827
|
+
"trace",
|
|
828
|
+
"trapezoid",
|
|
829
|
+
"trapz",
|
|
830
|
+
"transpose",
|
|
831
|
+
"tri",
|
|
832
|
+
"tril",
|
|
833
|
+
"tril_indices",
|
|
834
|
+
"tril_indices_from",
|
|
835
|
+
"trim_zeros",
|
|
836
|
+
"triu",
|
|
837
|
+
"triu_indices",
|
|
838
|
+
"triu_indices_from",
|
|
839
|
+
"true_divide",
|
|
840
|
+
"trunc",
|
|
841
|
+
"typename",
|
|
842
|
+
"uint8",
|
|
843
|
+
"uint16",
|
|
844
|
+
"uint32",
|
|
845
|
+
"uint64",
|
|
846
|
+
"union1d",
|
|
847
|
+
"unique",
|
|
848
|
+
"unique_all",
|
|
849
|
+
"unique_counts",
|
|
850
|
+
"unique_inverse",
|
|
851
|
+
"unique_values",
|
|
852
|
+
"unpackbits",
|
|
853
|
+
"unravel_index",
|
|
854
|
+
"unstack",
|
|
855
|
+
"unwrap",
|
|
856
|
+
"vander",
|
|
857
|
+
"var",
|
|
858
|
+
"vdot",
|
|
859
|
+
"vecdot",
|
|
860
|
+
"vecmat",
|
|
861
|
+
"vsplit",
|
|
862
|
+
"vstack",
|
|
863
|
+
"where",
|
|
864
|
+
"zeros",
|
|
865
|
+
"zeros_like",
|
|
866
|
+
]
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
def __getattr__(name: str):
|
|
870
|
+
if name in _LAZY_SUBMODULES:
|
|
871
|
+
module = _importlib.import_module(f"flopscope.numpy.{name}")
|
|
872
|
+
globals()[name] = module
|
|
873
|
+
return module
|
|
874
|
+
return _registry_getattr(name)
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
def __dir__() -> list[str]:
|
|
878
|
+
return sorted(set(globals()) | _LAZY_SUBMODULES)
|