Files
TinyTorch/modules/source/03_layers
Vijay Janapa Reddi 45208ea0a2 Add __call__ methods to enable PyTorch-style API
Enable cleaner API usage by adding __call__ methods to all activation,
layer, and loss classes. This allows students to write:
  - relu(x) instead of relu.forward(x)
  - layer(x) instead of layer.forward(x)
  - loss_fn(pred, target) instead of loss_fn.forward(pred, target)

Changes:
- Module 02 (Activations): Add __call__ to ReLU, Tanh, GELU, Softmax
  * Sigmoid already had __call__
- Module 03 (Layers): Add __call__ to Dropout
  * Linear already had __call__
- Module 04 (Losses): Add __call__ to MSELoss, CrossEntropyLoss, BinaryCrossEntropyLoss

This matches PyTorch's API convention where model(x) calls model.__call__(x)
which internally calls model.forward(x). Makes code more Pythonic and
intuitive for students familiar with PyTorch.

Expected impact: Test pass rates should improve significantly as tests
expect PyTorch-style callable API.
2025-09-30 12:33:45 -04:00
..