Debian Codegraph @

internal/execution/eng_minmaxbetween.go

raw
1 // Code generated by genlib2. DO NOT EDIT.
2
3 package execution
4
5 import (
6 "reflect"
7
8 "github.com/pkg/errors"
9 "gorgonia.org/tensor/internal/storage"
10 )
11
12 func (e E) MaxBetween(t reflect.Type, a *storage.Header, b *storage.Header) (err error) {
13 as := isScalar(a, t)
14 bs := isScalar(b, t)
15
16 switch t {
17 case Int:
18 at := a.Ints()
19 bt := b.Ints()
20 switch {
21 case as && bs:
22 VecMaxI(at, bt)
23 case as && !bs:
24 MaxSVI(at[0], bt)
25 case !as && bs:
26 MaxVSI(at, bt[0])
27 default:
28 VecMaxI(at, bt)
29 }
30 return
31 case Int8:
32 at := a.Int8s()
33 bt := b.Int8s()
34 switch {
35 case as && bs:
36 VecMaxI8(at, bt)
37 case as && !bs:
38 MaxSVI8(at[0], bt)
39 case !as && bs:
40 MaxVSI8(at, bt[0])
41 default:
42 VecMaxI8(at, bt)
43 }
44 return
45 case Int16:
46 at := a.Int16s()
47 bt := b.Int16s()
48 switch {
49 case as && bs:
50 VecMaxI16(at, bt)
51 case as && !bs:
52 MaxSVI16(at[0], bt)
53 case !as && bs:
54 MaxVSI16(at, bt[0])
55 default:
56 VecMaxI16(at, bt)
57 }
58 return
59 case Int32:
60 at := a.Int32s()
61 bt := b.Int32s()
62 switch {
63 case as && bs:
64 VecMaxI32(at, bt)
65 case as && !bs:
66 MaxSVI32(at[0], bt)
67 case !as && bs:
68 MaxVSI32(at, bt[0])
69 default:
70 VecMaxI32(at, bt)
71 }
72 return
73 case Int64:
74 at := a.Int64s()
75 bt := b.Int64s()
76 switch {
77 case as && bs:
78 VecMaxI64(at, bt)
79 case as && !bs:
80 MaxSVI64(at[0], bt)
81 case !as && bs:
82 MaxVSI64(at, bt[0])
83 default:
84 VecMaxI64(at, bt)
85 }
86 return
87 case Uint:
88 at := a.Uints()
89 bt := b.Uints()
90 switch {
91 case as && bs:
92 VecMaxU(at, bt)
93 case as && !bs:
94 MaxSVU(at[0], bt)
95 case !as && bs:
96 MaxVSU(at, bt[0])
97 default:
98 VecMaxU(at, bt)
99 }
100 return
101 case Uint8:
102 at := a.Uint8s()
103 bt := b.Uint8s()
104 switch {
105 case as && bs:
106 VecMaxU8(at, bt)
107 case as && !bs:
108 MaxSVU8(at[0], bt)
109 case !as && bs:
110 MaxVSU8(at, bt[0])
111 default:
112 VecMaxU8(at, bt)
113 }
114 return
115 case Uint16:
116 at := a.Uint16s()
117 bt := b.Uint16s()
118 switch {
119 case as && bs:
120 VecMaxU16(at, bt)
121 case as && !bs:
122 MaxSVU16(at[0], bt)
123 case !as && bs:
124 MaxVSU16(at, bt[0])
125 default:
126 VecMaxU16(at, bt)
127 }
128 return
129 case Uint32:
130 at := a.Uint32s()
131 bt := b.Uint32s()
132 switch {
133 case as && bs:
134 VecMaxU32(at, bt)
135 case as && !bs:
136 MaxSVU32(at[0], bt)
137 case !as && bs:
138 MaxVSU32(at, bt[0])
139 default:
140 VecMaxU32(at, bt)
141 }
142 return
143 case Uint64:
144 at := a.Uint64s()
145 bt := b.Uint64s()
146 switch {
147 case as && bs:
148 VecMaxU64(at, bt)
149 case as && !bs:
150 MaxSVU64(at[0], bt)
151 case !as && bs:
152 MaxVSU64(at, bt[0])
153 default:
154 VecMaxU64(at, bt)
155 }
156 return
157 case Float32:
158 at := a.Float32s()
159 bt := b.Float32s()
160 switch {
161 case as && bs:
162 VecMaxF32(at, bt)
163 case as && !bs:
164 MaxSVF32(at[0], bt)
165 case !as && bs:
166 MaxVSF32(at, bt[0])
167 default:
168 VecMaxF32(at, bt)
169 }
170 return
171 case Float64:
172 at := a.Float64s()
173 bt := b.Float64s()
174 switch {
175 case as && bs:
176 VecMaxF64(at, bt)
177 case as && !bs:
178 MaxSVF64(at[0], bt)
179 case !as && bs:
180 MaxVSF64(at, bt[0])
181 default:
182 VecMaxF64(at, bt)
183 }
184 return
185 case String:
186 at := a.Strings()
187 bt := b.Strings()
188 switch {
189 case as && bs:
190 VecMaxStr(at, bt)
191 case as && !bs:
192 MaxSVStr(at[0], bt)
193 case !as && bs:
194 MaxVSStr(at, bt[0])
195 default:
196 VecMaxStr(at, bt)
197 }
198 return
199 default:
200 return errors.Errorf("Unsupported type %v for Max", t)
201 }
202 }
203
204 func (e E) MinBetween(t reflect.Type, a *storage.Header, b *storage.Header) (err error) {
205 as := isScalar(a, t)
206 bs := isScalar(b, t)
207
208 switch t {
209 case Int:
210 at := a.Ints()
211 bt := b.Ints()
212 switch {
213 case as && bs:
214 VecMinI(at, bt)
215 case as && !bs:
216 MinSVI(at[0], bt)
217 case !as && bs:
218 MinVSI(at, bt[0])
219 default:
220 VecMinI(at, bt)
221 }
222 return
223 case Int8:
224 at := a.Int8s()
225 bt := b.Int8s()
226 switch {
227 case as && bs:
228 VecMinI8(at, bt)
229 case as && !bs:
230 MinSVI8(at[0], bt)
231 case !as && bs:
232 MinVSI8(at, bt[0])
233 default:
234 VecMinI8(at, bt)
235 }
236 return
237 case Int16:
238 at := a.Int16s()
239 bt := b.Int16s()
240 switch {
241 case as && bs:
242 VecMinI16(at, bt)
243 case as && !bs:
244 MinSVI16(at[0], bt)
245 case !as && bs:
246 MinVSI16(at, bt[0])
247 default:
248 VecMinI16(at, bt)
249 }
250 return
251 case Int32:
252 at := a.Int32s()
253 bt := b.Int32s()
254 switch {
255 case as && bs:
256 VecMinI32(at, bt)
257 case as && !bs:
258 MinSVI32(at[0], bt)
259 case !as && bs:
260 MinVSI32(at, bt[0])
261 default:
262 VecMinI32(at, bt)
263 }
264 return
265 case Int64:
266 at := a.Int64s()
267 bt := b.Int64s()
268 switch {
269 case as && bs:
270 VecMinI64(at, bt)
271 case as && !bs:
272 MinSVI64(at[0], bt)
273 case !as && bs:
274 MinVSI64(at, bt[0])
275 default:
276 VecMinI64(at, bt)
277 }
278 return
279 case Uint:
280 at := a.Uints()
281 bt := b.Uints()
282 switch {
283 case as && bs:
284 VecMinU(at, bt)
285 case as && !bs:
286 MinSVU(at[0], bt)
287 case !as && bs:
288 MinVSU(at, bt[0])
289 default:
290 VecMinU(at, bt)
291 }
292 return
293 case Uint8:
294 at := a.Uint8s()
295 bt := b.Uint8s()
296 switch {
297 case as && bs:
298 VecMinU8(at, bt)
299 case as && !bs:
300 MinSVU8(at[0], bt)
301 case !as && bs:
302 MinVSU8(at, bt[0])
303 default:
304 VecMinU8(at, bt)
305 }
306 return
307 case Uint16:
308 at := a.Uint16s()
309 bt := b.Uint16s()
310 switch {
311 case as && bs:
312 VecMinU16(at, bt)
313 case as && !bs:
314 MinSVU16(at[0], bt)
315 case !as && bs:
316 MinVSU16(at, bt[0])
317 default:
318 VecMinU16(at, bt)
319 }
320 return
321 case Uint32:
322 at := a.Uint32s()
323 bt := b.Uint32s()
324 switch {
325 case as && bs:
326 VecMinU32(at, bt)
327 case as && !bs:
328 MinSVU32(at[0], bt)
329 case !as && bs:
330 MinVSU32(at, bt[0])
331 default:
332 VecMinU32(at, bt)
333 }
334 return
335 case Uint64:
336 at := a.Uint64s()
337 bt := b.Uint64s()
338 switch {
339 case as && bs:
340 VecMinU64(at, bt)
341 case as && !bs:
342 MinSVU64(at[0], bt)
343 case !as && bs:
344 MinVSU64(at, bt[0])
345 default:
346 VecMinU64(at, bt)
347 }
348 return
349 case Float32:
350 at := a.Float32s()
351 bt := b.Float32s()
352 switch {
353 case as && bs:
354 VecMinF32(at, bt)
355 case as && !bs:
356 MinSVF32(at[0], bt)
357 case !as && bs:
358 MinVSF32(at, bt[0])
359 default:
360 VecMinF32(at, bt)
361 }
362 return
363 case Float64:
364 at := a.Float64s()
365 bt := b.Float64s()
366 switch {
367 case as && bs:
368 VecMinF64(at, bt)
369 case as && !bs:
370 MinSVF64(at[0], bt)
371 case !as && bs:
372 MinVSF64(at, bt[0])
373 default:
374 VecMinF64(at, bt)
375 }
376 return
377 case String:
378 at := a.Strings()
379 bt := b.Strings()
380 switch {
381 case as && bs:
382 VecMinStr(at, bt)
383 case as && !bs:
384 MinSVStr(at[0], bt)
385 case !as && bs:
386 MinVSStr(at, bt[0])
387 default:
388 VecMinStr(at, bt)
389 }
390 return
391 default:
392 return errors.Errorf("Unsupported type %v for Min", t)
393 }
394 }
395
396 func (e E) MaxBetweenIter(t reflect.Type, a *storage.Header, b *storage.Header, ait Iterator, bit Iterator) (err error) {
397 as := isScalar(a, t)
398 bs := isScalar(b, t)
399
400 switch t {
401 case Int:
402 at := a.Ints()
403 bt := b.Ints()
404 switch {
405 case as && bs:
406 VecMaxI(at, bt)
407 case as && !bs:
408 MaxIterSVI(at[0], bt, bit)
409 case !as && bs:
410 MaxIterVSI(at, bt[0], ait)
411 default:
412 VecMaxIterI(at, bt, ait, bit)
413 }
414 return
415 case Int8:
416 at := a.Int8s()
417 bt := b.Int8s()
418 switch {
419 case as && bs:
420 VecMaxI8(at, bt)
421 case as && !bs:
422 MaxIterSVI8(at[0], bt, bit)
423 case !as && bs:
424 MaxIterVSI8(at, bt[0], ait)
425 default:
426 VecMaxIterI8(at, bt, ait, bit)
427 }
428 return
429 case Int16:
430 at := a.Int16s()
431 bt := b.Int16s()
432 switch {
433 case as && bs:
434 VecMaxI16(at, bt)
435 case as && !bs:
436 MaxIterSVI16(at[0], bt, bit)
437 case !as && bs:
438 MaxIterVSI16(at, bt[0], ait)
439 default:
440 VecMaxIterI16(at, bt, ait, bit)
441 }
442 return
443 case Int32:
444 at := a.Int32s()
445 bt := b.Int32s()
446 switch {
447 case as && bs:
448 VecMaxI32(at, bt)
449 case as && !bs:
450 MaxIterSVI32(at[0], bt, bit)
451 case !as && bs:
452 MaxIterVSI32(at, bt[0], ait)
453 default:
454 VecMaxIterI32(at, bt, ait, bit)
455 }
456 return
457 case Int64:
458 at := a.Int64s()
459 bt := b.Int64s()
460 switch {
461 case as && bs:
462 VecMaxI64(at, bt)
463 case as && !bs:
464 MaxIterSVI64(at[0], bt, bit)
465 case !as && bs:
466 MaxIterVSI64(at, bt[0], ait)
467 default:
468 VecMaxIterI64(at, bt, ait, bit)
469 }
470 return
471 case Uint:
472 at := a.Uints()
473 bt := b.Uints()
474 switch {
475 case as && bs:
476 VecMaxU(at, bt)
477 case as && !bs:
478 MaxIterSVU(at[0], bt, bit)
479 case !as && bs:
480 MaxIterVSU(at, bt[0], ait)
481 default:
482 VecMaxIterU(at, bt, ait, bit)
483 }
484 return
485 case Uint8:
486 at := a.Uint8s()
487 bt := b.Uint8s()
488 switch {
489 case as && bs:
490 VecMaxU8(at, bt)
491 case as && !bs:
492 MaxIterSVU8(at[0], bt, bit)
493 case !as && bs:
494 MaxIterVSU8(at, bt[0], ait)
495 default:
496 VecMaxIterU8(at, bt, ait, bit)
497 }
498 return
499 case Uint16:
500 at := a.Uint16s()
501 bt := b.Uint16s()
502 switch {
503 case as && bs:
504 VecMaxU16(at, bt)
505 case as && !bs:
506 MaxIterSVU16(at[0], bt, bit)
507 case !as && bs:
508 MaxIterVSU16(at, bt[0], ait)
509 default:
510 VecMaxIterU16(at, bt, ait, bit)
511 }
512 return
513 case Uint32:
514 at := a.Uint32s()
515 bt := b.Uint32s()
516 switch {
517 case as && bs:
518 VecMaxU32(at, bt)
519 case as && !bs:
520 MaxIterSVU32(at[0], bt, bit)
521 case !as && bs:
522 MaxIterVSU32(at, bt[0], ait)
523 default:
524 VecMaxIterU32(at, bt, ait, bit)
525 }
526 return
527 case Uint64:
528 at := a.Uint64s()
529 bt := b.Uint64s()
530 switch {
531 case as && bs:
532 VecMaxU64(at, bt)
533 case as && !bs:
534 MaxIterSVU64(at[0], bt, bit)
535 case !as && bs:
536 MaxIterVSU64(at, bt[0], ait)
537 default:
538 VecMaxIterU64(at, bt, ait, bit)
539 }
540 return
541 case Float32:
542 at := a.Float32s()
543 bt := b.Float32s()
544 switch {
545 case as && bs:
546 VecMaxF32(at, bt)
547 case as && !bs:
548 MaxIterSVF32(at[0], bt, bit)
549 case !as && bs:
550 MaxIterVSF32(at, bt[0], ait)
551 default:
552 VecMaxIterF32(at, bt, ait, bit)
553 }
554 return
555 case Float64:
556 at := a.Float64s()
557 bt := b.Float64s()
558 switch {
559 case as && bs:
560 VecMaxF64(at, bt)
561 case as && !bs:
562 MaxIterSVF64(at[0], bt, bit)
563 case !as && bs:
564 MaxIterVSF64(at, bt[0], ait)
565 default:
566 VecMaxIterF64(at, bt, ait, bit)
567 }
568 return
569 case String:
570 at := a.Strings()
571 bt := b.Strings()
572 switch {
573 case as && bs:
574 VecMaxStr(at, bt)
575 case as && !bs:
576 MaxIterSVStr(at[0], bt, bit)
577 case !as && bs:
578 MaxIterVSStr(at, bt[0], ait)
579 default:
580 VecMaxIterStr(at, bt, ait, bit)
581 }
582 return
583 default:
584 return errors.Errorf("Unsupported type %v for Max", t)
585 }
586 }
587
588 func (e E) MinBetweenIter(t reflect.Type, a *storage.Header, b *storage.Header, ait Iterator, bit Iterator) (err error) {
589 as := isScalar(a, t)
590 bs := isScalar(b, t)
591
592 switch t {
593 case Int:
594 at := a.Ints()
595 bt := b.Ints()
596 switch {
597 case as && bs:
598 VecMinI(at, bt)
599 case as && !bs:
600 MinIterSVI(at[0], bt, bit)
601 case !as && bs:
602 MinIterVSI(at, bt[0], ait)
603 default:
604 VecMinIterI(at, bt, ait, bit)
605 }
606 return
607 case Int8:
608 at := a.Int8s()
609 bt := b.Int8s()
610 switch {
611 case as && bs:
612 VecMinI8(at, bt)
613 case as && !bs:
614 MinIterSVI8(at[0], bt, bit)
615 case !as && bs:
616 MinIterVSI8(at, bt[0], ait)
617 default:
618 VecMinIterI8(at, bt, ait, bit)
619 }
620 return
621 case Int16:
622 at := a.Int16s()
623 bt := b.Int16s()
624 switch {
625 case as && bs:
626 VecMinI16(at, bt)
627 case as && !bs:
628 MinIterSVI16(at[0], bt, bit)
629 case !as && bs:
630 MinIterVSI16(at, bt[0], ait)
631 default:
632 VecMinIterI16(at, bt, ait, bit)
633 }
634 return
635 case Int32:
636 at := a.Int32s()
637 bt := b.Int32s()
638 switch {
639 case as && bs:
640 VecMinI32(at, bt)
641 case as && !bs:
642 MinIterSVI32(at[0], bt, bit)
643 case !as && bs:
644 MinIterVSI32(at, bt[0], ait)
645 default:
646 VecMinIterI32(at, bt, ait, bit)
647 }
648 return
649 case Int64:
650 at := a.Int64s()
651 bt := b.Int64s()
652 switch {
653 case as && bs:
654 VecMinI64(at, bt)
655 case as && !bs:
656 MinIterSVI64(at[0], bt, bit)
657 case !as && bs:
658 MinIterVSI64(at, bt[0], ait)
659 default:
660 VecMinIterI64(at, bt, ait, bit)
661 }
662 return
663 case Uint:
664 at := a.Uints()
665 bt := b.Uints()
666 switch {
667 case as && bs:
668 VecMinU(at, bt)
669 case as && !bs:
670 MinIterSVU(at[0], bt, bit)
671 case !as && bs:
672 MinIterVSU(at, bt[0], ait)
673 default:
674 VecMinIterU(at, bt, ait, bit)
675 }
676 return
677 case Uint8:
678 at := a.Uint8s()
679 bt := b.Uint8s()
680 switch {
681 case as && bs:
682 VecMinU8(at, bt)
683 case as && !bs:
684 MinIterSVU8(at[0], bt, bit)
685 case !as && bs:
686 MinIterVSU8(at, bt[0], ait)
687 default:
688 VecMinIterU8(at, bt, ait, bit)
689 }
690 return
691 case Uint16:
692 at := a.Uint16s()
693 bt := b.Uint16s()
694 switch {
695 case as && bs:
696 VecMinU16(at, bt)
697 case as && !bs:
698 MinIterSVU16(at[0], bt, bit)
699 case !as && bs:
700 MinIterVSU16(at, bt[0], ait)
701 default:
702 VecMinIterU16(at, bt, ait, bit)
703 }
704 return
705 case Uint32:
706 at := a.Uint32s()
707 bt := b.Uint32s()
708 switch {
709 case as && bs:
710 VecMinU32(at, bt)
711 case as && !bs:
712 MinIterSVU32(at[0], bt, bit)
713 case !as && bs:
714 MinIterVSU32(at, bt[0], ait)
715 default:
716 VecMinIterU32(at, bt, ait, bit)
717 }
718 return
719 case Uint64:
720 at := a.Uint64s()
721 bt := b.Uint64s()
722 switch {
723 case as && bs:
724 VecMinU64(at, bt)
725 case as && !bs:
726 MinIterSVU64(at[0], bt, bit)
727 case !as && bs:
728 MinIterVSU64(at, bt[0], ait)
729 default:
730 VecMinIterU64(at, bt, ait, bit)
731 }
732 return
733 case Float32:
734 at := a.Float32s()
735 bt := b.Float32s()
736 switch {
737 case as && bs:
738 VecMinF32(at, bt)
739 case as && !bs:
740 MinIterSVF32(at[0], bt, bit)
741 case !as && bs:
742 MinIterVSF32(at, bt[0], ait)
743 default:
744 VecMinIterF32(at, bt, ait, bit)
745 }
746 return
747 case Float64:
748 at := a.Float64s()
749 bt := b.Float64s()
750 switch {
751 case as && bs:
752 VecMinF64(at, bt)
753 case as && !bs:
754 MinIterSVF64(at[0], bt, bit)
755 case !as && bs:
756 MinIterVSF64(at, bt[0], ait)
757 default:
758 VecMinIterF64(at, bt, ait, bit)
759 }
760 return
761 case String:
762 at := a.Strings()
763 bt := b.Strings()
764 switch {
765 case as && bs:
766 VecMinStr(at, bt)
767 case as && !bs:
768 MinIterSVStr(at[0], bt, bit)
769 case !as && bs:
770 MinIterVSStr(at, bt[0], ait)
771 default:
772 VecMinIterStr(at, bt, ait, bit)
773 }
774 return
775 default:
776 return errors.Errorf("Unsupported type %v for Min", t)
777 }
778 }