(ctx *WriteContext, value reflect.Value)
| 1456 | type bfloat16SliceSerializer struct{} |
| 1457 | |
| 1458 | func (s bfloat16SliceSerializer) WriteData(ctx *WriteContext, value reflect.Value) { |
| 1459 | // Cast to []bfloat16.BFloat16 |
| 1460 | v := value.Interface().([]bfloat16.BFloat16) |
| 1461 | buf := ctx.Buffer() |
| 1462 | length := len(v) |
| 1463 | size := length * 2 |
| 1464 | buf.WriteLength(size) |
| 1465 | if length > 0 { |
| 1466 | ptr := unsafe.Pointer(&v[0]) |
| 1467 | if isLittleEndian { |
| 1468 | buf.WriteBinary(unsafe.Slice((*byte)(ptr), size)) |
| 1469 | } else { |
| 1470 | for i := 0; i < length; i++ { |
| 1471 | buf.WriteUint16(v[i].Bits()) |
| 1472 | } |
| 1473 | } |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | func (s bfloat16SliceSerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) { |
| 1478 | done := writeSliceRefAndType(ctx, refMode, writeType, value, BFLOAT16_ARRAY) |
no test coverage detected