Skip to content

Commit

Permalink
Merge pull request #468 from unum-cloud/main-dev
Browse files Browse the repository at this point in the history
New GoLang, Swift, and Objective-C APIs
  • Loading branch information
ashvardanian committed Aug 26, 2024
2 parents c93ef76 + 1abc8e8 commit cfbeac2
Show file tree
Hide file tree
Showing 22 changed files with 994 additions and 102 deletions.
1 change: 1 addition & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
version-file: "VERSION"
update-version-in: |
package.json:"version": "(\d+\.\d+\.\d+)"
package-lock.json:"usearch",\n\s+"version": "(\d+\.\d+\.\d+)"
CITATION.cff:^version: (\d+\.\d+\.\d+)
Cargo.toml:^version = "(\d+\.\d+\.\d+)"
Cargo.lock:name = "usearch"\nversion = "(\d+\.\d+\.\d+)"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
version-file: "VERSION"
update-version-in: |
package.json:"version": "(\d+\.\d+\.\d+)"
package-lock.json:"usearch",\n\s+"version": "(\d+\.\d+\.\d+)"
CITATION.cff:^version: (\d+\.\d+\.\d+)
Cargo.toml:^version = "(\d+\.\d+\.\d+)"
Cargo.lock:name = "usearch"\nversion = "(\d+\.\d+\.\d+)"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ target/
.build
.swiftpm

# Golang builds
golang/usearch.h

# C# builds
csharp/**/[Bb]in/
csharp/**/[Oo]bj/
Expand Down
40 changes: 31 additions & 9 deletions BENCHMARKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,25 @@ Which would print the following instructions.

```txt
SYNOPSIS
build_profile/bench_cpp [--vectors <path>] [--queries <path>] [--neighbors <path>] [-b] [-j
<integer>] [-c <integer>] [--expansion-add <integer>]
[--expansion-search <integer>] [--native|--f16quant|--i8quant]
[--ip|--l2sq|--cos|--haversine] [-h]
build_profile/bench_cpp [--vectors <path>] [--queries <path>] [--neighbors <path>] [-o
<path>] [-b] [-j <integer>] [-c <integer>] [--expansion-add
<integer>] [--expansion-search <integer>] [--rows-skip <integer>]
[--rows-take <integer>] [-bf16|-f16|-i8|-b1]
[--ip|--l2sq|--cos|--hamming|--tanimoto|--sorensen|--haversine] [-h]
OPTIONS
--vectors <path>
.fbin file path to construct the index
.[fhbd]bin file path to construct the index
--queries <path>
.fbin file path to query the index
.[fhbd]bin file path to query the index
--neighbors <path>
.ibin file path with ground truth
-o, --output <path>
.usearch output file path
-b, --big Will switch to uint40_t for neighbors lists with over 4B entries
-j, --threads <integer>
Uses all available cores by default
Expand All @@ -98,12 +102,30 @@ OPTIONS
--expansion-search <integer>
Affects search depth
--native Use raw templates instead of type-punned classes
--f16quant Enable `f16_t` quantization
--i8quant Enable `int8_t` quantization
--rows-skip <integer>
Number of vectors to skip
--rows-take <integer>
Number of vectors to take
-bf16, --bf16quant
Enable `bf16_t` quantization
-f16, --f16quant
Enable `f16_t` quantization
-i8, --i8quant
Enable `i8_t` quantization
-b1, --b1quant
Enable `b1x8_t` quantization
--ip Choose Inner Product metric
--l2sq Choose L2 Euclidean metric
--cos Choose Angular metric
--hamming Choose Hamming metric
--tanimoto Choose Tanimoto metric
--sorensen Choose Sorensen metric
--haversine Choose Haversine metric
-h, --help Print this help information on this tool and exit
```
Expand Down
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ Testing and benchmarking:

```sh
npm install -g typescript
npm install
npm run build-js
npm test
npm run bench
Expand Down Expand Up @@ -335,10 +336,10 @@ So one should first compile the C library, link it with GoLang, and only then ru
cmake -B build_release -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_USE_OPENMP=1 -DUSEARCH_USE_SIMSIMD=1
cmake --build build_release --config Release -j

mv c/libusearch_c.so golang/ # or .dylib to install the library on MacOS
cp c/usearch.h golang/ # to make the header available to GoLang
cp build_release/libusearch_c.so golang/ # or .dylib to install the library on MacOS
cp c/usearch.h golang/ # to make the header available to GoLang

cd golang && go test -v ; cd ..
cd golang && LD_LIBRARY_PATH=. go test -v ; cd ..
```

## Java
Expand Down
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ let package = Package(
.target(
name: "USearchObjective",
path: "objc",
sources: ["USearchObjective.mm"],
sources: ["USearchObjective.mm"],
cxxSettings: [
.headerSearchPath("../include/"),
.headerSearchPath("../fp16/include/"),
.headerSearchPath("../simismd/include/"),
.headerSearchPath("../simsimd/include/"),
.define("USEARCH_USE_FP16LIB", to: "1"),
.define("USEARCH_USE_SIMSIMD", to: "1"),
]
),
.target(
Expand Down
4 changes: 4 additions & 0 deletions cpp/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ struct args_t {

bool big = false;

bool quantize_bf16 = false;
bool quantize_f16 = false;
bool quantize_i8 = false;
bool quantize_b1 = false;
Expand Down Expand Up @@ -500,6 +501,8 @@ struct args_t {
}

scalar_kind_t quantization() const noexcept {
if (quantize_bf16)
return scalar_kind_t::bf16_k;
if (quantize_f16)
return scalar_kind_t::f16_k;
if (quantize_i8)
Expand Down Expand Up @@ -611,6 +614,7 @@ int main(int argc, char** argv) {
(option("--rows-skip") & value("integer", args.vectors_to_skip)).doc("Number of vectors to skip"),
(option("--rows-take") & value("integer", args.vectors_to_take)).doc("Number of vectors to take"),
( //
option("-bf16", "--bf16quant").set(args.quantize_bf16).doc("Enable `bf16_t` quantization") |
option("-f16", "--f16quant").set(args.quantize_f16).doc("Enable `f16_t` quantization") |
option("-i8", "--i8quant").set(args.quantize_i8).doc("Enable `i8_t` quantization") |
option("-b1", "--b1quant").set(args.quantize_b1).doc("Enable `b1x8_t` quantization")),
Expand Down
Loading

0 comments on commit cfbeac2

Please sign in to comment.