fhelium.experimental.jit.passes.visualize_svg
Render a selected JIT Program entry as an SSA/dataflow SVG.
SvgGraphDirection
type alias View source
SvgGraphDirection = Literal['TB', 'BT', 'LR', 'RL']SvgGraphField
type alias View source
SvgGraphField = Literal['name', 'opcode', 'role', 'operands', 'result_types', 'attributes', 'scheduling_obligations', 'num_users']SvgGraphPresentation
class View source
SvgGraphPresentation(*, fields: Collection[SvgGraphField] | None=None, attribute_names: Collection[str] | None=None, attribute_preview_chars: int | None=180, theme: SvgGraphTheme | None=None)Select and format operation evidence for an SVG graph.
The presentation is independent of graph traversal and file production. Subclasses can override select_attributes for filtering, format_attribute_value for one-value display policy, operation_sections for complete operation-row transformation, or operation_tooltip for aggregate hover evidence. These methods must not mutate their operation, Program, or Workspace.
select_attributes
method
def select_attributes(operation: Operation) -> tuple[tuple[str, Attribute], ...]: ...Return sorted non-internal attributes selected for operation.
format_attribute_value
method
def format_attribute_value(operation: Operation, name: str, attribute: Attribute) -> str: ...Format one selected attribute for its bounded record preview.
operation_sections
method
def operation_sections(context: SvgOperationContext) -> tuple[SvgNodeSection, ...]: ...Return all displayed record rows for one operation.
Override this complete-row hook to reorder, rename, remove, or inject derived sections while reusing super().operation_sections(context).
operation_tooltip
method
def operation_tooltip(context: SvgOperationContext, sections: Collection[SvgNodeSection]) -> str | None: ...Return one aggregate node tooltip from already-rendered sections.
SvgGraphTheme
class View source
SvgGraphTheme(*, operation_palette: Collection[str] | None=None, operation_colors: Mapping[str, str] | None=None, operation_color_key: Callable[[SvgOperationContext], str] | None=None, canvas_color: str='transparent', input_fill_color: str='#DCE4FF', output_fill_color: str='#F3D89D', node_font_color: str='#181B26', node_stroke_color: str='#596178', edge_color: str='#7B8193')Define colors and operation color classification for an SVG graph.
An operation first receives a key from operation_color_key. An exact operation_colors entry wins; otherwise the key is deterministically mapped into operation_palette. The hash implementation is private, but equal keys under one theme always receive equal colors. None selects the FHElium default palette or color-key function. operation_colors=None retains the default constant color, while an empty mapping removes it. Theme configuration is read-only and deliberately unhashable because a caller-supplied color-key callable does not define a general cache identity.
Attributes
| Name | Type | Default/value |
|---|---|---|
operation_palette | tuple[str, ...] | |
operation_colors | Mapping[str, str] | |
operation_color_key | Callable[[SvgOperationContext], str] | |
canvas_color | str | |
input_fill_color | str | |
output_fill_color | str | |
node_font_color | str | |
node_stroke_color | str | |
edge_color | str |
operation_fill_color
method
def operation_fill_color(context: SvgOperationContext) -> str: ...Return the configured explicit or stable palette color.
SvgGraphVisualizationPass
class View source
SvgGraphVisualizationPass(output_path: str | PathLike[str], *, overwrite: bool=False, entry: str='main', presentation: SvgGraphPresentation | None=None, rank_direction: SvgGraphDirection='TB', name: str='visualize-svg')Write one selected entry's SSA/dataflow graph to an SVG file.
The pass owns entry traversal, stable SSA naming, dependency edges, Graphviz construction, overwrite policy, and SVG production. A composed SvgGraphPresentation owns operation rows, tooltips, color classification, and theme values. Rendering returns the Program unchanged and does not establish execution readiness or numerical correctness.
Parameters
output_path: Exact.svgfile to write.overwrite: Replace an existing output file when true.entry: Unique single-block function entry to render.presentation: Operation evidence and theme policy.Noneconstructs the default presentation.rank_direction: Graphviz rank direction: top-to-bottom, bottom-to-top, left-to-right, or right-to-left.name: Diagnostic pass name.
Attributes
| Name | Type | Default/value |
|---|---|---|
output_path | Path | |
presentation | SvgGraphPresentation | |
overwrite | bool | False |
entry | str | 'main' |
rank_direction | SvgGraphDirection | 'TB' |
name | str | 'visualize-svg' |
run
method
def run(program: Program, workspace: MutableMapping[Any, Any]) -> PassResult: ...Render one entry function and return an unchanged pass result.
SvgNodeSection
class View source
SvgNodeSection(name: str, value: str, tooltip: str | None = None)Represent one labeled record row inside an SVG operation node.
value participates in Graphviz layout. tooltip optionally retains complete or alternate evidence for the containing node's aggregate hover text; Graphviz does not attach a separate tooltip to each record cell.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | |
value | str | |
tooltip | str | None | None |
SvgOperationContext
class View source
SvgOperationContext(operation: Operation, result_names: tuple[str, ...], operand_names: tuple[str, ...])Provide stable operation evidence to an SVG presentation policy.
Attributes
| Name | Type | Default/value |
|---|---|---|
operation | Operation | |
result_names | tuple[str, ...] | |
operand_names | tuple[str, ...] |
opcode
property
opcode: strReturn the exact registered or dynamic operation name.
default_svg_operation_color_key
function View source
def default_svg_operation_color_key(context: SvgOperationContext) -> str: ...Return the default stable operation color key.
Exact operation names define ordinary keys. Preserved torch.call operations additionally include call kind and target so custom classifiers can delegate without reproducing that rule.