Draft
Conversation
Merge the two-tier `permute!`/`add_permute!` pattern into a single tier: `permute!`, `braid!`, `transpose!`, and `repartition!` now directly accept optional `α`, `β`, `backend`, and `allocator` arguments with sensible defaults (One(), Zero(), DefaultBackend(), DefaultAllocator()), matching TensorOperations convention. The old `add_permute!`, `add_braid!`, and `add_transpose!` are deprecated wrappers that emit `Base.depwarn` and forward to the new functions. The `allocator` kwarg is fully threaded through the internal call chain (`add_transform!`, all kernel functions, and `allocate_buffers`). Mooncake AD rules are updated to use the new function names. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace single-method-with-variadics (`backend::AbstractBackend...`) with the TensorOperations-style dispatch chain: four separate overloads per in-place function inserting One()/Zero(), DefaultBackend(), and DefaultAllocator() successively so that the full 7-arg form is the implementation endpoint. Move `allocator` from keyword to positional argument throughout the internal chain (`add_transform!`, all kernel functions, `allocate_buffers`). Non-inplace functions (`permute`, `braid`, `transpose`, `repartition`) gain `backend` as a new keyword alongside the existing `allocator` keyword, keeping the user-facing API ergonomic. Docstrings updated to use TO-style bracket notation showing optional arguments. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
After the build completes, the updated documentation will be available here |
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
This PR overhauls the index manipulation API in
src/tensors/indexmanipulations.jlto match TensorOperations dispatch conventions, reduces code duplication in the implementation, and adds a dedicated documentation page.The goal was a bunch of code simplification, (overall number of lines reduced, even though I added some docs 🎉 )
API changes
permute!,braid!,transpose!, andrepartition!now directly acceptα,β,backend, andallocatoras optional arguments (with defaultsOne(),Zero(),DefaultBackend(),DefaultAllocator()), following the TensorOperations dispatch pattern. The oldadd_permute!,add_braid!, andadd_transpose!are deprecated and forward to the new functions.allocatorsupport: previously, the index manipulation functions did not support a customallocatorat all. It is now a positional argument in both the public and internal interfaces, consistent with TensorOperations convention.permute,braid,transpose,repartition) gainbackendas a new keyword argument alongside the now-supportedallocatorkeyword.twist!added: new in-place variant oftwist.Implementation changes
braid!, eliminating duplicate codepaths.braid!method added forAdjointTensorMap.add_transform!kernels forTensorMaprefactored to operate on the raw data vector rather than the fullTensorMap. Because the data vector has a concrete type, this avoids recompilation for everyTensorMaptype combination, improving compilation time.Documentation
docs/src/man/indexmanipulations.mdwith a structured overview categorising operations into: reweighting (flip,twist), space insertion/removal (insertleftunit,insertrightunit,removeunit), and index rearrangements (permute,braid,transpose,repartition).