Loosen generic tensor operations to accept non-array operands#195
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #195 +/- ##
==========================================
- Coverage 83.38% 83.38% -0.01%
==========================================
Files 22 22
Lines 650 656 +6
==========================================
+ Hits 542 547 +5
- Misses 108 109 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2fe138c to
0446bc9
Compare
Loosens the generic tensor operations (contraction, factorizations, matrix functions, permuted-add) to accept operands that are not `AbstractArray`s, so a backend can flow its own tensor type through the generic orchestration by overloading a small set of hooks rather than subtyping `AbstractArray`. The supporting refactors: - `matricize`/`unmatricize` split into permuting and non-permuting forms by name: the permuting forms are `matricizeperm`/`unmatricizeperm`/`unmatricizeperm!` (and `matricizeop` becomes `matricizeopperm`), while `unmatricize` is again the split-axes primitive `unmatricize(m, codomain_axes, domain_axes)`. Distinguishing the two resolves the method ambiguities that had forced the flattened signature and restores the split-axes call. - Output allocation goes through the bipartitioned `similar_map` hook instead of a flat `similar`, so a map-shaped backend can build its codomain and domain directly. - A private `PermutedDims` lazy-permutation wrapper mirrors `PermutedDimsArray` for non-array operands, letting a downstream `permuteddims` hand a lazily-permuted operand to `bipermutedimsopadd!`. The public `matricizeop` to `matricizeopperm` rename is breaking. The TensorKit backend that exercises these hooks lands in a follow-up PR.
0446bc9 to
afe0300
Compare
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.
Summary
Loosens the generic tensor operations (contraction, factorizations, matrix functions, permuted-add) to accept operands that are not
AbstractArrays, so a backend can flow its own tensor type through the generic orchestration by overloading a small set of hooks rather than subtypingAbstractArray.The supporting refactors:
matricize/unmatricizesplit into permuting and non-permuting forms by name: the permuting forms arematricizeperm/unmatricizeperm/unmatricizeperm!(andmatricizeopbecomesmatricizeopperm), whileunmatricizeis again the split-axes primitiveunmatricize(m, codomain_axes, domain_axes). Distinguishing the two resolves the method ambiguities that had forced the flattened signature and restores the split-axes call.similar_maphook instead of a flatsimilar, so a map-shaped backend can build its codomain and domain directly.PermutedDimslazy-permutation wrapper mirrorsPermutedDimsArrayfor non-array operands, letting a downstreampermuteddimshand a lazily-permuted operand tobipermutedimsopadd!.The public
matricizeoptomatricizeoppermrename is breaking. The TensorKit backend that exercises these hooks lands in a follow-up PR.