Skip to content

Commit b779132

Browse files
addressed reviews - 1
1 parent 329d981 commit b779132

File tree

6 files changed

+593
-524
lines changed

6 files changed

+593
-524
lines changed

autotune.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package faiss
66
*/
77
import "C"
88
import (
9+
"fmt"
910
"unsafe"
1011
)
1112

@@ -30,11 +31,20 @@ func (p *ParameterSpace) SetIndexParameter(idx Index, name string, val float64)
3031
C.free(unsafe.Pointer(cname))
3132
}()
3233

33-
c := C.faiss_ParameterSpace_set_index_parameter(
34-
p.ps, idx.cPtr(), cname, C.double(val))
35-
if c != 0 {
36-
return getLastError()
34+
switch idx.(type) {
35+
case FloatIndex:
36+
idx := idx.(*IndexImpl)
37+
c := C.faiss_ParameterSpace_set_index_parameter(
38+
p.ps, idx.cPtrFloat(), cname, C.double(val))
39+
if c != 0 {
40+
return getLastError()
41+
}
42+
case BinaryIndex:
43+
return fmt.Errorf("binary indexes not supported for auto-tuning")
44+
default:
45+
return fmt.Errorf("unsupported index type")
3746
}
47+
3848
return nil
3949
}
4050

0 commit comments

Comments
 (0)