Debian Codegraph @

c_api/gpu/macros_impl.h

raw
1 /*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 // -*- c++ -*-
9
10 #ifndef GPU_MACROS_IMPL_H
11 #define GPU_MACROS_IMPL_H
12 #include "../macros_impl.h"
13
14 #undef DEFINE_GETTER
15 #define DEFINE_GETTER(clazz, ty, name) \
16 ty faiss_##clazz##_##name(const Faiss##clazz* obj) { \
17 return static_cast<ty>( \
18 reinterpret_cast<const faiss::gpu::clazz*>(obj)->name); \
19 }
20
21 #undef DEFINE_SETTER
22 #define DEFINE_SETTER(clazz, ty, name) \
23 void faiss_##clazz##_set_##name(Faiss##clazz* obj, ty val) { \
24 reinterpret_cast<faiss::gpu::clazz*>(obj)->name = val; \
25 }
26
27 #undef DEFINE_SETTER_STATIC
28 #define DEFINE_SETTER_STATIC(clazz, ty_to, ty_from, name) \
29 void faiss_##clazz##_set_##name(Faiss##clazz* obj, ty_from val) { \
30 reinterpret_cast<faiss::gpu::clazz*>(obj)->name = \
31 static_cast<ty_to>(val); \
32 }
33
34 #undef DEFINE_DESTRUCTOR
35 #define DEFINE_DESTRUCTOR(clazz) \
36 void faiss_##clazz##_free(Faiss##clazz* obj) { \
37 delete reinterpret_cast<faiss::gpu::clazz*>(obj); \
38 }
39
40 #endif