Do we enforce linearity of static edges (if linear-typed)? #368
Replies: 5 comments 2 replies
-
I think the simplest thing one might say is - if we have multiple static outputs from a Constant then each No, even then you declare a constant in a loop, and copying abounds. |
Beta Was this translation helpful? Give feedback.
-
So, if loading a constant is copying it, constants have to be copyable. If you want something like |
Beta Was this translation helpful? Give feedback.
-
How about: HUGR linearity (:= one connection from port) is defined only on Value ports, not Static. Loading static data from the program in to the runtime is always a copy (I can't picture a system where this isn't the case tbh, unless what you're actually enforcing linearity on is references to static constants). |
Beta Was this translation helpful? Give feedback.
-
In which case shouldn't the type say it's copyable?
If we mean, mutable references - the scary case here is that one invocation of a function could mutate that data, and then a second invocation....would see the mutation from the first??
|
Beta Was this translation helpful? Give feedback.
-
Resolving: |
Beta Was this translation helpful? Give feedback.
-
We decided that Constants should be able to be of linear type - for example, a really big structure, where linearity enables in-place mutation.
So,
load_constant
produces a value edge that may have linear type, and if so, we can't copy that, we can't send that value down an inter-graph edge, etc. Fine.But what about the static edge from the
Constant
to theload_constant
node? How many of those can I have?load_constant
is (as expected) copying that data out of the constant pool; if we can do that once, we can do it many times; the fact that memory constraints mean only one such constant is alive at a time is a different kind of problem (memory allocation, liveness, etc.) that we cannot solve with edges and should not look to (e.g. you couldload_constant
a "linear" constant in each iteration of a loop and append it to a list!). Note that a single inter-graph edge raises the same problems as many local edges.Neither of these options make much sense to me and I am wary of allowing load-constant in this way. I think the "non-copyable" values might have to be produced by runtime operations - an example might be "open network connection"...
Beta Was this translation helpful? Give feedback.
All reactions