MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RemovePrecedingNode

Function RemovePrecedingNode

tensorflow/lite/delegates/gpu/common/model.h:479–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477// to_remove inputs.
478template <typename TensorT>
479Status RemovePrecedingNode(Graph<TensorT>* graph, const Node* to_remove,
480 const Node* to_keep) {
481 // Make sure all outputs from to_remove are consumed by to_keep.
482 for (auto output : graph->FindOutputs(to_remove->id)) {
483 auto consumers = graph->FindConsumers(output->id);
484 if (consumers.size() > 1 ||
485 (consumers.size() == 1 && consumers[0] != to_keep)) {
486 return InvalidArgumentError(
487 "Output from to_remove node has other consumers");
488 }
489 }
490
491 // Update all references
492 for (auto input : graph->FindInputs(to_remove->id)) {
493 RETURN_IF_ERROR(graph->AddConsumer(to_keep->id, input->id));
494 }
495 for (auto output : graph->FindOutputs(to_remove->id)) {
496 RETURN_IF_ERROR(graph->DeleteValue(output->id));
497 }
498 return graph->DeleteNode(to_remove->id);
499}
500
501// Removes to_remove node that follows to_keep node only if to_remove has inputs
502// that are produced by to_keep. to_keep inherits all to_remove inputs.

Callers 6

ApplyToNodesSequenceMethod · 0.85
ApplyToNodeMethod · 0.85
ApplyToNodesSequenceMethod · 0.85
ApplyToNodesSequenceMethod · 0.85
ApplyToNodesSequenceMethod · 0.85
ApplyToNodeMethod · 0.85

Calls 8

FindOutputsMethod · 0.80
FindConsumersMethod · 0.80
FindInputsMethod · 0.80
AddConsumerMethod · 0.80
DeleteValueMethod · 0.80
DeleteNodeMethod · 0.80
InvalidArgumentErrorFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected