Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
a0ed04a3
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a0ed04a3
编写于
6月 16, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 16, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9014 bugfix: 测试用例执行失败Map fd to address failed!
Merge pull request !9014 from 汤石华/master
上级
1e5668d8
1437d6c4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
0 deletion
+38
-0
ai/neural_network_runtime/v1_0/common/mock_idevice.cpp
ai/neural_network_runtime/v1_0/common/mock_idevice.cpp
+17
-0
ai/neural_network_runtime/v1_0/common/mock_idevice.h
ai/neural_network_runtime/v1_0/common/mock_idevice.h
+3
-0
ai/neural_network_runtime/v2_0/common/mock_idevice.cpp
ai/neural_network_runtime/v2_0/common/mock_idevice.cpp
+15
-0
ai/neural_network_runtime/v2_0/common/mock_idevice.h
ai/neural_network_runtime/v2_0/common/mock_idevice.h
+3
-0
未找到文件。
ai/neural_network_runtime/v1_0/common/mock_idevice.cpp
浏览文件 @
a0ed04a3
...
...
@@ -42,6 +42,14 @@ MockIDevice::~MockIDevice()
}
}
MockIPreparedModel
::~
MockIPreparedModel
()
{
for
(
auto
ash
:
m_ashmems
)
{
ash
.
second
->
UnmapAshmem
();
ash
.
second
->
CloseAshmem
();
}
}
MockIDevice
*
MockIDevice
::
GetInstance
()
{
static
MockIDevice
iDevice
;
...
...
@@ -148,6 +156,11 @@ int32_t MockIDevice::IsModelCacheSupported(bool& isSupported)
int32_t
MockIDevice
::
AllocateBuffer
(
uint32_t
length
,
SharedBuffer
&
buffer
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mtx
);
for
(
auto
ash
:
m_ashmems
){
if
(
ash
.
second
->
GetAshmemSize
()
<=
0
){
ash
.
second
->
CloseAshmem
();
}
}
sptr
<
Ashmem
>
ashptr
=
Ashmem
::
CreateAshmem
(
"allocateBuffer"
,
length
);
if
(
ashptr
==
nullptr
)
{
LOGE
(
"[NNRtTest] Create shared memory failed."
);
...
...
@@ -231,6 +244,9 @@ int32_t MockIPreparedModel::ExportModelCache(std::vector<SharedBuffer>& modelCac
LOGE
(
"[NNRtTest] Map fd to write cache failed."
);
return
HDF_FAILURE
;
}
int
fd
=
cache
->
GetAshmemFd
();
m_ashmems
[
fd
]
=
cache
;
ret
=
cache
->
WriteToAshmem
(
buffer
,
size
,
0
);
cache
->
UnmapAshmem
();
...
...
@@ -238,6 +254,7 @@ int32_t MockIPreparedModel::ExportModelCache(std::vector<SharedBuffer>& modelCac
LOGE
(
"[NNRtTest] Write cache failed."
);
return
HDF_FAILURE
;
}
// SharedBuffer: fd, bufferSize, offset, dataSize
modelCache
.
emplace_back
(
SharedBuffer
{
cache
->
GetAshmemFd
(),
cache
->
GetAshmemSize
(),
0
,
cache
->
GetAshmemSize
()});
return
HDF_SUCCESS
;
...
...
ai/neural_network_runtime/v1_0/common/mock_idevice.h
浏览文件 @
a0ed04a3
...
...
@@ -111,6 +111,9 @@ public:
std
::
vector
<
std
::
vector
<
int32_t
>>&
outputsDims
,
std
::
vector
<
bool
>&
isOutputBufferEnough
)
override
;
int32_t
GetVersion
(
uint32_t
&
majorVersion
,
uint32_t
&
minorVersion
)
override
;
MockIPreparedModel
()
=
default
;
virtual
~
MockIPreparedModel
();
private:
std
::
unordered_map
<
int
,
sptr
<
Ashmem
>>
m_ashmems
;
};
}
// namespace V1_0
...
...
ai/neural_network_runtime/v2_0/common/mock_idevice.cpp
浏览文件 @
a0ed04a3
...
...
@@ -42,6 +42,14 @@ MockIDevice::~MockIDevice()
}
}
MockIPreparedModel
::~
MockIPreparedModel
()
{
for
(
auto
ash
:
m_ashmems
)
{
ash
.
second
->
UnmapAshmem
();
ash
.
second
->
CloseAshmem
();
}
}
MockIDevice
*
MockIDevice
::
GetInstance
()
{
static
MockIDevice
iDevice
;
...
...
@@ -148,6 +156,11 @@ int32_t MockIDevice::IsModelCacheSupported(bool& isSupported)
int32_t
MockIDevice
::
AllocateBuffer
(
uint32_t
length
,
SharedBuffer
&
buffer
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mtx
);
for
(
auto
ash
:
m_ashmems
){
if
(
ash
.
second
->
GetAshmemSize
()
<=
0
){
ash
.
second
->
CloseAshmem
();
}
}
sptr
<
Ashmem
>
ashptr
=
Ashmem
::
CreateAshmem
(
"allocateBuffer"
,
length
);
if
(
ashptr
==
nullptr
)
{
LOGE
(
"[NNRtTest] Create shared memory failed."
);
...
...
@@ -238,6 +251,8 @@ int32_t MockIPreparedModel::ExportModelCache(std::vector<SharedBuffer>& modelCac
LOGE
(
"[NNRtTest] Map fd to write cache failed."
);
return
HDF_FAILURE
;
}
int
fd
=
cache
->
GetAshmemFd
();
m_ashmems
[
fd
]
=
cache
;
ret
=
cache
->
WriteToAshmem
(
buffer
,
size
,
0
);
cache
->
UnmapAshmem
();
...
...
ai/neural_network_runtime/v2_0/common/mock_idevice.h
浏览文件 @
a0ed04a3
...
...
@@ -115,6 +115,9 @@ public:
int32_t
GetInputDimRanges
(
std
::
vector
<
std
::
vector
<
uint32_t
>>&
minInputDims
,
std
::
vector
<
std
::
vector
<
uint32_t
>>&
maxInputDims
)
override
;
int32_t
GetVersion
(
uint32_t
&
majorVersion
,
uint32_t
&
minorVersion
)
override
;
MockIPreparedModel
()
=
default
;
virtual
~
MockIPreparedModel
();
private:
std
::
unordered_map
<
int
,
sptr
<
Ashmem
>>
m_ashmems
;
};
}
// namespace V2_0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录