File size: 1,288 Bytes
90f0b29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**************************************************************************************************
 *
 * Copyright (c) 2019-2023 Axera Semiconductor (Ningbo) Co., Ltd. All Rights Reserved.
 *
 * This source file is the property of Axera Semiconductor (Ningbo) Co., Ltd. and
 * may not be copied or distributed in any isomorphic form without the prior
 * written consent of Axera Semiconductor (Ningbo) Co., Ltd.
 *
 **************************************************************************************************/

#pragma once

#include <string>
#include <vector>
#include <cstring>
#include <array>
#include <cstdint>

#include "ax_engine_api.h"


class EngineWrapper {
public:
    EngineWrapper() :
            m_hasInit(false),
            m_handle(nullptr) {}

    virtual ~EngineWrapper() {
        Release();
    }

    int Init(const char* strModelPath, uint32_t nNpuType = 0);

    int SetInput(void* pInput, int index);

    int Run();

    int GetOutput(void* pOutput, int index);

    int GetInputSize(int index);
    int GetOutputSize(int index);

    void* GetOutputPtr(int index);

    int Release();

protected:
    bool m_hasInit;
    AX_ENGINE_HANDLE m_handle;
    AX_ENGINE_IO_INFO_T *m_io_info{};
    AX_ENGINE_IO_T m_io{};
    int m_input_num{}, m_output_num{};
};