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

Method SetupTensorList

dali/pipeline/data/tensor_list_test.cc:91–112  ·  view source on GitHub ↗

* Initialize & check a TensorList based on an input shape * Allocate it as float */

Source from the content-addressed store, hash-verified

89 * Allocate it as float
90 */
91 void SetupTensorList(TensorList<Backend> *tensor_list, const TensorListShape<> &shape,
92 vector<Index> *offsets) {
93 const int num_tensor = shape.size();
94
95 Index offset = 0;
96
97 for (int i = 0; i < shape.size(); i++) {
98 offsets->push_back(offset);
99 offset += volume(shape[i]);
100 }
101
102 // Resize the buffer
103 tensor_list->Resize(shape, DALI_FLOAT);
104
105 // Check the internals
106 ASSERT_TRUE(tensor_list->has_data());
107 ASSERT_EQ(tensor_list->num_samples(), num_tensor);
108 for (int i = 0; i < num_tensor; ++i) {
109 ASSERT_NE(tensor_list->template mutable_tensor<float>(i), nullptr);
110 ASSERT_EQ(tensor_list->tensor_shape(i), shape[i]);
111 }
112 }
113
114 BatchContiguity inverse(BatchContiguity contiguity) {
115 DALI_ENFORCE(contiguity != BatchContiguity::Automatic,

Callers 1

TYPED_TESTFunction · 0.80

Calls 7

volumeFunction · 0.85
has_dataMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
ResizeMethod · 0.45
num_samplesMethod · 0.45
tensor_shapeMethod · 0.45

Tested by

no test coverage detected