Repository navigation
Support Nx.stack on Ortex tensors - #57
Open
reidmorrison wants to merge 2 commits into
Open
reidmorrison wants to merge 2 commits into
reidmorrison wants to merge 2 commits into
Conversation
Since Nx 0.8, Nx.stack/2 calls the backend's stack/3 instead of using new_axis plus concatenate, so stacking Ortex tensors on Nx 0.8 and later (including 1.0) raised "operation stack is not yet supported on Ortex.Backend". Implement it the way Nx did before: give each tensor the new axis with the backend's reshape, then join them with its concatenate.
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.
Since Nx 0.8,
Nx.stack/2calls the backend'sstack/3instead of usingnew_axisplusconcatenate, so on Nx 0.8 and later (including 1.0) stacking Ortex tensors raisesoperation stack is not yet supported on Ortex.Backend.This implements
stack/3the way Nx used to do it: each tensor gets the new axis through the backend'sreshape, then they're joined with the existingconcatenate. Tests are intest/shape/stack_test.exs. Becausestack/3isn't a callback on Nx 0.6 (the version inmix.lock),@implis derived fromNx.Backend.behaviour_info/1; a plain@impl truefails--warnings-as-errorsthere, which the first CI run caught.On Nx 1.0.0 the new tests fail without the change and pass with it, and the full suite passes with
--warnings-as-errorson both Nx 0.6.2 and 1.0.0. CI currently runs Nx 0.6.2, whereNx.stackdoesn't reach this code, so the newer-Nx CI job from #56 is what covers it in CI.Code Review. No findings.