You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HugrInternals::base_hugr returns the root Hugr used to implement a hugr view.
In practice, this call is used in a handful of cases:
To access the metadata/optype for a single node.
To access the ExtensionRegistry.
To access the Hierarchy that linked to the HugrInternals::portgraph
To run full-graph validation
To render mermaid/dot of the full base graph
In SiblingGraph, to avoid nesting views when creating one from a generic HugrView.
This works fine for our current definitions, but non-trivial wrappers like the one discussed in CQCL/tket2#778 are not necessarily based on a single base Hugr.
All but the last point I listed can be implemented as individual methods on HugrInternals instead,
metadata(&self, Node) -> Option<NodeMetadataMap>
optype(&self, None) -> Option<OpType>
extension_registry(&self) -> ExtensionRegistry
hierarchy would return a Cow<'_, Hierarchy> so we can either return a reference to the internally stored one, or compute one on-the-fly (for the CircuitHistory usecase).
Rendering should use the existing portgraph directly.
SiblingGraph shouldn't need to do the unwrapping. For non-dyn types all the calls through wrapping layers will hopefully be inlined and optimized away (we should benchmark this).
One drawback to keep in mind is that we no longer get the generic "escape hatch" that lets us recover the outer hugr from a filtered view. This means for example that focusing on a region will hide away non-local nodes outside the parent's hierarchy. I'd argue that those cases should use region-pointers instead. See #1642#1554.
The text was updated successfully, but these errors were encountered:
HugrInternals::base_hugr
returns the rootHugr
used to implement a hugr view.In practice, this call is used in a handful of cases:
ExtensionRegistry
.Hierarchy
that linked to theHugrInternals::portgraph
SiblingGraph
, to avoid nesting views when creating one from a genericHugrView
.This works fine for our current definitions, but non-trivial wrappers like the one discussed in CQCL/tket2#778 are not necessarily based on a single base
Hugr
.All but the last point I listed can be implemented as individual methods on
HugrInternals
instead,metadata(&self, Node) -> Option<NodeMetadataMap>
optype(&self, None) -> Option<OpType>
extension_registry(&self) -> ExtensionRegistry
hierarchy
would return aCow<'_, Hierarchy>
so we can either return a reference to the internally stored one, or compute one on-the-fly (for the CircuitHistory usecase).portgraph
directly.SiblingGraph
shouldn't need to do the unwrapping. For non-dyn types all the calls through wrapping layers will hopefully be inlined and optimized away (we should benchmark this).One drawback to keep in mind is that we no longer get the generic "escape hatch" that lets us recover the outer hugr from a filtered view. This means for example that focusing on a region will hide away non-local nodes outside the parent's hierarchy. I'd argue that those cases should use region-pointers instead. See #1642 #1554.
The text was updated successfully, but these errors were encountered: