Skip to content

Commit fd67161

Browse files
authored
Remove squeezing from C API - it probably never worked anyway. (#5893)
- daliMaxDimTensors returned a number of dimensions that depended on the dimensions (squeezing the innermost dim if the extent was 1 in all samples) - this PR removes this and returns the TensorList's ndim instead - TODO: Test this change with TRITON DALI backend. Signed-off-by: Michal Zientkiewicz <[email protected]>
1 parent edc7528 commit fd67161

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

dali/c_api/c_api.cc

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -569,31 +569,9 @@ size_t daliTensorSize(daliPipelineHandle_t pipe_handle, int n) {
569569
}
570570
}
571571

572-
template <typename T>
573-
static size_t daliMaxDimTensorsHelper(dali::Workspace* ws, int n) {
574-
const auto &out_tensor_list = ws->Output<T>(n);
575-
size_t tensors_num = out_tensor_list.num_samples();
576-
int max_num_dim = 0;
577-
for (size_t i = 0; i < tensors_num; ++i) {
578-
auto shape = out_tensor_list.tensor_shape(i);
579-
int num_dim = shape.size();
580-
// squeeze last dimension
581-
// TODO(michalz): Remove this logic! The client should be responsible for this!
582-
if (num_dim > 0 && shape[num_dim - 1] == 1) {
583-
--num_dim;
584-
}
585-
max_num_dim = std::max(max_num_dim, num_dim);
586-
}
587-
return static_cast<size_t>(max_num_dim);
588-
}
589-
590572
size_t daliMaxDimTensors(daliPipelineHandle_t pipe_handle, int n) {
591573
dali::Workspace* ws = &(*pipe_handle)->workspace;
592-
if (ws->OutputIsType<CPUBackend>(n)) {
593-
return daliMaxDimTensorsHelper<CPUBackend>(ws, n);
594-
} else {
595-
return daliMaxDimTensorsHelper<GPUBackend>(ws, n);
596-
}
574+
return ws->GetOutputDim(n);
597575
}
598576

599577
size_t daliGetDeclaredOutputNdim(daliPipelineHandle_t pipe_handle, int n) {

0 commit comments

Comments
 (0)