• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# mypy: ignore-errors
2
3import torch
4
5
6# These two dicts are autogenerated with autogen/gen_dtypes.py,
7# using numpy version 1.24.3.
8
9_can_cast_dict = {
10    "no": {
11        torch.float16: {
12            torch.float16: True,
13            torch.float32: False,
14            torch.float64: False,
15            torch.complex64: False,
16            torch.complex128: False,
17            torch.uint8: False,
18            torch.uint16: False,
19            torch.uint32: False,
20            torch.uint64: False,
21            torch.int8: False,
22            torch.int16: False,
23            torch.int32: False,
24            torch.int64: False,
25            torch.bool: False,
26        },
27        torch.float32: {
28            torch.float16: False,
29            torch.float32: True,
30            torch.float64: False,
31            torch.complex64: False,
32            torch.complex128: False,
33            torch.uint8: False,
34            torch.uint16: False,
35            torch.uint32: False,
36            torch.uint64: False,
37            torch.int8: False,
38            torch.int16: False,
39            torch.int32: False,
40            torch.int64: False,
41            torch.bool: False,
42        },
43        torch.float64: {
44            torch.float16: False,
45            torch.float32: False,
46            torch.float64: True,
47            torch.complex64: False,
48            torch.complex128: False,
49            torch.uint8: False,
50            torch.uint16: False,
51            torch.uint32: False,
52            torch.uint64: False,
53            torch.int8: False,
54            torch.int16: False,
55            torch.int32: False,
56            torch.int64: False,
57            torch.bool: False,
58        },
59        torch.complex64: {
60            torch.float16: False,
61            torch.float32: False,
62            torch.float64: False,
63            torch.complex64: True,
64            torch.complex128: False,
65            torch.uint8: False,
66            torch.uint16: False,
67            torch.uint32: False,
68            torch.uint64: False,
69            torch.int8: False,
70            torch.int16: False,
71            torch.int32: False,
72            torch.int64: False,
73            torch.bool: False,
74        },
75        torch.complex128: {
76            torch.float16: False,
77            torch.float32: False,
78            torch.float64: False,
79            torch.complex64: False,
80            torch.complex128: True,
81            torch.uint8: False,
82            torch.uint16: False,
83            torch.uint32: False,
84            torch.uint64: False,
85            torch.int8: False,
86            torch.int16: False,
87            torch.int32: False,
88            torch.int64: False,
89            torch.bool: False,
90        },
91        torch.uint8: {
92            torch.float16: False,
93            torch.float32: False,
94            torch.float64: False,
95            torch.complex64: False,
96            torch.complex128: False,
97            torch.uint8: True,
98            torch.uint16: False,
99            torch.uint32: False,
100            torch.uint64: False,
101            torch.int8: False,
102            torch.int16: False,
103            torch.int32: False,
104            torch.int64: False,
105            torch.bool: False,
106        },
107        torch.uint16: {
108            torch.float16: False,
109            torch.float32: False,
110            torch.float64: False,
111            torch.complex64: False,
112            torch.complex128: False,
113            torch.uint8: False,
114            torch.uint16: True,
115            torch.uint32: False,
116            torch.uint64: False,
117            torch.int8: False,
118            torch.int16: False,
119            torch.int32: False,
120            torch.int64: False,
121            torch.bool: False,
122        },
123        torch.uint32: {
124            torch.float16: False,
125            torch.float32: False,
126            torch.float64: False,
127            torch.complex64: False,
128            torch.complex128: False,
129            torch.uint8: False,
130            torch.uint16: False,
131            torch.uint32: True,
132            torch.uint64: False,
133            torch.int8: False,
134            torch.int16: False,
135            torch.int32: False,
136            torch.int64: False,
137            torch.bool: False,
138        },
139        torch.uint64: {
140            torch.float16: False,
141            torch.float32: False,
142            torch.float64: False,
143            torch.complex64: False,
144            torch.complex128: False,
145            torch.uint8: False,
146            torch.uint16: False,
147            torch.uint32: False,
148            torch.uint64: True,
149            torch.int8: False,
150            torch.int16: False,
151            torch.int32: False,
152            torch.int64: False,
153            torch.bool: False,
154        },
155        torch.int8: {
156            torch.float16: False,
157            torch.float32: False,
158            torch.float64: False,
159            torch.complex64: False,
160            torch.complex128: False,
161            torch.uint8: False,
162            torch.uint16: False,
163            torch.uint32: False,
164            torch.uint64: False,
165            torch.int8: True,
166            torch.int16: False,
167            torch.int32: False,
168            torch.int64: False,
169            torch.bool: False,
170        },
171        torch.int16: {
172            torch.float16: False,
173            torch.float32: False,
174            torch.float64: False,
175            torch.complex64: False,
176            torch.complex128: False,
177            torch.uint8: False,
178            torch.uint16: False,
179            torch.uint32: False,
180            torch.uint64: False,
181            torch.int8: False,
182            torch.int16: True,
183            torch.int32: False,
184            torch.int64: False,
185            torch.bool: False,
186        },
187        torch.int32: {
188            torch.float16: False,
189            torch.float32: False,
190            torch.float64: False,
191            torch.complex64: False,
192            torch.complex128: False,
193            torch.uint8: False,
194            torch.uint16: False,
195            torch.uint32: False,
196            torch.uint64: False,
197            torch.int8: False,
198            torch.int16: False,
199            torch.int32: True,
200            torch.int64: False,
201            torch.bool: False,
202        },
203        torch.int64: {
204            torch.float16: False,
205            torch.float32: False,
206            torch.float64: False,
207            torch.complex64: False,
208            torch.complex128: False,
209            torch.uint8: False,
210            torch.uint16: False,
211            torch.uint32: False,
212            torch.uint64: False,
213            torch.int8: False,
214            torch.int16: False,
215            torch.int32: False,
216            torch.int64: True,
217            torch.bool: False,
218        },
219        torch.bool: {
220            torch.float16: False,
221            torch.float32: False,
222            torch.float64: False,
223            torch.complex64: False,
224            torch.complex128: False,
225            torch.uint8: False,
226            torch.uint16: False,
227            torch.uint32: False,
228            torch.uint64: False,
229            torch.int8: False,
230            torch.int16: False,
231            torch.int32: False,
232            torch.int64: False,
233            torch.bool: True,
234        },
235    },
236    "equiv": {
237        torch.float16: {
238            torch.float16: True,
239            torch.float32: False,
240            torch.float64: False,
241            torch.complex64: False,
242            torch.complex128: False,
243            torch.uint8: False,
244            torch.uint16: False,
245            torch.uint32: False,
246            torch.uint64: False,
247            torch.int8: False,
248            torch.int16: False,
249            torch.int32: False,
250            torch.int64: False,
251            torch.bool: False,
252        },
253        torch.float32: {
254            torch.float16: False,
255            torch.float32: True,
256            torch.float64: False,
257            torch.complex64: False,
258            torch.complex128: False,
259            torch.uint8: False,
260            torch.uint16: False,
261            torch.uint32: False,
262            torch.uint64: False,
263            torch.int8: False,
264            torch.int16: False,
265            torch.int32: False,
266            torch.int64: False,
267            torch.bool: False,
268        },
269        torch.float64: {
270            torch.float16: False,
271            torch.float32: False,
272            torch.float64: True,
273            torch.complex64: False,
274            torch.complex128: False,
275            torch.uint8: False,
276            torch.uint16: False,
277            torch.uint32: False,
278            torch.uint64: False,
279            torch.int8: False,
280            torch.int16: False,
281            torch.int32: False,
282            torch.int64: False,
283            torch.bool: False,
284        },
285        torch.complex64: {
286            torch.float16: False,
287            torch.float32: False,
288            torch.float64: False,
289            torch.complex64: True,
290            torch.complex128: False,
291            torch.uint8: False,
292            torch.uint16: False,
293            torch.uint32: False,
294            torch.uint64: False,
295            torch.int8: False,
296            torch.int16: False,
297            torch.int32: False,
298            torch.int64: False,
299            torch.bool: False,
300        },
301        torch.complex128: {
302            torch.float16: False,
303            torch.float32: False,
304            torch.float64: False,
305            torch.complex64: False,
306            torch.complex128: True,
307            torch.uint8: False,
308            torch.uint16: False,
309            torch.uint32: False,
310            torch.uint64: False,
311            torch.int8: False,
312            torch.int16: False,
313            torch.int32: False,
314            torch.int64: False,
315            torch.bool: False,
316        },
317        torch.uint8: {
318            torch.float16: False,
319            torch.float32: False,
320            torch.float64: False,
321            torch.complex64: False,
322            torch.complex128: False,
323            torch.uint8: True,
324            torch.uint16: False,
325            torch.uint32: False,
326            torch.uint64: False,
327            torch.int8: False,
328            torch.int16: False,
329            torch.int32: False,
330            torch.int64: False,
331            torch.bool: False,
332        },
333        torch.uint16: {
334            torch.float16: False,
335            torch.float32: False,
336            torch.float64: False,
337            torch.complex64: False,
338            torch.complex128: False,
339            torch.uint8: False,
340            torch.uint16: True,
341            torch.uint32: False,
342            torch.uint64: False,
343            torch.int8: False,
344            torch.int16: False,
345            torch.int32: False,
346            torch.int64: False,
347            torch.bool: False,
348        },
349        torch.uint32: {
350            torch.float16: False,
351            torch.float32: False,
352            torch.float64: False,
353            torch.complex64: False,
354            torch.complex128: False,
355            torch.uint8: False,
356            torch.uint16: False,
357            torch.uint32: True,
358            torch.uint64: False,
359            torch.int8: False,
360            torch.int16: False,
361            torch.int32: False,
362            torch.int64: False,
363            torch.bool: False,
364        },
365        torch.uint64: {
366            torch.float16: False,
367            torch.float32: False,
368            torch.float64: False,
369            torch.complex64: False,
370            torch.complex128: False,
371            torch.uint8: False,
372            torch.uint16: False,
373            torch.uint32: False,
374            torch.uint64: True,
375            torch.int8: False,
376            torch.int16: False,
377            torch.int32: False,
378            torch.int64: False,
379            torch.bool: False,
380        },
381        torch.int8: {
382            torch.float16: False,
383            torch.float32: False,
384            torch.float64: False,
385            torch.complex64: False,
386            torch.complex128: False,
387            torch.uint8: False,
388            torch.uint16: False,
389            torch.uint32: False,
390            torch.uint64: False,
391            torch.int8: True,
392            torch.int16: False,
393            torch.int32: False,
394            torch.int64: False,
395            torch.bool: False,
396        },
397        torch.int16: {
398            torch.float16: False,
399            torch.float32: False,
400            torch.float64: False,
401            torch.complex64: False,
402            torch.complex128: False,
403            torch.uint8: False,
404            torch.uint16: False,
405            torch.uint32: False,
406            torch.uint64: False,
407            torch.int8: False,
408            torch.int16: True,
409            torch.int32: False,
410            torch.int64: False,
411            torch.bool: False,
412        },
413        torch.int32: {
414            torch.float16: False,
415            torch.float32: False,
416            torch.float64: False,
417            torch.complex64: False,
418            torch.complex128: False,
419            torch.uint8: False,
420            torch.uint16: False,
421            torch.uint32: False,
422            torch.uint64: False,
423            torch.int8: False,
424            torch.int16: False,
425            torch.int32: True,
426            torch.int64: False,
427            torch.bool: False,
428        },
429        torch.int64: {
430            torch.float16: False,
431            torch.float32: False,
432            torch.float64: False,
433            torch.complex64: False,
434            torch.complex128: False,
435            torch.uint8: False,
436            torch.uint16: False,
437            torch.uint32: False,
438            torch.uint64: False,
439            torch.int8: False,
440            torch.int16: False,
441            torch.int32: False,
442            torch.int64: True,
443            torch.bool: False,
444        },
445        torch.bool: {
446            torch.float16: False,
447            torch.float32: False,
448            torch.float64: False,
449            torch.complex64: False,
450            torch.complex128: False,
451            torch.uint8: False,
452            torch.uint16: False,
453            torch.uint32: False,
454            torch.uint64: False,
455            torch.int8: False,
456            torch.int16: False,
457            torch.int32: False,
458            torch.int64: False,
459            torch.bool: True,
460        },
461    },
462    "safe": {
463        torch.float16: {
464            torch.float16: True,
465            torch.float32: True,
466            torch.float64: True,
467            torch.complex64: True,
468            torch.complex128: True,
469            torch.uint8: False,
470            torch.uint16: False,
471            torch.uint32: False,
472            torch.uint64: False,
473            torch.int8: False,
474            torch.int16: False,
475            torch.int32: False,
476            torch.int64: False,
477            torch.bool: False,
478        },
479        torch.float32: {
480            torch.float16: False,
481            torch.float32: True,
482            torch.float64: True,
483            torch.complex64: True,
484            torch.complex128: True,
485            torch.uint8: False,
486            torch.uint16: False,
487            torch.uint32: False,
488            torch.uint64: False,
489            torch.int8: False,
490            torch.int16: False,
491            torch.int32: False,
492            torch.int64: False,
493            torch.bool: False,
494        },
495        torch.float64: {
496            torch.float16: False,
497            torch.float32: False,
498            torch.float64: True,
499            torch.complex64: False,
500            torch.complex128: True,
501            torch.uint8: False,
502            torch.uint16: False,
503            torch.uint32: False,
504            torch.uint64: False,
505            torch.int8: False,
506            torch.int16: False,
507            torch.int32: False,
508            torch.int64: False,
509            torch.bool: False,
510        },
511        torch.complex64: {
512            torch.float16: False,
513            torch.float32: False,
514            torch.float64: False,
515            torch.complex64: True,
516            torch.complex128: True,
517            torch.uint8: False,
518            torch.uint16: False,
519            torch.uint32: False,
520            torch.uint64: False,
521            torch.int8: False,
522            torch.int16: False,
523            torch.int32: False,
524            torch.int64: False,
525            torch.bool: False,
526        },
527        torch.complex128: {
528            torch.float16: False,
529            torch.float32: False,
530            torch.float64: False,
531            torch.complex64: False,
532            torch.complex128: True,
533            torch.uint8: False,
534            torch.uint16: False,
535            torch.uint32: False,
536            torch.uint64: False,
537            torch.int8: False,
538            torch.int16: False,
539            torch.int32: False,
540            torch.int64: False,
541            torch.bool: False,
542        },
543        torch.uint8: {
544            torch.float16: True,
545            torch.float32: True,
546            torch.float64: True,
547            torch.complex64: True,
548            torch.complex128: True,
549            torch.uint8: True,
550            torch.uint16: True,
551            torch.uint32: True,
552            torch.uint64: True,
553            torch.int8: False,
554            torch.int16: True,
555            torch.int32: True,
556            torch.int64: True,
557            torch.bool: False,
558        },
559        torch.uint16: {
560            torch.float16: False,
561            torch.float32: True,
562            torch.float64: True,
563            torch.complex64: True,
564            torch.complex128: True,
565            torch.uint8: False,
566            torch.uint16: True,
567            torch.uint32: True,
568            torch.uint64: True,
569            torch.int8: False,
570            torch.int16: False,
571            torch.int32: True,
572            torch.int64: True,
573            torch.bool: False,
574        },
575        torch.uint32: {
576            torch.float16: False,
577            torch.float32: False,
578            torch.float64: True,
579            torch.complex64: False,
580            torch.complex128: True,
581            torch.uint8: False,
582            torch.uint16: False,
583            torch.uint32: True,
584            torch.uint64: True,
585            torch.int8: False,
586            torch.int16: False,
587            torch.int32: False,
588            torch.int64: True,
589            torch.bool: False,
590        },
591        torch.uint64: {
592            torch.float16: False,
593            torch.float32: False,
594            torch.float64: True,
595            torch.complex64: False,
596            torch.complex128: True,
597            torch.uint8: False,
598            torch.uint16: False,
599            torch.uint32: False,
600            torch.uint64: True,
601            torch.int8: False,
602            torch.int16: False,
603            torch.int32: False,
604            torch.int64: False,
605            torch.bool: False,
606        },
607        torch.int8: {
608            torch.float16: True,
609            torch.float32: True,
610            torch.float64: True,
611            torch.complex64: True,
612            torch.complex128: True,
613            torch.uint8: False,
614            torch.uint16: False,
615            torch.uint32: False,
616            torch.uint64: False,
617            torch.int8: True,
618            torch.int16: True,
619            torch.int32: True,
620            torch.int64: True,
621            torch.bool: False,
622        },
623        torch.int16: {
624            torch.float16: False,
625            torch.float32: True,
626            torch.float64: True,
627            torch.complex64: True,
628            torch.complex128: True,
629            torch.uint8: False,
630            torch.uint16: False,
631            torch.uint32: False,
632            torch.uint64: False,
633            torch.int8: False,
634            torch.int16: True,
635            torch.int32: True,
636            torch.int64: True,
637            torch.bool: False,
638        },
639        torch.int32: {
640            torch.float16: False,
641            torch.float32: False,
642            torch.float64: True,
643            torch.complex64: False,
644            torch.complex128: True,
645            torch.uint8: False,
646            torch.uint16: False,
647            torch.uint32: False,
648            torch.uint64: False,
649            torch.int8: False,
650            torch.int16: False,
651            torch.int32: True,
652            torch.int64: True,
653            torch.bool: False,
654        },
655        torch.int64: {
656            torch.float16: False,
657            torch.float32: False,
658            torch.float64: True,
659            torch.complex64: False,
660            torch.complex128: True,
661            torch.uint8: False,
662            torch.uint16: False,
663            torch.uint32: False,
664            torch.uint64: False,
665            torch.int8: False,
666            torch.int16: False,
667            torch.int32: False,
668            torch.int64: True,
669            torch.bool: False,
670        },
671        torch.bool: {
672            torch.float16: True,
673            torch.float32: True,
674            torch.float64: True,
675            torch.complex64: True,
676            torch.complex128: True,
677            torch.uint8: True,
678            torch.uint16: True,
679            torch.uint32: True,
680            torch.uint64: True,
681            torch.int8: True,
682            torch.int16: True,
683            torch.int32: True,
684            torch.int64: True,
685            torch.bool: True,
686        },
687    },
688    "same_kind": {
689        torch.float16: {
690            torch.float16: True,
691            torch.float32: True,
692            torch.float64: True,
693            torch.complex64: True,
694            torch.complex128: True,
695            torch.uint8: False,
696            torch.uint16: False,
697            torch.uint32: False,
698            torch.uint64: False,
699            torch.int8: False,
700            torch.int16: False,
701            torch.int32: False,
702            torch.int64: False,
703            torch.bool: False,
704        },
705        torch.float32: {
706            torch.float16: True,
707            torch.float32: True,
708            torch.float64: True,
709            torch.complex64: True,
710            torch.complex128: True,
711            torch.uint8: False,
712            torch.uint16: False,
713            torch.uint32: False,
714            torch.uint64: False,
715            torch.int8: False,
716            torch.int16: False,
717            torch.int32: False,
718            torch.int64: False,
719            torch.bool: False,
720        },
721        torch.float64: {
722            torch.float16: True,
723            torch.float32: True,
724            torch.float64: True,
725            torch.complex64: True,
726            torch.complex128: True,
727            torch.uint8: False,
728            torch.uint16: False,
729            torch.uint32: False,
730            torch.uint64: False,
731            torch.int8: False,
732            torch.int16: False,
733            torch.int32: False,
734            torch.int64: False,
735            torch.bool: False,
736        },
737        torch.complex64: {
738            torch.float16: False,
739            torch.float32: False,
740            torch.float64: False,
741            torch.complex64: True,
742            torch.complex128: True,
743            torch.uint8: False,
744            torch.uint16: False,
745            torch.uint32: False,
746            torch.uint64: False,
747            torch.int8: False,
748            torch.int16: False,
749            torch.int32: False,
750            torch.int64: False,
751            torch.bool: False,
752        },
753        torch.complex128: {
754            torch.float16: False,
755            torch.float32: False,
756            torch.float64: False,
757            torch.complex64: True,
758            torch.complex128: True,
759            torch.uint8: False,
760            torch.uint16: False,
761            torch.uint32: False,
762            torch.uint64: False,
763            torch.int8: False,
764            torch.int16: False,
765            torch.int32: False,
766            torch.int64: False,
767            torch.bool: False,
768        },
769        torch.uint8: {
770            torch.float16: True,
771            torch.float32: True,
772            torch.float64: True,
773            torch.complex64: True,
774            torch.complex128: True,
775            torch.uint8: True,
776            torch.uint16: True,
777            torch.uint32: True,
778            torch.uint64: True,
779            torch.int8: True,
780            torch.int16: True,
781            torch.int32: True,
782            torch.int64: True,
783            torch.bool: False,
784        },
785        torch.uint16: {
786            torch.float16: True,
787            torch.float32: True,
788            torch.float64: True,
789            torch.complex64: True,
790            torch.complex128: True,
791            torch.uint8: True,
792            torch.uint16: True,
793            torch.uint32: True,
794            torch.uint64: True,
795            torch.int8: True,
796            torch.int16: True,
797            torch.int32: True,
798            torch.int64: True,
799            torch.bool: False,
800        },
801        torch.uint32: {
802            torch.float16: True,
803            torch.float32: True,
804            torch.float64: True,
805            torch.complex64: True,
806            torch.complex128: True,
807            torch.uint8: True,
808            torch.uint16: True,
809            torch.uint32: True,
810            torch.uint64: True,
811            torch.int8: True,
812            torch.int16: True,
813            torch.int32: True,
814            torch.int64: True,
815            torch.bool: False,
816        },
817        torch.uint64: {
818            torch.float16: True,
819            torch.float32: True,
820            torch.float64: True,
821            torch.complex64: True,
822            torch.complex128: True,
823            torch.uint8: True,
824            torch.uint16: True,
825            torch.uint32: True,
826            torch.uint64: True,
827            torch.int8: True,
828            torch.int16: True,
829            torch.int32: True,
830            torch.int64: True,
831            torch.bool: False,
832        },
833        torch.int8: {
834            torch.float16: True,
835            torch.float32: True,
836            torch.float64: True,
837            torch.complex64: True,
838            torch.complex128: True,
839            torch.uint8: False,
840            torch.uint16: False,
841            torch.uint32: False,
842            torch.uint64: False,
843            torch.int8: True,
844            torch.int16: True,
845            torch.int32: True,
846            torch.int64: True,
847            torch.bool: False,
848        },
849        torch.int16: {
850            torch.float16: True,
851            torch.float32: True,
852            torch.float64: True,
853            torch.complex64: True,
854            torch.complex128: True,
855            torch.uint8: False,
856            torch.uint16: False,
857            torch.uint32: False,
858            torch.uint64: False,
859            torch.int8: True,
860            torch.int16: True,
861            torch.int32: True,
862            torch.int64: True,
863            torch.bool: False,
864        },
865        torch.int32: {
866            torch.float16: True,
867            torch.float32: True,
868            torch.float64: True,
869            torch.complex64: True,
870            torch.complex128: True,
871            torch.uint8: False,
872            torch.uint16: False,
873            torch.uint32: False,
874            torch.uint64: False,
875            torch.int8: True,
876            torch.int16: True,
877            torch.int32: True,
878            torch.int64: True,
879            torch.bool: False,
880        },
881        torch.int64: {
882            torch.float16: True,
883            torch.float32: True,
884            torch.float64: True,
885            torch.complex64: True,
886            torch.complex128: True,
887            torch.uint8: False,
888            torch.uint16: False,
889            torch.uint32: False,
890            torch.uint64: False,
891            torch.int8: True,
892            torch.int16: True,
893            torch.int32: True,
894            torch.int64: True,
895            torch.bool: False,
896        },
897        torch.bool: {
898            torch.float16: True,
899            torch.float32: True,
900            torch.float64: True,
901            torch.complex64: True,
902            torch.complex128: True,
903            torch.uint8: True,
904            torch.uint16: True,
905            torch.uint32: True,
906            torch.uint64: True,
907            torch.int8: True,
908            torch.int16: True,
909            torch.int32: True,
910            torch.int64: True,
911            torch.bool: True,
912        },
913    },
914    "unsafe": {
915        torch.float16: {
916            torch.float16: True,
917            torch.float32: True,
918            torch.float64: True,
919            torch.complex64: True,
920            torch.complex128: True,
921            torch.uint8: True,
922            torch.uint16: True,
923            torch.uint32: True,
924            torch.uint64: True,
925            torch.int8: True,
926            torch.int16: True,
927            torch.int32: True,
928            torch.int64: True,
929            torch.bool: True,
930        },
931        torch.float32: {
932            torch.float16: True,
933            torch.float32: True,
934            torch.float64: True,
935            torch.complex64: True,
936            torch.complex128: True,
937            torch.uint8: True,
938            torch.uint16: True,
939            torch.uint32: True,
940            torch.uint64: True,
941            torch.int8: True,
942            torch.int16: True,
943            torch.int32: True,
944            torch.int64: True,
945            torch.bool: True,
946        },
947        torch.float64: {
948            torch.float16: True,
949            torch.float32: True,
950            torch.float64: True,
951            torch.complex64: True,
952            torch.complex128: True,
953            torch.uint8: True,
954            torch.uint16: True,
955            torch.uint32: True,
956            torch.uint64: True,
957            torch.int8: True,
958            torch.int16: True,
959            torch.int32: True,
960            torch.int64: True,
961            torch.bool: True,
962        },
963        torch.complex64: {
964            torch.float16: True,
965            torch.float32: True,
966            torch.float64: True,
967            torch.complex64: True,
968            torch.complex128: True,
969            torch.uint8: True,
970            torch.uint16: True,
971            torch.uint32: True,
972            torch.uint64: True,
973            torch.int8: True,
974            torch.int16: True,
975            torch.int32: True,
976            torch.int64: True,
977            torch.bool: True,
978        },
979        torch.complex128: {
980            torch.float16: True,
981            torch.float32: True,
982            torch.float64: True,
983            torch.complex64: True,
984            torch.complex128: True,
985            torch.uint8: True,
986            torch.uint16: True,
987            torch.uint32: True,
988            torch.uint64: True,
989            torch.int8: True,
990            torch.int16: True,
991            torch.int32: True,
992            torch.int64: True,
993            torch.bool: True,
994        },
995        torch.uint8: {
996            torch.float16: True,
997            torch.float32: True,
998            torch.float64: True,
999            torch.complex64: True,
1000            torch.complex128: True,
1001            torch.uint8: True,
1002            torch.uint16: True,
1003            torch.uint32: True,
1004            torch.uint64: True,
1005            torch.int8: True,
1006            torch.int16: True,
1007            torch.int32: True,
1008            torch.int64: True,
1009            torch.bool: True,
1010        },
1011        torch.uint16: {
1012            torch.float16: True,
1013            torch.float32: True,
1014            torch.float64: True,
1015            torch.complex64: True,
1016            torch.complex128: True,
1017            torch.uint8: True,
1018            torch.uint16: True,
1019            torch.uint32: True,
1020            torch.uint64: True,
1021            torch.int8: True,
1022            torch.int16: True,
1023            torch.int32: True,
1024            torch.int64: True,
1025            torch.bool: True,
1026        },
1027        torch.uint32: {
1028            torch.float16: True,
1029            torch.float32: True,
1030            torch.float64: True,
1031            torch.complex64: True,
1032            torch.complex128: True,
1033            torch.uint8: True,
1034            torch.uint16: True,
1035            torch.uint32: True,
1036            torch.uint64: True,
1037            torch.int8: True,
1038            torch.int16: True,
1039            torch.int32: True,
1040            torch.int64: True,
1041            torch.bool: True,
1042        },
1043        torch.uint64: {
1044            torch.float16: True,
1045            torch.float32: True,
1046            torch.float64: True,
1047            torch.complex64: True,
1048            torch.complex128: True,
1049            torch.uint8: True,
1050            torch.uint16: True,
1051            torch.uint32: True,
1052            torch.uint64: True,
1053            torch.int8: True,
1054            torch.int16: True,
1055            torch.int32: True,
1056            torch.int64: True,
1057            torch.bool: True,
1058        },
1059        torch.int8: {
1060            torch.float16: True,
1061            torch.float32: True,
1062            torch.float64: True,
1063            torch.complex64: True,
1064            torch.complex128: True,
1065            torch.uint8: True,
1066            torch.uint16: True,
1067            torch.uint32: True,
1068            torch.uint64: True,
1069            torch.int8: True,
1070            torch.int16: True,
1071            torch.int32: True,
1072            torch.int64: True,
1073            torch.bool: True,
1074        },
1075        torch.int16: {
1076            torch.float16: True,
1077            torch.float32: True,
1078            torch.float64: True,
1079            torch.complex64: True,
1080            torch.complex128: True,
1081            torch.uint8: True,
1082            torch.uint16: True,
1083            torch.uint32: True,
1084            torch.uint64: True,
1085            torch.int8: True,
1086            torch.int16: True,
1087            torch.int32: True,
1088            torch.int64: True,
1089            torch.bool: True,
1090        },
1091        torch.int32: {
1092            torch.float16: True,
1093            torch.float32: True,
1094            torch.float64: True,
1095            torch.complex64: True,
1096            torch.complex128: True,
1097            torch.uint8: True,
1098            torch.uint16: True,
1099            torch.uint32: True,
1100            torch.uint64: True,
1101            torch.int8: True,
1102            torch.int16: True,
1103            torch.int32: True,
1104            torch.int64: True,
1105            torch.bool: True,
1106        },
1107        torch.int64: {
1108            torch.float16: True,
1109            torch.float32: True,
1110            torch.float64: True,
1111            torch.complex64: True,
1112            torch.complex128: True,
1113            torch.uint8: True,
1114            torch.uint16: True,
1115            torch.uint32: True,
1116            torch.uint64: True,
1117            torch.int8: True,
1118            torch.int16: True,
1119            torch.int32: True,
1120            torch.int64: True,
1121            torch.bool: True,
1122        },
1123        torch.bool: {
1124            torch.float16: True,
1125            torch.float32: True,
1126            torch.float64: True,
1127            torch.complex64: True,
1128            torch.complex128: True,
1129            torch.uint8: True,
1130            torch.uint16: True,
1131            torch.uint32: True,
1132            torch.uint64: True,
1133            torch.int8: True,
1134            torch.int16: True,
1135            torch.int32: True,
1136            torch.int64: True,
1137            torch.bool: True,
1138        },
1139    },
1140}
1141
1142
1143_result_type_dict = {
1144    torch.float16: {
1145        torch.float16: torch.float16,
1146        torch.float32: torch.float32,
1147        torch.float64: torch.float64,
1148        torch.complex64: torch.complex64,
1149        torch.complex128: torch.complex128,
1150        torch.uint8: torch.float16,
1151        torch.uint16: torch.float32,
1152        torch.uint32: torch.float64,
1153        torch.uint64: torch.float64,
1154        torch.int8: torch.float16,
1155        torch.int16: torch.float32,
1156        torch.int32: torch.float64,
1157        torch.int64: torch.float64,
1158        torch.bool: torch.float16,
1159    },
1160    torch.float32: {
1161        torch.float16: torch.float32,
1162        torch.float32: torch.float32,
1163        torch.float64: torch.float64,
1164        torch.complex64: torch.complex64,
1165        torch.complex128: torch.complex128,
1166        torch.uint8: torch.float32,
1167        torch.uint16: torch.float32,
1168        torch.uint32: torch.float64,
1169        torch.uint64: torch.float64,
1170        torch.int8: torch.float32,
1171        torch.int16: torch.float32,
1172        torch.int32: torch.float64,
1173        torch.int64: torch.float64,
1174        torch.bool: torch.float32,
1175    },
1176    torch.float64: {
1177        torch.float16: torch.float64,
1178        torch.float32: torch.float64,
1179        torch.float64: torch.float64,
1180        torch.complex64: torch.complex128,
1181        torch.complex128: torch.complex128,
1182        torch.uint8: torch.float64,
1183        torch.uint16: torch.float64,
1184        torch.uint32: torch.float64,
1185        torch.uint64: torch.float64,
1186        torch.int8: torch.float64,
1187        torch.int16: torch.float64,
1188        torch.int32: torch.float64,
1189        torch.int64: torch.float64,
1190        torch.bool: torch.float64,
1191    },
1192    torch.complex64: {
1193        torch.float16: torch.complex64,
1194        torch.float32: torch.complex64,
1195        torch.float64: torch.complex128,
1196        torch.complex64: torch.complex64,
1197        torch.complex128: torch.complex128,
1198        torch.uint8: torch.complex64,
1199        torch.uint16: torch.complex64,
1200        torch.uint32: torch.complex128,
1201        torch.uint64: torch.complex128,
1202        torch.int8: torch.complex64,
1203        torch.int16: torch.complex64,
1204        torch.int32: torch.complex128,
1205        torch.int64: torch.complex128,
1206        torch.bool: torch.complex64,
1207    },
1208    torch.complex128: {
1209        torch.float16: torch.complex128,
1210        torch.float32: torch.complex128,
1211        torch.float64: torch.complex128,
1212        torch.complex64: torch.complex128,
1213        torch.complex128: torch.complex128,
1214        torch.uint8: torch.complex128,
1215        torch.uint16: torch.complex128,
1216        torch.uint32: torch.complex128,
1217        torch.uint64: torch.complex128,
1218        torch.int8: torch.complex128,
1219        torch.int16: torch.complex128,
1220        torch.int32: torch.complex128,
1221        torch.int64: torch.complex128,
1222        torch.bool: torch.complex128,
1223    },
1224    torch.uint8: {
1225        torch.float16: torch.float16,
1226        torch.float32: torch.float32,
1227        torch.float64: torch.float64,
1228        torch.complex64: torch.complex64,
1229        torch.complex128: torch.complex128,
1230        torch.uint8: torch.uint8,
1231        torch.uint16: torch.uint16,
1232        torch.uint32: torch.uint32,
1233        torch.uint64: torch.uint64,
1234        torch.int8: torch.int16,
1235        torch.int16: torch.int16,
1236        torch.int32: torch.int32,
1237        torch.int64: torch.int64,
1238        torch.bool: torch.uint8,
1239    },
1240    torch.uint16: {
1241        torch.float16: torch.float32,
1242        torch.float32: torch.float32,
1243        torch.float64: torch.float64,
1244        torch.complex64: torch.complex64,
1245        torch.complex128: torch.complex128,
1246        torch.uint8: torch.uint16,
1247        torch.uint16: torch.uint16,
1248        torch.uint32: torch.uint32,
1249        torch.uint64: torch.uint64,
1250        torch.int8: torch.int32,
1251        torch.int16: torch.int32,
1252        torch.int32: torch.int32,
1253        torch.int64: torch.int64,
1254        torch.bool: torch.uint16,
1255    },
1256    torch.uint32: {
1257        torch.float16: torch.float64,
1258        torch.float32: torch.float64,
1259        torch.float64: torch.float64,
1260        torch.complex64: torch.complex128,
1261        torch.complex128: torch.complex128,
1262        torch.uint8: torch.uint32,
1263        torch.uint16: torch.uint32,
1264        torch.uint32: torch.uint32,
1265        torch.uint64: torch.uint64,
1266        torch.int8: torch.int64,
1267        torch.int16: torch.int64,
1268        torch.int32: torch.int64,
1269        torch.int64: torch.int64,
1270        torch.bool: torch.uint32,
1271    },
1272    torch.uint64: {
1273        torch.float16: torch.float64,
1274        torch.float32: torch.float64,
1275        torch.float64: torch.float64,
1276        torch.complex64: torch.complex128,
1277        torch.complex128: torch.complex128,
1278        torch.uint8: torch.uint64,
1279        torch.uint16: torch.uint64,
1280        torch.uint32: torch.uint64,
1281        torch.uint64: torch.uint64,
1282        torch.int8: torch.float64,
1283        torch.int16: torch.float64,
1284        torch.int32: torch.float64,
1285        torch.int64: torch.float64,
1286        torch.bool: torch.uint64,
1287    },
1288    torch.int8: {
1289        torch.float16: torch.float16,
1290        torch.float32: torch.float32,
1291        torch.float64: torch.float64,
1292        torch.complex64: torch.complex64,
1293        torch.complex128: torch.complex128,
1294        torch.uint8: torch.int16,
1295        torch.uint16: torch.int32,
1296        torch.uint32: torch.int64,
1297        torch.uint64: torch.float64,
1298        torch.int8: torch.int8,
1299        torch.int16: torch.int16,
1300        torch.int32: torch.int32,
1301        torch.int64: torch.int64,
1302        torch.bool: torch.int8,
1303    },
1304    torch.int16: {
1305        torch.float16: torch.float32,
1306        torch.float32: torch.float32,
1307        torch.float64: torch.float64,
1308        torch.complex64: torch.complex64,
1309        torch.complex128: torch.complex128,
1310        torch.uint8: torch.int16,
1311        torch.uint16: torch.int32,
1312        torch.uint32: torch.int64,
1313        torch.uint64: torch.float64,
1314        torch.int8: torch.int16,
1315        torch.int16: torch.int16,
1316        torch.int32: torch.int32,
1317        torch.int64: torch.int64,
1318        torch.bool: torch.int16,
1319    },
1320    torch.int32: {
1321        torch.float16: torch.float64,
1322        torch.float32: torch.float64,
1323        torch.float64: torch.float64,
1324        torch.complex64: torch.complex128,
1325        torch.complex128: torch.complex128,
1326        torch.uint8: torch.int32,
1327        torch.uint16: torch.int32,
1328        torch.uint32: torch.int64,
1329        torch.uint64: torch.float64,
1330        torch.int8: torch.int32,
1331        torch.int16: torch.int32,
1332        torch.int32: torch.int32,
1333        torch.int64: torch.int64,
1334        torch.bool: torch.int32,
1335    },
1336    torch.int64: {
1337        torch.float16: torch.float64,
1338        torch.float32: torch.float64,
1339        torch.float64: torch.float64,
1340        torch.complex64: torch.complex128,
1341        torch.complex128: torch.complex128,
1342        torch.uint8: torch.int64,
1343        torch.uint16: torch.int64,
1344        torch.uint32: torch.int64,
1345        torch.uint64: torch.float64,
1346        torch.int8: torch.int64,
1347        torch.int16: torch.int64,
1348        torch.int32: torch.int64,
1349        torch.int64: torch.int64,
1350        torch.bool: torch.int64,
1351    },
1352    torch.bool: {
1353        torch.float16: torch.float16,
1354        torch.float32: torch.float32,
1355        torch.float64: torch.float64,
1356        torch.complex64: torch.complex64,
1357        torch.complex128: torch.complex128,
1358        torch.uint8: torch.uint8,
1359        torch.uint16: torch.uint16,
1360        torch.uint32: torch.uint32,
1361        torch.uint64: torch.uint64,
1362        torch.int8: torch.int8,
1363        torch.int16: torch.int16,
1364        torch.int32: torch.int32,
1365        torch.int64: torch.int64,
1366        torch.bool: torch.bool,
1367    },
1368}
1369