tensorflow / profiler

A profiling and performance analysis tool for TensorFlow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TF.timeline JSON 'ts' field uses relative time in TF 2.x, whereas it used absolute time in TF 1.x

crlishka opened this issue · comments

With TF 1.x, we were able to convert the tensorflow.timeline JSON file to a form (CSV) that was usable in VTune, as documented in: https://software.intel.com/content/www/us/en/develop/articles/profiling-tensorflow-workloads-with-intel-vtune-amplifier.html. This was possible because the TF 1.x JSON format used an absolute time from the host server for the 'ts' (start time) field, as seen in this example traceEvents entry:
{ "ph": "X", "cat": "Op", "name": "_MklToTf", "pid": 3, "tid": 0, "ts": 1607035402039614, "dur": 3, "args": { "name": "Mkl2Tf/_51", "op": "_MklToTf", "input0": "adam_optimizer/gradients/conv2/add_grad/Reshape_1", "input1": "adam_optimizer/gradients/conv2/add_grad/Reshape_1:1" } }

With TF Profiler 2.x, it looks like the 'ts' field has become a relative time (relative to the start of the model run), at least when running on CPU:
{'pid': 49, 'tid': 3623876352, 'ts': 52335.771, 'name': 'gradient_tape/sequential/dense_1/MatMul:_MklMatMul', 'ph': 'X', 'dur': 5.139, 'args': {'group_id': '4'}}

Questions:

  • Was this change in the 'ts' format, from absolute (in TF 1.x) to relative (in TF 2.x) intentional?
  • If it was intentional, where in the TF profiling data can we get the absolute start time (i.e. the host server's time) of the profile run, to add to the relative time in the 'ts' field?

Thanks for your help! -- ChrisL

Yes, using relative time is the intended behavior in TF 2.x profiler. Note that the trace analysis in TF 2.x profiler is completely different from the TF 1.x profiler, so we won't expect the behavior to be the same.

To get the absolute time, I think you can try hacking this line:
https://github.com/tensorflow/tensorflow/blob/5855c1c8ae2d2b36bf9d6f906b717046bb4afb36/tensorflow/core/profiler/convert/post_process_single_host_xplane.cc#L48