Skip to content

Commit

Permalink
Expose temporary NPY files created during profiling to user by giving…
Browse files Browse the repository at this point in the history
… the control to keep or delete them and specifying a path

Signed-off-by: Risbud, Sumedh <sumedh.risbud@intel.com>
  • Loading branch information
srrisbud committed Jan 26, 2024
1 parent a00d589 commit f97c96d
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/lava/lib/optimization/solvers/generic/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ class SolverConfig:
probe_energy: bool
A boolean flag to request time profiling, available only on "Loihi2"
backend.
probe_activity: bool
A boolean flag to request activity profiling, available only on
"Loihi2". Activity profiling entails reading the on-chip activity
counters, which record number of synaptic operations, number of
neuron updates, etc.
keep_temp_probe_data: bool
A boolean flag to keep temporary probe data for profiling.
Default is False.
temp_probe_data_dir: str
Path to the directory to save temporary probe data.
The time-stamp at the moment of creation of this directory is
appended to the name of the directory. Default is None, in which
case, Python's `tempfile.TemporaryDirectory()` function is used.
log_level: int
Select log verbosity (40: default, 20: verbose).
folded_compilation: bool
Expand All @@ -194,6 +207,9 @@ class SolverConfig:
probe_state: bool = False
probe_time: bool = False
probe_energy: bool = False
probe_activity: bool = False
keep_temp_probe_data: bool = False
temp_probe_data_dir: str = None
log_level: int = 40
folded_compilation: bool = False

Expand Down Expand Up @@ -512,12 +528,22 @@ def _get_run_config(
raise NotImplementedError(str(backend) + BACKEND_MSG)

def _prepare_profiler(self, config: SolverConfig, run_cfg) -> None:
if config.probe_time or config.probe_energy:
if config.probe_time or config.probe_energy or config.probe_activity:
self._profiler = Profiler.init(run_cfg)
if config.probe_time:
self._profiler.execution_time_probe(num_steps=config.timeout)
self._profiler.execution_time_probe(
num_steps=config.timeout,
keep_tmp_dir=config.keep_temp_probe_data,
tmp_dir_path=config.temp_probe_data_dir)
if config.probe_energy:
self._profiler.energy_probe(num_steps=config.timeout)
self._profiler.energy_probe(
num_steps=config.timeout,
keep_tmp_dir = config.keep_temp_probe_data,
tmp_dir_path = config.temp_probe_data_dir)
if config.probe_activity:
self._profiler.activity_probe(
keep_tmp_dir=config.keep_temp_probe_data,
tmp_dir_path=config.temp_probe_data_dir)
else:
self._profiler = None

Expand Down

0 comments on commit f97c96d

Please sign in to comment.