From 8a75b838897f6b172c90d716fecd2dc400035661 Mon Sep 17 00:00:00 2001 From: Hunter Nichols Date: Mon, 7 Dec 2020 14:36:01 -0800 Subject: [PATCH] Fixed input scaling bugs delay prediction model --- compiler/characterizer/lib.py | 7 +++++-- compiler/characterizer/linear_regression.py | 9 +++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/characterizer/lib.py b/compiler/characterizer/lib.py index 0204de62..948f8e47 100644 --- a/compiler/characterizer/lib.py +++ b/compiler/characterizer/lib.py @@ -585,11 +585,14 @@ class lib: def compute_delay(self): """Compute SRAM delays for current corner""" if self.use_model: + import math #FIXME: ML models only designed for delay. Cannot produce all values for Lib d = linear_regression() - model_inputs = [OPTS.num_words, + temp_wpr = 2.0 #OPTS not working right now + log_num_words = math.log(OPTS.num_words, 2) + model_inputs = [log_num_words, OPTS.word_size, - OPTS.words_per_row, + temp_wpr, self.sram.width * self.sram.height] char_results = d.get_prediction(model_inputs) diff --git a/compiler/characterizer/linear_regression.py b/compiler/characterizer/linear_regression.py index 897ad54b..511cd378 100644 --- a/compiler/characterizer/linear_regression.py +++ b/compiler/characterizer/linear_regression.py @@ -22,17 +22,14 @@ class linear_regression(): def __init__(self): self.model = None - def get_prediction(self, model_inputs): - - train_sets = [] - test_sets = [] + def get_prediction(self, model_inputs): file_path = data_dir +'/'+data_filename - scaled_inputs = np.asarray(scale_input_datapoint(model_inputs, data_dir)) + scaled_inputs = np.asarray([scale_input_datapoint(model_inputs, data_dir)]) features, labels = get_scaled_data(file_path, data_dir) self.train_model(features, labels) - scaled_pred = model_prediction(model_inputs) + scaled_pred = self.model_prediction(scaled_inputs) pred = unscale_data(scaled_pred.tolist(), data_dir) debug.info(1,"Unscaled Prediction = {}".format(pred)) return pred