catniff 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/core.js +5 -5
  2. package/package.json +1 -1
package/dist/core.js CHANGED
@@ -280,13 +280,13 @@ class Tensor {
280
280
  // New stride
281
281
  const newStrides = [...this.strides];
282
282
  let newDimStride;
283
- if (dim === 0) {
284
- // Inserting at front: use product of all original dimensions
285
- newDimStride = this.shape.reduce((a, b) => a * b, 1) || 1;
283
+ if (dim === this.shape.length) {
284
+ // Inserting at the back: reuse last stride or 1
285
+ newDimStride = this.strides[this.strides.length - 1] ?? 1;
286
286
  }
287
287
  else {
288
- // Inserting elsewhere: use stride of previous dimension
289
- newDimStride = this.strides[dim - 1];
288
+ // Inserting before dim: copy current stride at that dim
289
+ newDimStride = this.strides[dim] * this.shape[dim];
290
290
  }
291
291
  newStrides.splice(dim, 0, newDimStride);
292
292
  const out = new Tensor(this.value, { shape: newShape, strides: newStrides });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catniff",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "A cute autograd engine for Javascript",
5
5
  "main": "index.js",
6
6
  "scripts": {