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_RUNTIME_API__
17#define __HI_RUNTIME_API__
18
19#include "hi_type.h"
20#include "hi_runtime_comm.h"
21
22#ifdef __cplusplus
23#if __cplusplus
24extern "C" {
25#endif
26#endif /* __cplusplus */
27
28/* ****************************************************************************
29*   Prototype    : HI_SVPRT_RUNTIME_Init
30*   Description  : Environment Init
31*   Parameters   : HI_CHAR *pszGlobalSetting            GlobalSetting for runtime
32                                                        if NULL, use default
33                   HI_RUNTIME_MEM_CTRL_S *pstMemCtrl    Memory Controll by alloc,flush,and free
34                                                        if NULL, use mmz
35*   Return Value : HI_SUCCESS: Success; Error codes: Failure.
36**************************************************************************** */
37HI_S32 HI_SVPRT_RUNTIME_Init(IN const HI_CHAR* pszGlobalSetting, IN HI_RUNTIME_MEM_CTRL_S* pstMemCtrl);
38
39/* ****************************************************************************
40*   Prototype    : HI_SVPRT_RUNTIME_LoadModelGroupSync
41*   Description  : Load model
42*   Parameters   : HI_CHAR*                   pstModelGroupConfig    Input Group Config
43                   HI_RUNTIME_GROUP_INFO_S*   pstModelGroupAttr      Group Info, such as wk,cop,connector
44                   HI_RUNTIME_GROUP_HANDLE*   phGroupHandle          output Group Handle
45*   Return Value : HI_SUCCESS: Success; Error codes: Failure.
46**************************************************************************** */
47HI_S32 HI_SVPRT_RUNTIME_LoadModelGroup(IN const HI_CHAR* pstModelGroupConfig,
48    IN HI_RUNTIME_GROUP_INFO_S* pstModelGroupAttr, OUT HI_RUNTIME_GROUP_HANDLE* phGroupHandle);
49
50/* ****************************************************************************
51 * Prototype    : HI_SVPRT_RUNTIME_ForwardGroupSync
52 * Description  : Perform prediction on input sample(s), and output responses for corresponding sample(s), Sync Fuction
53 * Parameters   : HI_RUNTIME_GROUP_HANDLE               hGroupHandle    Group Handle generated by
54 * HI_SVPRT_RUNTIME_LoadModelGroup HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR   pstSrc           Input Blobs
55 * HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR   pstDst           Output Blobs.
56 * Return Value: HI_SUCCESS: Success; Error codes: Failure.
57 * *************************************************************************** */
58HI_S32 HI_SVPRT_RUNTIME_ForwardGroupSync(IN const HI_RUNTIME_GROUP_HANDLE hGroupHandle,
59    IN const HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR pstSrc, OUT HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR pstDst,
60    IN HI_U64 u64SrcId);
61
62/* ****************************************************************************
63*   Prototype    : HI_SVPRT_RUNTIME_ForwardGroupASync
64*   Description  : Perform prediction on input sample(s), and output responses for corresponding sample(s),ASync
65Function
66*   Parameters   : HI_RUNTIME_GROUP_HANDLE               hGroupHandle    Group Handle generated by
67HI_SVPRT_RUNTIME_LoadModelGroup can't be NULL
68*                  HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR   pstSrc      Input Blobs
69*                  HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR   pstDst      Output Blobs.
70*                  HI_U64                                u64SrcId    Frame id set by user,
71*                                                                    can be duplicate number
72*                  HI_RUNTIME_Forward_CallBack           pCbFun      Callback for ForwardGroup,
73*                                                                    can't be null
74*   Return Value: HI_SUCCESS: Success; Error codes: Failure.
75**************************************************************************** */
76HI_S32 HI_SVPRT_RUNTIME_ForwardGroupASync(IN const HI_RUNTIME_GROUP_HANDLE hGroupHandle,
77    IN const HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR pstSrc, OUT HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR pstDst,
78    IN HI_U64 u64SrcId, IN HI_RUNTIME_Forward_Callback pCbFun);
79
80/* ****************************************************************************
81 * Prototype    : HI_SVPRT_RUNTIME_UnloadModel
82 * Description  : Unload model
83 * Parameters   : HI_RUNTIME_GROUP_HANDLE   hGroupHandle           Group Handle generated by
84 * HI_SVPRT_RUNTIME_LoadModelGroup can not be NULL
85 *
86 * Return Value : HI_SUCCESS: Success; Error codes: Failure.
87 * *************************************************************************** */
88HI_S32 HI_SVPRT_RUNTIME_UnloadModelGroup(IN const HI_RUNTIME_GROUP_HANDLE hGroupHandle);
89
90/* ****************************************************************************
91 * Prototype    : HI_SVPRT_RUNTIME_deInit
92 * Description  : Environment DeInit
93 * Return Value : HI_SUCCESS: Success; Error codes: Failure.
94 * *************************************************************************** */
95HI_S32 HI_SVPRT_RUNTIME_DeInit();
96
97#ifdef __cplusplus
98#if __cplusplus
99}
100#endif
101#endif /* __cplusplus */
102
103#endif /* __HI_RUNTIME_API__ */
104