Skip to content

Commit

Permalink
tensor_shape.h warning fix (#5831)
Browse files Browse the repository at this point in the history
Signed-off-by: Joaquin Anton Guirao <[email protected]>
  • Loading branch information
jantonguirao authored Mar 3, 2025
1 parent 32153ea commit 63c0541
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions include/dali/core/tensor_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,17 @@ struct TensorListShapeBase {
*/
template <typename SampleShape>
void set_tensor_shape(int64_t sample, const SampleShape &sample_shape) {
detail::check_compatible_ndim<sample_ndim, compile_time_size<SampleShape>::value>();
assert(static_cast<int>(dali::size(sample_shape)) == static_cast<int>(sample_dim()));
constexpr int rhs_sample_ndim = compile_time_size<SampleShape>::value;
detail::check_compatible_ndim<sample_ndim, rhs_sample_ndim>();
constexpr bool is_scalar = sample_ndim == 0 || rhs_sample_ndim == 0;
assert(sample >= 0 && sample < nsamples && "Sample index out of range");
int64_t base = sample_dim() * sample;
for (int i = 0; i < sample_dim(); i++) {
shapes[base + i] = sample_shape[i];
assert(static_cast<int>(dali::size(sample_shape)) == static_cast<int>(sample_dim()));
assert(static_cast<int>(shapes.size()) == nsamples * sample_dim() && "shapes size mismatch");
if constexpr (!is_scalar) {
int64_t base = sample_dim() * sample;
for (int i = 0; i < sample_dim(); i++) {
shapes[base + i] = sample_shape[i];
}
}
}

Expand Down

0 comments on commit 63c0541

Please sign in to comment.