Skip to content
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

[WIP] change dense attr representation to bytes #3531

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jorendumoulin
Copy link
Collaborator

No description provided.

Comment on lines +1739 to +1741
if isinstance(element_type, IndexType):
# store IndexType as long long in bytes object
format_str = "{}q"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to remove support for Index before this PR, as the size of index is a function of the target, not the host computer.

| RankedStructure[AnyFloat]
]
data: ParameterDef[ArrayAttr[AnyIntegerAttr] | ArrayAttr[AnyFloatAttr]]
type: ParameterDef[RankedStructure[IntegerType | IndexType | AnyFloat]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be an independent change?

elif isinstance(element_type, IntegerType):
if element_type.size == 1:
# 1 byte signed char
format_str = "{}b"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be great to share code with the ptr.py file, if possible, potentially moving shared utilities to a third location.

]
data: ParameterDef[ArrayAttr[AnyIntegerAttr] | ArrayAttr[AnyFloatAttr]]
type: ParameterDef[RankedStructure[IntegerType | IndexType | AnyFloat]]
data: ParameterDef[BytesAttr]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend first migrating all users of this property to another property/getter that returns a sequence of AnyIntegerAttr or a sequence of AnyFloatAttr, to minimise the diff in other files (probably also a property/getter that returns a sequence of ints or a sequence of floats)

| RankedStructure[IndexType]
| RankedStructure[AnyFloat]
]
data: ParameterDef[ArrayAttr[AnyIntegerAttr] | ArrayAttr[AnyFloatAttr]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to migrate ArrayAttr to be bytes-based instead of DenseIntOrFPElementsAttr, BTW?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure of this BTW, but would be good to play with it and maybe chat about findings. It would be nice to have some sort of generic way to have a dense array of things, but maybe that should just be this class, and array should be left alone to explicitly be a tuple of attributes and nothing more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it would be better to keep them separate. ArrayAttr will always hold a new Attribute object for every one of its elements, and converting those to a dense array is not trivial (for example, ArrayAttr of AffineMapAttrs)

@jorendumoulin
Copy link
Collaborator Author

thank you for the comments! I'll first do some more incremental PRs before making the switch to bytes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants