See the following functions. dbl2
works with SIMD inputs, but dbl
does not compile: error: expected a type, not a value
.
How can I implement this generic dbl without using SIMD types?
fn dbl[T: DType](x: T) -> T:
return 2*x
fn dbl2[T: DType](x: Scalar[T]) -> Scalar[T]:
return 2*x
fn main():
var x = 4
var y = dbl(x)
print(y)
var x2 = SIMD[DType.float32, 1](4)
var y2 = dbl2(x2)
print(y2)