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

Method compile

tfjs-converter/src/executor/graph_executor.ts:167–191  ·  view source on GitHub ↗

* Compiles the inference graph and returns the minimal set of nodes that are * required for execution, in the correct execution order. * @returns {Object} compilation The compile result. * @returns {Node[]} compilation.orderedNodes Nodes in the correct execution * order. * @return

(inputs: NamedTensorMap, outputs: Node[])

Source from the content-addressed store, hash-verified

165 * tensors should be disposed after `x` is executed.
166 */
167 private compile(inputs: NamedTensorMap, outputs: Node[]):
168 {orderedNodes: Node[], nodeLiveUntilMap: Map<string, Node[]>} {
169 const executionInfo =
170 getExecutionSubgraph(inputs, outputs, this.weightMap, this._initNodes);
171 const {missingInputs, dynamicNode, syncInputs} = executionInfo;
172 if (dynamicNode != null) {
173 throw new Error(
174 `This execution contains the node '${dynamicNode.name}', which has ` +
175 `the dynamic op '${dynamicNode.op}'. Please use ` +
176 `model.executeAsync() instead. Alternatively, to avoid the ` +
177 `dynamic ops, specify the inputs [${syncInputs}]`);
178 }
179
180 if (missingInputs.length > 0) {
181 const outNames = outputs.map(n => n.name);
182 const inNames = Object.keys(inputs);
183 throw new Error(
184 `Cannot compute the outputs [${outNames}] from the provided inputs ` +
185 `[${inNames}]. Missing the following inputs: [${missingInputs}]`);
186 }
187
188 const orderedNodes = getNodesInTopologicalOrder(this.graph, executionInfo);
189 const nodeLiveUntilMap = getNodeLiveUntilMap(orderedNodes);
190 return {orderedNodes, nodeLiveUntilMap};
191 }
192
193 private cloneAndKeepTensor(tensor: Tensor) {
194 if (tensor == null) {

Calls 3

getExecutionSubgraphFunction · 0.90
getNodeLiveUntilMapFunction · 0.90