Skip GPU flip and color space conversion launches for zero-extent samples - #6507
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…ples Fixes #6504 Signed-off-by: Joaquin Anton <janton@nvidia.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
| @pipeline_def(batch_size=4, num_threads=4, device_id=0) | ||
| def zero_extent_flip_pipe(data): | ||
| images = fn.external_source(source=[data], cycle=True, layout="HWC") | ||
| return fn.flip(images.gpu(), horizontal=1, vertical=1) | ||
|
|
||
|
|
||
| def test_flip_zero_extent_samples(): | ||
| data = [ |
There was a problem hiding this comment.
Required test cases are missing The new flip test uses only a four-sample GPU batch. The new color-conversion test also uses only four-sample batches, and neither test checks invalid-input rejection. The repository's test-edge-cases directive requires new operator tests to cover single-sample batches, CPU and GPU variants, boundary values, and invalid-input errors with a message pattern. Add the applicable cases so those contracts are checked.
Rule Used: New operator tests must cover: empty input, single sample (batch_size=1), boundary values, CPU and GPU variants, and invalid-input rejection (via assert_raises(..., glob=...) with the expected message pattern). (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…CPU path Signed-off-by: Joaquin Anton <janton@nvidia.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
| if (volume(in_sample_sh) == 0) | ||
| return; |
There was a problem hiding this comment.
Unsupported conversions silently succeed When a CPU batch contains only zero-extent images, an unsupported conversion such as RGB to RGB returns here before
OpenCvColorConversion can reject it. The pipeline silently succeeds, whereas it previously reported an unsupported conversion and the GPU path still rejects the same pair. Validate the conversion pair before skipping empty samples.
Knowledge Base Used: Image and geometry operators
Category:
Bug fix (non-breaking change which fixes an issue)
Description:
Fixes #6504. A sample with a zero height or width in an otherwise non-empty batch reaches the GPU flip and color space conversion launchers, which then compute a launch configuration by dividing by a zero-sized block:
Both divisions happen on the host, before any kernel launch. Both launchers now return early when the sample has no pixels; the remaining samples of the batch are unaffected.
#6455 handled empty batches one layer up; this handles a zero-extent sample inside a non-empty batch.
Additional information:
Affected modules and functionalities:
dali/kernels/imgproc/color_manipulation/color_space_conversion_kernel.cuh—RunColorSpaceConversionKernelreturns whennpixels == 0.dali/kernels/imgproc/flip_gpu.cuh—FlipImplreturns whenvolume(shape) == 0.Key points relevant for the review:
The related sites in
warp_affine_params.cuandmatrix_adjust.cudivide by constants, so they produce a<<<0,0>>>launch andcudaErrorInvalidConfigurationrather than a host-side division by zero. They are left out of this PR, as suggested in the issue.Tests:
Existing tests apply
New tests added
N/A
operator_1/test_flip.py: test_flip_zero_extent_samplesoperator_1/test_color_space_conversion.py: test_color_space_conversion_zero_extent_samplesBoth feed a batch mixing zero-extent samples with a regular one and check the regular sample is still processed correctly. They were not run locally (no GPU in this environment); relying on CI.
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A
Link to Devin session: https://nvidia-cloud.devinenterprise.com/sessions/f56d1780b91f448f9e07d7d318245724
Open in Devin Desktop: https://nvidia-cloud.devinenterprise.com/desktop/session/f56d1780b91f448f9e07d7d318245724?variant=devin