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

Rethink live-queried attribute context in context-aware dialect conversion #1672

Open
j2kun opened this issue Apr 5, 2025 · 0 comments
Open

Comments

@j2kun
Copy link
Collaborator

j2kun commented Apr 5, 2025

I'm running into some small hiccups in #1633 with regards to context-aware dialect conversion and this issue is to record my idea for how to improve it.

Problem 1: each conversion pattern must persist layout information on the last op it creates, since that attribute is used by the framework for later type conversion. If a pattern also needs that layout for its implementation, then the type of the adatpor operand and the attribute associated with that operand will disagree (e.g., a materialized rank-1 type with a layout that assumes a rank-2 input tensor).

Problem 2: I am forced to remap values in the conversion framework because the original values may have lost their parent op (e.g., if it's a block argument, the parent op can be detached from its block, and hence you can't do the attribute lookup if it's an argattr of the func or an operandattr of a secret.generic). So I can't just have a conversion pattern implementer understand to use the attr lookup on the op.operand for the layout and data semantic type, while using the adaptor.operand for the ciphertext semantic type. This lack of a block also prevents me from using the original operand for type conversion.

Idea: instead of having the type conversion step use attributes at runtime, have it parse the attributes into a DenseMap (say, at construction time) and then use that DenseMap for lookups. Since there's no IR traversal, you can still have the (disconnected) SSA values as map keys (fixes problem 2), and so you don't need to remap values to enable type conversion. Second, since the layout information is now accessed via the op operand (not the adaptor operand), you don't need to persist the layouts on ops created by a kernel (fixing problem 1).

So basically, the initial attribute context will be frozen at the pass start time, and queried for both type conversion and kernel implementation via an op's original SSA values.

@j2kun j2kun changed the title Rethink attribute-based context in context-aware dialect conversion Rethink live-queried attribute context in context-aware dialect conversion Apr 5, 2025
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

No branches or pull requests

1 participant