no_grad = NOT backward
MODIFY
examples/benchmark_train_efficientnet.py
examples/benchmark_train_efficientnet.py
@@ -25,6 +25,7 @@ if __name__ == "__main__":
optimizer = optim.SGD(parameters, lr=0.001)
Tensor.training = TRAINING
+ Tensor.no_grad = not BACKWARD
for i in trange(CNT):
cpy = time.monotonic()
x_train = Tensor.randn(BS, 3, 224, 224, requires_grad=False).realize()

MODIFY
test/test_ops.py
test/test_ops.py
@@ -193,7 +193,7 @@ class TestOps(unittest.TestCase):
lambda x,w: Tensor.conv2d(x,w).relu(), atol=1e-4, grad_rtol=1e-5)
def test_simple_conv2d_forward(self):
- helper_test_op([(1,1,9,9), (1,1,3,3)],
+ helper_test_op([(2,10,9,9), (10,10,3,3)],
lambda x,w: torch.nn.functional.conv2d(x,w).relu(),
lambda x,w: Tensor.conv2d(x,w).relu(), atol=1e-4, grad_rtol=1e-5, forward_only=True)

no_grad = NOT backward