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.
- package/dist/core.js +5 -5
- 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 ===
|
|
284
|
-
// Inserting at
|
|
285
|
-
newDimStride = this.
|
|
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
|
|
289
|
-
newDimStride = this.strides[dim
|
|
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 });
|