GeezerVison is showing github.com — Better comparison if we failed the speed test or not. · zencoding/DeepLearningTutorials@53f7710
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: code/test.py +12-3Lines changed: 12 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -185,11 +185,20 @@ def do_tests(): |
185 | 185 | print >> sys.stderr, 'float32/gpu',float32_times/gpu_times |
186 | 186 | print >> sys.stderr, 'expected float32/gpu',expected_times_32/gpu_times |
187 | 187 |
|
| 188 | + def compare(x, y): |
| 189 | + ratio = x / y |
| 190 | + # If there is more then 5% difference between the expected |
| 191 | + # time and the real time, we consider this an error. |
| 192 | + return sum((ratio < 0.95) + (ratio > 1.05)) |
| 193 | + |
188 | 194 | if do_float64: |
189 | | - print >> sys.stderr, 'speed_failure_float64='+str(sum((expected_times_64/float64_times)>0.95)) |
| 195 | + err = compare(expected_times_64, float64_times) |
| 196 | + print >> sys.stderr, 'speed_failure_float64=' + str(err) |
190 | 197 | if do_float32: |
191 | | - print >> sys.stderr, 'speed_failure_float32='+str(sum((expected_times_32/float32_times)>0.95)) |
| 198 | + err = compare(expected_times_32, float32_times) |
| 199 | + print >> sys.stderr, 'speed_failure_float32=' + str(err) |
192 | 200 | if do_gpu: |
193 | | - print >> sys.stderr, 'speed_failure_gpu='+str(sum((expected_times_gpu/gpu_times)>0.95)) |
| 201 | + err = compare(expected_times_gpu, gpu_times) |
| 202 | + print >> sys.stderr, 'speed_failure_gpu=' + str(err) |
194 | 203 |
|
195 | 204 | assert not numpy.isnan(gpu_times).any() |