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

Missing includes for faiss when building for Android #1033

Open
DavidVentura opened this issue Jan 29, 2025 · 0 comments
Open

Missing includes for faiss when building for Android #1033

DavidVentura opened this issue Jan 29, 2025 · 0 comments
Labels

Comments

@DavidVentura
Copy link

DavidVentura commented Jan 29, 2025

Bug description

Hi
When building for Android on x86-64, the build fails with errors on the faiss library:

 error: unknown type name '__m128'
  148 | static inline __m128 masked_read(int d, const float *x)
      |               ^
 error: use of undeclared identifier '_mm_load_ps'
  165 |   return _mm_load_ps(buf);
      |          ^
...

How to reproduce

Link marian-dev from an android native library (in my case, via bergamot)

Context

This can be fixed with the following patch

diff --git a/src/3rd_party/faiss/VectorTransform.h b/src/3rd_party/faiss/VectorTransform.h
index f0ed1440..ab34bc93 100644
--- a/src/3rd_party/faiss/VectorTransform.h
+++ b/src/3rd_party/faiss/VectorTransform.h
@@ -21,6 +21,12 @@
 #if defined(__APPLE__) && !defined(__arm64__)
 #include <x86intrin.h>
 #endif
+#if defined(__x86_64__) || defined(_M_X64)
+#include <xmmintrin.h>
+#include <emmintrin.h>
+#include <pmmintrin.h>
+#endif
+
 
 
 namespace faiss {

Maybe masked_read should be gated by #ifdef __AVX__ instead of #ifdef __SSE__ ?

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

No branches or pull requests

1 participant