Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contrib/vecs_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import sys
import numpy as np

"""
Expand All @@ -13,6 +14,8 @@

def ivecs_read(fname):
a = np.fromfile(fname, dtype='int32')
if sys.byteorder == 'big':
a.byteswap(inplace=True)
d = a[0]
return a.reshape(-1, d + 1)[:, 1:].copy()

Expand Down
12 changes: 12 additions & 0 deletions faiss/impl/pq4_fast_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ void pq4_pack_codes(
return;
}
memset(blocks, 0, nb * nsq / 2);
#if !defined(_MSC_VER) && \
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
const uint8_t perm0[16] = {
8, 0, 9, 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15, 7};
#else
const uint8_t perm0[16] = {
0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15};
#endif

uint8_t* codes2 = blocks;
for (size_t i0 = 0; i0 < nb; i0 += bbs) {
Expand Down Expand Up @@ -93,8 +99,14 @@ void pq4_pack_codes_range(
size_t bbs,
size_t nsq,
uint8_t* blocks) {
#if !defined(_MSC_VER) && \
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
const uint8_t perm0[16] = {
8, 0, 9, 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15, 7};
#else
const uint8_t perm0[16] = {
0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15};
#endif

// range of affected blocks
size_t block0 = i0 / bbs;
Expand Down
13 changes: 13 additions & 0 deletions faiss/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,20 @@ else()
find_package(faiss REQUIRED)
endif()

if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
swig_add_library(swigfaiss
TYPE MODULE
LANGUAGE python
SOURCES swigfaiss.swig
)
else ()
swig_add_library(swigfaiss
TYPE SHARED
LANGUAGE python
SOURCES swigfaiss.swig
)
endif()

set_property(TARGET swigfaiss PROPERTY SWIG_COMPILE_OPTIONS -doxygen)

set_property(SOURCE swigfaiss_avx2.swig
Expand Down Expand Up @@ -160,6 +169,10 @@ set_property(TARGET faiss_python_callbacks
PROPERTY POSITION_INDEPENDENT_CODE ON
)

if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
target_link_libraries(faiss_python_callbacks PRIVATE faiss)
endif()

# Hack so that python_callbacks.h can be included as
# `#include <faiss/python/python_callbacks.h>`.
target_include_directories(faiss_python_callbacks PRIVATE ${PROJECT_SOURCE_DIR}/../..)
Expand Down