1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __HI_PLUGIN_TYPE_H__ 17 #define __HI_PLUGIN_TYPE_H__ 18 19 #include "hi_type.h" 20 21 #if defined(_MSC_VER) 22 #define EXPORT __declspec(dllexport) 23 #elif defined(__GNUC__) 24 #define EXPORT __attribute__((visibility("default"))) 25 #else 26 #define EXPORT 27 #pragma warning cant export dynamic symbos 28 #endif 29 30 #ifdef __cplusplus 31 #if __cplusplus 32 extern "C" { 33 #endif 34 #endif /* __cplusplus */ 35 36 enum { 37 MAX_OPERAND_NAME_LEN = 64, 38 }; 39 40 typedef struct hiNodePlugin_Shape_S { 41 HI_S32 s32H; 42 HI_S32 s32W; 43 HI_S32 s32C; 44 } HI_NodePlugin_Shape_S; 45 46 typedef enum hiNodePlugin_ElemType_E { 47 ELEM_TYPE_U8, 48 ELEM_TYPE_U16, 49 ELEM_TYPE_U32 50 } HI_NodePlugin_ElemType_E; 51 52 typedef struct hiNodePlugin_Operand_S { 53 HI_U64 u64Offset; // addr 54 HI_CHAR mName[MAX_OPERAND_NAME_LEN + 1]; 55 HI_NodePlugin_ElemType_E enElemType; 56 HI_U32 u32Num; 57 HI_U32 u32Stride; 58 HI_NodePlugin_Shape_S stShape; 59 } HI_NodePlugin_Operand_S; 60 61 typedef struct HiNodeParam { 62 HI_VOID *pParam; 63 HI_U32 u32Size; 64 } HI_NodePlugin_NodeParam_S; 65 66 typedef HI_S32 (*NodePluginCompute)(const HI_NodePlugin_Operand_S *, HI_U32, HI_NodePlugin_Operand_S *, 67 HI_U32, HI_NodePlugin_NodeParam_S *, HI_NodePlugin_NodeParam_S *); 68 69 typedef HI_S32 (*NodePluginGetType)(HI_CHAR pszNodeType[]); 70 71 EXPORT HI_S32 HI_NodePlugin_Compute(const HI_NodePlugin_Operand_S *pstInputs, HI_U32 u32InputNum, 72 HI_NodePlugin_Operand_S *pstOutputs, 73 HI_U32 u32Outputs, HI_NodePlugin_NodeParam_S *pstHyperParam, 74 HI_NodePlugin_NodeParam_S *pstTrainingParam); 75 76 EXPORT HI_S32 HI_NodePlugin_getNodeType(HI_CHAR pszNodeType[]); 77 78 #ifdef __cplusplus 79 #if __cplusplus 80 } 81 #endif 82 #endif /* __cplusplus */ 83 84 #endif 85