Skip to content

Commit

Permalink
fix tvmrt and tvmcg fot latest tvm
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Jul 19, 2022
1 parent f896da1 commit 5aaeb13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions mlonmcu/flow/tvm/backend/tvmcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ class TVMCGBackend(TVMRTBackend):

def get_max_workspace_size_from_metadata(self, metadata):
max_workspace = 0
for op in metadata["memory"]["functions"]["operator_functions"]:
if "modules" in metadata:
temp = metadata["modules"]["default"]["memory"]
else:
# backwards compatibility
temp = metadata["memory"]
for op in temp["functions"]["operator_functions"]:
max_workspace = max(
max_workspace,
op["workspace"][0]["workspace_size_bytes"] if len(op["workspace"]) > 0 else 0,
Expand All @@ -65,7 +70,8 @@ def generate_code(self):
with open(mlf_path / "metadata.json") as handle:
metadata = json.load(handle)
tvmcg_exe = self.config["utvmcg.exe"]
graph_json_file = mlf_path / "executor-config" / "graph" / "graph.json"
# graph_json_file = mlf_path / "executor-config" / "graph" / "graph.json"
graph_json_file = mlf_path / "executor-config" / "graph" / "default.graph"
params_bin_file = mlf_path / "parameters" / "default.params"
max_workspace_size = self.get_max_workspace_size_from_metadata(metadata)
args = []
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/flow/tvm/backend/tvmrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_tvmc_compile_args(self, out):

def get_graph_and_params_from_mlf(self, path):
graph = None
with open(Path(path) / "executor-config" / "graph" / "graph.json", "r") as handle:
with open(Path(path) / "executor-config" / "graph" / "default.graph", "r") as handle:
graph = handle.read()
params = None
with open(Path(path) / "parameters" / "default.params", "rb") as handle:
Expand Down

0 comments on commit 5aaeb13

Please sign in to comment.