How deep is the scope of torch.no_grad
and torch.inference_mode
?
At the following code:
with torch.no_grad():
y = my_fun(my_tensor)
Will it affect my_fun
? Or must I add @torch.no_grad
in its definition?
What if tensors are generated within my_fun
?
I assume the answer torch.inference_mode
will hold for as well.