github.com/wzzhu/tensor@v0.9.24/internal/storage/getset.go (about) 1 // Code generated by genlib2. DO NOT EDIT. 2 3 package storage 4 5 import "unsafe" 6 7 /* bool */ 8 9 func (h *Header) Bools() []bool { 10 return (*(*[]bool)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(bType):h.TypedLen(bType)] 11 } 12 func (h *Header) SetB(i int, x bool) { h.Bools()[i] = x } 13 func (h *Header) GetB(i int) bool { return h.Bools()[i] } 14 15 /* int */ 16 17 func (h *Header) Ints() []int { 18 return (*(*[]int)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(iType):h.TypedLen(iType)] 19 } 20 func (h *Header) SetI(i int, x int) { h.Ints()[i] = x } 21 func (h *Header) GetI(i int) int { return h.Ints()[i] } 22 23 /* int8 */ 24 25 func (h *Header) Int8s() []int8 { 26 return (*(*[]int8)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(i8Type):h.TypedLen(i8Type)] 27 } 28 func (h *Header) SetI8(i int, x int8) { h.Int8s()[i] = x } 29 func (h *Header) GetI8(i int) int8 { return h.Int8s()[i] } 30 31 /* int16 */ 32 33 func (h *Header) Int16s() []int16 { 34 return (*(*[]int16)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(i16Type):h.TypedLen(i16Type)] 35 } 36 func (h *Header) SetI16(i int, x int16) { h.Int16s()[i] = x } 37 func (h *Header) GetI16(i int) int16 { return h.Int16s()[i] } 38 39 /* int32 */ 40 41 func (h *Header) Int32s() []int32 { 42 return (*(*[]int32)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(i32Type):h.TypedLen(i32Type)] 43 } 44 func (h *Header) SetI32(i int, x int32) { h.Int32s()[i] = x } 45 func (h *Header) GetI32(i int) int32 { return h.Int32s()[i] } 46 47 /* int64 */ 48 49 func (h *Header) Int64s() []int64 { 50 return (*(*[]int64)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(i64Type):h.TypedLen(i64Type)] 51 } 52 func (h *Header) SetI64(i int, x int64) { h.Int64s()[i] = x } 53 func (h *Header) GetI64(i int) int64 { return h.Int64s()[i] } 54 55 /* uint */ 56 57 func (h *Header) Uints() []uint { 58 return (*(*[]uint)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(uType):h.TypedLen(uType)] 59 } 60 func (h *Header) SetU(i int, x uint) { h.Uints()[i] = x } 61 func (h *Header) GetU(i int) uint { return h.Uints()[i] } 62 63 /* uint8 */ 64 65 func (h *Header) Uint8s() []uint8 { 66 return (*(*[]uint8)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(u8Type):h.TypedLen(u8Type)] 67 } 68 func (h *Header) SetU8(i int, x uint8) { h.Uint8s()[i] = x } 69 func (h *Header) GetU8(i int) uint8 { return h.Uint8s()[i] } 70 71 /* uint16 */ 72 73 func (h *Header) Uint16s() []uint16 { 74 return (*(*[]uint16)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(u16Type):h.TypedLen(u16Type)] 75 } 76 func (h *Header) SetU16(i int, x uint16) { h.Uint16s()[i] = x } 77 func (h *Header) GetU16(i int) uint16 { return h.Uint16s()[i] } 78 79 /* uint32 */ 80 81 func (h *Header) Uint32s() []uint32 { 82 return (*(*[]uint32)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(u32Type):h.TypedLen(u32Type)] 83 } 84 func (h *Header) SetU32(i int, x uint32) { h.Uint32s()[i] = x } 85 func (h *Header) GetU32(i int) uint32 { return h.Uint32s()[i] } 86 87 /* uint64 */ 88 89 func (h *Header) Uint64s() []uint64 { 90 return (*(*[]uint64)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(u64Type):h.TypedLen(u64Type)] 91 } 92 func (h *Header) SetU64(i int, x uint64) { h.Uint64s()[i] = x } 93 func (h *Header) GetU64(i int) uint64 { return h.Uint64s()[i] } 94 95 /* uintptr */ 96 97 func (h *Header) Uintptrs() []uintptr { 98 return (*(*[]uintptr)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(uintptrType):h.TypedLen(uintptrType)] 99 } 100 func (h *Header) SetUintptr(i int, x uintptr) { h.Uintptrs()[i] = x } 101 func (h *Header) GetUintptr(i int) uintptr { return h.Uintptrs()[i] } 102 103 /* float32 */ 104 105 func (h *Header) Float32s() []float32 { 106 return (*(*[]float32)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(f32Type):h.TypedLen(f32Type)] 107 } 108 func (h *Header) SetF32(i int, x float32) { h.Float32s()[i] = x } 109 func (h *Header) GetF32(i int) float32 { return h.Float32s()[i] } 110 111 /* float64 */ 112 113 func (h *Header) Float64s() []float64 { 114 return (*(*[]float64)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(f64Type):h.TypedLen(f64Type)] 115 } 116 func (h *Header) SetF64(i int, x float64) { h.Float64s()[i] = x } 117 func (h *Header) GetF64(i int) float64 { return h.Float64s()[i] } 118 119 /* complex64 */ 120 121 func (h *Header) Complex64s() []complex64 { 122 return (*(*[]complex64)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(c64Type):h.TypedLen(c64Type)] 123 } 124 func (h *Header) SetC64(i int, x complex64) { h.Complex64s()[i] = x } 125 func (h *Header) GetC64(i int) complex64 { return h.Complex64s()[i] } 126 127 /* complex128 */ 128 129 func (h *Header) Complex128s() []complex128 { 130 return (*(*[]complex128)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(c128Type):h.TypedLen(c128Type)] 131 } 132 func (h *Header) SetC128(i int, x complex128) { h.Complex128s()[i] = x } 133 func (h *Header) GetC128(i int) complex128 { return h.Complex128s()[i] } 134 135 /* string */ 136 137 func (h *Header) Strings() []string { 138 return (*(*[]string)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(strType):h.TypedLen(strType)] 139 } 140 func (h *Header) SetStr(i int, x string) { h.Strings()[i] = x } 141 func (h *Header) GetStr(i int) string { return h.Strings()[i] } 142 143 /* unsafe.Pointer */ 144 145 func (h *Header) UnsafePointers() []unsafe.Pointer { 146 return (*(*[]unsafe.Pointer)(unsafe.Pointer(&h.Raw)))[:h.TypedLen(unsafePointerType):h.TypedLen(unsafePointerType)] 147 } 148 func (h *Header) SetUnsafePointer(i int, x unsafe.Pointer) { h.UnsafePointers()[i] = x } 149 func (h *Header) GetUnsafePointer(i int) unsafe.Pointer { return h.UnsafePointers()[i] }