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

[nomerge] Potential perf opt on bbox kernels #6872

Closed
wants to merge 1 commit into from

Conversation

datumbox
Copy link
Contributor

No description provided.

@@ -759,6 +764,7 @@ def pad_bounding_box(

bounding_box = bounding_box.clone()

# TODO: avoid repeated indexing and perform concurrently. `output.add_(torch.tensor([left, top, left, top]))` is 3x faster
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A quick check of:

def single(inpt, left, top):
    output = inpt.clone()
    output[..., 0] += left
    output[..., 1] += top
    output[..., 2] += left
    output[..., 3] += top

    return output


def concurrent(inpt, left, top):
    output = inpt.clone()
    output.add_(torch.tensor([left, top, left, top]))

    return output

Shows:

[-------- Pad cpu torch.float32 --------]
               |  single   |  concurrent 
1 threads: ------------------------------
      (16, 4)  |     60    |       20    
6 threads: ------------------------------
      (16, 4)  |     58    |       15    

Times are in microseconds (us).

There might be multiple opportunities for speed up like this.

@datumbox datumbox requested a review from vfdev-5 October 31, 2022 12:46
@datumbox datumbox closed this Oct 31, 2022
@datumbox datumbox deleted the nomerge/perf_bbox branch October 31, 2022 12:46
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.

2 participants