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

Function compute_field_dict

tensorflow/python/framework/error_interpolation.py:288–338  ·  view source on GitHub ↗

Return a dictionary mapping interpolation tokens to values. Args: op: op.Operation object having a _traceback member. strip_file_prefix: The common path in the stacktrace. We remove the prefix from the file names. Returns: A dictionary mapping string tokens to string values. T

(op, strip_file_prefix="")

Source from the content-addressed store, hash-verified

286
287
288def compute_field_dict(op, strip_file_prefix=""):
289 """Return a dictionary mapping interpolation tokens to values.
290
291 Args:
292 op: op.Operation object having a _traceback member.
293 strip_file_prefix: The common path in the stacktrace. We remove the prefix
294 from the file names.
295
296 Returns:
297 A dictionary mapping string tokens to string values. The keys are shown
298 below along with example values.
299 {
300 "file": "tool_utils.py",
301 "line": "124",
302 "defined_at": " (defined at tool_utils.py:124)",
303 "colocations":
304 '''Node-device colocations active during op creation:
305 with tf.compat.v1.colocate_with(test_node_1): <test_1.py:27>
306 with tf.compat.v1.colocate_with(test_node_2): <test_2.py:38>''&#x27;
307 "devices":
308 '''Device assignments active during op 'foo&#x27; creation:
309 with tf.device(/cpu:0): <test_1.py:27>
310 with tf.device(some_func<foo.py, 123>): <test_2.py:38>''&#x27;
311 "devs_and_colocs": A concatenation of colocations and devices, e.g.
312 ''&#x27;Node-device colocations active during op creation:
313 with tf.compat.v1.colocate_with(test_node_1): <test_1.py:27>
314 with tf.compat.v1.colocate_with(test_node_2): <test_2.py:38>''&#x27;
315 Device assignments active during op 'foo' creation:
316 with tf.device(/cpu:0): <test_1.py:27>
317 with tf.device(some_func<foo.py, 123>): <test_2.py:38>''&#x27;
318 }
319 """
320 frame = _get_defining_frame_from_op(op)
321 filename = frame[tf_stack.TB_FILENAME]
322 if filename.startswith(strip_file_prefix):
323 filename = filename[len(strip_file_prefix):]
324 lineno = frame[tf_stack.TB_LINENO]
325 defined_at = " (defined at %s:%d)" % (filename, lineno)
326 colocation_summary = _compute_colocation_summary_from_op(op)
327 device_summary = _compute_device_assignment_summary_from_op(op)
328 combined_summary = "\n".join([colocation_summary, device_summary])
329
330 field_dict = {
331 "file": filename,
332 "line": lineno,
333 "defined_at": defined_at,
334 "colocations": colocation_summary,
335 "devices": device_summary,
336 "devs_and_colocs": combined_summary,
337 }
338 return field_dict
339
340
341def traceback_files_common_prefix(all_ops):

Callers 2

_build_error_messageFunction · 0.85
interpolateFunction · 0.85

Tested by

no test coverage detected