Skip to content

Conversation

@justincdavis
Copy link

Summary

Add the backend kernel for ToDtype transform using CV-CUDA

How to use

import cvcuda
import torchvision.transforms.v2.functional as F

cvc_tensor = cvcuda.Tensor((1, 224, 224, 3), cvcuda.Type.U8, cvcuda.TensorLayout.NHWC)
# Dispatches to F.to_dtype_cvcuda
cvc_fp32_tensor = F.to_dtype(cvc_tensor, torch.float32)

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 19, 2025

🔗 Helpful Links

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

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

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

@meta-cla
Copy link

meta-cla bot commented Nov 19, 2025

Hi @justincdavis!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

Copy link
Member

@AntoineSimoulin AntoineSimoulin left a comment

Choose a reason for hiding this comment

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

Hey @justincdavis, thanks a lot for the PR. I left some comments and questions as a first review. Let me know what you think!

@AntoineSimoulin
Copy link
Member

@justincdavis could you complete the missing Contributor License Agreement (c.f. earlier comment from the meta-cla bot)?

Copy link
Member

@AntoineSimoulin AntoineSimoulin left a comment

Choose a reason for hiding this comment

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

Hey @justincdavis, thanks for addressing my first round of comments. I had another pass. Will it be possible to have another iteration on the PR based on my new comments? Thanks a lot for your time here!

@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.

Hi,

This is just a light pass of the review. Let me know what you think.


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

Choose a reason for hiding this comment

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

Hi @justincdavis, I think we have implemented this in #9277.

Copy link
Author

Choose a reason for hiding this comment

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

Yes you have! I need to go through this PR and rebase on main.

Comment on lines +2620 to +2675
inpt = make_input(dtype=input_dtype, device=device)
if as_dict:
output_dtype = {type(input): output_dtype}
check_transform(transforms.ToDtype(dtype=output_dtype, scale=scale), input, check_sample_input=not as_dict)
output_dtype = {type(inpt): output_dtype}
check_transform(transforms.ToDtype(dtype=output_dtype, scale=scale), inpt, check_sample_input=not as_dict)
Copy link
Contributor

Choose a reason for hiding this comment

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

May I ask what the reason is for changing "input" to "inpt"?

Copy link
Author

Choose a reason for hiding this comment

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

input is a reserved keyword in Python, while updating the function I went ahead and changed this to not overwrite it



def get_size_image_cvcuda(image: "cvcuda.Tensor") -> list[int]:
def _get_size_cvcuda(image: "cvcuda.Tensor") -> list[int]:
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems fair to keep the original name:#9277 (comment)

Copy link
Author

Choose a reason for hiding this comment

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

Yes very true, I will revert this an artifact from updating a few too many things at once

@justincdavis
Copy link
Author

Hi @zy1git thanks for the first pass! I have updated this PR to reflect the conventions of the flip PR, LMK what you think!

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