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

Method ValidateOutputShape

dali/kernels/common/block_setup.h:167–187  ·  view source on GitHub ↗

* @brief Check if `out_shape` matches the number of channels of `in_shape` and spatial dimensions * of `output_sizes` as if it was generated with GetOutputShape(in_shape, output_sizes). */

Source from the content-addressed store, hash-verified

165 * of `output_sizes` as if it was generated with GetOutputShape(in_shape, output_sizes).
166 */
167 void ValidateOutputShape(
168 const TensorListShape<tensor_ndim> &out_shape,
169 const TensorListShape<tensor_ndim> &in_shape,
170 span<const TensorShape<ndim>> output_sizes) {
171 TensorListShape<tensor_ndim> shape;
172 shape.resize(in_shape.num_samples(), tensor_ndim);
173 for (int i = 0; i < in_shape.num_samples(); i++) {
174 auto out_tshape = out_shape[i];
175 TensorShape<tensor_ndim> expected_shape;
176
177 int in_d = 0;
178 for (int j = 0; j < tensor_ndim; j++) {
179 expected_shape[j] = (j == channel_dim)
180 ? in_shape.tensor_shape_span(i)[channel_dim]
181 : output_sizes[i][in_d++];
182 }
183
184 DALI_ENFORCE(out_tshape == expected_shape,
185 "Invalid output tensor shape for sample: " + std::to_string(i));
186 }
187 }
188
189 dim3 BlockDim() const {
190 return dim3(block_dim_.x, block_dim_.y, block_dim_.z);

Callers 1

PerturbAndValidateFunction · 0.80

Calls 4

to_stringFunction · 0.50
resizeMethod · 0.45
num_samplesMethod · 0.45
tensor_shape_spanMethod · 0.45

Tested by 1

PerturbAndValidateFunction · 0.64