Skip to content

Commit f6a8838

Browse files
authored
Update profile_utils.py
1 parent e4e4826 commit f6a8838

File tree

1 file changed

+0
-44
lines changed
  • AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_InferenceOptimization/scripts

1 file changed

+0
-44
lines changed

AI-and-Analytics/Features-and-Functionality/IntelTensorFlow_InferenceOptimization/scripts/profile_utils.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import os, fnmatch
77
import psutil
88
import ast
9-
import tensorflow.estimator
109
from tensorflow.python.training import training_util
1110
try:
1211
from git import Repo
@@ -64,49 +63,6 @@ def save_timeline(self, fname):
6463
self.many_runs_timeline.save(fname)
6564

6665

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-
11066
class TensorflowUtils:
11167

11268
def is_mkl_enabled(self):

0 commit comments

Comments
 (0)