• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef I_AIP_CORE_MANAGER_H
16 #define I_AIP_CORE_MANAGER_H
17 
18 #include <string>
19 #include <vector>
20 
21 namespace OHOS {
22 namespace DataIntelligence {
23 struct ModelConfigData {
24     int32_t versionValue;
25     bool isNPUAvailableValue;
26     std::string cachePathValue;
27 };
28 
29 class IAipCoreManager {
30 public:
31     IAipCoreManager() = default;
32     virtual ~IAipCoreManager() = default;
33 
34     virtual int32_t InitTextModel(const ModelConfigData &config) = 0;
35     virtual int32_t InitImageModel(const ModelConfigData &config) = 0;
36     virtual int32_t LoadTextModel() = 0;
37     virtual int32_t ReleaseTextModel() = 0;
38     virtual int32_t GetTextEmbedding(std::string file, std::vector<float> &results) = 0;
39     virtual int32_t GetTextEmbedding(const std::vector<std::string> &files,
40         std::vector<std::vector<float>> &results) = 0;
41     virtual int32_t LoadImageModel() = 0;
42     virtual int32_t ReleaseImageModel() = 0;
43     virtual int32_t GetImageEmbedding(std::string uri, std::vector<float> &results) = 0;
44     virtual int32_t SplitText(std::string text, int32_t size, float overlap, std::vector<std::string> &results) = 0;
45 };
46 
47 struct AipCoreManagerHandle {
48     void *handle;
49     IAipCoreManager *(*create)();
50     void (*destroy)(const IAipCoreManager *);
51     IAipCoreManager *pAipManager;
AipCoreManagerHandleAipCoreManagerHandle52     AipCoreManagerHandle() : handle(nullptr), create(nullptr), destroy(nullptr), pAipManager(nullptr) {}
~AipCoreManagerHandleAipCoreManagerHandle53     ~AipCoreManagerHandle() {}
ClearAipCoreManagerHandle54     void Clear()
55     {
56         handle = nullptr;
57         create = nullptr;
58         destroy = nullptr;
59         pAipManager = nullptr;
60     }
61 };
62 } // namespace DataIntelligence
63 } // namespace OHOS
64 
65 #endif // I_AIP_CORE_MANAGER_H