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

Method add

tensorflow/python/profiler/pprof_profiler.py:223–251  ·  view source on GitHub ↗

Adds a sample data point. Args: datum: `ProfileDatum` to add a sample for. location_ids: List of numberic location ids for this sample.

(self, datum, location_ids)

Source from the content-addressed store, hash-verified

221 self._node_name_to_sample = {}
222
223 def add(self, datum, location_ids):
224 """Adds a sample data point.
225
226 Args:
227 datum: `ProfileDatum` to add a sample for.
228 location_ids: List of numberic location ids for this
229 sample.
230 """
231 node_name = datum.node_exec_stats.node_name
232 if node_name in self._node_name_to_sample:
233 sample = self._node_name_to_sample[node_name]
234 sample.location_id.extend(location_ids)
235 else:
236 sample = profile_pb2.Sample()
237 # Sample stores 3 values: count, all_time, op_time
238 sample.value.extend([0, 0, 0])
239
240 label = sample.label.add()
241 label.key = self._string_table.index_of('node_name')
242 label.str = self._string_table.index_of(node_name)
243 label = sample.label.add()
244 label.key = self._string_table.index_of('op_type')
245 label.str = self._string_table.index_of(datum.op_type)
246 self._node_name_to_sample[node_name] = sample
247 sample.value[0] += 1
248 sample.value[1] += datum.node_exec_stats.all_end_rel_micros
249 sample.value[2] += (
250 datum.node_exec_stats.op_end_rel_micros -
251 datum.node_exec_stats.op_start_rel_micros)
252
253 def get_sample_protos(self):
254 """Returns list of `Sample` protos for pprof profile."""

Callers 11

_get_pprof_protoMethod · 0.95
trace_next_stepMethod · 0.45
dump_next_stepMethod · 0.45
_should_traceMethod · 0.45
_get_logged_opsFunction · 0.45
testValidProfileMethod · 0.45
index_ofMethod · 0.45
testGradientGraphMethod · 0.45
_global_report_benchmarkFunction · 0.45
__new__Method · 0.45

Calls 3

extendMethod · 0.45
SampleMethod · 0.45
index_ofMethod · 0.45

Tested by 3

testValidProfileMethod · 0.36
testGradientGraphMethod · 0.36