mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 14:42:29 -05:00
[PR #1868] [MERGED] fix(conv): remove misleading super().__init__() on bare Conv2d/MaxPool2d/AvgPool2d #33421
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?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1868
Author: @Shashank-Tripathi-07
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/16/2026
Merged by: @profvjreddi
Base:
main← Head:fix/conv-pool-layer-inheritance📝 Commits (1)
61cd86eremove misleading super().init() calls from Conv2d, MaxPool2d and AvgPool2d📊 Changes
1 file changed (+0 additions, -6 deletions)
View changed files
📝
tinytorch/src/09_convolutions/09_convolutions.py(+0 -6)📄 Description
What's wrong
Conv2d,MaxPool2d, andAvgPool2dare all plain classes (class Conv2d:) with no base class, but their__init__methods each callsuper().__init__(). On a bare class this resolves toobject.__init__()-- a silent no-op at runtime.The problem is the implication: any reader seeing
super().__init__()expects that a meaningful parent class is being initialized. This is particularly confusing becauseLinearin03_layers.pydoes inherit fromLayerand thatsuper().__init__()is load-bearing there. Someone readingConv2dwould assume the same.Fix
Remove the no-op
super().__init__()calls. Add a comment onConv2dexplaining why Layer inheritance is the right long-term fix and what's needed to get there (exportLayerfromtinytorch.coreand add the import).Why not just add
Layerinheritance now?Layeris only defined insrc/03_layers/03_layers.py-- it is not exported throughtinytorch.core. Addingfrom tinytorch.core.layers import Layerwould fail. The wiring of Layer into the core package is a separate, larger change that should be a deliberate PR.Test plan
pytest tinytorch/tests/09_convolutions/passesConv2d,MaxPool2d,AvgPool2dstill instantiate correctly🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.