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

Method WrapExternalBufferVector

python/mod_cvcuda/nvcv/TensorBatch.cpp:62–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::shared_ptr<TensorBatch> TensorBatch::WrapExternalBufferVector(std::vector<py::object> buffers,
63 std::optional<nvcv::TensorLayout> layout)
64{
65 TensorList list;
66 list.reserve(buffers.size());
67 for (auto &obj : buffers)
68 {
69 std::shared_ptr<ExternalBuffer> buffer = cast_py_object_as<ExternalBuffer>(obj);
70 if (!buffer)
71 {
72 throw std::runtime_error("Input buffer doesn't provide cuda_array_interface or DLPack interfaces.");
73 }
74 auto tensor = Tensor::Wrap(*buffer, layout);
75 list.push_back(tensor);
76 }
77 auto batch = Create(buffers.size());
78 batch->pushBackMany(list);
79 return batch;
80}
81
82TensorBatch::TensorBatch(int capacity)
83 : m_key(capacity)

Callers

nothing calls this directly

Calls 4

reserveMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
pushBackManyMethod · 0.45

Tested by

no test coverage detected