[PR #1391] [MERGED] feat(tinytorch): add ndim, numel(), contiguous() to Tensor #8159

Closed
opened 2026-04-27 17:28:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1391
Author: @profvjreddi
Created: 4/17/2026
Status: Merged
Merged: 4/17/2026
Merged by: @profvjreddi

Base: devHead: feat/tinytorch


📝 Commits (2)

  • eaee587 Merge dev into feat/tinytorch
  • 3bbf2eb feat(tinytorch): add ndim, numel(), contiguous() to Tensor (closes #1298)

📊 Changes

1 file changed (+30 additions, -0 deletions)

View changed files

📝 tinytorch/src/01_tensor/01_tensor.py (+30 -0)

📄 Description

Summary

  • Adds ndim property, numel(), and contiguous() to the Tensor class
  • PyTorch-compatible utility methods so students can follow PyTorch tutorials without AttributeError
  • All three are thin wrappers over existing attributes — zero risk to downstream modules
  • Updates architecture diagram, docstring, and test assertions to match

Closes #1298 (partial — covers the safe API aliases; view(), masked_fill(), and __init__ changes deferred)

Test plan

  • Python syntax verified via ast.parse
  • python3 -m pytest tinytorch/tests/01_tensor/ -v passes
  • Full module self-test: python3 tinytorch/src/01_tensor/01_tensor.py

🔄 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/1391 **Author:** [@profvjreddi](https://github.com/profvjreddi) **Created:** 4/17/2026 **Status:** ✅ Merged **Merged:** 4/17/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `feat/tinytorch` --- ### 📝 Commits (2) - [`eaee587`](https://github.com/harvard-edge/cs249r_book/commit/eaee5872de406329574075cc180d449a5d99cdbe) Merge dev into feat/tinytorch - [`3bbf2eb`](https://github.com/harvard-edge/cs249r_book/commit/3bbf2eb15b9d2fca5129d80947ec49abd9d917c4) feat(tinytorch): add ndim, numel(), contiguous() to Tensor (closes #1298) ### 📊 Changes **1 file changed** (+30 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tinytorch/src/01_tensor/01_tensor.py` (+30 -0) </details> ### 📄 Description ## Summary - Adds `ndim` property, `numel()`, and `contiguous()` to the Tensor class - PyTorch-compatible utility methods so students can follow PyTorch tutorials without AttributeError - All three are thin wrappers over existing attributes — zero risk to downstream modules - Updates architecture diagram, docstring, and test assertions to match Closes #1298 (partial — covers the safe API aliases; `view()`, `masked_fill()`, and `__init__` changes deferred) ## Test plan - [x] Python syntax verified via `ast.parse` - [ ] `python3 -m pytest tinytorch/tests/01_tensor/ -v` passes - [ ] Full module self-test: `python3 tinytorch/src/01_tensor/01_tensor.py` --- <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-04-27 17:28:03 -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#8159