mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-03-25 04:25:02 -05:00
feat: Add consistent 'Where This Code Lives' template across modules
- Add template section to tensor, layers, activations, and cnn modules - Create docs/development/module-template.md for future reference - Clarify learning vs building structure consistently - Show students where their code will live in the final package - Decouple learning modules from production organization
This commit is contained in:
55
docs/development/module-template.md
Normal file
55
docs/development/module-template.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Module Template: "Where This Code Lives" Section
|
||||
|
||||
## 📦 Where This Code Lives in the Final Package
|
||||
|
||||
**Learning Side:** You work in `modules/{module_name}/{module_name}_dev.py`
|
||||
**Building Side:** Code exports to `tinytorch.core.{destination}`
|
||||
|
||||
```python
|
||||
# Final package structure:
|
||||
from tinytorch.core.{destination} import {exported_classes}
|
||||
from tinytorch.core.tensor import Tensor
|
||||
```
|
||||
|
||||
**Why this matters:**
|
||||
- **Learning:** Focused modules for deep understanding
|
||||
- **Production:** Proper organization like industry frameworks
|
||||
- **Consistency:** Related functionality grouped together
|
||||
|
||||
## Template Variables
|
||||
|
||||
Replace these placeholders in each module:
|
||||
|
||||
- `{module_name}`: The module directory name (e.g., "tensor", "layers", "cnn")
|
||||
- `{destination}`: Where the code exports in the final package (e.g., "tensor", "layers", "activations")
|
||||
- `{exported_classes}`: The main classes/functions being exported (e.g., "Tensor", "Dense, Conv2D", "ReLU, Sigmoid")
|
||||
|
||||
## Examples
|
||||
|
||||
### Tensor Module
|
||||
```python
|
||||
# Learning Side: modules/tensor/tensor_dev.py
|
||||
# Building Side: tinytorch.core.tensor
|
||||
from tinytorch.core.tensor import Tensor
|
||||
```
|
||||
|
||||
### Layers Module
|
||||
```python
|
||||
# Learning Side: modules/layers/layers_dev.py
|
||||
# Building Side: tinytorch.core.layers
|
||||
from tinytorch.core.layers import Dense, Conv2D
|
||||
```
|
||||
|
||||
### CNN Module
|
||||
```python
|
||||
# Learning Side: modules/cnn/cnn_dev.py
|
||||
# Building Side: tinytorch.core.layers (Conv2D lives with Dense)
|
||||
from tinytorch.core.layers import Dense, Conv2D
|
||||
```
|
||||
|
||||
## Usage Instructions
|
||||
|
||||
1. Copy this template section into each module's `*_dev.py` file
|
||||
2. Replace the template variables with module-specific values
|
||||
3. Update the `#| default_exp` directive to match the destination
|
||||
4. Ensure the exported classes match what's actually being exported
|
||||
Reference in New Issue
Block a user