MCPcopy
hub / github.com/tensorflow/tfjs / get

Method get

tfjs-core/src/tensor.ts:100–118  ·  view source on GitHub ↗

* Returns the value in the buffer at the provided location. * * @param locs The location indices. * * @doc {heading: 'Tensors', subheading: 'Creation'}

(...locs: number[])

Source from the content-addressed store, hash-verified

98 * @doc {heading: 'Tensors', subheading: 'Creation'}
99 */
100 get(...locs: number[]): SingleValueMap[D] {
101 if (locs.length === 0) {
102 locs = [0];
103 }
104 let i = 0;
105 for (const loc of locs) {
106 if (loc < 0 || loc >= this.shape[i]) {
107 const msg = `Requested out of range element at ${locs}. ` +
108 ` Buffer shape=${this.shape}`;
109 throw new Error(msg);
110 }
111 i++;
112 }
113 let index = locs[locs.length - 1];
114 for (let i = 0; i < locs.length - 1; ++i) {
115 index += this.strides[i] * locs[i];
116 }
117 return this.values[index] as SingleValueMap[D];
118 }
119
120 locToIndex(locs: number[]): number {
121 if (this.rank === 0) {

Callers 15

conv2DBackpropFilterFunction · 0.95
uniqueImplFunction · 0.95
getSurfaceMethod · 0.45
barchartFunction · 0.45
fetchFunction · 0.45
downloadTextureDataFunction · 0.45
drawTextureFunction · 0.45
runResizeProgramFunction · 0.45
drawTextureProgramFunction · 0.45
resizeProgramFunction · 0.45
detectGLCapabilitiesFunction · 0.45

Calls

no outgoing calls