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

R interface could use inplace prediction #7616

Closed
david-cortes opened this issue Jan 28, 2022 · 4 comments
Closed

R interface could use inplace prediction #7616

david-cortes opened this issue Jan 28, 2022 · 4 comments

Comments

@david-cortes
Copy link
Contributor

The Python interface where possible uses inplace_predict, which is fater than creating a DMatrix object for making predictions. The R interface OTOH always uses DMatrix, which requires 2 redundant copies of the data. It should be possible to use functions such as XGBoosterPredictFromDense in the R interface too, avoiding an extra data copy, and wrapping them should be even simpler since R does not support as many array configurations as numpy (e.g. no strided array views).

@david-cortes david-cortes changed the title (R) R interface could use inplace prediction R interface could use inplace prediction Jan 28, 2022
@trivialfis
Copy link
Member

Do you think we should add a parameter for the predict function to use inplace prediction optionally? The prediction using DMatrix can be cached as we can use its memory address as the cache key so it's not always slower than inplace prediction.

@david-cortes
Copy link
Contributor Author

Do you think we should add a parameter for the predict function to use inplace prediction optionally? The prediction using DMatrix can be cached as we can use its memory address as the cache key so it's not always slower than inplace prediction.

Bu whether it's cached or not, it first needs to produce a data copy when it casts the double R array to a float vector, and then when it copies that float vector to the DMatrix that's being created.

@trivialfis
Copy link
Member

Would you like to work on the interface? :-). The R package can use a lot of help.

@david-cortes
Copy link
Contributor Author

I'll pass on this specific feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants