Skip to main content

models.types.CNNWorkload

models.types.CNNWorkload()

Workload representation of a Convolutional Neural Network (e.g., Vision).

Methods

Name Description
activation_traffic_bytes Calculate per-image feature-map read/write traffic across CNN layers.
lower Lower the declared convolutional forward-pass work.

activation_traffic_bytes

models.types.CNNWorkload.activation_traffic_bytes(
    precision=BYTES_FP16,
    tokens_per_sample=1,
    ops_multiplier=1,
)

Calculate per-image feature-map read/write traffic across CNN layers.

Parameters

Name Type Description Default
precision Quantity or str Bytes per feature-map element, or a registered format such as ‘fp16’. BYTES_FP16
tokens_per_sample int Positive sample token count (unused for fixed-resolution CNN images; validated for interface uniformity). 1
ops_multiplier int Positive pass multiplier (1 for forward inference, 3 for standard training, 4 with full activation recomputation). 1

Returns

Name Type Description
Quantity Off-chip feature-map bytes read and written per image in byte units.

Notes

Equation: A_sample = 2 * feature_map_elements * b * ops_multiplier when feature_map_elements is populated, else 0 byte.

Assumptions: unfused layer-by-layer execution writes each layer output feature map once and reads it once as the next layer’s input (factor of 2 over summed feature-map elements). Conv+BN+ReLU fusion is assumed within each counted layer boundary.

Excludes: cross-layer operator fusion into SRAM tiles, im2col workspace materialization, and residual-branch extra reads beyond sequential flow.

References

Derivation: in unfused layer-by-layer execution, each feature map in sum_l C_l * H_l * W_l is written once and read once at byte width b.

Examples

>>> from mlsysim import Models
>>> resnet = Models.Vision.ResNet50
>>> resnet.activation_traffic_bytes('fp16') == 2 * resnet.activation_traffic_bytes('int8')
True

lower

models.types.CNNWorkload.lower(precision=BYTES_FP16)

Lower the declared convolutional forward-pass work.

Parameters

Name Type Description Default
precision Quantity or str Bytes per stored element, or a registered format such as ‘fp16’. A byte quantity specifies the width directly; it must be positive. BYTES_FP16

Returns

Name Type Description
ComputationGraph Work in FLOPs, resident weight bytes, parameter count, arithmetic intensity in FLOP/byte, and the available layer count.

Notes

Equation: F = inference_flops; W = size_in_bytes(precision); I = F / W.

Assumptions: inference_flops describes one image at the registered input resolution. Precision changes stored weights but does not change the declared operation count.

Excludes: input-resolution scaling, convolution shape tracing, activation storage, backward work, and device-specific kernels.

References

Derivation: multiply parameter count by storage width to obtain weight bytes, then divide the declared or approximated work by those bytes. This is a demand-accounting projection; it does not predict device time.

Examples

>>> from mlsysim import Models
>>> model = Models.Vision.ResNet50
>>> graph = model.lower('fp16')
>>> graph.total_ops == model.inference_flops
True
Back to top