@ -0,0 +1,3 @@ | |||||
build/ | |||||
*.out | |||||
*.exe |
@ -0,0 +1,18 @@ | |||||
set(CMAKE_DEBUG_POSTFIX "_d") | |||||
set(CMAKE_RELEASE_POSTFIX "_r") | |||||
set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX "_d") | |||||
set_target_properties(${TARGET_NAME} PROPERTIES RELEASE_POSTFIX "_r") | |||||
cmake_minimum_required(VERSION 3.1) | |||||
project("hnswlab") | |||||
set(CMAKE_C_STANDARD 11) | |||||
# generate .so file | |||||
include_directories(inc) | |||||
add_library(hnswc | |||||
SHARED | |||||
src/utils.c | |||||
src/hnsw.c | |||||
) | |||||
add_executable(hnsw_test src/test.c) | |||||
target_link_libraries(hnsw_test hnswc) |
@ -0,0 +1 @@ | |||||
# HNSW-Lab |
@ -0,0 +1,29 @@ | |||||
#pragma once | |||||
#include <stdio.h> | |||||
#include "utils.h" | |||||
typedef struct NSWGraph | |||||
{ | |||||
} NSWGraph; | |||||
typedef struct HNSWGraph | |||||
{ | |||||
size_t layers_num; // number of layers | |||||
NSWGraph **layers; | |||||
} HNSWGraph; | |||||
typedef struct HNSWContext | |||||
{ | |||||
size_t dim; // dimension of dataset | |||||
size_t len; // size of dataset | |||||
HNSWGraph *graph; // graph of HNSW | |||||
} HNSWContext; | |||||
// help functions | |||||
// public functions | |||||
HNSWContext *init_hnsw_context(const char *file_path, size_t dim, size_t len); | |||||
void insert_vec(HNSWContext *ctx, VecData vec); | |||||
void approximate_knn(HNSWContext *ctx, VecData *results); |
@ -0,0 +1,6 @@ | |||||
typedef char* VecData; | |||||
float vec_dist(VecData x, VecData y); | |||||
@ -0,0 +1,2 @@ | |||||
#include "hnsw.h" | |||||
@ -0,0 +1,8 @@ | |||||
#include <stdio.h> | |||||
#include "hnsw.h" | |||||
#include "utils.h" | |||||
int main() { | |||||
printf("Hello, world!\n"); | |||||
return 0; | |||||
} |