Hello,
I’m looking at the documentation of the load method for the UnsafePointer, specifically at the second version that provides an offset as argument.
The offset type is SIMD[dtype,1]. I was expecting some sort of integer.
What do I miss?
Hello,
I’m looking at the documentation of the load method for the UnsafePointer, specifically at the second version that provides an offset as argument.
The offset type is SIMD[dtype,1]. I was expecting some sort of integer.
What do I miss?
SIMD[dtype, 1]
is an integer and is equivalent to Scalar[dtype]
, which is in turn equivalent to {UInt32, Int64, Float64, UInt8, Int16...}
etc.
The first line of code in that function is constrained[offset.dtype.is_integral(), “offset must be integer”]()
. We’re waiting on restrict
to make that more ergonomic and clear.
Thanks for help.
In my case the cause of the compilation crash was the fact the I passed the with parameter with without the name. The compiler messages weren’t helpful.
Coming back to the documentation, as you might bellow the identifier dtype is used for the type parameter and it appears in the offset type as well. I would read that for loads of Float32 the offset is also a Float32, which does not make sense.
Hmm. That seems like a bug in our doc generator. The actual signature for the offset
is just Scalar
. The dtype
for this scalar should be inferred, and is separate from the infer-only dtype
parameter in the signature (which relates to the type of the pointer and the type of the returned SIMD.
The doc generator is trying to fill in helpful information here, but in this case it ends up obfuscating rather than helping.