Skip to content

fix: move shape definition before use in mean_dim function#21

Open
Jah-yee wants to merge 1 commit into
thinking-machines-lab:mainfrom
Jah-yee:fix-shape-order
Open

fix: move shape definition before use in mean_dim function#21
Jah-yee wants to merge 1 commit into
thinking-machines-lab:mainfrom
Jah-yee:fix-shape-order

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 15, 2026

Good day,

I found a bug in the mean_dim function where the shape variable was referenced before it was defined. This causes a potential NameError when handling the empty dimension case.

Changes

  • Move shape = list(input.shape) definition before the empty dimension check
  • Also handle dtype properly in the empty dimension early return case

This fix ensures the code executes correctly when passing a tensor with an empty dimension (e.g., shape (1, 0, 8)).

Thank you for your work...

Warmly, RoomWithOutRoof

Move the shape variable definition before the empty dimension check to avoid NameError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant