[Routines] Introduce HostExecutor backend#329
Merged
shivasankarka merged 469 commits intoMar 4, 2026
Merged
Conversation
until we implement views for NDArray.
and original instances.
iterator returns mutable views.
clauses (for methods) and `comptime assert` (for init)
merging upstream changes
forfudan
approved these changes
Mar 3, 2026
forfudan
left a comment
Collaborator
There was a problem hiding this comment.
@shivasankarka, thanks! I did some fixes:
- Add treatment of 0d array in
apply_unary() - The shape check is before 0d check in
apply_binary(), which may cause mismatches. It is re-ordered. apply_binary_predicate(array, scalar)usessimd_width_of[DType.bool](), seemingly mismatches with thedtype. It is changed tosimd_width_of[dtype]().- Iport operations
Collaborator
Author
|
@forfudan Thanks. Regarding 3) shouldn't it be The width of bool type. Because if not, we are writing onto a Boolean pointer with int/float wide SIMD vectors which may be incorrect/inefficient. I'm not sure how it works under the hood. |
Collaborator
@shivasankarka you are absolutely right! I got it wrong. Please revert this change. |
shivasankarka
merged commit Mar 4, 2026
c6715aa
into
Mojo-Numerics-and-Algorithms-group:pre-0.9
2 checks passed
forfudan
added a commit
that referenced
this pull request
Mar 31, 2026
This PR adds support for `HostExecutor` (name subject to change) implemented in `routines/operations/backend.mojo` following #328 . This struct contains the following methods, - `apply_unary` - takes one argument as input (SIMD, NDArray) - `apply_binary` - takes two arguments as input (any combination of SIMD, NDArray) - `apply_unary_predicate` - takes one argument (SIMD, NDArray) and returns some boolean value (SIMD[DType.boo], NDArray[DType.bool]) - `apply_binary_predicate` - takes two arguments and returns some boolean value (SIMD[DType.bool], NDArray[DType.bool]) All the operations are vectorized. --------- Co-authored-by: ZHU Yuhao <dr.yuhao.zhu@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for
HostExecutor(name subject to change) implemented inroutines/operations/backend.mojofollowing #328 . This struct contains the following methods,apply_unary- takes one argument as input (SIMD, NDArray)apply_binary- takes two arguments as input (any combination of SIMD, NDArray)apply_unary_predicate- takes one argument (SIMD, NDArray) and returns some boolean value (SIMD[DType.boo], NDArray[DType.bool])apply_binary_predicate- takes two arguments and returns some boolean value (SIMD[DType.bool], NDArray[DType.bool])All the operations are vectorized.