MCPcopy Create free account
hub / github.com/tensorflow/tfjs / unstack_

Function unstack_

tfjs-core/src/ops/unstack.ts:43–56  ·  view source on GitHub ↗

* Unstacks a `tf.Tensor` of rank-`R` into a list of rank-`(R-1)` `tf.Tensor`s. * * ```js * const a = tf.tensor2d([1, 2, 3, 4], [2, 2]); * * tf.unstack(a).forEach(tensor => tensor.print()); * ``` * * @param x A tensor object. * @param axis The axis to unstack along. Defaults to 0 (the first

(x: Tensor|TensorLike, axis = 0)

Source from the content-addressed store, hash-verified

41 * @doc {heading: 'Tensors', subheading: 'Slicing and Joining'}
42 */
43function unstack_(x: Tensor|TensorLike, axis = 0): Tensor[] {
44 const $x = convertToTensor(x, 'x', 'unstack', 'string_or_numeric');
45 util.assert(
46 axis >= -$x.shape.length && axis < $x.shape.length,
47 () =>
48 `Axis = ${axis} is not in [-${$x.shape.length}, ${$x.shape.length})`);
49
50 const inputs: UnpackInputs = {value: $x};
51 const attrs: UnpackAttrs = {axis};
52
53 return ENGINE.runKernel(
54 Unpack, inputs as unknown as NamedTensorMap,
55 attrs as unknown as NamedAttrMap);
56}
57
58export const unstack = /* @__PURE__ */ op({unstack_});

Callers

nothing calls this directly

Calls 2

convertToTensorFunction · 0.90
runKernelMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…