Skip to content
ml-recall

#asynchronous-execution

1 question from Deep Learning Frameworks

Timed test

1 question · 1 min · score and explanations at the end

Take a test
Q 1 / 1Score 0 / 0

Question 1: Single choice

mediumAI-checkedDeep Learning Frameworks

Two loops run 1000 products of 100×100100 \times 100 matrices on a GPU and record the Frobenius norm of each result:

# A
log = []
for _ in range(1000):
    Y = X @ W
    log.append(torch.linalg.norm(Y).item())

# B
norms = torch.empty(1000, device="cuda")
for i in range(1000):
    Y = X @ W
    norms[i] = torch.linalg.norm(Y)
log = norms.cpu()

Why is B usually much faster?

Choose one option