Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary copies when preparing detection inputs #57

Merged
merged 2 commits into from
May 2, 2024

Conversation

robertknight
Copy link
Owner

Remove a copy that is sometimes redundant:

  • If the image doesn't need to be padded, don't copy it
  • If the image doesn't need to be resized, don't do an identity resize

For small inputs where both spatial dimensions are smaller than the model's
input we'll need to pad but not resize. For large inputs where the opposite is
true we'll need to resize but not pad. For medium inputs where one dim exceeds
the corresponding model input size and the other is smaller, we'll need to do
both.

This is useful for code which needs to conditionally copy a tensor. This should
be upstreamed to `rten-tensor`.
 - If the image doesn't need to be padded, don't copy it
 - If the image doesn't need to be resized, don't do an identity resize

For small inputs where both spatial dimensions are smaller than the model's
input we'll need to pad but not resize. For large inputs where the opposite is
true we'll need to resize but not pad. For medium inputs where one dim exceeds
the corresponding model input size and the other is smaller, we'll need to do
both.
@robertknight robertknight merged commit bc9c9ea into main May 2, 2024
2 checks passed
@robertknight robertknight deleted the reduce-detect-copies branch May 2, 2024 22:10
robertknight added a commit to robertknight/rten that referenced this pull request May 5, 2024
This is useful for code which needs to conditionally copy or create a tensor,
and then get the results of the copying and non-copying code paths into the same
type. See robertknight/ocrs#57 for a downstream solution
that can be replaced by this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant