Allow local constants #74
Replies: 6 comments 7 replies
-
Do I understand correctly that the questions wrt. a new "locality" are only, what do we require in terms of locality to enable local constants? The main issue I see here is that this makes locality depend upon node type, and asymmetrically at that. Previously localities had no concern with the node type, nor port type (ports did not specify a locality). However, the proposed "const locality" makes new kinds of requirement on the source (namely, that they be a const node) - whereas the target will be a value port of unspecified locality. Another way of looking at this might be that the target port, if the incoming edge is of "const locality", now has to do extra work (loading the constant from the constant pool into memory, say - rather than it already being in a register). |
Beta Was this translation helpful? Give feedback.
-
Currently we use A somewhat extreme simplification is to say |
Beta Was this translation helpful? Give feedback.
-
I guess we can also rename |
Beta Was this translation helpful? Give feedback.
-
In the spec currently we state the |
Beta Was this translation helpful? Give feedback.
-
Partially implemented in #112. The builder now allows adding constants at any level. This required a horrible hack to "NotADag" validation to add logic for "when top sorting through nodes, if node is a LoadConstant connected to a Const with the same parent, count it as two nodes instead of 1". When defs are also made local this will require the same special casing. |
Beta Was this translation helpful? Give feedback.
-
Now implemented with the special casing described above. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@aborgna-q
27 April 2023
We need a separate category of inter-graph edges for const wires, from a const value node to a load operation.
@ss2165
27 April 2023
Do we? Or do we just say “inter-graph edges can have Value or Const kind”?
@aborgna-q
27 April 2023
Inter-graph const edges don’t work with the requirements of external nor dominator edges.
They don’t really have any special requirement since the source node is always in the top-level module and completely disjoint from the constant load node.
@ss2165
27 April 2023
I’m not sure we want to enforce that const nodes are always at the top level
@aborgna-q
28 April 2023
Uhm. Where else should they be allowed to be? I think currently they can only be children of the single root module?
@ss2165
28 April 2023
I’m suggesting that const and def/declare are allowed to be in any dataflow context and obey the same locality rules as Value (Ext or Dom)
This allows these definitions to be scoped rather than accessible from anywhere in the HUGR
@aborgna-q
2 May 2023
That sounds nice, but I don’t think the def/declare nodes should need to care about state ordering.
The validation should be a bit more lax than the Dom/Ext edges, requiring a common parent but no special ordering between siblings.
Btw, can we define mutually recursive operations?
@ss2165
2 May 2023
yes, mutual recursion should be possible
@acl-cqc
3 May 2023
I think “Ext” edges work if the constants are module-level; they require that the parent of the source is an ancestor of the target. The source is a constant, so its parent is the module root, which is ancestor of anything? This probably is the right constraint for more local constants too but I am not yet convinced about those.
@acl-cqc
16 May 2023
I’ve changed this so that it says it applies to value edges only. That is, this section says nothing about ConstE edges. I think the section introducing ConstE edges says enough about them, but maybe we need more (somewhere)? Otherwise, can we resolve this comment now?
@cqc-alec
16 May 2023
So ConstE intergraph edges wouldn’t require the Order edge, is that right?
👍
1
@acl-cqc
16 May 2023
Indeed.
Beta Was this translation helpful? Give feedback.
All reactions