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

Method SortParams

tensorflow/core/kernels/hexagon/graph_transferer.cc:240–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240void GraphTransferer::SortParams(const std::vector<string>& output_node_names) {
241 // TODO(satok): optimize complexity
242 std::unordered_map<int, GraphTransferNodeInputInfo*> input_map;
243 for (GraphTransferNodeInputInfo& input :
244 *graph_transfer_info_->mutable_node_input_info()) {
245 input_map.emplace(input.node_id(), &input);
246 }
247
248 // Setup dependency map placeholder
249 std::vector<int> output_node_ids;
250 std::unordered_map<int, std::unordered_set<int>> dependency_map;
251 for (const GraphTransferNodeInfo& params :
252 graph_transfer_info_->node_info()) {
253 const int node_id = params.node_id();
254 for (const string& output_node_name : output_node_names) {
255 if (params.name() == output_node_name) {
256 output_node_ids.emplace_back(node_id);
257 }
258 }
259
260 dependency_map.emplace(std::piecewise_construct, std::make_tuple(node_id),
261 std::make_tuple());
262 if (params.input_count() == 0) {
263 continue;
264 }
265 CHECK_EQ(input_map.count(node_id), 1);
266 for (const GraphTransferNodeInput& node_input :
267 input_map.at(node_id)->node_input()) {
268 dependency_map.at(node_id).emplace(node_input.node_id());
269 }
270 }
271
272 // Create dependency map traversed from output nodes
273 std::unordered_set<int> completed;
274 for (int output_node_id : output_node_ids) {
275 FillDependencyRec(output_node_id, dependency_map, completed);
276 }
277
278 std::sort(graph_transfer_info_->mutable_node_info()->begin(),
279 graph_transfer_info_->mutable_node_info()->end(),
280 TransferParamsComparator(dependency_map));
281}
282
283void GraphTransferer::EnableStrictCheckMode(const bool enable) {
284 strict_check_mode_ = enable;

Callers

nothing calls this directly

Calls 11

sortFunction · 0.85
node_infoMethod · 0.80
input_countMethod · 0.80
nameMethod · 0.65
emplaceMethod · 0.45
emplace_backMethod · 0.45
countMethod · 0.45
atMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected