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

Method AddRunMeta

tensorflow/core/profiler/internal/tfprof_stats.cc:264–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264void TFStats::AddRunMeta(int64 step, std::unique_ptr<RunMetadata> run_meta) {
265 if (!run_meta || !run_meta->has_step_stats()) {
266 fprintf(stderr, "Invalid RunMetadata for step %lld\n", step);
267 return;
268 }
269 if (steps_.find(step) == steps_.end()) {
270 steps_.insert(step);
271 }
272 steps_.insert(step);
273
274 bool has_gpu_scheduling = false;
275 bool has_gpu_stream = false;
276
277 for (const auto& dev_stat : run_meta->step_stats().dev_stats()) {
278 string dev = absl::AsciiStrToLower(dev_stat.device());
279 if (IsPlacedOnAccelerator(dev)) {
280 has_gpu_scheduling = true;
281 if (CountAsAcceleratorTime(dev)) {
282 has_gpu_stream = true;
283 }
284 }
285 for (const NodeExecStats& node_stat : dev_stat.node_stats()) {
286 string name = node_stat.node_name();
287 // Sometimes the node_name is suffixed with unnecessary information.
288 auto split_pos = node_stat.node_name().find(":");
289 if (split_pos != node_stat.node_name().npos) {
290 name = node_stat.node_name().substr(0, split_pos);
291 }
292 auto node = nodes_map_.find(name);
293 if (node == nodes_map_.end()) {
294 NodeDef def;
295 if (CreateRunMetadataNode(name, &def)) {
296 size_t num_nodes = nodes_map_.size();
297 nodes_map_[name] = std::unique_ptr<TFGraphNode>(
298 new TFGraphNode(&def, num_nodes, &nodes_map_));
299 nodes_map_.at(name)->AddStepStat(step, dev_stat.device(), node_stat);
300 }
301 } else {
302 covered_nodes_.insert(node->second->id());
303 node->second->AddStepStat(step, dev_stat.device(), node_stat);
304 }
305 }
306 }
307
308 if (has_gpu_scheduling && !has_gpu_stream) {
309 miss_accelerator_stream_ = true;
310 }
311}
312
313string TFStats::MaybeReportMissingTrace() const {
314 string report = "";

Callers 3

RunFunction · 0.80
AddStepFunction · 0.80
AddStepMethod · 0.80

Calls 12

IsPlacedOnAcceleratorFunction · 0.85
CountAsAcceleratorTimeFunction · 0.85
CreateRunMetadataNodeFunction · 0.85
AddStepStatMethod · 0.80
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
deviceMethod · 0.45
node_nameMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected