Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C bindings for IDIndexMap #9

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

uhbuhb
Copy link

@uhbuhb uhbuhb commented Jul 4, 2021

This was missing from the library and is necessary do addWithId.

Other than that added a test to show example usage and a Dockerfile with faiss and go-faiss installed inside to ease trying it out.

IndexIDMap was missing from the go bindings, even though is is important
to wrap a flat index in if addWithID functionality is required.
IDMapWrapper isn't practical bc I would like to be able to transfer
gpuIndex (or any other index for that matter) to gpu using the
transferToGpu. So I dont want a specific structure which wraps an idmap
index, rather just return an Index interface.
Better to have a test to make sure everything functions properly than an
example usage..
In addition added a test for the bindings which show how to use the
functionality.
This is potentially necessary for various things, but specifically is
critical for us NOW because RemoveIDs isn't implemented for GPUIndexs,
so until we implement that functionality in faiss, the only solution is
to transfer the index back and forth to the CPU and remove ids which the
index is on CPU.
This is so that it will be possible to compile and use the library on a
machine which doesn't have a gpu as well.
Didn't know t.Log existed, better to use it.
I discoverd the hard way that after transferring an index to the GPU,
the gpu memory isn't freed when the index is deleted. It seems like a
gpuResource is being allocated and holding the memory. Its necessary to
free the gpuResource in order to free the Gpumemory.

In order to free the gpuResource we will need to save it, and call free
on it. In the next commit I will add the Free functionality to
gpu_bindings.go.
…letes the index

TransferToCpu will free the gpu memory after copying the index to CPU.

Also added a function to CreateGpuIndex just because it was easy and may
be useful for someone.
Its not really the best, but I assume that most Gpus will run out of
memory when creating 20 gpu indices, so if the test passes, most likely
the free function is working ;)
@@ -1,3 +1,5 @@
module github.com/DataIntelligenceCrew/go-faiss
module github.com/Anyvisionltd/go-faiss
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, changing the module name would break the existing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants