MCPcopy Index your code
hub / github.com/tensorflow/tfjs / concat

Method concat

tfjs-converter/src/executor/tensor_array.ts:216–239  ·  view source on GitHub ↗

* Return the values in the TensorArray as a concatenated Tensor.

(dtype?: DataType)

Source from the content-addressed store, hash-verified

214 * Return the values in the TensorArray as a concatenated Tensor.
215 */
216 concat(dtype?: DataType): Tensor {
217 if (!!dtype && dtype !== this.dtype) {
218 throw new Error(`TensorArray dtype is ${
219 this.dtype} but concat requested dtype ${dtype}`);
220 }
221
222 if (this.size() === 0) {
223 return tensor([], [0].concat(this.elementShape));
224 }
225
226 const indices = [];
227 for (let i = 0; i < this.size(); i++) {
228 indices.push(i);
229 }
230 // Collect all the tensors from the tensors array.
231 const tensors = this.readMany(indices);
232
233 assertShapesMatchAllowUndefinedSize(
234 this.elementShape, tensors[0].shape,
235 `TensorArray shape mismatch: tensor array shape (${
236 this.elementShape}) vs first tensor shape (${tensors[0].shape})`);
237
238 return concat(tensors, 0);
239 }
240
241 /**
242 * Scatter the values of a Tensor in specific indices of a TensorArray.

Callers

nothing calls this directly

Calls 7

sizeMethod · 0.95
readManyMethod · 0.95
tensorFunction · 0.90
concatMethod · 0.65
concatFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected