|
| 1 | +#ifndef __INFINIOP_BINARY_OP_API_H__ |
| 2 | +#define __INFINIOP_BINARY_OP_API_H__ |
| 3 | + |
| 4 | +#include "../operator_descriptor.h" |
| 5 | + |
| 6 | +/** |
| 7 | + * @brief Macro to generate the C API header for a binary operator. |
| 8 | + * |
| 9 | + * This macro generates all the necessary declarations for a binary operator: |
| 10 | + * - Descriptor type definition |
| 11 | + * - Create descriptor function |
| 12 | + * - Get workspace size function |
| 13 | + * - Execute operator function |
| 14 | + * - Destroy descriptor function |
| 15 | + * |
| 16 | + * Usage: |
| 17 | + * BINARY_OP_API_DECLARE(div, Div) |
| 18 | + * BINARY_OP_API_DECLARE(pow, Pow) |
| 19 | + * |
| 20 | + * @param OP_NAME Lowercase operator name (e.g., div, pow, mod) |
| 21 | + * @param OP_NAME_UPPER Uppercase operator name (e.g., Div, Pow, Mod) |
| 22 | + */ |
| 23 | +#define BINARY_OP_API_DECLARE(OP_NAME, OP_NAME_UPPER) \ |
| 24 | + \ |
| 25 | + typedef struct InfiniopDescriptor *infiniop##OP_NAME_UPPER##Descriptor_t; \ |
| 26 | + \ |
| 27 | + __C __export infiniStatus_t infiniopCreate##OP_NAME_UPPER##Descriptor( \ |
| 28 | + infiniopHandle_t handle, \ |
| 29 | + infiniop##OP_NAME_UPPER##Descriptor_t *desc_ptr, \ |
| 30 | + infiniopTensorDescriptor_t c, \ |
| 31 | + infiniopTensorDescriptor_t a, \ |
| 32 | + infiniopTensorDescriptor_t b); \ |
| 33 | + \ |
| 34 | + __C __export infiniStatus_t infiniopGet##OP_NAME_UPPER##WorkspaceSize( \ |
| 35 | + infiniop##OP_NAME_UPPER##Descriptor_t desc, \ |
| 36 | + size_t *size); \ |
| 37 | + \ |
| 38 | + __C __export infiniStatus_t infiniop##OP_NAME_UPPER( \ |
| 39 | + infiniop##OP_NAME_UPPER##Descriptor_t desc, \ |
| 40 | + void *workspace, \ |
| 41 | + size_t workspace_size, \ |
| 42 | + void *c, \ |
| 43 | + const void *a, \ |
| 44 | + const void *b, \ |
| 45 | + void *stream); \ |
| 46 | + \ |
| 47 | + __C __export infiniStatus_t infiniopDestroy##OP_NAME_UPPER##Descriptor( \ |
| 48 | + infiniop##OP_NAME_UPPER##Descriptor_t desc); |
| 49 | + |
| 50 | +#endif // __INFINIOP_BINARY_OP_API_H__ |
0 commit comments