Tuner: better formating
This commit is contained in:
@@ -15,6 +15,7 @@ from kivy.uix.settings import SettingsWithNoMenu
|
|||||||
import isaac as sc
|
import isaac as sc
|
||||||
import json
|
import json
|
||||||
import thread
|
import thread
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from tune.tune import Tuner
|
from tune.tune import Tuner
|
||||||
from tune.tools import metric_name_of
|
from tune.tools import metric_name_of
|
||||||
@@ -40,11 +41,16 @@ class LabelProgressBar:
|
|||||||
self.label = label
|
self.label = label
|
||||||
self.metric_name = metric_name
|
self.metric_name = metric_name
|
||||||
self.length = length
|
self.length = length
|
||||||
|
self.old_percent = 0
|
||||||
|
|
||||||
def set_prefix(self, prefix):
|
def set_prefix(self, prefix):
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
self.text_start = self.label.text
|
self.text_start = self.label.text
|
||||||
|
|
||||||
|
def set_finished(self):
|
||||||
|
self.old_percent = 0
|
||||||
|
self.label.text += '\n'
|
||||||
|
|
||||||
def update(self, i, total, x, y, complete=False):
|
def update(self, i, total, x, y, complete=False):
|
||||||
percent = float(i) / total
|
percent = float(i) / total
|
||||||
hashes = '#' * int(round(percent * self.length))
|
hashes = '#' * int(round(percent * self.length))
|
||||||
@@ -52,11 +58,12 @@ class LabelProgressBar:
|
|||||||
#Format of structures to print
|
#Format of structures to print
|
||||||
xformat = ','.join(map(str,map(int, x)))
|
xformat = ','.join(map(str,map(int, x)))
|
||||||
yformat = int(y)
|
yformat = int(y)
|
||||||
percentformat = int(round(percent * 100))
|
percent = int(round(percent * 100))
|
||||||
msg = (self.prefix.ljust(10) + ": [{0}] {1: >3}% [{2} " + self.metric_name + "] ({3})\n").format(hashes + spaces, percentformat, yformat, xformat)
|
msg = (self.prefix.ljust(10) + ": [{0}] {1: >3}% [{2} " + self.metric_name + "] ({3})").format(hashes + spaces, percent, yformat, xformat)
|
||||||
self.label.text = self.text_start + msg
|
if percent > self.old_percent:
|
||||||
#if complete:
|
sleep(.01)
|
||||||
# self.label.text += '\n'
|
self.label.text = self.text_start + msg
|
||||||
|
self.old_percent = percent
|
||||||
|
|
||||||
|
|
||||||
class IsaacScreen(Screen):
|
class IsaacScreen(Screen):
|
||||||
@@ -112,7 +119,7 @@ class IsaacApp(App):
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
operations = [('blas1', (sc.templates.axpy,)),
|
operations = [('blas1', (sc.templates.axpy,)),
|
||||||
('blas2', (sc.templates.ger, sc.templates.gemv_n, sc.templates.gemv_t)),
|
('blas2', (sc.templates.gemv_n, sc.templates.gemv_t)),
|
||||||
('blas3', (sc.templates.gemm_nn, sc.templates.gemm_tn, sc.templates.gemm_nt, sc.templates.gemm_tt))]
|
('blas3', (sc.templates.gemm_nn, sc.templates.gemm_tn, sc.templates.gemm_nt, sc.templates.gemm_tt))]
|
||||||
for opclass, optype in operations:
|
for opclass, optype in operations:
|
||||||
for op in optype:
|
for op in optype:
|
||||||
|
@@ -13,6 +13,7 @@ from numpy import cumsum
|
|||||||
|
|
||||||
import tools
|
import tools
|
||||||
from tools import profile_execution_failure
|
from tools import profile_execution_failure
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
fetch_types = [sc.templates.fetching_policy_type.FETCH_FROM_GLOBAL_CONTIGUOUS,
|
fetch_types = [sc.templates.fetching_policy_type.FETCH_FROM_GLOBAL_CONTIGUOUS,
|
||||||
sc.templates.fetching_policy_type.FETCH_FROM_GLOBAL_STRIDED,
|
sc.templates.fetching_policy_type.FETCH_FROM_GLOBAL_STRIDED,
|
||||||
|
@@ -129,12 +129,13 @@ class Tuner:
|
|||||||
|
|
||||||
##### Exploration #####
|
##### Exploration #####
|
||||||
for idx, x in enumerate(sizes):
|
for idx, x in enumerate(sizes):
|
||||||
|
|
||||||
self.progress_bar.set_prefix(', '.join(map(str, x)))
|
self.progress_bar.set_prefix(', '.join(map(str, x)))
|
||||||
#Skip if saved
|
#Skip if saved
|
||||||
if x in X:
|
if x in X:
|
||||||
row = Y[X.index(x)]
|
row = Y[X.index(x)]
|
||||||
self.progress_bar.update(1, 1, profiles[argmax(row)], max(row), complete=True)
|
self.progress_bar.update(1, 1, profiles[argmax(row)], max(row))
|
||||||
|
self.progress_bar.set_finished()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#Check if the current best prediction is not a local optimum
|
#Check if the current best prediction is not a local optimum
|
||||||
@@ -197,7 +198,8 @@ class Tuner:
|
|||||||
#print performance info in case no tuning was done
|
#print performance info in case no tuning was done
|
||||||
if not retune:
|
if not retune:
|
||||||
row = Y[X.index(x)]
|
row = Y[X.index(x)]
|
||||||
self.progress_bar.update(1, 1, profiles[argmax(row)], max(row), complete=True)
|
self.progress_bar.update(1, 1, profiles[argmax(row)], max(row))
|
||||||
|
self.progress_bar.set_finished()
|
||||||
|
|
||||||
|
|
||||||
##### Exportation #####
|
##### Exportation #####
|
||||||
|
@@ -45,6 +45,9 @@ class ProgressBar:
|
|||||||
|
|
||||||
def set_prefix(self, prefix):
|
def set_prefix(self, prefix):
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
|
|
||||||
|
def set_finished(self):
|
||||||
|
sys.stdout.write("\n")
|
||||||
|
|
||||||
def update(self, i, total, x, y, complete=False):
|
def update(self, i, total, x, y, complete=False):
|
||||||
percent = float(i) / total
|
percent = float(i) / total
|
||||||
@@ -55,8 +58,6 @@ class ProgressBar:
|
|||||||
yformat = int(y)
|
yformat = int(y)
|
||||||
percentformat = int(round(percent * 100))
|
percentformat = int(round(percent * 100))
|
||||||
sys.stdout.write(("\r" + self.prefix.ljust(10) + ": [{0}] {1: >3}% [{2} " + self.metric_name + "] ({3})").format(hashes + spaces, percentformat, yformat, xformat))
|
sys.stdout.write(("\r" + self.prefix.ljust(10) + ": [{0}] {1: >3}% [{2} " + self.metric_name + "] ({3})").format(hashes + spaces, percentformat, yformat, xformat))
|
||||||
if complete:
|
|
||||||
sys.stdout.write("\n")
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user