(
inputNodes: Node[], stack: NodeWithContexts[], context: ExecutionContext,
tensorMap: NamedTensorsMap, added: {[key: string]: boolean},
tensorsToKeep: Set<number>, outputNodeNameSet: Set<string>,
intermediateTensorConsumerCount: {[key: number]: number},
usedNodes: Set<string>)
| 605 | } |
| 606 | |
| 607 | private processStack( |
| 608 | inputNodes: Node[], stack: NodeWithContexts[], context: ExecutionContext, |
| 609 | tensorMap: NamedTensorsMap, added: {[key: string]: boolean}, |
| 610 | tensorsToKeep: Set<number>, outputNodeNameSet: Set<string>, |
| 611 | intermediateTensorConsumerCount: {[key: number]: number}, |
| 612 | usedNodes: Set<string>) { |
| 613 | const promises: Array<Promise<Tensor[]>> = []; |
| 614 | while (stack.length > 0) { |
| 615 | const item = stack.pop(); |
| 616 | context.currentContext = item.contexts; |
| 617 | let nodeName = ''; |
| 618 | // The tensor of the Enter op with isConstant set should be set |
| 619 | // in the parent scope, so it will be available as constant for the |
| 620 | // whole loop. |
| 621 | if (item.node.op === 'Enter' && |
| 622 | getParamValue('isConstant', item.node, tensorMap, context)) { |
| 623 | [nodeName] = getNodeNameAndIndex(item.node.name, context); |
| 624 | } |
| 625 | |
| 626 | // only process nodes that are not in the tensorMap yet, this include |
| 627 | // inputNodes and internal initNodes. |
| 628 | if (tensorMap[item.node.name] == null) { |
| 629 | const tensors = |
| 630 | executeOp(item.node, tensorMap, context, this._resourceManager); |
| 631 | if (!nodeName) { |
| 632 | [nodeName] = getNodeNameAndIndex(item.node.name, context); |
| 633 | } |
| 634 | const currentContext = context.currentContext; |
| 635 | if (util.isPromise(tensors)) { |
| 636 | promises.push(tensors.then(t => { |
| 637 | tensorMap[nodeName] = t; |
| 638 | if (this.keepIntermediateTensors) { |
| 639 | this.clonedTensorsMap[nodeName] = this.cloneTensorList(t); |
| 640 | } |
| 641 | context.currentContext = currentContext; |
| 642 | this.checkTensorForDisposal( |
| 643 | nodeName, item.node, tensorMap, context, tensorsToKeep, |
| 644 | outputNodeNameSet, intermediateTensorConsumerCount); |
| 645 | this.processChildNodes( |
| 646 | item.node, stack, context, tensorMap, added, usedNodes); |
| 647 | return t; |
| 648 | })); |
| 649 | } else { |
| 650 | tensorMap[nodeName] = tensors; |
| 651 | if (this.keepIntermediateTensors) { |
| 652 | this.clonedTensorsMap[nodeName] = this.cloneTensorList(tensors); |
| 653 | } |
| 654 | this.checkTensorForDisposal( |
| 655 | nodeName, item.node, tensorMap, context, tensorsToKeep, |
| 656 | outputNodeNameSet, intermediateTensorConsumerCount); |
| 657 | this.processChildNodes( |
| 658 | item.node, stack, context, tensorMap, added, usedNodes); |
| 659 | } |
| 660 | } else { |
| 661 | this.processChildNodes( |
| 662 | item.node, stack, context, tensorMap, added, usedNodes); |
| 663 | } |
| 664 | } |
no test coverage detected