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

Method Wrap

python/mod_cvcuda/nvcv/Array.cpp:119–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117} // namespace
118
119std::shared_ptr<Array> Array::Wrap(ExternalBuffer &buffer)
120{
121 const DLTensor &dlTensor = buffer.dlTensor();
122
123 nvcv::ArrayDataCuda data{FillNVCVArrayDataCUDA(dlTensor)};
124
125 // This is the key of a tensor wrapper.
126 // All tensor wrappers have the same key.
127 Array::Key key;
128 // We take this opportunity to remove from cache all wrappers that aren't
129 // being used. They aren't reusable anyway.
130 Cache::Instance().removeAllNotInUseMatching(key);
131
132 auto array = std::shared_ptr<Array>(new Array(data, py::cast(buffer.shared_from_this())));
133
134 // Need to add wrappers to cache so that they don't get destroyed by
135 // the cuda stream when they're last used, and python script isn't
136 // holding a reference to them. If we don't do it, things might break.
137 Cache::Instance().add(*array);
138 return array;
139}
140
141std::shared_ptr<Array> Array::ResizeArray(Array &array, int64_t length)
142{

Callers

nothing calls this directly

Calls 5

FillNVCVArrayDataCUDAFunction · 0.85
castFunction · 0.85
shared_from_thisMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected