File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -426,14 +426,25 @@ func TestBufferBitcast(t *testing.T) {
426426 requireNoError (t , err )
427427 assertEqualSlice (t , []int {2 }, dims )
428428
429+ // Bitcast back to uint8:
430+ bufUint8 , err := bufInt4 .Bitcast (dtypes .Uint8 )
431+ requireNoError (t , err )
432+ dtype , err = bufUint8 .DType ()
433+ requireNoError (t , err )
434+ assertEqual (t , dtypes .Uint8 , dtype )
435+
436+ dims , err = bufUint8 .Dimensions ()
437+ requireNoError (t , err )
438+ assertEqualSlice (t , []int {}, dims )
439+
429440 // To check the data, we use ToHost.
430441 // ToHost for Int4 will return the packed bytes.
431- size , err := bufInt4 .Size ()
442+ size , err := bufUint8 .Size ()
432443 requireNoError (t , err )
433444 assertEqual (t , 1 , size ) // 2 * 4 bits = 8 bits = 1 byte.
434-
435445 data := make ([]byte , 1 )
436- err = bufInt4 .ToHost (data )
446+ err = bufUint8 .ToHost (data )
437447 requireNoError (t , err )
448+ fmt .Printf ("\t - data=[0x%X]\n " , data )
438449 assertEqual (t , val , data [0 ])
439450}
You can’t perform that action at this time.
0 commit comments