-
Notifications
You must be signed in to change notification settings - Fork 25
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
uhbuhb
wants to merge
13
commits into
DataIntelligenceCrew:master
Choose a base branch
from
uhbuhb:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ;)
arjunsk
reviewed
Sep 30, 2023
@@ -1,3 +1,5 @@ | |||
module github.com/DataIntelligenceCrew/go-faiss | |||
module github.com/Anyvisionltd/go-faiss |
There was a problem hiding this comment.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.