MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / restore_program_cache_from_file

Function restore_program_cache_from_file

src/runtime/CL/Utils.cpp:35–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33namespace arm_compute
34{
35void restore_program_cache_from_file(const std::string &filename)
36{
37 std::ifstream cache_file(filename, std::ios::binary);
38 if (cache_file.is_open())
39 {
40 if (!CLScheduler::get().is_initialised())
41 {
42 arm_compute::CLScheduler::get().default_init();
43 }
44
45 while (!cache_file.eof())
46 {
47 size_t name_len = 0;
48 size_t binary_len = 0;
49 cache_file.read(reinterpret_cast<char *>(&name_len), sizeof(size_t));
50 cache_file.read(reinterpret_cast<char *>(&binary_len), sizeof(size_t));
51 if (name_len == 0 || binary_len == 0)
52 {
53 break;
54 }
55 std::vector<char> tmp(name_len);
56 std::vector<unsigned char> binary(binary_len);
57 std::string name;
58 cache_file.read(tmp.data(), name_len);
59 name.assign(tmp.data(), name_len);
60 tmp.resize(binary_len);
61 cache_file.read(reinterpret_cast<char *>(binary.data()), binary_len);
62 cl::Context context = arm_compute::CLScheduler::get().context();
63 cl::Program::Binaries binaries{binary};
64 std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
65 cl::Program program(context, devices, binaries);
66 program.build();
67 CLKernelLibrary::get().add_built_program(name, program);
68 }
69 cache_file.close();
70 }
71}
72
73void save_program_cache_to_file(const std::string &filename)
74{

Callers 3

do_setupMethod · 0.85
do_setupMethod · 0.85
do_setupMethod · 0.85

Calls 10

is_initialisedMethod · 0.80
default_initMethod · 0.80
readMethod · 0.80
contextMethod · 0.80
is_openMethod · 0.45
dataMethod · 0.45
resizeMethod · 0.45
buildMethod · 0.45
add_built_programMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected