Problem
The reshapeArray function in src/utils.ts (line ~208) uses shape.slice(0, -1) when recursing into sub-dimensions. This removes the last dimension instead of the first (already consumed) dimension, causing silent data corruption for any tensor with 3 or more dimensions.
Steps to Reproduce
import { reshapeArray } from './utils';
const flat = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
const result = reshapeArray(flat, [2, 3, 4]);
// Expected: [[[1,2,3,4],[5,6,7,8],[9,10,11,12]],[[13,14,15,16],[17,18,19,20],[21,22,23,24]]]
// Actual: incorrectly shaped array due to wrong dimension slicing
Root Cause
Line 208: const subShape = shape.slice(0, -1);
For shape [2, 3, 4]:
- Current (broken): consumes dim 0 (size=2), recurses with
[2, 3] — reuses the already-consumed dimension
- Correct: consumes dim 0 (size=2), recurses with
[3, 4] — passes remaining dimensions
Fix: change to shape.slice(1)
Additional Issues
src/client.ts line ~302: llmChat has gas estimation commented out, replaced with hardcoded 100000. The infer and llmCompletion methods properly use estimateGas()
src/client.ts line ~142: uses var instead of const
Impact
Critical — any user working with 3D+ tensor model outputs through the TypeScript SDK gets silently corrupted data with no error or warning. This affects ML model inference results.
Problem
The
reshapeArrayfunction insrc/utils.ts(line ~208) usesshape.slice(0, -1)when recursing into sub-dimensions. This removes the last dimension instead of the first (already consumed) dimension, causing silent data corruption for any tensor with 3 or more dimensions.Steps to Reproduce
Root Cause
Line 208:
const subShape = shape.slice(0, -1);For shape
[2, 3, 4]:[2, 3]— reuses the already-consumed dimension[3, 4]— passes remaining dimensionsFix: change to
shape.slice(1)Additional Issues
src/client.tsline ~302:llmChathas gas estimation commented out, replaced with hardcoded100000. TheinferandllmCompletionmethods properly useestimateGas()src/client.tsline ~142: usesvarinstead ofconstImpact
Critical — any user working with 3D+ tensor model outputs through the TypeScript SDK gets silently corrupted data with no error or warning. This affects ML model inference results.