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

Method profile

tensorflow/python/profiler/pprof_profiler.py:274–301  ·  view source on GitHub ↗

Generates pprof profiles. Returns: Dictionary mapping from device name to proto in `profile_pb2.Profile` format.

(self)

Source from the content-addressed store, hash-verified

272 self._locations = Locations(self._functions)
273
274 def profile(self):
275 """Generates pprof profiles.
276
277 Returns:
278 Dictionary mapping from device name to proto in `profile_pb2.Profile`
279 format.
280 """
281 profiles = {}
282 data_generator_func = self._get_profile_data_generator()
283 for device_index, device_stats in enumerate(
284 self._run_metadata.step_stats.dev_stats):
285 # Create profile
286 pprof_proto = self._get_pprof_proto(data_generator_func(device_stats))
287 if not pprof_proto.sample:
288 print(
289 'Not enough data to create profile for device %s. Did you pass '
290 'RunMetadata to session.run call?' % device_stats.device)
291 continue
292 # Add device name comment
293 device_count = len(self._run_metadata.step_stats.dev_stats)
294 device_description = (
295 'Device %d of %d: %s' %
296 (device_index + 1, device_count, device_stats.device))
297 device_description_str_index = self._string_table.next_index()
298 pprof_proto.string_table.append(device_description)
299 pprof_proto.comment.append(device_description_str_index)
300 profiles[device_stats.device] = pprof_proto
301 return profiles
302
303 def _get_pprof_proto(self, profile_datum_generator):
304 """Returns profile data in pprof proto format.

Callers 15

_model_rf_and_flopsFunction · 0.80
testProfileBasicMethod · 0.80
testDataEmptyMethod · 0.80
testRunMetadataEmptyMethod · 0.80
testValidProfileMethod · 0.80
get_profilesFunction · 0.80
testDumpToFileMethod · 0.80
testSelectEverythingMethod · 0.80
testSimpleCodeViewMethod · 0.80
testTimelineMethod · 0.80
testOpViewMethod · 0.80

Calls 4

_get_pprof_protoMethod · 0.95
next_indexMethod · 0.45
appendMethod · 0.45

Tested by 15

testProfileBasicMethod · 0.64
testDataEmptyMethod · 0.64
testRunMetadataEmptyMethod · 0.64
testValidProfileMethod · 0.64
testDumpToFileMethod · 0.64
testSelectEverythingMethod · 0.64
testSimpleCodeViewMethod · 0.64
testTimelineMethod · 0.64
testOpViewMethod · 0.64
pprof_test_helperMethod · 0.64
testMinOptionMethod · 0.64