You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TensorData.copyToFloatArray() default implementation is rank-broken — flat index into vararg get() trips every impl's arity check #930
The default implementation on the base interface (skainet-lang-core/src/commonMain/kotlin/sk/ainet/lang/tensor/data/TensorData.kt) iterates a single flat index and calls get(idx) — one vararg argument — regardless of tensor rank. Every concrete implementation's get begins with require(indices.size == shape.dimensions.size), so for any rank ≥ 2 tensor the default throws on the first element.
It is masked today because the implementations that matter override copyToFloatArray() — which makes this a latent trap for the next implementor: write a new TensorData, forget the override, and dense-looking code fails at runtime with a confusing arity error (or worse, works only for rank-1 test fixtures and fails on real tensors).
Also worth a look while in there: the default does get(idx) as Number and .toFloat(), which for packed-quant implementations (TensorData<DType, Byte>) would silently widen raw quantized bytes to floats if any of them ever inherited the default — semantically wrong, not just slow.
Options, cheapest first:
Fix the default to do proper multi-dimensional index iteration (row-major unravel of the flat index) — correct for any rank.
Or drop the default body entirely and make it abstract, forcing each implementor to decide — turns the latent runtime trap into a compile error.
Either way, a commonTest contract test that runs copyToFloatArray() against a rank-2 instance of each implementation would pin the behavior.
Activity
Merge pull request #934 from SKaiNET-developers/fix/tensordata-copyto…
Merge origin/develop into fix/memorytracker-source-attribution-931
Merge origin/develop into feature/q4_0-neon-920
Merge origin/develop into fix/storage-transfer-materialize-929
fix(lang): rank-safe default TensorData.copyToFloatArray