(binary_file_name, load_func_name, size_func_name,
output_path)
| 23 | |
| 24 | |
| 25 | def 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 | |
| 47 | def parse_args(): |
no outgoing calls
no test coverage detected