-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcagra_wrapper.h
More file actions
71 lines (58 loc) · 1.37 KB
/
Copy pathcagra_wrapper.h
File metadata and controls
71 lines (58 loc) · 1.37 KB
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
/*
* CAGRA wrapper header for gobed
*/
#ifndef CAGRA_WRAPPER_H
#define CAGRA_WRAPPER_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// Forward declaration
typedef struct cagra_wrapper_t cagra_wrapper_t;
// Performance stats
typedef struct {
double build_time_ms;
double search_time_ms;
double serialize_time_ms;
double deserialize_time_ms;
size_t index_memory_bytes;
int num_vectors;
int dim;
} cagra_stats_t;
// Core API
cagra_wrapper_t* cagra_create(int max_vectors, int dim);
void cagra_destroy(cagra_wrapper_t* wrapper);
// Index operations
int cagra_build_index(
cagra_wrapper_t* wrapper,
const int8_t* vectors,
const float* scales,
int num_vectors
);
// Search operations
int cagra_search(
cagra_wrapper_t* wrapper,
const int8_t* query,
float query_scale,
int k,
uint32_t* neighbors,
float* distances
);
int cagra_search_batch(
cagra_wrapper_t* wrapper,
const int8_t* queries,
const float* query_scales,
int num_queries,
int k,
uint32_t* neighbors,
float* distances
);
// Persistence
int cagra_serialize_index(cagra_wrapper_t* wrapper, const char* filepath);
int cagra_deserialize_index(cagra_wrapper_t* wrapper, const char* filepath);
// Stats
void cagra_get_stats(cagra_wrapper_t* wrapper, cagra_stats_t* stats);
#ifdef __cplusplus
}
#endif
#endif // CAGRA_WRAPPER_H