[PR #1868] [MERGED] fix(conv): remove misleading super().__init__() on bare Conv2d/MaxPool2d/AvgPool2d #27329

Closed
opened 2026-06-18 16:55:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 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: mainHead: fix/conv-pool-layer-inheritance


📝 Commits (1)

  • 61cd86e remove 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, and AvgPool2d are all plain classes (class Conv2d:) with no base class, but their __init__ methods each call super().__init__(). On a bare class this resolves to object.__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 because Linear in 03_layers.py does inherit from Layer and that super().__init__() is load-bearing there. Someone reading Conv2d would assume the same.

Fix

Remove the no-op super().__init__() calls. Add a comment on Conv2d explaining why Layer inheritance is the right long-term fix and what's needed to get there (export Layer from tinytorch.core and add the import).

Why not just add Layer inheritance now?

Layer is only defined in src/03_layers/03_layers.py -- it is not exported through tinytorch.core. Adding from tinytorch.core.layers import Layer would 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/ passes
  • Conv2d, MaxPool2d, AvgPool2d still instantiate correctly

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1868 **Author:** [@Shashank-Tripathi-07](https://github.com/Shashank-Tripathi-07) **Created:** 6/16/2026 **Status:** ✅ Merged **Merged:** 6/16/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `main` ← **Head:** `fix/conv-pool-layer-inheritance` --- ### 📝 Commits (1) - [`61cd86e`](https://github.com/harvard-edge/cs249r_book/commit/61cd86ef079321e9f4257fd54f065800eef1d88d) remove misleading super().__init__() calls from Conv2d, MaxPool2d and AvgPool2d ### 📊 Changes **1 file changed** (+0 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tinytorch/src/09_convolutions/09_convolutions.py` (+0 -6) </details> ### 📄 Description ## What's wrong `Conv2d`, `MaxPool2d`, and `AvgPool2d` are all plain classes (`class Conv2d:`) with no base class, but their `__init__` methods each call `super().__init__()`. On a bare class this resolves to `object.__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 because `Linear` in `03_layers.py` does inherit from `Layer` and that `super().__init__()` is load-bearing there. Someone reading `Conv2d` would assume the same. ## Fix Remove the no-op `super().__init__()` calls. Add a comment on `Conv2d` explaining why Layer inheritance is the right long-term fix and what's needed to get there (export `Layer` from `tinytorch.core` and add the import). ## Why not just add `Layer` inheritance now? `Layer` is only defined in `src/03_layers/03_layers.py` -- it is not exported through `tinytorch.core`. Adding `from tinytorch.core.layers import Layer` would 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/` passes - [ ] `Conv2d`, `MaxPool2d`, `AvgPool2d` still instantiate correctly --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-06-18 16:55:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#27329