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

Method _subarray

packages/transformers/src/utils/tensor.js:174–181  ·  view source on GitHub ↗

* @param {number} index * @param {number} iterSize * @param {any} iterDims * @returns {Tensor}

(index, iterSize, iterDims)

Source from the content-addressed store, hash-verified

172 * @returns {Tensor}
173 */
174 _subarray(index, iterSize, iterDims) {
175 const o1 = index * iterSize;
176 const o2 = (index + 1) * iterSize;
177
178 // We use subarray if available (typed array), otherwise we use slice (normal array)
179 const data = 'subarray' in this.data ? this.data.subarray(o1, o2) : this.data.slice(o1, o2);
180 return new Tensor(this.type, data, iterDims);
181 }
182
183 /**
184 * Returns the value of this tensor as a standard JavaScript Number. This only works

Callers 2

[Symbol.iterator]Method · 0.95
_getitemMethod · 0.95

Calls 1

sliceMethod · 0.45

Tested by

no test coverage detected