Skip to content

fix(lang): rank-safe default TensorData.copyToFloatArray (#930) - #934

Merged
michalharakal merged 2 commits into
developfrom
fix/tensordata-copytofloat-rank-930
Aug 10, 2026
Merged

michalharakal merged 2 commits into
developfrom
fix/tensordata-copytofloat-rank-930

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

The interface default indexed rank-≥2 tensors with a single flat index into the vararg get(), tripping every implementation's arity require — full analysis in #930. Masked today only because the implementations that matter override it.

Fix: unravel each flat position into per-dimension indices (row-major). Rank-1 unchanged, rank-0 degenerates to a no-index get().

Tests: new commonTest TensorDataDefaultCopyTest whose fixture deliberately does not override copyToFloatArray, exercising the interface default at ranks 1–3.

Verified: :skainet-lang:skainet-lang-core:jvmTest green (full module).

Note: CHANGELOG entry included — expect trivial [Unreleased] merge conflicts with sibling hygiene PRs (#927–#931 series), all resolvable by keeping both bullets.

Closes #930

The interface default iterated a single flat index into the vararg get(),
which trips every implementation's one-index-per-dimension arity require
for rank >= 2 tensors. Masked today because the implementations that
matter override the method — a latent trap for the next implementor.

Unravel each flat position into per-dimension indices (row-major) instead.
Rank-1 behavior is unchanged; rank-0 degenerates to a no-index get().
New contract test exercises the interface default (fixture deliberately
does not override) at ranks 1, 2 and 3.

Closes #930
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-934 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal
michalharakal requested a review from aharakal August 10, 2026 08:52
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-934 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal
michalharakal merged commit 2375f4a into develop Aug 10, 2026
14 checks passed
@michalharakal
michalharakal deleted the fix/tensordata-copytofloat-rank-930 branch August 10, 2026 08:56
michalharakal added a commit that referenced this pull request Aug 10, 2026
Resolve the [Unreleased] CHANGELOG conflict with the merged #930 entry
(the earlier remote merge predated PRs #934/#926): keep all bullets.
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.

TensorData.copyToFloatArray() default implementation is rank-broken — flat index into vararg get() trips every impl's arity check

2 participants