toGpu (Function)

Signature: toGpu(source: List<int8> | List<int16> | List<int32> | List<int> | List<uint8> | List<uint16> | List<uint32> | List<float16> | List<float32> | List<float> | List<bool> | Iterator<int8> | Iterator<int16> | Iterator<int32> | Iterator<int> | Iterator<uint8> | Iterator<uint16> | Iterator<uint32> | Iterator<float16> | Iterator<float32> | Iterator<float> | Iterator<bool>) -> Result<GpuBuffer<t0>, Error>

Description: Returns a dense GpuBuffer in Success, or Error with the allocation reason, for a list of numeric scalars at any width or bools. Also consumes an iterator pipeline, replaying its map/filter stages into the buffer with no list in between.

Parameters

  • source (List<int8> | List<int16> | List<int32> | List<int> | List<uint8> | List<uint16> | List<uint32> | List<float16> | List<float32> | List<float> | List<bool> | Iterator<int8> | Iterator<int16> | Iterator<int32> | Iterator<int> | Iterator<uint8> | Iterator<uint16> | Iterator<uint32> | Iterator<float16> | Iterator<float32> | Iterator<float> | Iterator<bool>): The scalar list or iterator to copy into a buffer

Returns: Result<GpuBuffer<t0>, Error>

Example

match toGpu([1, 2, 3, 4]) {
    Success { value } => { let buffer = value
    print(gpuLength(buffer))
    }
    Error { message } => print(message)
}