autofaiss.utils package

Submodules

autofaiss.utils.algorithms module

Various optimization algorithms

Binary search in a function domain

Parameters:
  • is_ok (bool) – Boolean monotone function defined on range(n)

  • n (int) – length of the search scope

Return type:

int

Returns:

  • i (int) – first index i such that is_ok(i) or returns n if is_ok is all False

  • complexity: O(log(n))

autofaiss.utils.array_functions module

useful functions t apply on numpy arrays

autofaiss.utils.array_functions.multi_array_split(array_list, nb_chunk)[source]
autofaiss.utils.array_functions.sanitize(x)[source]

autofaiss.utils.cast module

function to cast variables in others

autofaiss.utils.cast.cast_bytes_to_memory_string(num_bytes)[source]

Cast a number of bytes to a readable string

Return type:

str

autofaiss.utils.cast.cast_memory_to_bytes(memory_string)[source]

Parse a memory string and returns the number of bytes >>> cast_memory_to_bytes(“16B”) 16 >>> cast_memory_to_bytes(“16G”) == 16*1024*1024*1024 True

Return type:

float

autofaiss.utils.cast.to_faiss_metric_type(metric_type)[source]

convert metric_type string/enum to faiss enum of the distance metric

Return type:

int

autofaiss.utils.cast.to_readable_time(seconds, rounding=False)[source]

cast time in seconds to readable string

Return type:

str

autofaiss.utils.decorators module

Useful decorators for fast debuging

class autofaiss.utils.decorators.Timeit(comment=None, indent=0, verbose=True)[source]

Bases: ContextDecorator

Timing class, used as a context manager

autofaiss.utils.decorators.should_run_once(func)[source]

Decorator to force a function to run only once. The fonction raises a ValueError otherwise.

autofaiss.utils.decorators.timer(func)[source]

Print the runtime of the decorated function

autofaiss.utils.path module

path

autofaiss.utils.path.extract_partition_name_from_path(path)[source]

Extract partition name from path

Return type:

str

autofaiss.utils.path.make_path_absolute(path)[source]
Return type:

str

Module contents