Traits with compile-time SIMD size
I can't seem to fulfill a trait that can return different length SIMDs
I can fall back to
trait PRNGEngine(Movable):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
pass
fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
pass
fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
pass
struct DummyEngine[n: Int](PRNGEngine):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
return 2
fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
return 42
fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
var res: SIMD[DType.uint64, Self.ndim()] = 42
return restrait PRNGEngine(Movable):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
pass
fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
pass
fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
pass
struct DummyEngine[n: Int](PRNGEngine):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
return 2
fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
return 42
fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
var res: SIMD[DType.uint64, Self.ndim()] = 42
return resI can fall back to
next_scalarnext_scalar. I'd like to be able to use nextnext e.g. to generate a set of normal deviates, etc.