| 31 | namespace nvcvpy::priv { |
| 32 | |
| 33 | std::shared_ptr<Array> Array::CreateFromReqs(const nvcv::Array::Requirements &reqs) |
| 34 | { |
| 35 | std::vector<std::shared_ptr<CacheItem>> vcont = Cache::Instance().fetch(Key{reqs}); |
| 36 | |
| 37 | // None found? |
| 38 | if (vcont.empty()) |
| 39 | { |
| 40 | std::shared_ptr<Array> array(new Array(reqs)); |
| 41 | array->impl().resize(reqs.capacity); |
| 42 | Cache::Instance().add(*array); |
| 43 | return array; |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | // Get the first one |
| 48 | auto array = std::static_pointer_cast<Array>(vcont[0]); |
| 49 | NVCV_ASSERT(array->dtype() == reqs.dtype); |
| 50 | return array; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | std::shared_ptr<Array> Array::Create(int64_t length, nvcv::DataType dtype) |
| 55 | { |