1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
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 NNIE_ADAPTER_H
17 #define NNIE_ADAPTER_H
18 
19 #include <cstdint>
20 #include <cstdlib>
21 
22 #include "engine_adapter.h"
23 
24 namespace OHOS {
25 namespace AI {
26 class NNIEAdapter : public EngineAdapter {
27 public:
28     NNIEAdapter();
29     virtual ~NNIEAdapter();
30 
31     /* Initializes the algorithm and get the algorithm execution handle. */
32     int32_t Init(const char *modelPath, intptr_t &handle) override;
33 
34     /* De-Initializes all the algorithms. */
35     int32_t Deinit() override;
36 
37     /* Makes the model based on the given handle Inference once. */
38     int32_t Invoke(intptr_t handle) override;
39 
40     /* Gets the inputBuffer and inputSize after the handle related model is initialized. */
41     int32_t GetInputAddr(intptr_t handle, uint16_t nodeId, uintptr_t &inputBuffer, size_t &inputSize) override;
42 
43     /* Gets the outputBuffer and outputSize after the handle related model is initialized. */
44     int32_t GetOutputAddr(intptr_t handle, uint16_t nodeId, uintptr_t &outputBuffer, size_t &outputSize) override;
45 
46     /* Releases the algorithm based on the given handle. */
47     int32_t ReleaseHandle(intptr_t handle) override;
48 };
49 } // namespace AI
50 } // namespace OHOS
51 #endif // NNIE_ADAPTER_H