Skip to content

Pad CV-CUDA Backend#9289

Open
justincdavis wants to merge 21 commits intopytorch:mainfrom
justincdavis:feat/pad_cvcuda
Open

Pad CV-CUDA Backend#9289
justincdavis wants to merge 21 commits intopytorch:mainfrom
justincdavis:feat/pad_cvcuda

Conversation

@justincdavis
Copy link
Copy Markdown

Summary

Add the CV-CUDA backend kernel for the pad transform

Testing

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

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Dec 2, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit b68b3a7 with merge base 1e53952 (image):
💚 Looks good so far! There are no failures yet. 💚

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
Copy Markdown
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 one minor comment.



def _get_cvcuda_border_from_pad_mode(pad_mode: str) -> "cvcuda.Border":
if len(_pad_mode_to_cvcuda_border) == 0:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can use rewrite this line to if not _pad_mode_to_cvcuda_border:

Comment thread test/test_transforms_v2.py Outdated
def test_image_correctness(self, padding, padding_mode, fill, fn):
image = make_image(dtype=torch.uint8, device="cpu")
def test_image_correctness(self, make_input, padding, padding_mode, fill, fn):
image = make_input(dtype=torch.uint8, device="cpu")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@zy1git , I'm surprised to see device="cpu" here. Can you check if there's a particular reason that it was set in the first place? Is it still relevant?
We should probably remove it, at least when make_input is make_image_cvcuda.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I checked out the make_image function in the common_utils.py file and find that the default is "cpu" for device:

def make_image(
    size=DEFAULT_SIZE,
    *,
    color_space="RGB",
    batch_dims=(),
    dtype=None,
    device="cpu",
    memory_format=torch.contiguous_format,
):

And the function make_image_cvcuda called the function make_image:

def make_image_cvcuda(*args, batch_dims=(1,), **kwargs):
    return to_cvcuda_tensor(make_image(*args, batch_dims=batch_dims, **kwargs))

Thus, I think it is safe to remove the device="cpu". I am not sure why it was set in the first place. Maybe the previous author want to be explicit for clarity/readability?

Copy link
Copy Markdown
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.

address one comment

Comment thread test/test_transforms_v2.py Outdated
def test_image_correctness(self, padding, padding_mode, fill, fn):
image = make_image(dtype=torch.uint8, device="cpu")
def test_image_correctness(self, make_input, padding, padding_mode, fill, fn):
image = make_input(dtype=torch.uint8, device="cpu")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I checked out the make_image function in the common_utils.py file and find that the default is "cpu" for device:

def make_image(
    size=DEFAULT_SIZE,
    *,
    color_space="RGB",
    batch_dims=(),
    dtype=None,
    device="cpu",
    memory_format=torch.contiguous_format,
):

And the function make_image_cvcuda called the function make_image:

def make_image_cvcuda(*args, batch_dims=(1,), **kwargs):
    return to_cvcuda_tensor(make_image(*args, batch_dims=batch_dims, **kwargs))

Thus, I think it is safe to remove the device="cpu". I am not sure why it was set in the first place. Maybe the previous author want to be explicit for clarity/readability?

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.

3 participants