MCPcopy
hub / github.com/huggingface/transformers.js / stack

Function stack

packages/transformers/src/utils/tensor.js:1371–1378  ·  view source on GitHub ↗
(tensors, dim = 0)

Source from the content-addressed store, hash-verified

1369 * @returns {Tensor} The stacked tensor.
1370 */
1371export function stack(tensors, dim = 0) {
1372 // TODO do validation of shapes
1373 // NOTE: stack expects each tensor to be equal size
1374 return cat(
1375 tensors.map((t) => t.unsqueeze(dim)),
1376 dim,
1377 );
1378}
1379
1380/**
1381 * @param {(previousValue: any, currentValue: any, currentIndex?: number, resultIndex?: number) => any} callbackfn

Callers 9

_callMethod · 0.90
_callMethod · 0.90
_callMethod · 0.90
_callMethod · 0.90
_callMethod · 0.90
_callMethod · 0.90
tensor.test.jsFile · 0.90

Calls 3

catFunction · 0.85
mapMethod · 0.80
unsqueezeMethod · 0.80

Tested by

no test coverage detected