[PR #1101] [CLOSED] Fix: Add requires_grad parameter to Tensor.__init__ for Linear layer compatibility #8888

Closed
opened 2026-05-03 01:03:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1101
Author: @mrinalchaturvedi27
Created: 1/4/2026
Status: Closed

Base: devHead: fix-tensor-requires-grad


📝 Commits (1)

  • f8ebd25 Fix: Add requires_grad parameter to Tensor.init to support autograd flag used in Linear layer

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 tinytorch/src/01_tensor/01_tensor.py (+2 -1)

📄 Description

  • Added requires_grad parameter to Tensor.__init__ in tinytorch/src/01_tensor/01_tensor.py
  • Fixes TypeError caused by Tensor(weight_data, requires_grad=True) in Linear layer
  • Ensures compatibility with autograd flag usage across activation and layer modules
  • Tested locally: Linear layer unit test passes after this change

🔄 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/1101 **Author:** [@mrinalchaturvedi27](https://github.com/mrinalchaturvedi27) **Created:** 1/4/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-tensor-requires-grad` --- ### 📝 Commits (1) - [`f8ebd25`](https://github.com/harvard-edge/cs249r_book/commit/f8ebd25a7fcb815d2188631ab49da694d04bafd0) Fix: Add requires_grad parameter to Tensor.__init__ to support autograd flag used in Linear layer ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tinytorch/src/01_tensor/01_tensor.py` (+2 -1) </details> ### 📄 Description - Added `requires_grad` parameter to `Tensor.__init__` in `tinytorch/src/01_tensor/01_tensor.py` - Fixes TypeError caused by `Tensor(weight_data, requires_grad=True)` in Linear layer - Ensures compatibility with autograd flag usage across activation and layer modules - Tested locally: Linear layer unit test passes after this change --- <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-05-03 01:03:59 -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#8888