MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / AddSerializedCache

Method AddSerializedCache

tensorflow/lite/delegates/gpu/cl/program_cache.cc:86–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86Status ProgramCache::AddSerializedCache(
87 const CLContext& context, const CLDevice& device,
88 absl::Span<const uint8_t> serialized_cache) {
89 flatbuffers::Verifier verifier(serialized_cache.data(),
90 serialized_cache.size());
91 if (!data::VerifyCompiledCacheBuffer(verifier)) {
92 return InvalidArgumentError("Serialized model is corrupted.");
93 }
94
95 auto model = data::GetCompiledCache(serialized_cache.data());
96 std::string platform_version(model->driver_version()->c_str(),
97 model->driver_version()->size());
98
99 if (device.GetPlatformVersion() != platform_version) {
100 return InvalidArgumentError(
101 "OpenCL driver changed, cache invalid, should be regenerated");
102 }
103
104 use_fingerprints_ = true;
105
106 for (auto serialized_program : *model->programs()) {
107 ProgramDescriptor desc(serialized_program->fingerprint());
108 CLProgram program;
109 RETURN_IF_ERROR(CreateCLProgramFromBinary(
110 context, device,
111 absl::MakeSpan(serialized_program->binary()->data(),
112 serialized_program->binary()->size()),
113 &program));
114 auto it = programs_.find(desc);
115 if (it == programs_.end()) {
116 programs_.insert(std::make_pair(std::move(desc), std::move(program)));
117 }
118 }
119 return OkStatus();
120}
121
122Status ProgramCache::GetSerializedCache(
123 const CLDevice& device, std::vector<uint8_t>* serialized_cache) const {

Callers 1

NewInferenceBuilderMethod · 0.80

Calls 10

OkStatusFunction · 0.85
c_strMethod · 0.80
GetPlatformVersionMethod · 0.80
InvalidArgumentErrorFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected