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

Method Build

tensorflow/core/profiler/internal/tfprof_code.cc:319–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317
318 private:
319 void Build(pprof::Profile* profile_pb) {
320 string sample_type_description = "count";
321 auto sample_type = profile_pb->mutable_sample_type()->Add();
322 sample_type->set_type(string_table_.GetIndex(sample_type_description));
323 sample_type->set_unit(string_table_.GetIndex("count"));
324
325 string type = *opts_->select.begin();
326 sample_type_description = type;
327 sample_type = profile_pb->mutable_sample_type()->Add();
328 sample_type->set_type(string_table_.GetIndex(sample_type_description));
329 if (type == kShown[1] || type == kShown[9] || type == kShown[10]) {
330 sample_type->set_unit(string_table_.GetIndex("microseconds"));
331 if (type == kShown[1]) {
332 profile_pb->mutable_comment()->Add(string_table_.GetIndex(
333 "Sum of accelerator execution time and cpu execution time."));
334 } else if (type == kShown[9]) {
335 profile_pb->mutable_comment()->Add(
336 string_table_.GetIndex("Accelerator execution time."));
337 } else if (type == kShown[10]) {
338 profile_pb->mutable_comment()->Add(
339 string_table_.GetIndex("CPU execution time."));
340 }
341 } else if (type == kShown[0]) {
342 sample_type->set_unit(string_table_.GetIndex("bytes"));
343 profile_pb->mutable_comment()->Add(
344 string_table_.GetIndex("Sum of operation total memory requests, "
345 "excluding deallocations."));
346 } else if (type == kShown[11]) {
347 sample_type->set_unit(string_table_.GetIndex("bytes"));
348 profile_pb->mutable_comment()->Add(
349 string_table_.GetIndex("Sum of operation peak memory usage."));
350 } else if (type == kShown[12]) {
351 sample_type->set_unit(string_table_.GetIndex("bytes"));
352 profile_pb->mutable_comment()->Add(string_table_.GetIndex(
353 "Sum of operation allocated memory after finish."));
354 } else if (type == kShown[13]) {
355 sample_type->set_unit(string_table_.GetIndex("bytes"));
356 profile_pb->mutable_comment()->Add(
357 string_table_.GetIndex("Sum of operation output size."));
358 } else if (type == kShown[2]) {
359 sample_type->set_unit(string_table_.GetIndex("count"));
360 profile_pb->mutable_comment()->Add(
361 string_table_.GetIndex("Model parameters."));
362 } else if (type == kShown[3]) {
363 sample_type->set_unit(string_table_.GetIndex("count"));
364 profile_pb->mutable_comment()->Add(string_table_.GetIndex(
365 "Model float operations (Only available if defined)."));
366 } else {
367 fprintf(stderr, "pprof doesn't support selecting: %s\n", type.c_str());
368 }
369
370 for (const string& str : string_table_.strings()) {
371 *profile_pb->mutable_string_table()->Add() = str;
372 }
373 for (const auto& sample_it : samples_->samples()) {
374 // TODO(xpan): Consider swap.
375 profile_pb->mutable_sample()->Add()->MergeFrom(sample_it.second);
376 }

Callers

nothing calls this directly

Calls 5

c_strMethod · 0.80
AddMethod · 0.45
GetIndexMethod · 0.45
beginMethod · 0.45
functionsMethod · 0.45

Tested by

no test coverage detected