Skip to content

vectorize and use torch_inverse and linalg_solve for perspective_boxes performance - #395

Merged
cregouby merged 1 commit into
mainfrom
perfo/perspective_boxes
Aug 25, 2026
Merged

vectorize and use torch_inverse and linalg_solve for perspective_boxes performance#395
cregouby merged 1 commit into
mainfrom
perfo/perspective_boxes

Conversation

@cregouby

Copy link
Copy Markdown
Collaborator

Improve perspective_boxes performance by 48 % :

image

Reprex :

library(torch)
library(here)
library(dplyr)
library(bench)
library(ggplot2)
devtools::load_all()
startpoints <- list(c(0,0), c(0,200), c(150,0), c(150,200))
endpoints <- list(c(10,20), c(7,120), c(100,0), c(110,180))
boxes <- torch_randint(low = 1, high = 20, size = c(130, 4))
boxes[3:4, ] <- boxes[1:2, ] + boxes[3:4, ] # make max > min

res <- mark(min_time = 5,
            manual_inverse = perspective_boxes(boxes, startpoints, endpoints),
            torch_inverse = perspective_boxes_2(boxes, startpoints, endpoints))
autoplot(res, type = "beeswarm") 

@cregouby
cregouby merged commit 99f2353 into main Aug 25, 2026
3 checks passed
@cregouby
cregouby deleted the perfo/perspective_boxes branch August 25, 2026 08:06
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