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

Method UndoAllDelegates

tensorflow/lite/core/subgraph.cc:1111–1145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1109}
1110
1111TfLiteStatus Subgraph::UndoAllDelegates() {
1112 // Return early if there is nothing to reset to.
1113 if (pre_delegation_execution_plan_.empty()) return kTfLiteOk;
1114
1115 // First free all delegate nodes.
1116 for (int execution_plan_index = 0;
1117 execution_plan_index < execution_plan_.size(); ++execution_plan_index) {
1118 int node_index = execution_plan_[execution_plan_index];
1119 TfLiteNode& node = nodes_and_registration_[node_index].first;
1120 if (node.delegate == nullptr) {
1121 continue;
1122 }
1123 CleanupNode(node_index);
1124 }
1125
1126 // Reset execution plan.
1127 execution_plan_ = pre_delegation_execution_plan_;
1128 pre_delegation_execution_plan_.clear();
1129
1130 // Delegate nodes are appended to nodes_and_registration_. Therefore,
1131 // cleanup nodes_and_registration_ to only contain nodes from
1132 // pre_delegation_execution_plan_.
1133 int max_retained_node_index = 0;
1134 for (int execution_plan_index = 0;
1135 execution_plan_index < execution_plan_.size(); ++execution_plan_index) {
1136 max_retained_node_index = std::max(max_retained_node_index,
1137 execution_plan_[execution_plan_index]);
1138 }
1139 nodes_and_registration_.resize(max_retained_node_index + 1);
1140 // After undoing delegates, the graph is uninvokable, but mutable.
1141 state_ = kStateUninvokable;
1142
1143 delegates_undone_ = true;
1144 return kTfLiteOk;
1145}
1146
1147TfLiteStatus Subgraph::RedoAllDelegates() {
1148 if (!delegates_undone_) return kTfLiteOk;

Callers 1

Calls 5

maxFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected