@thi.ng/tensors
Version:
1D/2D/3D/4D tensors with extensible polymorphic operations and customizable storage
23 lines (22 loc) • 453 B
JavaScript
import { typedArrayType } from "@thi.ng/api/typedarray";
import { tensor } from "./tensor.js";
const fromFloatBuffer = ({
size: [sx, sy],
stride: [tx, ty],
data,
format: { size }
}) => {
const type = typedArrayType(data);
return size > 1 ? tensor(type, [sy, sx, size], {
stride: [ty, tx, 1],
copy: false,
data
}) : tensor(type, [sy, sx], {
stride: [ty, tx],
copy: false,
data
});
};
export {
fromFloatBuffer
};