M
Modular11mo ago
benny

Memset

From the docs -
memset memset[type: DType, address_space: AddressSpace](ptr: DTypePointer[type, address_space], value: SIMD[ui8, 1], count: Int) Fills memory with the given value. Parameters: ​type (DType): The element dtype. ​address_space (AddressSpace): The address space of the pointer. Args: ​ptr (DTypePointer[type, address_space]): Pointer to the beginning of the memory block to fill. ​value (SIMD[ui8, 1]): The value to fill with. ​count (Int): Number of elements to fill (in elements, not bytes).
Shouldn't the type of value be of type rather than SIMD[ui8, 1]? For example
let a = DTypePointer[DType.float32].alloc(10)
memset[DType.float32](a, 1.0, 10)
let a = DTypePointer[DType.float32].alloc(10)
memset[DType.float32](a, 1.0, 10)
The above code gives an error since 1.0 cannot be converted to ui8
1 Reply
sora
sora11mo ago
I think memset is probably too low level to support this. That said, I agree we could have a function/method to fill simd values.
Want results from more Discord servers?
Add your server