microsoft / microsoft/SPTAG

Segmentation fault (core dumped)

Open
#41 5 comments 0 reactions 1 assignee View on GitHub

@MaggieQi is already working on this.

Since Jul 10, 2019.

bug
Dominant language
C++
Stars
5k
Forks
622
Avg merge
8h 37m
Merged PRs (30d)
5

Description

Describe the bug

Test SPTag wrapper on python 2.7, ubuntu 18.04
TRY x is FLOAT data. Got error Segmentation fault (core dumped)

import SPTAG
import numpy as np

n = 100
k = 3
r = 3

def testBuild(algo, distmethod, x, out):
    i = SPTAG.AnnIndex(algo, 'Float', x.shape[1])
    i.SetBuildParam("NumberOfThreads", '4')
    i.SetBuildParam("DistCalcMethod", distmethod)
    ret = i.Build(x.tobytes(), x.shape[0])
    i.Save(out)

def testSearch(index, q, k):
    j = SPTAG.AnnIndex.Load(index)
    for t in range(q.shape[0]):
        result = j.Search(q[t].tobytes(), k)
        print(result[0])  # ids
        print(result[1])  # distances

def Test(algo, distmethod):
    x = np.ones((n, 10), dtype=np.float32) * np.reshape(np.random.uniform(low=0.5, high=13.3, size=(n,)), (n,1))

    print('x.shape: ', str(x.shape))
    print(x[1,])

    print("Build.............................")
    testBuild(algo, distmethod, x, 'testindices')
    testSearch('testindices', q, k)

if __name__ == '__main__':
    Test('BKT', 'L2')
    # Test('KDT', 'L2')

Log console:

('x.shape: ', '(100, 10)')
[ 0.60697413 0.60697413 0.60697413 0.60697413 0.60697413 0.60697413
0.60697413 0.60697413 0.60697413 0.60697413]
Build.............................
Setting NumberOfThreads with value 4
Setting DistCalcMethod with value L2
Save Data To testindices/vectors.bin
Save Data (0, 1) Finish!
Save BKT to testindices/tree.bin
Segmentation fault (core dumped)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.