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

Function ValidateSampleShape

dali/c_api_2/validation.h:45–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template <typename ShapeLike>
45void ValidateSampleShape(
46 int sample_index,
47 ShapeLike &&sample_shape,
48 std::optional<int> expected_ndim = std::nullopt) {
49 int ndim = std::size(sample_shape);
50 if (expected_ndim.has_value() && ndim != *expected_ndim)
51 throw std::invalid_argument(make_string(
52 "Unexpected number of dimensions (", ndim, ") in sample ", sample_index,
53 ". Expected ", *expected_ndim, "."));
54
55 for (int j = 0; j < ndim; j++)
56 if (sample_shape[j] < 0)
57 throw std::invalid_argument(make_string(
58 "Negative extent encountered in the shape of sample ", sample_index, ". Offending shape: ",
59 TensorShape<-1>(sample_shape)));
60}
61
62inline void ValidateNumSamples(int num_samples) {
63 if (num_samples < 0)

Callers 2

ValidateShapeFunction · 0.85
AttachSamplesMethod · 0.85

Calls 2

sizeFunction · 0.50
make_stringFunction · 0.50

Tested by

no test coverage detected