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

Make a forward calculation (predict) method that can take several samples #60

Closed
oysteijo opened this issue Dec 6, 2023 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@oysteijo
Copy link
Owner

oysteijo commented Dec 6, 2023

The neuralnet_predict() method takes one sample (and one sample only)

If I can rather calculate all inputs for several samples and store those inputs in a matrix, the forward calculation through the neural network becomes a matrix-matrix multiplication at each level. A BLAS system can do matrix-matrix calculations much faster than the corresponding N times vector-matrix calculations. I think that is a huge potential speedup.

What about:

void neuralnet_predict_batch( const neuralnet_t *nn, const int n_samples, const float *inputs, float *output );

Then this can be really optimized by BLAS. I also need bigger work memory and stuff. This could be cool.

@oysteijo oysteijo added the enhancement New feature or request label Dec 6, 2023
@oysteijo
Copy link
Owner Author

oysteijo commented Dec 7, 2023

I wonder how to add this feature. Should it be inside neuralnet.c? Guarded by #ifdef USE_CBLAS?

Or maybe I should add this as en "extension" in some way. I will probably have to pass in a pointer to some work memory, such that I can allocate work memory once. I can maybe just leave the code in the example folder?

@oysteijo
Copy link
Owner Author

Closed by #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant