//
// Output, a CASK IR shader for gemm and all nodes starting from tgt
// connected by fusible arrows, or a null shader if this fusion is
// not supported.
//
Shader *construct(fdag_arrow_t *arrow) {
src, tgt = arrow
// Collect all nodes reachable by fusible nodes from tgt
// inputs are the source nodes of arrows (A, B) where A is not in
// nodes, and B is in nodes.
// Similarly, outputs are the target nodes of arrows (A, B) where A
// is in nodes and B is not in nodes.
nodes, outputs, inputs = all_fused_nodes(tgt)
// Tracking CASK tensors produced by nodes
shader_data = {}
// Codegen starting from outputs. This recursively traverses
// producers and the recursion is bounded by the input nodes.
for node in outputs
visit(node, shader_data, inputs)
// construct the final CASK shader from input and output tensors.
shader = makeShader(shader_data)
return shader;
}