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

Method append

include/dali/core/tensor_shape.h:716–743  ·  view source on GitHub ↗

@{ */ * Append this TensorListShape with shapes from other TensorListShapes. */

Source from the content-addressed store, hash-verified

714 * Append this TensorListShape with shapes from other TensorListShapes.
715 */
716 void append(span<const TensorListShape<sample_ndim>> tlss) {
717 int new_samples = 0;
718 for (const auto &tls : tlss) {
719 new_samples += tls.num_samples();
720 }
721 if (new_samples == 0) return;
722
723 // The following line is imperfect, because uninitialized TensorListShape<-1>
724 // has `ndim` == 0, while `0` is legal number of dimensions.
725 bool is_uninitialized = empty() && sample_dim() <= 0;
726
727 auto reference_dim_value = is_uninitialized ? tlss[0].sample_dim() : sample_dim();
728 for (const auto &tls : tlss) {
729 if (tls.sample_dim() != reference_dim_value) {
730 throw std::invalid_argument(
731 "All samples in TensorListShape must have the same number of dimensions");
732 }
733 }
734 nsamples += new_samples;
735 if (is_uninitialized) {
736 // If `this` TLS has DynamicDimensions and wasn't initialized yet
737 set_sample_dim(reference_dim_value);
738 }
739 shapes.reserve(nsamples * sample_dim());
740 for (const auto &tls : tlss) {
741 shapes.insert(shapes.end(), tls.shapes.begin(), tls.shapes.end());
742 }
743 }
744
745 void append(const TensorListShape<sample_ndim> &tls) {
746 append(make_cspan(&tls, 1));

Callers

nothing calls this directly

Calls 11

emptyFunction · 0.85
sample_dimFunction · 0.85
make_cspanFunction · 0.85
num_samplesMethod · 0.45
sample_dimMethod · 0.45
reserveMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected