blob: f8e2d9fe681b279e350d7831321f118f8181c989 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "tensorflow/core/graph/costutil.h"
#include "tensorflow/core/graph/algorithm.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/graph/costmodel.h"
namespace tensorflow {
std::vector<int64> LongestOutgoingPathCost(const Graph& graph,
const CostModel& cm) {
std::vector<int64> result(graph.num_node_ids());
DFS(graph, nullptr, [&result, &cm](Node* n) {
int64 max_child = 0;
for (const Node* out : n->out_nodes()) {
max_child = std::max(max_child, result[out->id()]);
}
result[n->id()] = max_child + (n->IsOp() ? cm.TimeEstimate(n).value() : 0);
});
return result;
}
} // namespace tensorflow
|