Skip to content

Commit

Permalink
fix negative value of computation time when stdev exists (#233)
Browse files Browse the repository at this point in the history
Due to the nature of normal random equation, the value generated can be
negative.

Enforcing it to be positive using `abs` will fix the issue
  • Loading branch information
rayandrew authored Oct 16, 2024
1 parent 05d67d1 commit b95fb26
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dlio_benchmark/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _eval(self, epoch):
eval_time = 0.0
if self.eval_time > 0:
if self.eval_time_stdev > 0:
eval_time = random.normal(self.eval_time, self.eval_time_stdev)
eval_time = abs(random.normal(self.eval_time, self.eval_time_stdev))
else:
eval_time = self.eval_time
self.framework.compute(batch, epoch, step, eval_time)
Expand Down Expand Up @@ -265,7 +265,7 @@ def _train(self, epoch):
if self.computation_time > 0:
self.framework.trace_object("Train", overall_step, 1)
if self.computation_time_stdev > 0:
computation_time = random.normal(self.computation_time, self.computation_time_stdev)
computation_time = abs(random.normal(self.computation_time, self.computation_time_stdev))
else:
computation_time = self.computation_time
self.framework.compute(batch, epoch, block_step, computation_time)
Expand Down

0 comments on commit b95fb26

Please sign in to comment.