Skip to main content

Module dataflow

Module dataflow 

Source
Expand description

Dataflow repeated-pattern mining. Where motifs walks linear single- consumer op chains, this canonicalizes each node’s input cone (the branching sub-DAG that produces it, up to a depth) into a structural signature and counts recurrences. A sub-DAG that recurs across the graph is a unit of repeated computation — a candidate to be decomposed once and shared, or fused into a specialized op. This is the “track the data flow that can be additionally decomposed, especially repeated patterns” seam.

The signature is a merkle hash of the cone: sig(n, d) = the op name of n joined with sig of each operand at depth d-1; at d = 0 or a leaf the cone is truncated to just the op name. Two nodes share a signature iff their depth-d input cones are op-isomorphic. Cheap (memoized), exact for DAGs.

The miner runs on a plain node list (op_name, input_indices) so it works on both an in-memory Graph and a graph dumped from another workspace (see repeated_flow_patterns_on and the opscope-graph bin).

Structs§

FlowPattern
A recurring rooted dataflow pattern.

Functions§

decomposition_hint
A short “how to exploit this repeat” hint for a mined cone.
op_name
A readable op label that keeps the discriminating detail (activation kind, binary op) instead of collapsing everything to Activation/Binary.
repeated_flow_patterns
Convenience over an in-memory Graph. Node ids are dense insertion order, so NodeId.0 doubles as the list index.
repeated_flow_patterns_on
Mine repeated input-cone patterns over a plain node list. ops[i] is node i’s op label, inputs[i] its operand indices. Keeps cones recurring at least min_count times, ranked by payoff; bare leaves are dropped.