-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NDTensors] replace UnitRangeDual with GradedUnitRangeDual #1531
base: main
Are you sure you want to change the base?
Conversation
Overall I still find there are too many kind of For instance, |
For dispatch it is helpful to have special ranges that start at one since that is used as axes by most arrays, like how Base has |
To be more specific, if we write most code in terms of One thing to consider is that dual only really makes sense for graded unit ranges, so maybe we could consider dropping |
I have no strong opinion whether there should be a However I believe dual and not dual axes should be handled on equal footing: deciding who is dual and who is not is a pure convention and they should always appear with a 1:1 ratio for contraction to be possible. If there is some gain in having both |
I realize that with the current design, there are already I will remove |
Sounds good, that's what I was going to suggest (i.e. |
I think this is now ready for |
@ogauthe I realized that one reason to keep That could be helpful since then it could make it easier to create a dual graded unit range out of the blocks of another dual graded unit range (say if you have a dual graded unit range and want to remove one of the blocks, it could make it easier to write that kind of code). |
Indeed slicing a Now, how generic I favor the second as it would make it simpler to use a |
I agree with your assessment that I think it should be valid to make a The question to me more comes down to how and when dual axes get constructed, depending on the unit range type and operation. So to be concrete, if you have a block sparse matrix However, I think it would be surprising and unnecessarily complicated if We may want to define that |
This PR aims to simplify the use of
GradedAxes.dual
, especially to be used in aBlockSparseArray
. It proposes to remove theUnitRangeDual
type:AbstractUnitRange
is now self dualGradedUnitRange
orGradedOneTo
are cast toGradedUnitRangeDual{<:LabelledInteger,<:AbstractGradedUnitRange} <: AbstractGradedUnitRange
This should simplify slicing a
BlockSparseArray
with dual axes and allows to preserve labels or take their dual.This branch is similar to #1529 but is based on main.
Currently, this branche solves:
blocklengths(dual(...))
GradedUnitRange
behavior when slicing:DualGradedUnitRange
Meaning one can create and manipulate
BlockSparseArray
withGradedUnitRange
or its dual (not justBlockedOneTo
). Howeveraxes(a[:,:])
are stillBase.IdentityUnitRange(GradedUnitRangeDual{...})
, which creates other issues.It also adds many tests, including broken ones.