TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

183. Arithmetic Intensity

Easy

Arithmetic intensity is the ratio of FLOPs performed to bytes of memory accessed. It tells you whether a kernel is compute-bound or memory-bound on a given accelerator.

Signature: def arithmetic_intensity(flops: int, bytes_accessed: int) -> float

Return flops / bytes_accessed as a float.

Examples:

  • GEMM (M=128, N=128, K=128) in fp32: flops = 2 * 128**3, bytes = 3 * 128**2 * 4 (read A, B; write C) → ~21.33
  • Elementwise add of N fp32 elements: flops = N, bytes = 12 * N (read A, read B, write C) → ~0.083

Math

I=BytesFLOPs​

Asked at

NumPy

import numpy as np

 

def arithmetic_intensity(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?