Enforce contiguous outputs on the transforms v2 kernels?

Open
#6,839 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with the listed transforms v2 kernels, comparing contiguous and noncontiguous inputs in performance benchmarks for affine_image_tensor, convert_color_space, rotate_image_tensor, crop_image_tensor, center_crop_image_tensor, five_crop_image_tensor, and ten_crop_image_tensor. Include the *_mask and *_video wrappers where applicable; done means determining whether the measured degradation justifies enforcing contiguous outputs.

Written by the indexing model from the issue text.

Description

module: transforms needs discussion Perf prototype

All the performance benchmarks that did so far for transforms v1 vs. v2 were on contiguous inputs. However, we have a few kernels that leave the output in a noncontiguous state:

  • affine_image_tensor in case image.numel() > 0 and image.ndim == 4 and fill is not None
  • convert_color_space in case we only strip the alpha channel, i.e. RGB_ALPHA -> RGB and GRAY_ALPHA -> ALPHA
  • rotate_image_tensor in case image.numel() > 0 and image.ndim == 4 and fill is not None
  • crop_image_tensor
  • center_crop_image_tensor
  • five_crop_image_tensor
  • ten_crop_image_tensor

If applicable, the same is also valid for the *_mask and *_video kernels since they are thin wrappers around the *_image_tensor ones.

We should benchmark at least for a few kernels whether noncontiguous inputs cause a performance degredation that is larger than enforcing contiguous outputs on the kernels above. If so we should probably enforce contiguous outputs of our kernels.

cc @vfdev-5 @datumbox @bjuncek

Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pytorch/vision

All issues in pytorch/vision

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.