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

Method index_of

tensorflow/python/profiler/pprof_profiler.py:165–198  ·  view source on GitHub ↗

Returns index of the location, adding the location if needed. Args: file_path: (string) Path to file that makes the call. line_number: (integer) Call line number. called_function_name: (string) Function name of the function called at `file_path` and `line_number`.

(
      self, file_path, line_number, called_function_name, called_file_path,
      called_function_start_line)

Source from the content-addressed store, hash-verified

163 self._location_key_to_location = {}
164
165 def index_of(
166 self, file_path, line_number, called_function_name, called_file_path,
167 called_function_start_line):
168 """Returns index of the location, adding the location if needed.
169
170 Args:
171 file_path: (string) Path to file that makes the call.
172 line_number: (integer) Call line number.
173 called_function_name: (string) Function name of the function called at
174 `file_path` and `line_number`.
175 called_file_path: (string) Path to file where the called function is
176 defined.
177 called_function_start_line: (integer) Start line number of called
178 function definition in `called_file_path` file.
179
180 Returns:
181 Index of location.
182 """
183 location_key = (file_path, called_function_name, line_number)
184 if location_key in self._location_key_to_location:
185 location = self._location_key_to_location[location_key]
186 return location.id
187 else:
188 # Location indexes should start from 1
189 location_index = len(self._location_key_to_location) + 1
190 location = profile_pb2.Location()
191 location.id = location_index
192 self._location_key_to_location[location_key] = location
193
194 line = location.line.add()
195 line.function_id = self._functions.index_of(
196 called_file_path, called_function_name, called_function_start_line)
197 line.line = line_number
198 return location_index
199
200 def location_protos(self):
201 """Returns list of `profile_pb2.Location` protos."""

Callers

nothing calls this directly

Calls 2

addMethod · 0.45
index_ofMethod · 0.45

Tested by

no test coverage detected