|
6 | 6 | import os, fnmatch |
7 | 7 | import psutil |
8 | 8 | import ast |
9 | | -import tensorflow.estimator |
10 | 9 | from tensorflow.python.training import training_util |
11 | 10 | try: |
12 | 11 | from git import Repo |
@@ -64,49 +63,6 @@ def save_timeline(self, fname): |
64 | 63 | self.many_runs_timeline.save(fname) |
65 | 64 |
|
66 | 65 |
|
67 | | -class tfProfileHook(tf.estimator.ProfilerHook): |
68 | | - def __init__(self, save_steps=None, save_secs=None, output_dir="", json_fname="", timeline_count=10): |
69 | | - self._output_tag = "blah-{}" |
70 | | - self._output_dir = output_dir |
71 | | - self._timer = tf.estimator.SecondOrStepTimer(every_secs=save_secs, |
72 | | - every_steps=save_steps) |
73 | | - self._atomic_counter = 0 |
74 | | - self.many_runs_timeline = TimeLiner() |
75 | | - self.timeline_count = timeline_count |
76 | | - import os |
77 | | - ProfileUtilsRoot = os.environ['ProfileUtilsRoot'] |
78 | | - self.json_fname = ProfileUtilsRoot + "/../" + json_fname |
79 | | - if output_dir == "": |
80 | | - output_dir = ProfileUtilsRoot + "/../" |
81 | | - |
82 | | - def begin(self): |
83 | | - self._next_step = None |
84 | | - self._global_step_tensor = training_util.get_global_step() |
85 | | - |
86 | | - if self._global_step_tensor is None: |
87 | | - raise RuntimeError("Global step should be created to use ProfilerHook.") |
88 | | - |
89 | | - def before_run(self, run_context): |
90 | | - self._request_summary = (self._next_step is None or self._timer.should_trigger_for_step(self._next_step)) |
91 | | - requests = {} |
92 | | - opts = tf.compat.v1.RunOptions(trace_level=tf.compat.v1.RunOptions.FULL_TRACE) |
93 | | - return tf.estimator.SessionRunArgs(requests, options=opts) |
94 | | - |
95 | | - def after_run(self, run_context, run_values): |
96 | | - |
97 | | - global_step = self._atomic_counter + 1 |
98 | | - self._atomic_counter = self._atomic_counter + 1 |
99 | | - self._next_step = global_step + 1 |
100 | | - |
101 | | - self.many_runs_timeline.update_timeline_from_runmeta(run_values.run_metadata) |
102 | | - if self._atomic_counter == self.timeline_count: |
103 | | - self.many_runs_timeline.save(self.json_fname) |
104 | | - |
105 | | - def end(self, session): |
106 | | - if self._atomic_counter < self.timeline_count: |
107 | | - self.many_runs_timeline.save(self.json_fname) |
108 | | - |
109 | | - |
110 | 66 | class TensorflowUtils: |
111 | 67 |
|
112 | 68 | def is_mkl_enabled(self): |
|
0 commit comments