Skip to content

Fix stack last-axis layout mismatch - #21

Merged
CodeWithKyrian merged 1 commit into
mainfrom
fix/stack-standard-layout
May 14, 2026
Merged

CodeWithKyrian merged 1 commit into
mainfrom
fix/stack-standard-layout

Conversation

@CodeWithKyrian

Copy link
Copy Markdown
Contributor

This PR fixes NDArray::stack so stacked results use C row-major storage that matches the strides PHP assumes for indexing, getAt, and toArray.

Motivation and context

ndarray::stack could return a valid shape with a non-standard memory layout, while PHP always derives strides from shape alone. That mismatch made last-axis stacks look correct by shape but wrong in real use until data was read back element-wise.

What’s changed

  • Fixed: stack (all dtypes) now normalizes output to standard row-major layout so logical indexing matches the underlying buffer.
  • Added: regression test for stack(..., -1) on three 2D planes—shape, strides, contiguity, per-element equality vs inputs, and logical getAt checks.

Breaking changes

None.

@CodeWithKyrian
CodeWithKyrian merged commit db79564 into main May 14, 2026
14 checks passed
@CodeWithKyrian
CodeWithKyrian deleted the fix/stack-standard-layout branch May 14, 2026 19:13
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