Skip to content
ml-recall

#gpu

5 questions from Deep Learning Frameworks, PyTorch

Timed test

5 questions · 5 min · score and explanations at the end

Take a test
Q 1 / 5Score 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