Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dimension check in ssd_random_crop #5240

Merged
merged 5 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dali/operators/ssd/random_crop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ void SSDRandomCrop<CPUBackend>::RunImpl(SampleWorkspace &ws) {
int sample = ws.data_idx();

auto N = bboxes.dim(0);
DALI_ENFORCE(bboxes.ndim() == 2 && bboxes.dim(1) == 4,
"The second dimension of the bounding box tensor should be 4.");

const float* bbox_data = bboxes.data<float>();

const int* label_data = labels.data<int>();
Expand Down
2 changes: 1 addition & 1 deletion dali/test/python/checkpointing/test_dali_checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def test_ssd_random_crop():
@pipeline_def
def pipeline():
data = fn.random.uniform(shape=(100, 100), dtype=types.DALIDataType.UINT8)
bbox = fn.random.uniform(shape=(4,), range=[0, 100], dtype=types.DALIDataType.FLOAT)
bbox = fn.random.uniform(shape=(7, 4), range=[0, 100], dtype=types.DALIDataType.FLOAT)
labels = fn.random.uniform(shape=(1,), dtype=types.DALIDataType.INT32)
return fn.ssd_random_crop(data, bbox, labels, device="cpu")[0]

Expand Down