[PR #1120] [MERGED] fix: matmul should not allow 0D tensors #31591

Closed
opened 2026-07-12 08:18:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1120
Author: @minhdang26403
Created: 1/20/2026
Status: Merged
Merged: 1/20/2026
Merged by: @profvjreddi

Base: devHead: fix/tensor-matmul


📝 Commits (1)

  • f314db2 fix: matmul should not allow 0D tensors

📊 Changes

1 file changed (+9 additions, -11 deletions)

View changed files

📝 tinytorch/src/01_tensor/01_tensor.py (+9 -11)

📄 Description

Both NumPy and PyTorch do not allow operands of the matmul operation to be 0D tensors. To make TinyTorch achieve the same functionality as PyTorch, the method matmul should raise error when it receives a 0D tensor. For 0D tensor multiplication, users should use element-wise multiplication *.

All Tensor module tests pass and there is no regression.


🔄 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/1120 **Author:** [@minhdang26403](https://github.com/minhdang26403) **Created:** 1/20/2026 **Status:** ✅ Merged **Merged:** 1/20/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/tensor-matmul` --- ### 📝 Commits (1) - [`f314db2`](https://github.com/harvard-edge/cs249r_book/commit/f314db2a0810dac3585d68b4277a353709040e49) fix: matmul should not allow 0D tensors ### 📊 Changes **1 file changed** (+9 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `tinytorch/src/01_tensor/01_tensor.py` (+9 -11) </details> ### 📄 Description Both NumPy and PyTorch do not allow operands of the matmul operation to be 0D tensors. To make TinyTorch achieve the same functionality as PyTorch, the method matmul should raise error when it receives a 0D tensor. For 0D tensor multiplication, users should use element-wise multiplication `*`. All Tensor module tests pass and there is no regression. --- <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-07-12 08:18:52 -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#31591