@@ -18,6 +18,7 @@ pub enum CpuStorage {
1818 I16 ( Vec < i16 > ) ,
1919 U16 ( Vec < u16 > ) ,
2020 U32 ( Vec < u32 > ) ,
21+ U64 ( Vec < u64 > ) ,
2122 I32 ( Vec < i32 > ) ,
2223 I64 ( Vec < i64 > ) ,
2324 F16 ( Vec < f16 > ) ,
@@ -89,6 +90,7 @@ impl CpuStorage {
8990 Self :: I16 ( _) => DType :: I16 ,
9091 Self :: U16 ( _) => DType :: U16 ,
9192 Self :: U32 ( _) => DType :: U32 ,
93+ Self :: U64 ( _) => DType :: U64 ,
9294 Self :: I32 ( _) => DType :: I32 ,
9395 Self :: I64 ( _) => DType :: I64 ,
9496 Self :: F16 ( _) => DType :: F16 ,
@@ -106,6 +108,7 @@ impl CpuStorage {
106108 Self :: I16 ( v) => v. len ( ) ,
107109 Self :: U16 ( v) => v. len ( ) ,
108110 Self :: U32 ( v) => v. len ( ) ,
111+ Self :: U64 ( v) => v. len ( ) ,
109112 Self :: I32 ( v) => v. len ( ) ,
110113 Self :: I64 ( v) => v. len ( ) ,
111114 Self :: F16 ( v) => v. len ( ) ,
@@ -170,6 +173,7 @@ impl CpuStorage {
170173 DType :: I16 => Self :: I16 ( data. iter ( ) . map ( |x| x. to_f64 ( ) as i16 ) . collect ( ) ) ,
171174 DType :: U16 => Self :: U16 ( data. iter ( ) . map ( |x| x. to_f64 ( ) as u16 ) . collect ( ) ) ,
172175 DType :: U32 => Self :: U32 ( data. iter ( ) . map ( |x| x. to_f64 ( ) as u32 ) . collect ( ) ) ,
176+ DType :: U64 => Self :: U64 ( data. iter ( ) . map ( |x| x. to_u64 ( ) ) . collect ( ) ) ,
173177 DType :: I32 => Self :: I32 ( data. iter ( ) . map ( |x| x. to_f64 ( ) as i32 ) . collect ( ) ) ,
174178 DType :: I64 => Self :: I64 ( data. iter ( ) . map ( |x| x. to_i64 ( ) ) . collect ( ) ) ,
175179 DType :: F16 => Self :: F16 ( data. iter ( ) . map ( |x| f16:: from_f32 ( x. to_f32 ( ) ) ) . collect ( ) ) ,
@@ -188,6 +192,7 @@ impl CpuStorage {
188192 DType :: I16 => Self :: I16 ( vec ! [ val as i16 ; numel] ) ,
189193 DType :: U16 => Self :: U16 ( vec ! [ val as u16 ; numel] ) ,
190194 DType :: U32 => Self :: U32 ( vec ! [ val as u32 ; numel] ) ,
195+ DType :: U64 => Self :: U64 ( vec ! [ val as u64 ; numel] ) ,
191196 DType :: I32 => Self :: I32 ( vec ! [ val as i32 ; numel] ) ,
192197 DType :: I64 => Self :: I64 ( vec ! [ val as i64 ; numel] ) ,
193198 DType :: F16 => Self :: F16 ( vec ! [ f16:: from_f32( val as f32 ) ; numel] ) ,
@@ -247,6 +252,7 @@ impl CpuStorage {
247252 Self :: I16 ( v) => extract ! ( v, |& x: & i16 | T :: from_f64( x as f64 ) ) ,
248253 Self :: U16 ( v) => extract ! ( v, |& x: & u16 | T :: from_f64( x as f64 ) ) ,
249254 Self :: U32 ( v) => extract ! ( v, |& x: & u32 | T :: from_f64( x as f64 ) ) ,
255+ Self :: U64 ( v) => extract ! ( v, |& x: & u64 | T :: from_u64( x) ) ,
250256 Self :: I32 ( v) => extract ! ( v, |& x: & i32 | T :: from_f64( x as f64 ) ) ,
251257 Self :: I64 ( v) => extract ! ( v, |& x: & i64 | T :: from_i64( x) ) ,
252258 Self :: F16 ( v) => extract ! ( v, |& x: & f16| T :: from_f32( x. to_f32( ) ) ) ,
@@ -322,6 +328,7 @@ impl CpuStorage {
322328 Self :: I16 ( v) => copy_typed ! ( I16 , v) ,
323329 Self :: U16 ( v) => copy_typed ! ( U16 , v) ,
324330 Self :: U32 ( v) => copy_typed ! ( U32 , v) ,
331+ Self :: U64 ( v) => copy_typed ! ( U64 , v) ,
325332 Self :: I32 ( v) => copy_typed ! ( I32 , v) ,
326333 Self :: I64 ( v) => copy_typed ! ( I64 , v) ,
327334 Self :: F16 ( v) => copy_typed ! ( F16 , v) ,
@@ -342,6 +349,7 @@ impl CpuStorage {
342349 DType :: I16 => Ok ( Self :: I16 ( self . to_vec :: < i16 > ( layout) ) ) ,
343350 DType :: U16 => Ok ( Self :: U16 ( self . to_vec :: < u16 > ( layout) ) ) ,
344351 DType :: U32 => Ok ( Self :: U32 ( self . to_vec :: < u32 > ( layout) ) ) ,
352+ DType :: U64 => Ok ( Self :: U64 ( self . to_vec :: < u64 > ( layout) ) ) ,
345353 DType :: I32 => Ok ( Self :: I32 ( self . to_vec :: < i32 > ( layout) ) ) ,
346354 DType :: I64 => Ok ( Self :: I64 ( self . to_vec :: < i64 > ( layout) ) ) ,
347355 DType :: F16 => Ok ( Self :: F16 ( self . to_vec :: < f16 > ( layout) ) ) ,
@@ -386,6 +394,7 @@ impl CpuStorage {
386394 Self :: I16 ( v) => scatter_typed ! ( I16 , v, 0i16 , |a: & mut i16 , b: i16 | * a = a. wrapping_add( b) ) ,
387395 Self :: U16 ( v) => scatter_typed ! ( U16 , v, 0u16 , |a: & mut u16 , b: u16 | * a = a. wrapping_add( b) ) ,
388396 Self :: U32 ( v) => scatter_typed ! ( U32 , v, 0u32 , |a: & mut u32 , b: u32 | * a = a. wrapping_add( b) ) ,
397+ Self :: U64 ( v) => scatter_typed ! ( U64 , v, 0u64 , |a: & mut u64 , b: u64 | * a = a. wrapping_add( b) ) ,
389398 Self :: I32 ( v) => {
390399 scatter_typed ! ( I32 , v, 0i32 , |a: & mut i32 , b: i32 | * a = a. wrapping_add( b) )
391400 }
@@ -476,6 +485,7 @@ impl CpuStorage {
476485 Self :: I16 ( v) => run_unary ! ( I16 , v, |x: i16 | eval_unary_f64( x as f64 , op) as i64 as i16 ) ,
477486 Self :: U16 ( v) => run_unary ! ( U16 , v, |x: u16 | eval_unary_f64( x as f64 , op) as i64 as u16 ) ,
478487 Self :: U32 ( v) => run_unary ! ( U32 , v, |x: u32 | eval_unary_f64( x as f64 , op) as i64 as u32 ) ,
488+ Self :: U64 ( v) => run_unary ! ( U64 , v, |x: u64 | eval_unary_f64( x as f64 , op) as i64 as u64 ) ,
479489 Self :: Bool ( _) => Err ( Error :: UnsupportedDType {
480490 op : "unary_op" ,
481491 dtype : DType :: Bool ,
@@ -514,7 +524,7 @@ impl CpuStorage {
514524 // Integer division by zero is an error, not a panic. Only denominators
515525 // inside the (pre-broadcast) view count. MIN/-1 keeps wrapping
516526 // semantics via wrapping_div below (the wrapped quotient is MIN).
517- if matches ! ( op, BinaryOp :: Div | BinaryOp :: Fmod | BinaryOp :: Remainder | BinaryOp :: FloorDiv ) && matches ! ( self , Self :: I32 ( _) | Self :: I64 ( _) | Self :: U8 ( _) | Self :: I8 ( _) | Self :: I16 ( _) | Self :: U16 ( _) | Self :: U32 ( _) )
527+ if matches ! ( op, BinaryOp :: Div | BinaryOp :: Fmod | BinaryOp :: Remainder | BinaryOp :: FloorDiv ) && matches ! ( self , Self :: I32 ( _) | Self :: I64 ( _) | Self :: U8 ( _) | Self :: I8 ( _) | Self :: I16 ( _) | Self :: U16 ( _) | Self :: U32 ( _) | Self :: U64 ( _ ) )
518528 {
519529 let denoms = rhs. to_vec :: < i64 > ( rhs_l) ;
520530 if denoms. contains ( & 0 ) {
@@ -523,7 +533,7 @@ impl CpuStorage {
523533 }
524534 // Integer pow is exact: negative exponents have no integer value and
525535 // silently saturated/wrapped huge powers hid bugs, so both are errors.
526- if matches ! ( op, BinaryOp :: Pow ) && matches ! ( self , Self :: I32 ( _) | Self :: I64 ( _) | Self :: U8 ( _) | Self :: I8 ( _) | Self :: I16 ( _) | Self :: U16 ( _) | Self :: U32 ( _) )
536+ if matches ! ( op, BinaryOp :: Pow ) && matches ! ( self , Self :: I32 ( _) | Self :: I64 ( _) | Self :: U8 ( _) | Self :: I8 ( _) | Self :: I16 ( _) | Self :: U16 ( _) | Self :: U32 ( _) | Self :: U64 ( _ ) )
527537 {
528538 let bases = self . to_vec :: < i64 > ( lhs_l) ;
529539 let exps = rhs. to_vec :: < i64 > ( rhs_l) ;
@@ -535,6 +545,7 @@ impl CpuStorage {
535545 Self :: I16 ( _) => ( i16:: MIN as i128 , i16:: MAX as i128 ) ,
536546 Self :: U16 ( _) => ( 0 , u16:: MAX as i128 ) ,
537547 Self :: U32 ( _) => ( 0 , u32:: MAX as i128 ) ,
548+ Self :: U64 ( _) => ( 0 , u64:: MAX as i128 ) ,
538549 _ => unreachable ! ( "guarded by the outer matches" ) ,
539550 } ;
540551 for ( & b, & e) in bases. iter ( ) . zip ( exps. iter ( ) ) {
@@ -855,6 +866,17 @@ impl CpuStorage {
855866 BinaryOp :: Fmod | BinaryOp :: Remainder => x % y,
856867 BinaryOp :: FloorDiv => x / y,
857868 } ) ,
869+ ( Self :: U64 ( a) , Self :: U64 ( b) ) => run_bin ! ( U64 , a, b, |x: u64 , y: u64 | match op {
870+ BinaryOp :: Add => x. wrapping_add( y) ,
871+ BinaryOp :: Sub => x. wrapping_sub( y) ,
872+ BinaryOp :: Mul => x. wrapping_mul( y) ,
873+ BinaryOp :: Div => x. wrapping_div( y) ,
874+ BinaryOp :: Maximum => x. max( y) ,
875+ BinaryOp :: Minimum => x. min( y) ,
876+ BinaryOp :: Pow => int_pow_kernel( x as i64 , y as i64 ) as u64 ,
877+ BinaryOp :: Fmod | BinaryOp :: Remainder => x % y,
878+ BinaryOp :: FloorDiv => x / y,
879+ } ) ,
858880 ( Self :: Bool ( a) , Self :: Bool ( b) ) => run_bin ! ( Bool , a, b, |x: bool , y: bool | match op {
859881 BinaryOp :: Add | BinaryOp :: Maximum => x || y,
860882 BinaryOp :: Mul | BinaryOp :: Minimum => x && y,
@@ -1119,6 +1141,9 @@ impl CpuStorage {
11191141 ( Self :: U32 ( a) , Self :: U32 ( b) ) => {
11201142 run_cmp ! ( a, b, |x: u32 , y: u32 | eval_cmp( x, y, op) )
11211143 }
1144+ ( Self :: U64 ( a) , Self :: U64 ( b) ) => {
1145+ run_cmp ! ( a, b, |x: u64 , y: u64 | eval_cmp( x, y, op) )
1146+ }
11221147 ( Self :: Bool ( a) , Self :: Bool ( b) ) => {
11231148 run_cmp ! ( a, b, |x: bool , y: bool | eval_cmp( x, y, op) )
11241149 }
@@ -1181,6 +1206,7 @@ impl CpuStorage {
11811206 ( Self :: I16 ( a) , Self :: I16 ( b) ) => bit_typed ! ( I16 , a, b) ,
11821207 ( Self :: U16 ( a) , Self :: U16 ( b) ) => bit_typed ! ( U16 , a, b) ,
11831208 ( Self :: U32 ( a) , Self :: U32 ( b) ) => bit_typed ! ( U32 , a, b) ,
1209+ ( Self :: U64 ( a) , Self :: U64 ( b) ) => bit_typed ! ( U64 , a, b) ,
11841210 ( Self :: I32 ( a) , Self :: I32 ( b) ) => bit_typed ! ( I32 , a, b) ,
11851211 ( Self :: I64 ( a) , Self :: I64 ( b) ) => bit_typed ! ( I64 , a, b) ,
11861212 _ => Err ( Error :: UnsupportedDType {
@@ -1260,6 +1286,7 @@ impl CpuStorage {
12601286 Self :: I16 ( v) => not_typed ! ( I16 , v) ,
12611287 Self :: U16 ( v) => not_typed ! ( U16 , v) ,
12621288 Self :: U32 ( v) => not_typed ! ( U32 , v) ,
1289+ Self :: U64 ( v) => not_typed ! ( U64 , v) ,
12631290 Self :: I32 ( v) => not_typed ! ( I32 , v) ,
12641291 Self :: I64 ( v) => not_typed ! ( I64 , v) ,
12651292 _ => Err ( Error :: UnsupportedDType {
@@ -1316,6 +1343,7 @@ impl CpuStorage {
13161343 Self :: I16 ( _) => select_typed ! ( I16 , i16 ) ,
13171344 Self :: U16 ( _) => select_typed ! ( U16 , u16 ) ,
13181345 Self :: U32 ( _) => select_typed ! ( U32 , u32 ) ,
1346+ Self :: U64 ( _) => select_typed ! ( U64 , u64 ) ,
13191347 Self :: I32 ( _) => select_typed ! ( I32 , i32 ) ,
13201348 Self :: I64 ( _) => select_typed ! ( I64 , i64 ) ,
13211349 Self :: F16 ( _) => select_typed ! ( F16 , f16) ,
@@ -1386,6 +1414,9 @@ impl CpuStorage {
13861414 ( Self :: U32 ( _) , Self :: U32 ( _) ) => {
13871415 add_typed ! ( U32 , u32 , |a: & mut u32 , b: u32 | * a = a. wrapping_add( b) )
13881416 }
1417+ ( Self :: U64 ( _) , Self :: U64 ( _) ) => {
1418+ add_typed ! ( U64 , u64 , |a: & mut u64 , b: u64 | * a = a. wrapping_add( b) )
1419+ }
13891420 ( Self :: I32 ( _) , Self :: I32 ( _) ) => {
13901421 add_typed ! ( I32 , i32 , |a: & mut i32 , b: i32 | * a = a. wrapping_add( b) )
13911422 }
@@ -1461,6 +1492,7 @@ impl CpuStorage {
14611492 Self :: I16 ( _) => gather_typed ! ( I16 , i16 ) ,
14621493 Self :: U16 ( _) => gather_typed ! ( U16 , u16 ) ,
14631494 Self :: U32 ( _) => gather_typed ! ( U32 , u32 ) ,
1495+ Self :: U64 ( _) => gather_typed ! ( U64 , u64 ) ,
14641496 Self :: I32 ( _) => gather_typed ! ( I32 , i32 ) ,
14651497 Self :: I64 ( _) => gather_typed ! ( I64 , i64 ) ,
14661498 Self :: F16 ( _) => gather_typed ! ( F16 , f16) ,
@@ -1539,6 +1571,9 @@ impl CpuStorage {
15391571 ( Self :: U32 ( _) , Self :: U32 ( _) ) => {
15401572 scatter_typed ! ( U32 , u32 , |a: & mut u32 , b: u32 | * a = a. wrapping_add( b) )
15411573 }
1574+ ( Self :: U64 ( _) , Self :: U64 ( _) ) => {
1575+ scatter_typed ! ( U64 , u64 , |a: & mut u64 , b: u64 | * a = a. wrapping_add( b) )
1576+ }
15421577 ( Self :: I32 ( _) , Self :: I32 ( _) ) => {
15431578 scatter_typed ! ( I32 , i32 , |a: & mut i32 , b: i32 | * a = a. wrapping_add( b) )
15441579 }
@@ -1626,6 +1661,7 @@ impl CpuStorage {
16261661 ( Self :: I16 ( _) , Self :: I16 ( _) ) => scatter_write ! ( I16 , i16 ) ,
16271662 ( Self :: U16 ( _) , Self :: U16 ( _) ) => scatter_write ! ( U16 , u16 ) ,
16281663 ( Self :: U32 ( _) , Self :: U32 ( _) ) => scatter_write ! ( U32 , u32 ) ,
1664+ ( Self :: U64 ( _) , Self :: U64 ( _) ) => scatter_write ! ( U64 , u64 ) ,
16291665 ( Self :: I32 ( _) , Self :: I32 ( _) ) => scatter_write ! ( I32 , i32 ) ,
16301666 ( Self :: I64 ( _) , Self :: I64 ( _) ) => scatter_write ! ( I64 , i64 ) ,
16311667 ( Self :: F16 ( _) , Self :: F16 ( _) ) => scatter_write ! ( F16 , f16) ,
@@ -1681,6 +1717,7 @@ impl CpuStorage {
16811717 ( Self :: I16 ( tv) , Self :: I16 ( fv) ) => select_typed ! ( I16 , tv, fv) ,
16821718 ( Self :: U16 ( tv) , Self :: U16 ( fv) ) => select_typed ! ( U16 , tv, fv) ,
16831719 ( Self :: U32 ( tv) , Self :: U32 ( fv) ) => select_typed ! ( U32 , tv, fv) ,
1720+ ( Self :: U64 ( tv) , Self :: U64 ( fv) ) => select_typed ! ( U64 , tv, fv) ,
16841721 ( Self :: I32 ( tv) , Self :: I32 ( fv) ) => select_typed ! ( I32 , tv, fv) ,
16851722 ( Self :: I64 ( tv) , Self :: I64 ( fv) ) => select_typed ! ( I64 , tv, fv) ,
16861723 ( Self :: F16 ( tv) , Self :: F16 ( fv) ) => select_typed ! ( F16 , tv, fv) ,
0 commit comments