Skip to content

Commit

Permalink
followup for str2bool assertion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Jun 29, 2022
1 parent 19fd7e7 commit ffa2427
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 22 deletions.
24 changes: 16 additions & 8 deletions mlonmcu/feature/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,35 +887,40 @@ def __init__(self, features=None, config=None):

@property
def ic_enable(self):
return str2bool(self.config["ic_enable"])
value = self.config["ic_enable"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def ic_config(self):
return self.config["ic_config"]

@property
def dc_enable(self):
return str2bool(self.config["dc_enable"])
value = self.config["dc_enable"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def dc_config(self):
return self.config["dc_config"]

@property
def l2_enable(self):
return str2bool(self.config["l2_enable"])
value = self.config["l2_enable"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def l2_config(self):
return self.config["l2_config"]

@property
def log_misses(self):
return str2bool(self.config["log_misses"])
value = self.config["log_misses"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def detailed(self):
return str2bool(self.config["detailed"])
value = self.config["detailed"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def add_target_config(self, target, config):
assert target in ["spike"], f"Unsupported feature '{self.name}' for target '{target}'"
Expand Down Expand Up @@ -1049,15 +1054,18 @@ def riscv_gcc_install_dir(self):

@property
def verbose(self):
return str2bool(self.config["verbose"])
value = self.config["verbose"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def debug(self):
return str2bool(self.config["debug"])
value = self.config["debug"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def transport(self):
return str2bool(self.config["transport"])
value = self.config["transport"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def get_platform_config(self, platform):
assert platform == "microtvm", f"Unsupported feature '{self.name}' for platform '{platform}'"
Expand Down
3 changes: 2 additions & 1 deletion mlonmcu/flow/tflm/backend/tflmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class TFLMCBackend(TFLMBackend):

@property
def print_outputs(self):
return str2bool(self.config["print_outputs"])
value = self.config["print_outputs"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def __init__(self, features=None, config=None):
super().__init__(features=features, config=config)
Expand Down
3 changes: 2 additions & 1 deletion mlonmcu/flow/tvm/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def tvm_configs_dir(self):

@property
def print_outputs(self):
return str2bool(self.config["print_outputs"])
value = self.config["print_outputs"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def get_target_details(self):
ret = {}
Expand Down
6 changes: 4 additions & 2 deletions mlonmcu/models/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def __init__(self, features=None, config=None):

@property
def visualize_enable(self):
return str2bool(self.config["visualize_enable"])
value = self.config["visualize_enable"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def visualize_script(self):
Expand Down Expand Up @@ -307,7 +308,8 @@ def __init__(self, features=None, config=None):

@property
def visualize_graph(self):
return str2bool(self.config["visualize_graph"])
value = self.config["visualize_graph"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def relayviz_plotter(self):
Expand Down
9 changes: 6 additions & 3 deletions mlonmcu/platform/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,19 @@ def idf_exe(self):

@property
def use_idf_monitor(self):
return str2bool(self.config["use_idf_monitor"])
value = self.config["use_idf_monitor"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def wait_for_user(self):
return str2bool(self.config["wait_for_user"])
value = self.config["wait_for_user"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def flash_only(self):
# TODO: get rid of this
return str2bool(self.config["flash_only"])
value = self.config["flash_only"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def invoke_idf_exe(self, *args, **kwargs):
env = os.environ.copy()
Expand Down
6 changes: 4 additions & 2 deletions mlonmcu/platform/microtvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,17 @@ def print_top(self):

# @property
# def profile(self):
# return str2bool(self.config["profile"])
# value = self.config["profile"]
# return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def repeat(self):
return self.config["repeat"]

# @property
# def use_rpc(self):
# return str2bool(self.config["use_rpc"])
# value = self.config["use_rpc"]
# return str2bool(value) if not isinstance(value, (bool, int)) else value

# @property
# def rpc_key(self):
Expand Down
3 changes: 2 additions & 1 deletion mlonmcu/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def supports_monitor(self):

@property
def print_outputs(self):
return str2bool(self.config["print_outputs"])
value = self.config["print_outputs"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def process_features(self, features):
if features is None:
Expand Down
6 changes: 4 additions & 2 deletions mlonmcu/platform/tvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,17 @@ def print_top(self):

@property
def profile(self):
return str2bool(self.config["profile"])
value = self.config["profile"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def repeat(self):
return self.config["repeat"]

@property
def use_rpc(self):
return str2bool(self.config["use_rpc"])
value = self.config["use_rpc"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

@property
def rpc_key(self):
Expand Down
3 changes: 2 additions & 1 deletion mlonmcu/target/spike.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def spikepk_extra_args(self):

@property
def end_to_end_cycles(self):
return str2bool(self.config["end_to_end_cycles"])
value = self.config["end_to_end_cycles"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def exec(self, program, *args, cwd=os.getcwd(), **kwargs):
"""Use target to execute a executable with given arguments"""
Expand Down
3 changes: 2 additions & 1 deletion mlonmcu/target/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def __init__(

@property
def print_outputs(self):
return str2bool(self.config["print_outputs"])
value = self.config["print_outputs"]
return str2bool(value) if not isinstance(value, (bool, int)) else value

def __repr__(self):
return f"Target({self.name})"
Expand Down

0 comments on commit ffa2427

Please sign in to comment.