Pad CV-CUDA Backend#9289
Conversation
🔗 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 FailuresAs of commit b68b3a7 with merge base 1e53952 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
e4c14ef to
95dcf5d
Compare
zy1git
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
We can use rewrite this line to if not _pad_mode_to_cvcuda_border:
| 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") |
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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?
…pr-9289 address the outstanding comments.
| 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") |
There was a problem hiding this comment.
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?
Summary
Add the CV-CUDA backend kernel for the
padtransformTesting
python3 -m pytest test/test_transforms_v2.py::TestPad