44import itertools
55from .typeconv import TypeManager , TypeCastingRules
66from numba .core import types
7- from numba .cuda import config
87
98
109default_type_manager = TypeManager ()
@@ -16,58 +15,49 @@ def dump_number_rules():
1615 print (a , "->" , b , tm .check_compatible (a , b ))
1716
1817
19- if config .USE_LEGACY_TYPE_SYSTEM : # Old type system
18+ def _init_casting_rules (tm ):
19+ tcr = TypeCastingRules (tm )
20+ tcr .safe_unsafe (types .boolean , types .int8 )
21+ tcr .safe_unsafe (types .boolean , types .uint8 )
2022
21- def _init_casting_rules (tm ):
22- tcr = TypeCastingRules (tm )
23- tcr .safe_unsafe (types .boolean , types .int8 )
24- tcr .safe_unsafe (types .boolean , types .uint8 )
23+ tcr .promote_unsafe (types .int8 , types .int16 )
24+ tcr .promote_unsafe (types .uint8 , types .uint16 )
2525
26- tcr .promote_unsafe (types .int8 , types .int16 )
27- tcr .promote_unsafe (types .uint8 , types .uint16 )
26+ tcr .promote_unsafe (types .int16 , types .int32 )
27+ tcr .promote_unsafe (types .uint16 , types .uint32 )
2828
29- tcr .promote_unsafe (types .int16 , types .int32 )
30- tcr .promote_unsafe (types .uint16 , types .uint32 )
29+ tcr .promote_unsafe (types .int32 , types .int64 )
30+ tcr .promote_unsafe (types .uint32 , types .uint64 )
3131
32- tcr .promote_unsafe (types .int32 , types .int64 )
33- tcr .promote_unsafe (types .uint32 , types .uint64 )
32+ tcr .safe_unsafe (types .uint8 , types .int16 )
33+ tcr .safe_unsafe (types .uint16 , types .int32 )
34+ tcr .safe_unsafe (types .uint32 , types .int64 )
3435
35- tcr .safe_unsafe (types .uint8 , types .int16 )
36- tcr .safe_unsafe (types .uint16 , types .int32 )
37- tcr .safe_unsafe (types .uint32 , types .int64 )
36+ tcr .safe_unsafe (types .int8 , types .float16 )
37+ tcr .safe_unsafe (types .int16 , types .float32 )
38+ tcr .safe_unsafe (types .int32 , types .float64 )
3839
39- tcr .safe_unsafe (types .int8 , types .float16 )
40- tcr .safe_unsafe (types .int16 , types .float32 )
41- tcr .safe_unsafe (types .int32 , types .float64 )
40+ tcr .unsafe_unsafe (types .int16 , types .float16 )
41+ tcr .unsafe_unsafe (types .int32 , types .float32 )
42+ # XXX this is inconsistent with the above; but we want to prefer
43+ # float64 over int64 when typing a heterogeneous operation,
44+ # e.g. `float64 + int64`. Perhaps we need more granularity in the
45+ # conversion kinds.
46+ tcr .safe_unsafe (types .int64 , types .float64 )
47+ tcr .safe_unsafe (types .uint64 , types .float64 )
4248
43- tcr .unsafe_unsafe (types .int16 , types .float16 )
44- tcr .unsafe_unsafe (types .int32 , types .float32 )
45- # XXX this is inconsistent with the above; but we want to prefer
46- # float64 over int64 when typing a heterogeneous operation,
47- # e.g. `float64 + int64`. Perhaps we need more granularity in the
48- # conversion kinds.
49- tcr .safe_unsafe (types .int64 , types .float64 )
50- tcr .safe_unsafe (types .uint64 , types .float64 )
49+ tcr .promote_unsafe (types .float16 , types .float32 )
50+ tcr .promote_unsafe (types .float32 , types .float64 )
5151
52- tcr .promote_unsafe (types .float16 , types .float32 )
53- tcr .promote_unsafe (types .float32 , types .float64 )
52+ tcr .safe (types .float32 , types .complex64 )
53+ tcr .safe (types .float64 , types .complex128 )
5454
55- tcr .safe (types .float32 , types .complex64 )
56- tcr .safe (types .float64 , types .complex128 )
55+ tcr .promote_unsafe (types .complex64 , types .complex128 )
5756
58- tcr .promote_unsafe (types .complex64 , types .complex128 )
57+ # Allow integers to cast ot void*
58+ tcr .unsafe_unsafe (types .uintp , types .voidptr )
5959
60- # Allow integers to cast ot void*
61- tcr .unsafe_unsafe (types .uintp , types .voidptr )
62-
63- return tcr
64- else : # New type system
65- # Currently left as empty
66- # If no casting rules are required we may opt to remove
67- # this framework upon deprecation
68- def _init_casting_rules (tm ):
69- tcr = TypeCastingRules (tm )
70- return tcr
60+ return tcr
7161
7262
7363default_casting_rules = _init_casting_rules (default_type_manager )
0 commit comments