AutoTune_c.h 2.23 KB
Newer Older
huchen's avatar
huchen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

// Copyright 2004-present Facebook. All Rights Reserved.
// -*- c -*-

#ifndef FAISS_AUTO_TUNE_C_H
#define FAISS_AUTO_TUNE_C_H

#include "Index_c.h"
#include "faiss_c.h"

#ifdef __cplusplus
extern "C" {
#endif

/// possible values of a parameter, sorted from least to most expensive/accurate
FAISS_DECLARE_CLASS(ParameterRange)

FAISS_DECLARE_GETTER(ParameterRange, const char*, name)

/// Getter for the values in the range. The output values are invalidated
/// upon any other modification of the range.
void faiss_ParameterRange_values(FaissParameterRange*, double**, size_t*);

/** Uses a-priori knowledge on the Faiss indexes to extract tunable parameters.
 */
FAISS_DECLARE_CLASS(ParameterSpace)

FAISS_DECLARE_DESTRUCTOR(ParameterSpace)

/// Parameter space default constructor
int faiss_ParameterSpace_new(FaissParameterSpace** space);

/// nb of combinations, = product of values sizes
size_t faiss_ParameterSpace_n_combinations(const FaissParameterSpace*);

/// get string representation of the combination
/// by writing it to the given character buffer.
/// A buffer size of 1000 ensures that the full name is collected.
int faiss_ParameterSpace_combination_name(
        const FaissParameterSpace*,
        size_t,
        char*,
        size_t);

/// set a combination of parameters described by a string
int faiss_ParameterSpace_set_index_parameters(
        const FaissParameterSpace*,
        FaissIndex*,
        const char*);

/// set a combination of parameters on an index
int faiss_ParameterSpace_set_index_parameters_cno(
        const FaissParameterSpace*,
        FaissIndex*,
        size_t);

/// set one of the parameters
int faiss_ParameterSpace_set_index_parameter(
        const FaissParameterSpace*,
        FaissIndex*,
        const char*,
        double);

/// print a description on stdout
void faiss_ParameterSpace_display(const FaissParameterSpace*);

/// add a new parameter (or return it if it exists)
int faiss_ParameterSpace_add_range(
        FaissParameterSpace*,
        const char*,
        FaissParameterRange**);

#ifdef __cplusplus
}
#endif

#endif