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

Normalization should not be done in the wrapper #453

Open
DavidGOrtega opened this issue Apr 8, 2023 · 2 comments
Open

Normalization should not be done in the wrapper #453

DavidGOrtega opened this issue Apr 8, 2023 · 2 comments

Comments

@DavidGOrtega
Copy link

DavidGOrtega commented Apr 8, 2023

Normalization should be done on the C++ side (if any, my vectors come out from my models already normalised).
If not every time the C++ code is used by another programming languages (i.e. nodejs) normalization has to be reimplemented

if (normalize) {

Proposed solution is to move this within the lib

void normalize_vector(float* data, float* norm_array) {
        float norm = 0.0f;
        for (int i = 0; i < dim; i++)
            norm += data[i] * data[i];
        norm = 1.0f / (sqrtf(norm) + 1e-30f);
        for (int i = 0; i < dim; i++)
            norm_array[i] = data[i] * norm;
    }
@yurymalkov
Copy link
Member

Hi @DavidGOrtega,
Sure, we can move it. PRs are welcome.
Thanks!

@kiplingw
Copy link

I agree. I think it would be a good idea to have this functionality implemented internally, as opposed to being binding specific.

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

No branches or pull requests

3 participants