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

Method map_

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

* Apply a callback function to each element of the tensor in place. * @param {Function} callback - The function to apply to each element. It should take three arguments: * the current element, its index, and the tensor's data array. * @returns {Tensor} Ret

(callback)

Source from the content-addressed store, hash-verified

239 * @returns {Tensor} Returns `this`.
240 */
241 map_(callback) {
242 const this_data = this.data;
243 for (let i = 0; i < this_data.length; ++i) {
244 this_data[i] = callback(this_data[i], i, this_data);
245 }
246 return this;
247 }
248
249 /**
250 * Return a new Tensor with every element multiplied by a constant.

Callers 2

mapMethod · 0.80
_callMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected