You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read the roadmap and priorities and I believe this request falls within the priorities.
What is your request?
@staticmethodfnfrom_range[start: Int, end: Int, step: Int = 1]() -> Self:
"""Construct from a compile time range using the index as value. Parameters: start: The start of the range. end: The end of the range. step: The step of the range. Constraints: The range must be equal to or less than SIMD size. Examples: ```mojoprint(SIMD[DType.uint8, 4].from_range[0, 4]()) # [0, 1, 2, 3]print(SIMD[DType.uint8, 4].from_range[3, -1, -1]()) # [3, 2, 1, 0] ``` ."""
constrained[
abs((start - end) // step) <= size,
"The range must be equal to or less than SIMD size.",
]()
varvec= Self()
varidx=0@parameterfor i inrange(start, end, step):
vec[idx] = i
idx =1return vec
To be able to implement a SIMD.index() function, it would be needed to be able to contruct a range for the SIMD vec
for example if a generic version for SIMD.index() is wanted:
martinvuyk
changed the title
[Feature Request] [stdlib] Add comp time SIMD range constructor
[Feature Request] [stdlib] [proposal] Add comp time SIMD range constructor
Jun 24, 2024
Review Mojo's priorities
What is your request?
test:
What is your motivation for this change?
To be able to implement a
SIMD.index()
function, it would be needed to be able to contruct a range for the SIMD vecfor example if a generic version for
SIMD.index()
is wanted:To be able to construct a reversed function for example shuffle could take in a compile time range
or using the range constructor
Any other details?
No response
The text was updated successfully, but these errors were encountered: