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

Method ViewAsTensor

dali/c_api_2/data_objects.h:725–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723 }
724
725 RefCountedPtr<ITensor> ViewAsTensor() const override {
726 if (!tl_->IsDenseTensor())
727 throw std::runtime_error(
728 "Only a densely packed list of tensors of uniform shape can be viewed as a Tensor.");
729
730 auto t = std::make_shared<Tensor<Backend>>();
731 auto buf = unsafe_owner(*tl_);
732 auto &lshape = tl_->shape();
733 TensorShape<> tshape = shape_cat(lshape.num_samples(), lshape[0]);
734 t->ShareData(
735 std::move(buf),
736 tl_->nbytes(),
737 tl_->is_pinned(),
738 tshape,
739 tl_->type(),
740 tl_->device_id(),
741 tl_->order(),
742 tl_->ready_event());
743 TensorLayout layout = tl_->GetLayout();
744 if (layout.size() == lshape.sample_dim()) {
745 t->SetLayout("N" + layout);
746 }
747 return Wrap(std::move(t));
748 }
749
750 void CopyOut(
751 void *dst_buffer,

Callers 1

Calls 12

WrapFunction · 0.85
IsDenseTensorMethod · 0.80
shapeMethod · 0.45
num_samplesMethod · 0.45
ShareDataMethod · 0.45
nbytesMethod · 0.45
typeMethod · 0.45
device_idMethod · 0.45
GetLayoutMethod · 0.45
sizeMethod · 0.45
sample_dimMethod · 0.45
SetLayoutMethod · 0.45

Tested by

no test coverage detected