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

Function ApplyBuffersAssignment

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

Source from the content-addressed store, hash-verified

426}
427
428Status ApplyBuffersAssignment(
429 const ObjectsAssignment<size_t>& assignment,
430 const std::vector<size_t>& global_ref_to_usage_rec,
431 const std::vector<Object*>& global_ref_to_object_ptr,
432 std::vector<ObjectRef>* global_ref_to_shared_ref,
433 std::vector<Object>* shared_objects) {
434 std::vector<ObjectRef> assigned_id_to_shared_ref(
435 assignment.object_sizes.size(), kInvalidObjectRef);
436 for (size_t global_ref = 0; global_ref < global_ref_to_usage_rec.size();
437 ++global_ref) {
438 const auto& usage_rec_id = global_ref_to_usage_rec[global_ref];
439 Object* object = global_ref_to_object_ptr[global_ref];
440 if (usage_rec_id == kNotAssigned || object == nullptr ||
441 object->object_type != ObjectType::BUFFER) {
442 // Skip objects with other data type and non-buffers.
443 continue;
444 }
445
446 // id of shared object, returned by memory allocation algorithm.
447 size_t assigned_id = assignment.object_ids[usage_rec_id];
448
449 // id of corresponding shared object in vector share_objects.
450 ObjectRef shared_ref = assigned_id_to_shared_ref[assigned_id];
451
452 if (shared_ref == kInvalidObjectRef) {
453 // We need to create new shared object for current buffer.
454 shared_ref = shared_objects->size();
455 Object shared_object = *object;
456 shared_object.access = AccessType::READ_WRITE;
457 shared_object.object = shared_ref;
458 shared_object.size = assignment.object_sizes[assigned_id];
459 shared_objects->push_back(std::move(shared_object));
460 assigned_id_to_shared_ref[assigned_id] = shared_ref;
461 }
462 (*global_ref_to_shared_ref)[global_ref] = shared_ref;
463 }
464 return OkStatus();
465}
466
467template <typename ObjectSizeT>
468Status ApplyTexturesAssignment(

Callers 1

AssignInternalObjectsMethod · 0.85

Calls 3

OkStatusFunction · 0.85
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected