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

Method GetIndex

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

Returns the index of a function. If not found, adds a function proto and returns the function index.

Source from the content-addressed store, hash-verified

102 // Returns the index of a function. If not found, adds a function proto
103 // and returns the function index.
104 uint64 GetIndex(const string& file_path, const string& func_name,
105 uint64 func_start_line) {
106 auto key = std::tuple<string, string, uint64>(file_path, func_name,
107 func_start_line);
108 auto idx = function_table_.find(key);
109 if (idx != function_table_.end()) {
110 return idx->second.id();
111 }
112 pprof::Function* func_pb = &function_table_[key];
113 // function index should start from 1.
114 func_pb->set_id(function_table_.size());
115
116 string file_base(io::Basename(file_path));
117 file_base = file_base.substr(0, file_base.find_last_of("."));
118 func_pb->set_name(
119 string_table_->GetIndex(strings::StrCat(file_base, ":", func_name)));
120 func_pb->set_filename(string_table_->GetIndex(file_path));
121 func_pb->set_start_line(func_start_line);
122 return func_pb->id();
123 }
124
125 const std::map<std::tuple<string, string, uint64>, pprof::Function>&
126 functions() const {

Callers

nothing calls this directly

Calls 8

BasenameFunction · 0.85
StrCatFunction · 0.50
findMethod · 0.45
endMethod · 0.45
idMethod · 0.45
sizeMethod · 0.45
set_nameMethod · 0.45
GetIndexMethod · 0.45

Tested by

no test coverage detected