-
Notifications
You must be signed in to change notification settings - Fork 2
/
sparseoperations.html
589 lines (581 loc) · 33.9 KB
/
sparseoperations.html
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
<!DOCTYPE html>
<!-- Generated by Cython 0.27.3 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cython: sparseoperations.pyx</title>
<style type="text/css">
body.cython { font-family: courier; font-size: 12; }
.cython.tag { }
.cython.line { margin: 0em }
.cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }
.cython.line .run { background-color: #B0FFB0; }
.cython.line .mis { background-color: #FFB0B0; }
.cython.code.run { border-left: 8px solid #B0FFB0; }
.cython.code.mis { border-left: 8px solid #FFB0B0; }
.cython.code .py_c_api { color: red; }
.cython.code .py_macro_api { color: #FF7000; }
.cython.code .pyx_c_api { color: #FF3000; }
.cython.code .pyx_macro_api { color: #FF7000; }
.cython.code .refnanny { color: #FFA000; }
.cython.code .trace { color: #FFA000; }
.cython.code .error_goto { color: #FFA000; }
.cython.code .coerce { color: #008000; border: 1px dotted #008000 }
.cython.code .py_attr { color: #FF0000; font-weight: bold; }
.cython.code .c_attr { color: #0000FF; }
.cython.code .py_call { color: #FF0000; font-weight: bold; }
.cython.code .c_call { color: #0000FF; }
.cython.score-0 {background-color: #FFFFff;}
.cython.score-1 {background-color: #FFFFe7;}
.cython.score-2 {background-color: #FFFFd4;}
.cython.score-3 {background-color: #FFFFc4;}
.cython.score-4 {background-color: #FFFFb6;}
.cython.score-5 {background-color: #FFFFaa;}
.cython.score-6 {background-color: #FFFF9f;}
.cython.score-7 {background-color: #FFFF96;}
.cython.score-8 {background-color: #FFFF8d;}
.cython.score-9 {background-color: #FFFF86;}
.cython.score-10 {background-color: #FFFF7f;}
.cython.score-11 {background-color: #FFFF79;}
.cython.score-12 {background-color: #FFFF73;}
.cython.score-13 {background-color: #FFFF6e;}
.cython.score-14 {background-color: #FFFF6a;}
.cython.score-15 {background-color: #FFFF66;}
.cython.score-16 {background-color: #FFFF62;}
.cython.score-17 {background-color: #FFFF5e;}
.cython.score-18 {background-color: #FFFF5b;}
.cython.score-19 {background-color: #FFFF57;}
.cython.score-20 {background-color: #FFFF55;}
.cython.score-21 {background-color: #FFFF52;}
.cython.score-22 {background-color: #FFFF4f;}
.cython.score-23 {background-color: #FFFF4d;}
.cython.score-24 {background-color: #FFFF4b;}
.cython.score-25 {background-color: #FFFF48;}
.cython.score-26 {background-color: #FFFF46;}
.cython.score-27 {background-color: #FFFF44;}
.cython.score-28 {background-color: #FFFF43;}
.cython.score-29 {background-color: #FFFF41;}
.cython.score-30 {background-color: #FFFF3f;}
.cython.score-31 {background-color: #FFFF3e;}
.cython.score-32 {background-color: #FFFF3c;}
.cython.score-33 {background-color: #FFFF3b;}
.cython.score-34 {background-color: #FFFF39;}
.cython.score-35 {background-color: #FFFF38;}
.cython.score-36 {background-color: #FFFF37;}
.cython.score-37 {background-color: #FFFF36;}
.cython.score-38 {background-color: #FFFF35;}
.cython.score-39 {background-color: #FFFF34;}
.cython.score-40 {background-color: #FFFF33;}
.cython.score-41 {background-color: #FFFF32;}
.cython.score-42 {background-color: #FFFF31;}
.cython.score-43 {background-color: #FFFF30;}
.cython.score-44 {background-color: #FFFF2f;}
.cython.score-45 {background-color: #FFFF2e;}
.cython.score-46 {background-color: #FFFF2d;}
.cython.score-47 {background-color: #FFFF2c;}
.cython.score-48 {background-color: #FFFF2b;}
.cython.score-49 {background-color: #FFFF2b;}
.cython.score-50 {background-color: #FFFF2a;}
.cython.score-51 {background-color: #FFFF29;}
.cython.score-52 {background-color: #FFFF29;}
.cython.score-53 {background-color: #FFFF28;}
.cython.score-54 {background-color: #FFFF27;}
.cython.score-55 {background-color: #FFFF27;}
.cython.score-56 {background-color: #FFFF26;}
.cython.score-57 {background-color: #FFFF26;}
.cython.score-58 {background-color: #FFFF25;}
.cython.score-59 {background-color: #FFFF24;}
.cython.score-60 {background-color: #FFFF24;}
.cython.score-61 {background-color: #FFFF23;}
.cython.score-62 {background-color: #FFFF23;}
.cython.score-63 {background-color: #FFFF22;}
.cython.score-64 {background-color: #FFFF22;}
.cython.score-65 {background-color: #FFFF22;}
.cython.score-66 {background-color: #FFFF21;}
.cython.score-67 {background-color: #FFFF21;}
.cython.score-68 {background-color: #FFFF20;}
.cython.score-69 {background-color: #FFFF20;}
.cython.score-70 {background-color: #FFFF1f;}
.cython.score-71 {background-color: #FFFF1f;}
.cython.score-72 {background-color: #FFFF1f;}
.cython.score-73 {background-color: #FFFF1e;}
.cython.score-74 {background-color: #FFFF1e;}
.cython.score-75 {background-color: #FFFF1e;}
.cython.score-76 {background-color: #FFFF1d;}
.cython.score-77 {background-color: #FFFF1d;}
.cython.score-78 {background-color: #FFFF1c;}
.cython.score-79 {background-color: #FFFF1c;}
.cython.score-80 {background-color: #FFFF1c;}
.cython.score-81 {background-color: #FFFF1c;}
.cython.score-82 {background-color: #FFFF1b;}
.cython.score-83 {background-color: #FFFF1b;}
.cython.score-84 {background-color: #FFFF1b;}
.cython.score-85 {background-color: #FFFF1a;}
.cython.score-86 {background-color: #FFFF1a;}
.cython.score-87 {background-color: #FFFF1a;}
.cython.score-88 {background-color: #FFFF1a;}
.cython.score-89 {background-color: #FFFF19;}
.cython.score-90 {background-color: #FFFF19;}
.cython.score-91 {background-color: #FFFF19;}
.cython.score-92 {background-color: #FFFF19;}
.cython.score-93 {background-color: #FFFF18;}
.cython.score-94 {background-color: #FFFF18;}
.cython.score-95 {background-color: #FFFF18;}
.cython.score-96 {background-color: #FFFF18;}
.cython.score-97 {background-color: #FFFF17;}
.cython.score-98 {background-color: #FFFF17;}
.cython.score-99 {background-color: #FFFF17;}
.cython.score-100 {background-color: #FFFF17;}
.cython.score-101 {background-color: #FFFF16;}
.cython.score-102 {background-color: #FFFF16;}
.cython.score-103 {background-color: #FFFF16;}
.cython.score-104 {background-color: #FFFF16;}
.cython.score-105 {background-color: #FFFF16;}
.cython.score-106 {background-color: #FFFF15;}
.cython.score-107 {background-color: #FFFF15;}
.cython.score-108 {background-color: #FFFF15;}
.cython.score-109 {background-color: #FFFF15;}
.cython.score-110 {background-color: #FFFF15;}
.cython.score-111 {background-color: #FFFF15;}
.cython.score-112 {background-color: #FFFF14;}
.cython.score-113 {background-color: #FFFF14;}
.cython.score-114 {background-color: #FFFF14;}
.cython.score-115 {background-color: #FFFF14;}
.cython.score-116 {background-color: #FFFF14;}
.cython.score-117 {background-color: #FFFF14;}
.cython.score-118 {background-color: #FFFF13;}
.cython.score-119 {background-color: #FFFF13;}
.cython.score-120 {background-color: #FFFF13;}
.cython.score-121 {background-color: #FFFF13;}
.cython.score-122 {background-color: #FFFF13;}
.cython.score-123 {background-color: #FFFF13;}
.cython.score-124 {background-color: #FFFF13;}
.cython.score-125 {background-color: #FFFF12;}
.cython.score-126 {background-color: #FFFF12;}
.cython.score-127 {background-color: #FFFF12;}
.cython.score-128 {background-color: #FFFF12;}
.cython.score-129 {background-color: #FFFF12;}
.cython.score-130 {background-color: #FFFF12;}
.cython.score-131 {background-color: #FFFF12;}
.cython.score-132 {background-color: #FFFF11;}
.cython.score-133 {background-color: #FFFF11;}
.cython.score-134 {background-color: #FFFF11;}
.cython.score-135 {background-color: #FFFF11;}
.cython.score-136 {background-color: #FFFF11;}
.cython.score-137 {background-color: #FFFF11;}
.cython.score-138 {background-color: #FFFF11;}
.cython.score-139 {background-color: #FFFF11;}
.cython.score-140 {background-color: #FFFF11;}
.cython.score-141 {background-color: #FFFF10;}
.cython.score-142 {background-color: #FFFF10;}
.cython.score-143 {background-color: #FFFF10;}
.cython.score-144 {background-color: #FFFF10;}
.cython.score-145 {background-color: #FFFF10;}
.cython.score-146 {background-color: #FFFF10;}
.cython.score-147 {background-color: #FFFF10;}
.cython.score-148 {background-color: #FFFF10;}
.cython.score-149 {background-color: #FFFF10;}
.cython.score-150 {background-color: #FFFF0f;}
.cython.score-151 {background-color: #FFFF0f;}
.cython.score-152 {background-color: #FFFF0f;}
.cython.score-153 {background-color: #FFFF0f;}
.cython.score-154 {background-color: #FFFF0f;}
.cython.score-155 {background-color: #FFFF0f;}
.cython.score-156 {background-color: #FFFF0f;}
.cython.score-157 {background-color: #FFFF0f;}
.cython.score-158 {background-color: #FFFF0f;}
.cython.score-159 {background-color: #FFFF0f;}
.cython.score-160 {background-color: #FFFF0f;}
.cython.score-161 {background-color: #FFFF0e;}
.cython.score-162 {background-color: #FFFF0e;}
.cython.score-163 {background-color: #FFFF0e;}
.cython.score-164 {background-color: #FFFF0e;}
.cython.score-165 {background-color: #FFFF0e;}
.cython.score-166 {background-color: #FFFF0e;}
.cython.score-167 {background-color: #FFFF0e;}
.cython.score-168 {background-color: #FFFF0e;}
.cython.score-169 {background-color: #FFFF0e;}
.cython.score-170 {background-color: #FFFF0e;}
.cython.score-171 {background-color: #FFFF0e;}
.cython.score-172 {background-color: #FFFF0e;}
.cython.score-173 {background-color: #FFFF0d;}
.cython.score-174 {background-color: #FFFF0d;}
.cython.score-175 {background-color: #FFFF0d;}
.cython.score-176 {background-color: #FFFF0d;}
.cython.score-177 {background-color: #FFFF0d;}
.cython.score-178 {background-color: #FFFF0d;}
.cython.score-179 {background-color: #FFFF0d;}
.cython.score-180 {background-color: #FFFF0d;}
.cython.score-181 {background-color: #FFFF0d;}
.cython.score-182 {background-color: #FFFF0d;}
.cython.score-183 {background-color: #FFFF0d;}
.cython.score-184 {background-color: #FFFF0d;}
.cython.score-185 {background-color: #FFFF0d;}
.cython.score-186 {background-color: #FFFF0d;}
.cython.score-187 {background-color: #FFFF0c;}
.cython.score-188 {background-color: #FFFF0c;}
.cython.score-189 {background-color: #FFFF0c;}
.cython.score-190 {background-color: #FFFF0c;}
.cython.score-191 {background-color: #FFFF0c;}
.cython.score-192 {background-color: #FFFF0c;}
.cython.score-193 {background-color: #FFFF0c;}
.cython.score-194 {background-color: #FFFF0c;}
.cython.score-195 {background-color: #FFFF0c;}
.cython.score-196 {background-color: #FFFF0c;}
.cython.score-197 {background-color: #FFFF0c;}
.cython.score-198 {background-color: #FFFF0c;}
.cython.score-199 {background-color: #FFFF0c;}
.cython.score-200 {background-color: #FFFF0c;}
.cython.score-201 {background-color: #FFFF0c;}
.cython.score-202 {background-color: #FFFF0c;}
.cython.score-203 {background-color: #FFFF0b;}
.cython.score-204 {background-color: #FFFF0b;}
.cython.score-205 {background-color: #FFFF0b;}
.cython.score-206 {background-color: #FFFF0b;}
.cython.score-207 {background-color: #FFFF0b;}
.cython.score-208 {background-color: #FFFF0b;}
.cython.score-209 {background-color: #FFFF0b;}
.cython.score-210 {background-color: #FFFF0b;}
.cython.score-211 {background-color: #FFFF0b;}
.cython.score-212 {background-color: #FFFF0b;}
.cython.score-213 {background-color: #FFFF0b;}
.cython.score-214 {background-color: #FFFF0b;}
.cython.score-215 {background-color: #FFFF0b;}
.cython.score-216 {background-color: #FFFF0b;}
.cython.score-217 {background-color: #FFFF0b;}
.cython.score-218 {background-color: #FFFF0b;}
.cython.score-219 {background-color: #FFFF0b;}
.cython.score-220 {background-color: #FFFF0b;}
.cython.score-221 {background-color: #FFFF0b;}
.cython.score-222 {background-color: #FFFF0a;}
.cython.score-223 {background-color: #FFFF0a;}
.cython.score-224 {background-color: #FFFF0a;}
.cython.score-225 {background-color: #FFFF0a;}
.cython.score-226 {background-color: #FFFF0a;}
.cython.score-227 {background-color: #FFFF0a;}
.cython.score-228 {background-color: #FFFF0a;}
.cython.score-229 {background-color: #FFFF0a;}
.cython.score-230 {background-color: #FFFF0a;}
.cython.score-231 {background-color: #FFFF0a;}
.cython.score-232 {background-color: #FFFF0a;}
.cython.score-233 {background-color: #FFFF0a;}
.cython.score-234 {background-color: #FFFF0a;}
.cython.score-235 {background-color: #FFFF0a;}
.cython.score-236 {background-color: #FFFF0a;}
.cython.score-237 {background-color: #FFFF0a;}
.cython.score-238 {background-color: #FFFF0a;}
.cython.score-239 {background-color: #FFFF0a;}
.cython.score-240 {background-color: #FFFF0a;}
.cython.score-241 {background-color: #FFFF0a;}
.cython.score-242 {background-color: #FFFF0a;}
.cython.score-243 {background-color: #FFFF0a;}
.cython.score-244 {background-color: #FFFF0a;}
.cython.score-245 {background-color: #FFFF0a;}
.cython.score-246 {background-color: #FFFF09;}
.cython.score-247 {background-color: #FFFF09;}
.cython.score-248 {background-color: #FFFF09;}
.cython.score-249 {background-color: #FFFF09;}
.cython.score-250 {background-color: #FFFF09;}
.cython.score-251 {background-color: #FFFF09;}
.cython.score-252 {background-color: #FFFF09;}
.cython.score-253 {background-color: #FFFF09;}
.cython.score-254 {background-color: #FFFF09;}
</style>
<script>
function toggleDiv(id) {
theDiv = id.nextElementSibling
if (theDiv.style.display != 'block') theDiv.style.display = 'block';
else theDiv.style.display = 'none';
}
</script>
</head>
<body class="cython">
<p><span style="border-bottom: solid 1px grey;">Generated by Cython 0.27.3</span></p>
<p>
<span style="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br />
Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it.
</p>
<p>Raw output: <a href="sparseoperations.c">sparseoperations.c</a></p>
<div class="cython"><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">01</span>: # compile this file with: "cythonize -a -i sparseoperations.pyx"</pre>
<pre class='cython code score-8 '> __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyDict_NewPresized</span>(0);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)</span>
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) <span class='error_goto'>__PYX_ERR(0, 1, __pyx_L1_error)</span>
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-0"> <span class="">02</span>: # I have tested this method in Linux (Ubuntu). If you compile it in Windows you may need some work around.</pre>
<pre class="cython line score-0"> <span class="">03</span>: </pre>
<pre class="cython line score-0"> <span class="">04</span>: cimport numpy as np</pre>
<pre class="cython line score-0"> <span class="">05</span>: </pre>
<pre class="cython line score-115" onclick='toggleDiv(this)'>+<span class="">06</span>: def backpropagation_updates_Cython(np.ndarray[np.float64_t,ndim=2] a, np.ndarray[np.float64_t,ndim=2] delta, np.ndarray[int,ndim=1] rows, np.ndarray[int,ndim=1] cols,np.ndarray[np.float64_t,ndim=1] out):</pre>
<pre class='cython code score-115 '>/* Python wrapper */
static PyObject *__pyx_pw_16sparseoperations_1backpropagation_updates_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_16sparseoperations_1backpropagation_updates_Cython = {"backpropagation_updates_Cython", (PyCFunction)__pyx_pw_16sparseoperations_1backpropagation_updates_Cython, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_16sparseoperations_1backpropagation_updates_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyArrayObject *__pyx_v_a = 0;
PyArrayObject *__pyx_v_delta = 0;
PyArrayObject *__pyx_v_rows = 0;
PyArrayObject *__pyx_v_cols = 0;
PyArrayObject *__pyx_v_out = 0;
PyObject *__pyx_r = 0;
<span class='refnanny'>__Pyx_RefNannyDeclarations</span>
<span class='refnanny'>__Pyx_RefNannySetupContext</span>("backpropagation_updates_Cython (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_delta,&__pyx_n_s_rows,&__pyx_n_s_cols,&__pyx_n_s_out,0};
PyObject* values[5] = {0,0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args);
switch (pos_args) {
case 5: values[4] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = <span class='py_c_api'>PyDict_Size</span>(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_delta)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("backpropagation_updates_Cython", 1, 5, 5, 1); <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L3_error)</span>
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_rows)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("backpropagation_updates_Cython", 1, 5, 5, 2); <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L3_error)</span>
}
CYTHON_FALLTHROUGH;
case 3:
if (likely((values[3] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_cols)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("backpropagation_updates_Cython", 1, 5, 5, 3); <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L3_error)</span>
}
CYTHON_FALLTHROUGH;
case 4:
if (likely((values[4] = <span class='py_c_api'>PyDict_GetItem</span>(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
else {
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("backpropagation_updates_Cython", 1, 5, 5, 4); <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L3_error)</span>
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(<span class='pyx_c_api'>__Pyx_ParseOptionalKeywords</span>(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "backpropagation_updates_Cython") < 0)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L3_error)</span>
}
} else if (<span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args) != 5) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 0);
values[1] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 1);
values[2] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 2);
values[3] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 3);
values[4] = <span class='py_macro_api'>PyTuple_GET_ITEM</span>(__pyx_args, 4);
}
__pyx_v_a = ((PyArrayObject *)values[0]);
__pyx_v_delta = ((PyArrayObject *)values[1]);
__pyx_v_rows = ((PyArrayObject *)values[2]);
__pyx_v_cols = ((PyArrayObject *)values[3]);
__pyx_v_out = ((PyArrayObject *)values[4]);
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
<span class='pyx_c_api'>__Pyx_RaiseArgtupleInvalid</span>("backpropagation_updates_Cython", 1, 5, 5, <span class='py_macro_api'>PyTuple_GET_SIZE</span>(__pyx_args)); <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L3_error)</span>
__pyx_L3_error:;
<span class='pyx_c_api'>__Pyx_AddTraceback</span>("sparseoperations.backpropagation_updates_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
<span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!<span class='pyx_c_api'>__Pyx_ArgTypeTest</span>(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
if (unlikely(!<span class='pyx_c_api'>__Pyx_ArgTypeTest</span>(((PyObject *)__pyx_v_delta), __pyx_ptype_5numpy_ndarray, 1, "delta", 0))) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
if (unlikely(!<span class='pyx_c_api'>__Pyx_ArgTypeTest</span>(((PyObject *)__pyx_v_rows), __pyx_ptype_5numpy_ndarray, 1, "rows", 0))) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
if (unlikely(!<span class='pyx_c_api'>__Pyx_ArgTypeTest</span>(((PyObject *)__pyx_v_cols), __pyx_ptype_5numpy_ndarray, 1, "cols", 0))) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
if (unlikely(!<span class='pyx_c_api'>__Pyx_ArgTypeTest</span>(((PyObject *)__pyx_v_out), __pyx_ptype_5numpy_ndarray, 1, "out", 0))) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
__pyx_r = __pyx_pf_16sparseoperations_backpropagation_updates_Cython(__pyx_self, __pyx_v_a, __pyx_v_delta, __pyx_v_rows, __pyx_v_cols, __pyx_v_out);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
<span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
return __pyx_r;
}
static PyObject *__pyx_pf_16sparseoperations_backpropagation_updates_Cython(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_a, PyArrayObject *__pyx_v_delta, PyArrayObject *__pyx_v_rows, PyArrayObject *__pyx_v_cols, PyArrayObject *__pyx_v_out) {
size_t __pyx_v_i;
size_t __pyx_v_j;
double __pyx_v_s;
__Pyx_LocalBuf_ND __pyx_pybuffernd_a;
__Pyx_Buffer __pyx_pybuffer_a;
__Pyx_LocalBuf_ND __pyx_pybuffernd_cols;
__Pyx_Buffer __pyx_pybuffer_cols;
__Pyx_LocalBuf_ND __pyx_pybuffernd_delta;
__Pyx_Buffer __pyx_pybuffer_delta;
__Pyx_LocalBuf_ND __pyx_pybuffernd_out;
__Pyx_Buffer __pyx_pybuffer_out;
__Pyx_LocalBuf_ND __pyx_pybuffernd_rows;
__Pyx_Buffer __pyx_pybuffer_rows;
PyObject *__pyx_r = NULL;
<span class='refnanny'>__Pyx_RefNannyDeclarations</span>
<span class='refnanny'>__Pyx_RefNannySetupContext</span>("backpropagation_updates_Cython", 0);
__pyx_pybuffer_a.pybuffer.buf = NULL;
__pyx_pybuffer_a.refcount = 0;
__pyx_pybuffernd_a.data = NULL;
__pyx_pybuffernd_a.rcbuffer = &__pyx_pybuffer_a;
__pyx_pybuffer_delta.pybuffer.buf = NULL;
__pyx_pybuffer_delta.refcount = 0;
__pyx_pybuffernd_delta.data = NULL;
__pyx_pybuffernd_delta.rcbuffer = &__pyx_pybuffer_delta;
__pyx_pybuffer_rows.pybuffer.buf = NULL;
__pyx_pybuffer_rows.refcount = 0;
__pyx_pybuffernd_rows.data = NULL;
__pyx_pybuffernd_rows.rcbuffer = &__pyx_pybuffer_rows;
__pyx_pybuffer_cols.pybuffer.buf = NULL;
__pyx_pybuffer_cols.refcount = 0;
__pyx_pybuffernd_cols.data = NULL;
__pyx_pybuffernd_cols.rcbuffer = &__pyx_pybuffer_cols;
__pyx_pybuffer_out.pybuffer.buf = NULL;
__pyx_pybuffer_out.refcount = 0;
__pyx_pybuffernd_out.data = NULL;
__pyx_pybuffernd_out.rcbuffer = &__pyx_pybuffer_out;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_a.rcbuffer->pybuffer, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
}
__pyx_pybuffernd_a.diminfo[0].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_a.diminfo[0].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_a.diminfo[1].strides = __pyx_pybuffernd_a.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_a.diminfo[1].shape = __pyx_pybuffernd_a.rcbuffer->pybuffer.shape[1];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_delta.rcbuffer->pybuffer, (PyObject*)__pyx_v_delta, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
}
__pyx_pybuffernd_delta.diminfo[0].strides = __pyx_pybuffernd_delta.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_delta.diminfo[0].shape = __pyx_pybuffernd_delta.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_delta.diminfo[1].strides = __pyx_pybuffernd_delta.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_delta.diminfo[1].shape = __pyx_pybuffernd_delta.rcbuffer->pybuffer.shape[1];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_rows.rcbuffer->pybuffer, (PyObject*)__pyx_v_rows, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
}
__pyx_pybuffernd_rows.diminfo[0].strides = __pyx_pybuffernd_rows.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_rows.diminfo[0].shape = __pyx_pybuffernd_rows.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_cols.rcbuffer->pybuffer, (PyObject*)__pyx_v_cols, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
}
__pyx_pybuffernd_cols.diminfo[0].strides = __pyx_pybuffernd_cols.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cols.diminfo[0].shape = __pyx_pybuffernd_cols.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(<span class='pyx_c_api'>__Pyx_GetBufferAndValidate</span>(&__pyx_pybuffernd_out.rcbuffer->pybuffer, (PyObject*)__pyx_v_out, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
}
__pyx_pybuffernd_out.diminfo[0].strides = __pyx_pybuffernd_out.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_out.diminfo[0].shape = __pyx_pybuffernd_out.rcbuffer->pybuffer.shape[0];
/* … */
/* function exit code */
__pyx_r = Py_None; <span class='pyx_macro_api'>__Pyx_INCREF</span>(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
<span class='pyx_c_api'>__Pyx_ErrFetch</span>(&__pyx_type, &__pyx_value, &__pyx_tb);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_cols.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_delta.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_rows.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_ErrRestore</span>(__pyx_type, __pyx_value, __pyx_tb);}
<span class='pyx_c_api'>__Pyx_AddTraceback</span>("sparseoperations.backpropagation_updates_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
goto __pyx_L2;
__pyx_L0:;
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_a.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_cols.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_delta.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_out.rcbuffer->pybuffer);
<span class='pyx_c_api'>__Pyx_SafeReleaseBuffer</span>(&__pyx_pybuffernd_rows.rcbuffer->pybuffer);
__pyx_L2:;
<span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);
<span class='refnanny'>__Pyx_RefNannyFinishContext</span>();
return __pyx_r;
}
/* … */
__pyx_tuple__10 = <span class='py_c_api'>PyTuple_Pack</span>(8, __pyx_n_s_a, __pyx_n_s_delta, __pyx_n_s_rows, __pyx_n_s_cols, __pyx_n_s_out, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_s);<span class='error_goto'> if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 6, __pyx_L1_error)</span>
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__10);
<span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__10);
/* … */
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_16sparseoperations_1backpropagation_updates_Cython, NULL, __pyx_n_s_sparseoperations);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)</span>
<span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);
if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_backpropagation_updates_Cython, __pyx_t_1) < 0) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>
<span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;
</pre><pre class="cython line score-0"> <span class="">07</span>: cdef:</pre>
<pre class="cython line score-0"> <span class="">08</span>: size_t i,j</pre>
<pre class="cython line score-0"> <span class="">09</span>: double s</pre>
<pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">10</span>: for i in range (out.shape[0]):</pre>
<pre class='cython code score-0 '> __pyx_t_1 = (__pyx_v_out->dimensions[0]);
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">11</span>: s=0</pre>
<pre class='cython code score-0 '> __pyx_v_s = 0.0;
</pre><pre class="cython line score-0" onclick='toggleDiv(this)'>+<span class="">12</span>: for j in range(a.shape[0]):</pre>
<pre class='cython code score-0 '> __pyx_t_3 = (__pyx_v_a->dimensions[0]);
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_j = __pyx_t_4;
</pre><pre class="cython line score-8" onclick='toggleDiv(this)'>+<span class="">13</span>: s+=a[j,rows[i]]*delta[j, cols[i]]</pre>
<pre class='cython code score-8 '> __pyx_t_5 = __pyx_v_i;
__pyx_t_6 = -1;
if (unlikely(__pyx_t_5 >= (size_t)__pyx_pybuffernd_rows.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_6);
<span class='error_goto'>__PYX_ERR(0, 13, __pyx_L1_error)</span>
}
__pyx_t_7 = __pyx_v_j;
__pyx_t_8 = (*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_rows.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_rows.diminfo[0].strides));
__pyx_t_6 = -1;
if (unlikely(__pyx_t_7 >= (size_t)__pyx_pybuffernd_a.diminfo[0].shape)) __pyx_t_6 = 0;
if (__pyx_t_8 < 0) {
__pyx_t_8 += __pyx_pybuffernd_a.diminfo[1].shape;
if (unlikely(__pyx_t_8 < 0)) __pyx_t_6 = 1;
} else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_a.diminfo[1].shape)) __pyx_t_6 = 1;
if (unlikely(__pyx_t_6 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_6);
<span class='error_goto'>__PYX_ERR(0, 13, __pyx_L1_error)</span>
}
__pyx_t_9 = __pyx_v_i;
__pyx_t_6 = -1;
if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_cols.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_6);
<span class='error_goto'>__PYX_ERR(0, 13, __pyx_L1_error)</span>
}
__pyx_t_10 = __pyx_v_j;
__pyx_t_11 = (*__Pyx_BufPtrStrided1d(int *, __pyx_pybuffernd_cols.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_cols.diminfo[0].strides));
__pyx_t_6 = -1;
if (unlikely(__pyx_t_10 >= (size_t)__pyx_pybuffernd_delta.diminfo[0].shape)) __pyx_t_6 = 0;
if (__pyx_t_11 < 0) {
__pyx_t_11 += __pyx_pybuffernd_delta.diminfo[1].shape;
if (unlikely(__pyx_t_11 < 0)) __pyx_t_6 = 1;
} else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_delta.diminfo[1].shape)) __pyx_t_6 = 1;
if (unlikely(__pyx_t_6 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_6);
<span class='error_goto'>__PYX_ERR(0, 13, __pyx_L1_error)</span>
}
__pyx_v_s = (__pyx_v_s + ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_a.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_a.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_a.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_delta.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_delta.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_delta.diminfo[1].strides))));
}
</pre><pre class="cython line score-7" onclick='toggleDiv(this)'>+<span class="">14</span>: out[i]=s/a.shape[0]</pre>
<pre class='cython code score-7 '> if (unlikely((__pyx_v_a->dimensions[0]) == 0)) {
<span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, "float division");
<span class='error_goto'>__PYX_ERR(0, 14, __pyx_L1_error)</span>
}
__pyx_t_4 = __pyx_v_i;
__pyx_t_6 = -1;
if (unlikely(__pyx_t_4 >= (size_t)__pyx_pybuffernd_out.diminfo[0].shape)) __pyx_t_6 = 0;
if (unlikely(__pyx_t_6 != -1)) {
<span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_6);
<span class='error_goto'>__PYX_ERR(0, 14, __pyx_L1_error)</span>
}
*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_out.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_out.diminfo[0].strides) = (__pyx_v_s / (__pyx_v_a->dimensions[0]));
}
</pre><pre class="cython line score-0"> <span class="">15</span>: #return out</pre>
<pre class="cython line score-0"> <span class="">16</span>: </pre>
</div></body></html>