MCPcopy Create free account
hub / github.com/NVIDIA/DALI / TensorListGetItemImpl

Function TensorListGetItemImpl

dali/python/backend_impl.cc:1192–1209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1190
1191template <typename Backend>
1192std::unique_ptr<Tensor<Backend> > TensorListGetItemImpl(TensorList<Backend> &t, Index id) {
1193 int num_tensors = static_cast<int>(t.num_samples());
1194 if (id < 0) {
1195 id = num_tensors + id;
1196 }
1197 if (id >= num_tensors || id < 0) {
1198 throw py::index_error("TensorListCPU index out of range");
1199 }
1200 auto ptr = std::make_unique<Tensor<Backend>>();
1201 // TODO(klecki): Rework this with proper sample-based tensor batch data structure
1202 auto &sample_shared_ptr = unsafe_sample_owner(t, id);
1203 auto &tshape = t.tensor_shape(id);
1204 size_t num_bytes = tshape.num_elements() * t.type_info().size();
1205 ptr->ShareData(sample_shared_ptr, num_bytes, t.is_pinned(), tshape, t.type(),
1206 t.device_id(), t.order(), t.ready_event());
1207 ptr->SetMeta(t.GetMeta(id));
1208 return ptr;
1209}
1210
1211template <typename Backend>
1212constexpr uint32_t TensorListDLPackRangeColor() {

Callers 2

ExposeTensorListCPUFunction · 0.85
ExposeTesorListGPUFunction · 0.85

Calls 8

num_samplesMethod · 0.45
tensor_shapeMethod · 0.45
num_elementsMethod · 0.45
sizeMethod · 0.45
ShareDataMethod · 0.45
typeMethod · 0.45
device_idMethod · 0.45
SetMetaMethod · 0.45

Tested by

no test coverage detected