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

Function slice

packages/transformers/src/utils/tensor.js:1141–1150  ·  view source on GitHub ↗
(data, starts, ends, axes, steps)

Source from the content-addressed store, hash-verified

1139 * @returns {Promise<Tensor>} Sliced data tensor.
1140 */
1141export async function slice(data, starts, ends, axes, steps) {
1142 const op = await TensorOpRegistry.slice;
1143 return await op({
1144 x: data,
1145 s: arrayToIndexTensor(starts),
1146 e: arrayToIndexTensor(ends),
1147 a: arrayToIndexTensor(axes),
1148 t: arrayToIndexTensor(steps ?? new Array(axes.length).fill(1)),
1149 });
1150}
1151
1152/**
1153 * Perform mean pooling of the last hidden state followed by a normalization step.

Callers 3

_callMethod · 0.90
split_imageMethod · 0.90
tensor_ops.test.jsFile · 0.90

Calls 1

arrayToIndexTensorFunction · 0.85

Tested by

no test coverage detected