mirror of
https://gitee.com/openharmony/ai_neural_network_runtime
synced 2024-12-04 14:11:01 +00:00
1_0 memory_allocate fixed
Signed-off-by: w30052974 <wangyifan94@huawei.com>
This commit is contained in:
parent
51e949d93c
commit
2fd876a165
@ -165,6 +165,17 @@ HDIPreparedModelV1_0::HDIPreparedModelV1_0(OHOS::sptr<V1_0::IPreparedModel> hdiP
|
||||
hdiPreparedModel->GetVersion(m_hdiVersion.first, m_hdiVersion.second);
|
||||
}
|
||||
|
||||
HDIPreparedModelV2_0::HDIPreparedModelV2_0()
|
||||
{
|
||||
for (auto addr : m_addrs) {
|
||||
auto memManager = MemoryManager::GetInstance();
|
||||
OH_NN_ReturnCode ret = memManager->UnMapMemory(addr);
|
||||
if (ret != OH_NN_SUCCESS) {
|
||||
LOGE("~HDIPreparedModelV2_0 UnMapMemory failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OH_NN_ReturnCode HDIPreparedModelV1_0::ExportModelCache(std::vector<Buffer>& modelCache)
|
||||
{
|
||||
if (!modelCache.empty()) {
|
||||
@ -187,6 +198,7 @@ OH_NN_ReturnCode HDIPreparedModelV1_0::ExportModelCache(std::vector<Buffer>& mod
|
||||
LOGE("Export the %zuth model cache failed, cannot not map fd to address.", i + 1);
|
||||
return OH_NN_MEMORY_ERROR;
|
||||
}
|
||||
m_addrs.emplace_back(addr);
|
||||
Buffer modelbuffer {addr, iBuffers[i].bufferSize};
|
||||
modelCache.emplace_back(modelbuffer);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ namespace NeuralNetworkRuntime {
|
||||
class HDIPreparedModelV1_0 : public PreparedModel {
|
||||
public:
|
||||
explicit HDIPreparedModelV1_0(OHOS::sptr<V1_0::IPreparedModel> hdiPreparedModel);
|
||||
~HDIPreparedModelV2_0() override;
|
||||
|
||||
OH_NN_ReturnCode ExportModelCache(std::vector<Buffer>& modelCache) override;
|
||||
|
||||
@ -50,6 +51,7 @@ private:
|
||||
// first: major version, second: minor version
|
||||
std::pair<uint32_t, uint32_t> m_hdiVersion;
|
||||
OHOS::sptr<V1_0::IPreparedModel> m_hdiPreparedModel {nullptr};
|
||||
std::vector<void *> m_addrs;
|
||||
};
|
||||
} // namespace NeuralNetworkRuntime
|
||||
} // OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user