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 PLUGIN_HELPER_H
17 #define PLUGIN_HELPER_H
18 
19 #include <cstdint>
20 #include <utility>
21 #include <vector>
22 
23 #include "ai_datatype.h"
24 #include "aie_info_define.h"
25 #include "aie_macros.h"
26 #include "data_decoder.h"
27 #include "data_encoder.h"
28 
29 namespace OHOS {
30 namespace AI {
31 /**
32  *
33  * @brief Defines the basic config parameters for <b>Plugin</b>s.
34  *
35  *
36  * @since 1.0
37  * @version 1.0
38  */
39 struct PluginConfig {
40     // Indicates the size of inputData
41     size_t inputSize;
42     // Indicates the size of outputData
43     size_t outputSize;
44     // Indicates the start address of input
45     uintptr_t inputAddr;
46     // Indicates the start address of output
47     uintptr_t outputAddr;
48 };
49 
50 template<>
51 int32_t DataEncoder::EncodeOneParameter(const std::vector<std::pair<int32_t, int32_t>> &outputData);
52 
53 template<>
54 int32_t DataDecoder::DecodeOneParameter(Array<uint8_t> &val);
55 
56 template<>
57 int32_t DataDecoder::DecodeOneParameter(Array<uint16_t> &val);
58 
59 template<>
60 int32_t DataDecoder::DecodeOneParameter(Array<uint32_t> &val);
61 
62 template<>
63 int32_t DataDecoder::DecodeOneParameter(Array<int16_t> &val);
64 
65 template<>
66 int32_t DataDecoder::DecodeOneParameter(Array<int32_t> &val);
67 
68 template<>
69 int32_t DataEncoder::EncodeOneParameter(const Array<uint8_t> &val);
70 
71 template<>
72 int32_t DataEncoder::EncodeOneParameter(const Array<uint16_t> &val);
73 
74 template<>
75 int32_t DataEncoder::EncodeOneParameter(const Array<uint32_t> &val);
76 
77 template<>
78 int32_t DataEncoder::EncodeOneParameter(const Array<int16_t> &val);
79 
80 template<>
81 int32_t DataEncoder::EncodeOneParameter(const Array<int32_t> &val);
82 }
83 }
84 #endif // PLUGIN_HELPER_H