Skip to content

Commit

Permalink
add chemfp algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunjiangZhu committed Jun 21, 2020
1 parent e9f4436 commit 5221721
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ann_benchmarks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _test(df):

try:
if args.local:
run(definition, args.dataset, args.count, args.runs, args.batch, args.rq, args.radius)
run(definition, args.dataset, args.count, args.runs, args.batch, args.rq)
elif args.docker:
run_docker(definition, args.dataset, args.count, args.runs, args.timeout, args.batch, args.rq, args.radius)
else:# by default run Singularity
Expand Down
27 changes: 14 additions & 13 deletions ann_benchmarks/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def run_individual_query(algoname, algo, X_train, X_test, distance, count, run_c
n_items_processed = [0] # a bit dumb but can't be a scalar since of Python's scoping rules

def single_query(v):
# special code for the Risc and DivideSkip
if "Risc" in algoname or 'DivideSkip' in algoname:
# special code for the Risc, DivideSkip, and Chemfp
if algoname in ['Risc', 'DivideSkip', 'Chemfp']:
algo.pre_query(v, count)

start = time.time()
Expand All @@ -45,8 +45,8 @@ def single_query(v):
candidates = algo.query(v, count)
total = (time.time() - start)

# special code for the Risc and DivideSkip
if "Risc" in algoname or 'DivideSkip' in algoname:
# special code for the Risc, DivideSkip, and Chemfp
if algoname in ['Risc', 'DivideSkip', 'Chemfp']:
candidates = algo.post_query()

if issparse(X_train):
Expand Down Expand Up @@ -123,12 +123,15 @@ def run(definition, dataset, count, run_count, batch, rq):
print('got %d queries' % len(X_test))

try:
# special code for the Risc and DivideSkip
print(X_train.shape)
if 'Risc' in definition.algorithm or 'DivideSkip' in definition.algorithm:
# special code for Risc and DivideSkip
if definition.algorithm in ['Risc', 'DivideSkip']:
X_train = numpy.concatenate((X_train, [numpy.ones(X_train.shape[1], dtype=numpy.bool)]), axis=0)
print(X_train.shape)
algo.pre_fit(X_train)
# special code for Chemfp
if definition.algorithm in 'Chemfp':
algo.pre_fit(X_train)

t0 = time.time()
index_size_before = algo.get_index_size("self")
Expand Down Expand Up @@ -298,11 +301,9 @@ def run_singularity(definition, dataset, count, runs, timeout, batch, rq, radius
strCmd = ' '.join(["'" + k + "'" for k in cmd])
print('String of command', strCmd)

subprocess.check_call('singularity exec %s/%s.sif python3 run_algorithm.py %s' %(sif_dir, definition.singularity_tag, strCmd), shell=True)
#subprocess.check_call('singularity exec ../../singularity/ann-bench-nmslib3.sif python3 run_algorithm.py %s' %(strCmd), shell=True)
#subprocess.check_call('singularity exec ../singularity/ann-bench-pynndescent.sif python3 run_algorithm.py %s' %(strCmd), shell=True)
#subprocess.check_call('singularity exec ../singularity/ann-bench-datasketch.sif python3 run_algorithm.py %s' %(strCmd), shell=True)
#subprocess.check_call('singularity exec ../singularity/ann-bench-sklearn.sif python3 run_algorithm.py %s' %(strCmd), shell=True)
#subprocess.check_call('singularity exec ../singularity/ann-bench-risc.sif python3 run_algorithm.py %s' %(strCmd), shell=True)
#subprocess.check_call('singularity exec ../singularity/ann-bench-ngt.sif python3 run_algorithm.py %s' %(strCmd), shell=True)
# Chemfp uses Python2 while others use Python3
if definition.algorithm in 'Chemfp':
subprocess.check_call('singularity exec %s/%s.sif python run_algorithm.py %s' %(sif_dir, definition.singularity_tag, strCmd), shell=True)
else:
subprocess.check_call('singularity exec %s/%s.sif python3 run_algorithm.py %s' %(sif_dir, definition.singularity_tag, strCmd), shell=True)

0 comments on commit 5221721

Please sign in to comment.