Shortcuts

wrap

class torchvision.tv_tensors.wrap(wrappee, *, like, **kwargs)[source]

Convert a torch.Tensor (wrappee) into the same TVTensor subclass as like.

If like carries metadata (e.g. format, canvas_size), that metadata is copied to the output. Individual metadata fields can be overridden via kwargs.

Subclass authors can override wrap() to define how their metadata is propagated.

Parameters:
  • wrappee (Tensor) – The tensor to convert.

  • like (TVTensor) – The reference. wrappee will be converted into the same subclass as like.

  • kwargs – Metadata overrides passed to the subclass’s wrap() method.

Examples using wrap:

How to write your own v2 transforms

How to write your own v2 transforms

How to write your own TVTensor class

How to write your own TVTensor class

TVTensors FAQ

TVTensors FAQ

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources