semiAIfoundry

Model–machine co-design · Atlas v1.3.0

Model graph and tensor intermediate representation

Preserves operation semantics before committing to a device instruction schedule.

Explore in AtlasSoftware abstraction layers mapped to physical memory and compute

Learning objectiveDistinguish graph semantics, tensor types and physical execution mapping.

The mechanism

A framework expresses a model as tensor operations and control flow. A compiler front end captures an appropriate portion of that program into an intermediate representation, recording shapes, element types and dependencies. StableHLO is one public operation specification used between frameworks and compilers; it describes what operations mean, not which physical unit must execute them. A matrix multiplication followed by bias and activation may begin as several graph nodes. These can later be transformed or fused if their semantics allow it. Dynamic shapes and data-dependent control can require specialization, runtime decisions or boundaries between compiled regions.

A graph representation can carry shapes and operator semantics while leaving memory placement and execution schedules unresolved. When this graph is lowered, each representation needs a checkable relation to the same intended output. Equal array dimensions do not establish equal axis meaning. Explicit input/output examples and value ownership let a reader determine what was preserved instead of treating a compiler stage as a decorative box.

  1. Identify the model region captured for compilation and the inputs whose shapes or values remain dynamic.
  2. Represent operators with defined semantics, including broadcasting, reductions and numerical element types.
  3. Record producer-to-consumer dependencies so transformations preserve the required result.
  4. Apply legal simplifications such as eliminating unused results or combining constant expressions.
  5. Pass a typed graph to device-aware lowering while retaining enough provenance to relate optimized operations back to the model.
  6. The graph declares which axes are contracted, broadcast or retained before any physical buffer is chosen.
  7. A lowered implementation is compared against an independent reference on a stated arithmetic domain and input set.

Science and assumptions

Logical tensor size

Mlogical=s∏idiM_{\mathrm{logical}}=s\prod_i d_i

Dense logical tensor size is bytes per element times the product of all dimension extents.

Symbols and units
M_logical
Dense logical tensor payload size

bytes

s
Stored size per tensor element

bytes/element

dᵢ
Extent along tensor dimension i

element count

i
Tensor-axis index

integer index

di counts elements along dimension i and s is bytes per stored element; Mlogical is bytes.

Assumptions Dense unpadded representation; metadata, alignment, sparse encoding and replication can change allocated size.

Engineering example

Synthetic graph: Y = maximum(XW + b, 0) contains a dot, broadcasted bias add and activation. With X of shape 4×8 and two-byte elements, X has 64 logical bytes before padding or replication.

For X=[[1,2]] and W=[[3],[4]], XW is [[11]]. Adding bias −12 and applying ReLU gives [[0]]. Applying ReLU before adding the bias instead gives [[−1]], so moving operations because their intermediate shapes match changes the function. A legal fusion can eliminate materialized intermediates only while preserving the specified order and result.

Distinctions and tradeoffs

One framework operation does not necessarily become one kernel, one instruction or one dedicated hardware block.

More shape specialization enables optimization but creates additional compiled variants and potential compilation delay when new shapes appear.

The graph connects model intent to executable work; unsupported operations and graph breaks can move data or execution back to the host.

Specifications and interfaces

Tensor type
Shape plus element representation

Logical shape does not fix physical strides or memory location.

Graph edge
Value dependency

A software graph is not a wiring diagram of a processor.

Interfaces

Framework program Input
Tensor operators, parameters and control dependencies
Compiler IR Output
Typed operations with explicit dataflow and shape constraints

Check your understanding

What does a tensor type of shape 4×8 establish by itself?

  1. The logical element dimensions
  2. The exact GPU addresses and strides
  3. The number of physical tensor cores used
Answer and reasoning

The logical element dimensions

The shape describes logical indexing; memory layout and hardware mapping are later choices or separately specified properties.

Can operations be reordered merely because their intermediate shapes match?

  1. Yes, shape equality proves semantic equality
  2. No, the function and dependencies must be preserved
  3. Yes, if all operators use the same dtype
Answer and reasoning

No, the function and dependencies must be preserved

The bias/ReLU example has the same shapes but a different output after reordering.

Evidence and scope

StableHLO is a named reference path. Other stacks have different capture rules and IRs; portability of meaning does not imply identical performance or binary compatibility.

The arithmetic is an authored exact example. It does not claim that a real compiler performs this invalid transformation or that a new compiler implementation has been executed.

Use the execution investigation for the shared tensor-to-memory-to-result thread; no current standalone calculator models this lesson’s full mechanism.

Sources

Published lesson data · Atlas releases and licensing

Continue exploring

Foundations

Related lessons