MCPcopy Create free account
hub / github.com/XiaoMi/mace / gen_micro_source_from_array

Method gen_micro_source_from_array

tools/python/micro/micro_codegen.py:62–78  ·  view source on GitHub ↗
(self, model_tag, embed_data,
                                    jinja_file_name, output_path)

Source from the content-addressed store, hash-verified

60 f.write(source)
61
62 def gen_micro_source_from_array(self, model_tag, embed_data,
63 jinja_file_name, output_path):
64 cwd = os.path.dirname(__file__)
65 j2_env = Environment(loader=FileSystemLoader(
66 cwd), trim_blocks=True, keep_trailing_newline=True)
67
68 template_name = JINJA2_DIR + jinja_file_name
69
70 hex_bytes_string = ", ".join(map(hex, embed_data))
71
72 source = j2_env.get_template(template_name).render(
73 model_tag=model_tag,
74 hex_bytes_string=hex_bytes_string,
75 data_size=len(embed_data),
76 )
77 with open(output_path, "w") as f:
78 f.write(source)
79
80 def gen_net_def_data(self, model_tag, model_def_data, output_path):
81 embed_data = np.frombuffer(model_def_data, dtype=np.uint8)

Callers 3

gen_net_def_dataMethod · 0.95
gen_graph_dataMethod · 0.95
gen_model_dataMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected