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

Function MakeBindingFunc

tensorflow/lite/delegates/gpu/gl/runtime.cc:145–179  ·  view source on GitHub ↗

Looks up an object with the given id. If found, makes a binding function.

Source from the content-addressed store, hash-verified

143
144// Looks up an object with the given id. If found, makes a binding function.
145Status MakeBindingFunc(const Object& object, uint32_t id,
146 const ObjectManager& objects,
147 std::function<Status()>* binding_func) {
148 const uint32_t binding = object.binding;
149 switch (object.object_type) {
150 case ObjectType::BUFFER: {
151 auto ptr = objects.FindBuffer(id);
152 if (!ptr) {
153 return NotFoundError(absl::StrCat("Buffer ", id, " is not found"));
154 }
155
156 // Validate buffer.
157 size_t size_in_bytes = ByteSizeOf(object);
158 // TODO(akulik): make comparison != instead of <
159 if (ptr->bytes_size() < size_in_bytes) {
160 return FailedPreconditionError(
161 absl::StrCat("Buffer ", id, " size in bytes ", ptr->bytes_size(),
162 " < requested size_in_bytes ", size_in_bytes));
163 }
164 *binding_func = [=]() { return ptr->BindToIndex(binding); };
165 break;
166 }
167 case ObjectType::TEXTURE: {
168 auto ptr = objects.FindTexture(id);
169 if (!ptr) {
170 return NotFoundError(absl::StrCat("Texture ", id, " is not found"));
171 }
172 *binding_func = [=]() { return ptr->BindAsReadWriteImage(binding); };
173 break;
174 }
175 case ObjectType::UNKNOWN:
176 return InvalidArgumentError("Unknown object type");
177 }
178 return OkStatus();
179}
180
181} // namespace
182

Callers 2

AddProgramMethod · 0.85
PrepareForExecutionMethod · 0.85

Calls 11

OkStatusFunction · 0.85
FindBufferMethod · 0.80
BindToIndexMethod · 0.80
FindTextureMethod · 0.80
BindAsReadWriteImageMethod · 0.80
ByteSizeOfFunction · 0.70
NotFoundErrorFunction · 0.50
StrCatFunction · 0.50
FailedPreconditionErrorFunction · 0.50
InvalidArgumentErrorFunction · 0.50
bytes_sizeMethod · 0.45

Tested by

no test coverage detected