What is Computational graph?
A representation of a model's computation with operations as nodes and tensor flows as edges, underpinning automatic differentiation and AI compiler optimization.
Japanese name: 計算グラフ
A representation of a model's computation with operations as nodes and tensor flows as edges, underpinning automatic differentiation and AI compiler optimization.
Japanese name: 計算グラフ
A computational graph is usually a directed acyclic graph. Nodes are operations such as matrix multiplication, convolution, addition or an activation function; edges are tensors, each with a known shape and data type, flowing from the operation that produces them to the ones that consume them. Inputs and trainable weights appear as source nodes. Because dependencies are explicit, the graph shows at a glance which operations can run in parallel and which must wait, and it gives software a complete, analyzable description of the model independent of the Python code that created it.
Training needs the gradient of the loss with respect to every weight. During the forward pass a framework records the graph; reverse-mode automatic differentiation then walks it backward from the loss, applying each operation's local derivative rule and the chain rule to accumulate gradients, which is backpropagation. This requires the intermediate outputs (activations) saved from the forward pass, which is why training uses far more memory than inference. Activation checkpointing trades compute for memory by discarding some activations and recomputing them during the backward pass.
In a static, define-and-run style, the whole graph is built first and then executed, which makes global optimization easy but complicates data-dependent control flow and debugging. In a dynamic, define-by-run or eager style, operations execute immediately as the program runs and the graph is recorded on the fly, which is flexible but leaves little room for optimization across operations. Many frameworks mix the two: code is written eagerly, and a compile step traces or captures the graph so that a compiler can optimize it before execution.
AI compilers rewrite the graph before generating code. Operator fusion merges chains such as matrix multiply, bias add and activation into one kernel so intermediate tensors stay in on-chip memory instead of making a round trip to DRAM. Other passes include constant folding, removal of unused nodes, choice of tensor memory layout, tiling to fit caches or scratchpads, and memory planning that reuses buffers whose lifetimes do not overlap. Exchange formats such as ONNX (Open Neural Network Exchange) serialize the graph and weights so different runtimes and hardware toolchains can execute the same model.
Answer: C. A representation of a model's computation with operations as nodes and tensor flows as edges
A computational graph is a blueprint of a model's computation, with operations such as matrix products, additions and activations as nodes and the tensors flowing between them as edges. Frameworks traverse it backward to compute backpropagation gradients automatically, and compilers optimize it as a whole through fusion and reordering. The graph also shows which operations are independent and can run in parallel.
It is a representation of a model as operations (nodes) connected by the tensors they pass to each other (edges). Frameworks use it to compute gradients automatically and compilers use it to optimize execution.
Many operations, such as activations and normalization, are memory-bound, so writing their outputs to DRAM and reading them back dominates the time. Fusing them into one kernel keeps intermediates on chip and cuts memory traffic.
Eager execution runs each operation immediately as Python reaches it, while graph mode builds or captures the whole graph first and then optimizes and runs it. Eager is easier to debug; graph mode allows fusion and other whole-model optimizations.
Computational graph appears in 4 practice questions across 1 topic, including AI Hardware & Software Stack.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.