Skip to content

Conversation

@datumbox
Copy link
Contributor

No description provided.


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