mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-03-11 18:53:37 -05:00
Simplify module test execution for notebook compatibility
Removed redundant test calls from all modules: - Eliminated verbose if __name__ == '__main__': blocks - Removed duplicate individual test calls - Each module now simply calls test_module() directly Changes made to all 9 modules: - Module 01 (Tensor): Simplified from 16-line main block to 1 line - Module 02 (Activations): Simplified from 13-line main block to 1 line - Module 03 (Layers): Simplified from 17-line main block to 1 line - Module 04 (Losses): Simplified from 20-line main block to 1 line - Module 05 (Autograd): Simplified from 19-line main block to 1 line - Module 06 (Optimizers): Simplified from 17-line main block to 1 line - Module 07 (Training): Simplified from 16-line main block to 1 line - Module 08 (DataLoader): Simplified from 17-line main block to 1 line - Module 09 (Spatial): Simplified from 14-line main block to 1 line Impact: - Notebook-friendly: Tests run immediately in Jupyter environments - No redundancy: test_module() already runs all unit tests - Cleaner code: ~140 lines of redundant code removed - Better for students: Simpler, more direct execution flow
This commit is contained in:
@@ -1636,26 +1636,8 @@ def test_module():
|
||||
print("🎉 ALL TESTS PASSED! Module ready for export.")
|
||||
print("Run: tito module complete 01_tensor")
|
||||
|
||||
# test_module() # Moved to main block
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
print("🚀 Running Tensor Foundation module...")
|
||||
|
||||
# Run all unit tests
|
||||
test_unit_tensor_creation()
|
||||
test_unit_arithmetic_operations()
|
||||
test_unit_matrix_multiplication()
|
||||
test_unit_shape_manipulation()
|
||||
test_unit_reduction_operations()
|
||||
|
||||
# Run integration demo
|
||||
demonstrate_tensor_integration()
|
||||
|
||||
# Run final module test
|
||||
test_module()
|
||||
|
||||
print("✅ Module validation complete!")
|
||||
# Run comprehensive module test
|
||||
test_module()
|
||||
|
||||
|
||||
# %% [markdown]
|
||||
|
||||
Reference in New Issue
Block a user