forked from facebookresearch/faiss
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request facebookresearch#1 from yuhaijun999/wip-add-faiss-…
…hook-dingodb Added InnerProduct and L2Sqr hook interfaces.
- Loading branch information
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// -*- c++ -*- | ||
|
||
#include "FaissHook.h" | ||
|
||
namespace faiss { | ||
|
||
extern float fvec_L2sqr_default(const float* x, const float* y, size_t d); | ||
|
||
extern float fvec_inner_product_default( | ||
const float* x, | ||
const float* y, | ||
size_t d); | ||
|
||
FVEC_L2SQR_HOOK fvec_L2sqr_hook = fvec_L2sqr_default; | ||
FVEC_INNER_PRODUCT_HOOK fvec_inner_product_hook = fvec_inner_product_default; | ||
|
||
void set_fvec_L2sqr_hook(FVEC_L2SQR_HOOK_C hook) { | ||
if (nullptr != hook) | ||
fvec_L2sqr_hook = hook; | ||
} | ||
FVEC_L2SQR_HOOK_C get_fvec_L2sqr_hook() { | ||
return fvec_L2sqr_hook; | ||
} | ||
|
||
void set_fvec_inner_product_hook(FVEC_INNER_PRODUCT_HOOK_C hook) { | ||
if (nullptr != hook) | ||
fvec_inner_product_hook = hook; | ||
} | ||
FVEC_INNER_PRODUCT_HOOK_C get_fvec_inner_product_hook() { | ||
return fvec_inner_product_hook; | ||
} | ||
|
||
} // namespace faiss |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// -*- c++ -*- | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include "faiss/impl/platform_macros.h" | ||
|
||
namespace faiss { | ||
|
||
using FVEC_L2SQR_HOOK = float (*)(const float*, const float*, size_t); | ||
|
||
using FVEC_INNER_PRODUCT_HOOK = float (*)(const float*, const float*, size_t); | ||
|
||
extern FVEC_L2SQR_HOOK fvec_L2sqr_hook; | ||
extern FVEC_INNER_PRODUCT_HOOK fvec_inner_product_hook; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef float (*FVEC_L2SQR_HOOK_C)(const float*, const float*, size_t); | ||
typedef float (*FVEC_INNER_PRODUCT_HOOK_C)(const float*, const float*, size_t); | ||
|
||
FAISS_API void set_fvec_L2sqr_hook(FVEC_L2SQR_HOOK_C hook); | ||
FAISS_API FVEC_L2SQR_HOOK_C get_fvec_L2sqr_hook(); | ||
|
||
FAISS_API void set_fvec_inner_product_hook(FVEC_INNER_PRODUCT_HOOK_C hook); | ||
FAISS_API FVEC_INNER_PRODUCT_HOOK_C get_fvec_inner_product_hook(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
} // namespace faiss |
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