MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / fetch

Method fetch

python/mod_cvcuda/operators/OpFindHomography.cpp:108–132  ·  view source on GitHub ↗

The static fetch function can be used to specialize the fetch of a specific object from the cache. It can be used to select the best object among a number of matched cache objects. It can also be used to remove other objects that are not needed in the cache anymore. Here, it fetches the biggest payload OP among cache items and remove all other OPs from the cache. It is ok to remove them since the

Source from the content-addressed store, hash-verified

106 // It is ok to remove them since the biggest payload OP can be used to accomodate all of them,
107 // so they will never be reused and thus are no longer necessary.
108 static std::shared_ptr<nvcvpy::ICacheItem> fetch(std::vector<std::shared_ptr<nvcvpy::ICacheItem>> &cache)
109 {
110 assert(!cache.empty());
111
112 std::shared_ptr<nvcvpy::ICacheItem> retItem = cache[0];
113 size_t maxPayloadSize = 0;
114
115 for (const auto &item : cache)
116 {
117 const Key &key = static_cast<const Key &>(item.get()->key());
118 size_t keyPayloadSize = key.payloadSize();
119
120 if (keyPayloadSize > maxPayloadSize)
121 {
122 maxPayloadSize = keyPayloadSize;
123 retItem = item;
124 }
125 }
126
127 cache.clear();
128
129 nvcvpy::Cache::removeAllNotInUseMatching(retItem.get()->key());
130
131 return retItem;
132 }
133
134private:
135 Key m_key;

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.45
keyMethod · 0.45
getMethod · 0.45
payloadSizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected