|
| 1 | +//***************************************************************************** |
| 2 | +// Copyright (c) 2016-2020, Intel Corporation |
| 3 | +// All rights reserved. |
| 4 | +// |
| 5 | +// Redistribution and use in source and binary forms, with or without |
| 6 | +// modification, are permitted provided that the following conditions are met: |
| 7 | +// - Redistributions of source code must retain the above copyright notice, |
| 8 | +// this list of conditions and the following disclaimer. |
| 9 | +// - Redistributions in binary form must reproduce the above copyright notice, |
| 10 | +// this list of conditions and the following disclaimer in the documentation |
| 11 | +// and/or other materials provided with the distribution. |
| 12 | +// |
| 13 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 14 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 16 | +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 17 | +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | +// THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | +//***************************************************************************** |
| 25 | + |
| 26 | +/* |
| 27 | + * This header file is for interface Cython with C++. |
| 28 | + * It should not contains any backend specific headers (like SYCL or MKL) because |
| 29 | + * all included headers will be exposed in Cython compilation procedure |
| 30 | + * |
| 31 | + * We would like to avoid backend specific things in higher level Cython modules. |
| 32 | + * Any backend interface functions and types should be defined here. |
| 33 | + * |
| 34 | + * Also, this file should contains documentation on functions and types |
| 35 | + * which are used in the interface |
| 36 | + */ |
| 37 | + |
| 38 | +#pragma once |
| 39 | + |
| 40 | +#include <vector> |
| 41 | + |
| 42 | +#ifdef _WIN |
| 43 | +#define INP_DLLEXPORT __declspec(dllexport) |
| 44 | +#else |
| 45 | +#define INP_DLLEXPORT |
| 46 | +#endif |
| 47 | + |
| 48 | +/** |
| 49 | + * @defgroup BACKEND_FUNC_PTR_API Backend C++ library runtime interface API |
| 50 | + * @{ |
| 51 | + * This section describes Backend API for runtime function pointers |
| 52 | + * @} |
| 53 | + */ |
| 54 | + |
| 55 | +/** |
| 56 | + * @ingroup BACKEND_FUNC_PTR_API |
| 57 | + * @brief Function names to request via this interface |
| 58 | + * |
| 59 | + * The structure defines the parameters that are used |
| 60 | + * by @ref get_dpnp_function_ptr "get_dpnp_function_ptr". |
| 61 | + */ |
| 62 | +enum class DPNPFuncName : uint32_t |
| 63 | +{ |
| 64 | + DPNP_FN_NONE, /**< Very first element of the enumeration */ |
| 65 | + DPNP_FN_DOT, /**< Used in numpy.dot() implementation */ |
| 66 | + DPNP_FN_LAST /**< The latest element of the enumeration */ |
| 67 | +}; |
| 68 | + |
| 69 | +/** |
| 70 | + * @ingroup BACKEND_FUNC_PTR_API |
| 71 | + * @brief Template types which are used in this interface |
| 72 | + * |
| 73 | + * The structure defines the types that are used |
| 74 | + * by @ref get_dpnp_function_ptr "get_dpnp_function_ptr". |
| 75 | + */ |
| 76 | +enum class DPNPFuncType : uint32_t |
| 77 | +{ |
| 78 | + DPNP_FT_INT, /**< analog of numpy.int32 or int */ |
| 79 | + DPNP_FT_LONG, /**< analog of numpy.int64 or long */ |
| 80 | + DPNP_FT_FLOAT, /**< analog of numpy.float32 or float */ |
| 81 | + DPNP_FT_DOUBLE /**< analog of numpy.float32 or double */ |
| 82 | +}; |
| 83 | + |
| 84 | +/** |
| 85 | + * @ingroup BACKEND_API |
| 86 | + * @brief get runtime pointer to selected function |
| 87 | + * |
| 88 | + * Runtime pointer to the backend API function |
| 89 | + * |
| 90 | + * @param [in] name Name of the function pointed by @ref DPNPFuncName |
| 91 | + * @param [in] type The function template type pointed by @ref DPNPFuncType |
| 92 | + * |
| 93 | + * @return A pointer to the backend API function. |
| 94 | + */ |
| 95 | +INP_DLLEXPORT |
| 96 | +void* get_dpnp_function_ptr(DPNPFuncName func_name, DPNPFuncType func_type); |
| 97 | + |
| 98 | +/** |
| 99 | + * DEPRECATED. |
| 100 | + * Experimental interface. DO NOT USE IT! |
| 101 | + * |
| 102 | + * parameter @ref type_name will be converted into var_args or char *[] with extra length parameter |
| 103 | + */ |
| 104 | +INP_DLLEXPORT |
| 105 | +void* get_backend_function_name(const char* func_name, const char* type_name) __attribute__((deprecated)); |
0 commit comments