mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-18 00:44:29 -05:00
[GH-ISSUE #1128] With tinytorch 0.1.3, 06_autograd.py test_unit_function_classes should be moved after enable_autograd #16225
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @avikde on GitHub (Jan 21, 2026).
Original GitHub issue: https://github.com/harvard-edge/cs249r_book/issues/1128
Originally assigned to: @profvjreddi on GitHub.
The
test_unit_function_classes()function fails if called (currently first in line 1276) beforeenable_autograd(quiet=True)(currently in line 2288). It appears thattest_unit_function_classes()is also called fromtest_module(), so maybe it just does not need to be called in line 1276.@profvjreddi commented on GitHub (Jan 21, 2026):
👍 Will look at fixing it!
@profvjreddi commented on GitHub (Jan 22, 2026):
Status: Fixed ✅
You were correct. The
test_unit_function_classes()function at line 1276 was being called in anif __name__ == "__main__"block, butenable_autograd()isn't called until line 2288. Since the test creates Tensors withrequires_grad=True, and that parameter is only added to the Tensor class byenable_autograd(), running the file directly would fail.Fix: Removed the premature test call. The test is already called from
test_module()which runs afterenable_autograd()is invoked.Thanks for catching this!
@avikde commented on GitHub (Jan 22, 2026):
Thanks @profvjreddi! As I mentioned in the other issue, feel free to close the issue whenever is best for your workflow.
@profvjreddi commented on GitHub (Jan 22, 2026):
Also fixed in v0.1.4! Removed the premature
test_unit_function_classes()call - as you noted, it's already called fromtest_module()afterenable_autograd()runs.(See #1127 for update instructions and contributor details!)