-
Notifications
You must be signed in to change notification settings - Fork 52
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
Introduce TaggedAbstractTensor #2933
Conversation
This generalizes `AbstractTensor` to the templated struct `AbstractTensorWithInfo<Info>`. Related to #2913.
!build |
This cleans up the additional constructors for TaggedAbstractTensor quite a bit.
TaggedAbstractTensor( | ||
std::initializer_list<AbstractId> domain, | ||
std::initializer_list<std::initializer_list<Tag>> tag_sets) | ||
: AbstractTensorWithInfo<TagSetInfo<Tag>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
: AbstractTensorWithInfo<TagSetInfo<Tag>>( | |
: AbstractTensorWithInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I could get rid of these also but clang complains if I even remove Tag
here. 🤷♂️
std::initializer_list<std::initializer_list<Tag>> tag_sets) | ||
: AbstractTensorWithInfo<TagSetInfo<Tag>>( | ||
domain, | ||
{tag_sets.begin(), tag_sets.end()}) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
{tag_sets.begin(), tag_sets.end()}) {} | |
tag_sets) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually didn't work for me because although there is an unordered_set
ctor for TagSetInfo
, there's no vector<unordered_set<Tag>>
ctor for vector<TagSetInfo>
.
!build |
Fixes test failure in AbstractTensorTest.Reorder caused by operator== returning false although the vector<AbstractId> given exactly matched domain. Previously these were automatically converted to AbstractTensor but I guess this no longer works given the new constructors.
`AbstractTensor` now has many methods and as of #2933 it is subclassed into `TaggedAbstractTensor` which has additional methods. Also, there is no longer just a single vector attribute `domain` but also `info`. Instead of requiring the user to manage those vectors and keep them the same length, instead this PR makes them `protected` and uses the existing accessors to adjust them, as suggested in #2963 (comment).
`AbstractTensor` now has many methods and as of #2933 it is subclassed into `TaggedAbstractTensor` which has additional methods. Also, there is no longer just a single vector attribute `domain` but also `info`. Instead of requiring the user to manage those vectors and keep them the same length, this PR makes them `protected` members of a class and uses the existing accessors to adjust them, as suggested in #2963 (comment).
This generalizes
AbstractTensor
to the templated structAbstractTensorWithInfo<Info>
and introduces a special case subclassTaggedAbstractTensor<Tag>
. This can be used by passing an enum class forTag
, and holds anunordered_set<Tag>
for each dimension. Merging and swizzling unions these sets, and split duplicates the set.Note that a lot of code had to be moved out of the cpp into the header because of templatization. However, there are no changes to the
Dispatch*
classes. TheAbstractTensorWithInfo
methods like split, merge, swizzle, etc. are just changed to add calls toInfo::merge
.Related to #2913, which specializes this as
using AbstractMatmulTensor = TaggedAbstractTensor<MatmulDimRole>
.