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

Function getSourceInputs

tfjs-layers/src/engine/topology.ts:1627–1657  ·  view source on GitHub ↗
(
    tensor: SymbolicTensor, layer?: Layer,
    nodeIndex?: number)

Source from the content-addressed store, hash-verified

1625 * @return Array of input tensors.
1626 */
1627export function getSourceInputs(
1628 tensor: SymbolicTensor, layer?: Layer,
1629 nodeIndex?: number): SymbolicTensor[] {
1630 if (layer == null || (nodeIndex != null && nodeIndex > 0)) {
1631 layer = tensor.sourceLayer;
1632 nodeIndex = tensor.nodeIndex;
1633 }
1634 if (layer.inboundNodes.length === 0) {
1635 return [tensor];
1636 } else {
1637 const node = layer.inboundNodes[nodeIndex];
1638 if (node.inboundLayers.length === 0) {
1639 return node.inputTensors;
1640 } else {
1641 const sourceTensors: SymbolicTensor[] = [];
1642 for (let i = 0; i < node.inboundLayers.length; i++) {
1643 const x = node.inputTensors[i];
1644 const layer = node.inboundLayers[i];
1645 const nodeIndex = node.nodeIndices[i];
1646 const previousSources = getSourceInputs(x, layer, nodeIndex);
1647 // Avoid input redundancy.
1648 for (const x of previousSources) {
1649 if (sourceTensors.indexOf(x) === -1) {
1650 sourceTensors.push(x);
1651 }
1652 }
1653 }
1654 return sourceTensors;
1655 }
1656 }
1657}
1658
1659type MaybeSymbolic = SymbolicTensor|Tensor;
1660

Callers 2

addMethod · 0.90
container_test.tsFile · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…