Skip to content
ml-recall

#tracing

2 questions from Deep Learning Frameworks

Timed test

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

Take a test
Q 1 / 2Score 0 / 0

Question 1: Single choice

mediumAI-checkedDeep Learning Frameworks

A simple tracer, such as PyTorch's torch.jit.trace, runs a function once on an example input and records the tensor operations that execute. Plain Python values, such as the outcome of an if test, are frozen as constants, and no check on them is recorded. The function below is traced with the example input torch.ones(3):

def f(x):
    if x.sum() > 0:
        return x * 2
    return -x

What does the recorded graph return when it is then called with -torch.ones(3)?

Choose one option