Skip to content

Conversation

@justincdavis
Copy link

Summary

Implements Elastic using CV-CUDA backend kernel with cvcuda.remap

Testing

python3 -m pytest test/test_transforms_v2.py::TestElastic

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 2, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9293

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 5 New Failures

As of commit 95cbb8b with merge base aa35ca1 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the cla signed label Dec 2, 2025
Copy link
Contributor

@zy1git zy1git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments for the first round review. Feel free to let me know your thoughts.

Comment on lines +3427 to +3428
@pytest.mark.needs_cvcuda
@needs_cuda
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# checking properties that are not the pixel values
# see note below on pixel-value differences
assert_close(result, expected, atol=get_max_value(torch.uint8), rtol=0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_max_value(torch.uint8) is 255. This assertion will pass for any pixel values (since uint8 range is 0-255). The comment says "checking properties that are not the pixel values" - does this mean it's checking shape/dtype? If so, consider making that explicit:

assert result.shape == expected.shape
assert result.dtype == expected.dtype

Comment on lines +3447 to +3452
# visually, the results are identical, however the underlying computations are different
# we can define an mae_threshold based on the interpolation mode
# the primary difference is along the borders where pixels appear to be shifted in location
# by up to 1, causing potentially up to a diff of 255 on a single pixel
# this could be because one has fill of 0 and CV-CUDA is shifted and has value with some color
# thresholds decrease as image size gets larger since shifted pixels are fewer in comparision
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some more investigation about this. @NicolasHug

# this could be because one has fill of 0 and CV-CUDA is shifted and has value with some color
# thresholds decrease as image size gets larger since shifted pixels are fewer in comparision
mae = (expected.float() - result.float()).abs().mean()
mae_threshold = 30.0 if interpolation is transforms.InterpolationMode.NEAREST else 20.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum comparison is preferred to use "==".

"""
Get the CV-CUDA interpolation mode for a given interpolation mode.
CV-CUDA has the two following differences (evaluated in tests) comapred to TorchVision/PIL:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo for "comapred"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants