UNPKG

@hoff97/tensor-js

Version:

PyTorch like deep learning inferrence library

13 lines 475 B
import { CPUTensor } from '../../tensor/cpu/tensor'; import { incrementIndex } from '../../util/shape'; export function expand(x, resultShape) { const rank = x.shape.length; const result = new CPUTensor(resultShape, undefined, x.dtype); const index = new Array(rank).fill(0); for (let i = 0; i < result.size; i++) { result.set(i, x.get(index)); incrementIndex(index, result.shape); } return result; } //# sourceMappingURL=expand.js.map