@thi.ng/tensors
Version:
0D/1D/2D/3D/4D tensors with extensible polymorphic operations and customizable storage
24 lines • 1.41 kB
TypeScript
import type { ITensor, Shape } from "./api.js";
/**
* Helper function for various tensor operators which support broadcasting.
* Takes two tensors and attempts to adjust their shape & stride configurations
* to be compatible, applying the steps and rules below. Returns an object of
* adjusted shape and possibly adjusted shallow copies of both tensors.
*
* - if the dimensions are unequal, the smaller tensor's dimensions will be
* increased as needed. The size of each added dimension will be set to 1 and
* its stride to zero.
* - Size of each dimension will be compared and only the following cases are
* accepted (otherwise will throw an error): sizes are equal or one side is 1
* - Any of the tensors requiring shape adjustments will be shallow copied with
* new shape/stride config applied (via {@link ITensor.broadcast}).
*
* @param a
* @param b
*/
export declare const broadcast: <T = number>(a: ITensor<T>, b: ITensor<T>) => {
shape: Shape;
a: ITensor<T> | import("./tensor.js").Tensor4<T> | import("./tensor.js").Tensor3<T> | import("./tensor.js").Tensor2<T> | import("./tensor.js").Tensor0<T> | import("./tensor.js").Tensor1<T>;
b: ITensor<T> | import("./tensor.js").Tensor4<T> | import("./tensor.js").Tensor3<T> | import("./tensor.js").Tensor2<T> | import("./tensor.js").Tensor0<T> | import("./tensor.js").Tensor1<T>;
};
//# sourceMappingURL=broadcast.d.ts.map