Skip to content

Commit

Permalink
tflmc related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Jun 29, 2022
1 parent 4db1fe7 commit 19fd7e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions mlonmcu/flow/tflm/backend/tflmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@ def __init__(self, features=None, config=None):
) # TODO: either make sure that ony one model is processed at a time or move the artifacts to the methods
# TODO: decide if artifacts should be handled by code (str) or file path or binary data

def generate_header(self):
upper_prefix = self.prefix.upper()
code = f"""
// This file is generated. Do not edit.
#ifndef {upper_prefix}_GEN_H
#define {upper_prefix}_GEN_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {{
#endif
void model_init();
void *model_input_ptr(int index);
size_t model_input_size(int index);
size_t model_inputs();
void model_invoke();
void *model_output_ptr(int index);
size_t model_output_size(int index);
size_t model_outputs();
#ifdef __cplusplus
}}
#endif
#endif // {upper_prefix}_GEN_H
"""
return code

def generate_code(self):
artifacts = []
assert self.model is not None
Expand All @@ -81,6 +111,9 @@ def generate_code(self):
with open(Path(tmpdirname) / filename, "r") as handle:
content = handle.read()
artifacts.append(Artifact(filename, content=content, fmt=ArtifactFormat.SOURCE))
header_content = self.generate_header()
header_artifact = Artifact(f"{self.prefix}.cc.h", content=header_content, fmt=ArtifactFormat.SOURCE)
artifacts.append(header_artifact)
stdout_artifact = Artifact("tflmc_out.log", content=out, fmt=ArtifactFormat.TEXT)
artifacts.append(stdout_artifact)

Expand Down
4 changes: 2 additions & 2 deletions resources/templates/tumeda.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ paths:
repos:
tensorflow: # TODO: rename to tflite-micro?
url: "[email protected]:de-tum-ei-eda-esl/tflite-micro.git"
ref: feature/tflmc_support
ref: feature/tflmc_support2
tflite_micro_compiler:
url: "[email protected]:philippvk/tflite_micro_compiler.git"
ref: philippvk_new
ref: philippvk_new2
tvm:
url: "[email protected]:rafzi/privtvm.git"
ref: moiopt
Expand Down

0 comments on commit 19fd7e7

Please sign in to comment.