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

Function generate_opencl_code

mace/python/tools/opencl_binary_codegen.py:25–44  ·  view source on GitHub ↗
(binary_file_name, load_func_name, size_func_name,
                         output_path)

Source from the content-addressed store, hash-verified

23
24
25def generate_opencl_code(binary_file_name, load_func_name, size_func_name,
26 output_path):
27 binary_array = []
28 if os.path.exists(binary_file_name):
29 with open(binary_file_name, 'rb') as f:
30 binary_array = np.fromfile(f, dtype=np.uint8)
31
32 cwd = os.path.dirname(__file__)
33 env = jinja2.Environment(
34 loader=jinja2.FileSystemLoader(cwd))
35 content = env.get_template('file_binary.cc.jinja2').render(
36 data=binary_array,
37 data_size=len(binary_array),
38 load_func_name=load_func_name,
39 size_func_name=size_func_name)
40
41 if os.path.isfile(output_path):
42 os.remove(output_path)
43 with open(output_path, "w") as w_file:
44 w_file.write(content)
45
46
47def parse_args():

Callers 2

gen_opencl_binary_cppsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected