[WIP] Broadcast and Merge library nodes, reachable from NumPy - #2515
Draft
ThrudPrimrose wants to merge 1 commit into
Draft
[WIP] Broadcast and Merge library nodes, reachable from NumPy#2515ThrudPrimrose wants to merge 1 commit into
ThrudPrimrose wants to merge 1 commit into
Conversation
Broadcast covers Fortran SPREAD (integer dim, insert one axis) and, with dim=None, the right-aligned NumPy rule; Merge is the per-element select -- Fortran MERGE(t, f, mask), np.where(mask, t, f), an element-wise if-then-else -- with every operand broadcast against the result by that same rule. numpy.where hands the node the case it expresses exactly (three arrays, no cast, a condition that broadcasts into the result rather than widening it) and keeps the inlined tasklet otherwise; numpy.broadcast_to is new, and materializes a transient because NumPy's zero-stride view would make every write to the result alias.
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.
Adds two standard library nodes --
Broadcast(FortranSPREADwith an integerdim, the right-aligned NumPy rule withdim=None) andMergeLibraryNode(the per-element select: FortranMERGE,np.where, element-wise if-then-else) -- both describing every operand by the same broadcasting rule instead of a special case.numpy.wherehands the node the case it expresses exactly (three arrays, no cast, a condition that broadcasts into the result) and keeps the inlined tasklet otherwise, andnumpy.broadcast_tois new.