Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
57800320
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看板
提交
57800320
编写于
11月 14, 2022
作者:
T
tangshihua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
静态检查修改
Signed-off-by:
N
tangshihua
<
tangshihua@huawei.com
>
上级
79e2f061
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
21 deletion
+22
-21
ai/neural_network_runtime/common/mock_idevice.cpp
ai/neural_network_runtime/common/mock_idevice.cpp
+2
-2
ai/neural_network_runtime/common/mock_idevice.h
ai/neural_network_runtime/common/mock_idevice.h
+1
-1
ai/neural_network_runtime/common/nnrt_utils.cpp
ai/neural_network_runtime/common/nnrt_utils.cpp
+10
-9
ai/neural_network_runtime/common/nnrt_utils.h
ai/neural_network_runtime/common/nnrt_utils.h
+2
-2
ai/neural_network_runtime/interface/src/ExecutorTest.cpp
ai/neural_network_runtime/interface/src/ExecutorTest.cpp
+1
-1
ai/neural_network_runtime/interface/src/ModelTest.cpp
ai/neural_network_runtime/interface/src/ModelTest.cpp
+6
-6
未找到文件。
ai/neural_network_runtime/common/mock_idevice.cpp
浏览文件 @
57800320
...
@@ -175,7 +175,7 @@ int32_t MockIDevice::ReleaseBuffer(const SharedBuffer &buffer)
...
@@ -175,7 +175,7 @@ int32_t MockIDevice::ReleaseBuffer(const SharedBuffer &buffer)
return
HDF_SUCCESS
;
return
HDF_SUCCESS
;
}
}
int32_t
MockIDevice
::
MemoryCopy
(
float
*
data
,
uint32_t
length
)
int32_t
MockIDevice
::
MemoryCopy
(
float
*
data
,
uint32_t
length
)
{
{
auto
memManager
=
NeuralNetworkRuntime
::
MemoryManager
::
GetInstance
();
auto
memManager
=
NeuralNetworkRuntime
::
MemoryManager
::
GetInstance
();
auto
memAddress
=
memManager
->
MapMemory
(
m_bufferFd
,
length
);
auto
memAddress
=
memManager
->
MapMemory
(
m_bufferFd
,
length
);
...
@@ -198,7 +198,7 @@ int32_t MockIDevice::PrepareModel(const Model& model, const ModelConfig& config,
...
@@ -198,7 +198,7 @@ int32_t MockIDevice::PrepareModel(const Model& model, const ModelConfig& config,
}
}
int32_t
MockIDevice
::
PrepareModelFromModelCache
(
const
std
::
vector
<
SharedBuffer
>&
modelCache
,
const
ModelConfig
&
config
,
int32_t
MockIDevice
::
PrepareModelFromModelCache
(
const
std
::
vector
<
SharedBuffer
>&
modelCache
,
const
ModelConfig
&
config
,
sptr
<
IPreparedModel
>&
preparedModel
)
sptr
<
IPreparedModel
>&
preparedModel
)
{
{
preparedModel
=
new
(
std
::
nothrow
)
V1_0
::
MockIPreparedModel
();
preparedModel
=
new
(
std
::
nothrow
)
V1_0
::
MockIPreparedModel
();
return
HDF_SUCCESS
;
return
HDF_SUCCESS
;
...
...
ai/neural_network_runtime/common/mock_idevice.h
浏览文件 @
57800320
...
@@ -70,7 +70,7 @@ public:
...
@@ -70,7 +70,7 @@ public:
int32_t
PrepareModelFromModelCache
(
const
std
::
vector
<
SharedBuffer
>&
modelCache
,
const
ModelConfig
&
config
,
int32_t
PrepareModelFromModelCache
(
const
std
::
vector
<
SharedBuffer
>&
modelCache
,
const
ModelConfig
&
config
,
sptr
<
IPreparedModel
>&
preparedModel
)
override
;
sptr
<
IPreparedModel
>&
preparedModel
)
override
;
int32_t
MemoryCopy
(
float
*
data
,
uint32_t
length
);
int32_t
MemoryCopy
(
float
*
data
,
uint32_t
length
);
void
SetFP16Supported
(
bool
isSupported
);
void
SetFP16Supported
(
bool
isSupported
);
...
...
ai/neural_network_runtime/common/nnrt_utils.cpp
浏览文件 @
57800320
...
@@ -35,7 +35,7 @@ int BuildMultiOpGraph(OH_NNModel *model, const OHNNGraphArgsMulti &graphArgs)
...
@@ -35,7 +35,7 @@ int BuildMultiOpGraph(OH_NNModel *model, const OHNNGraphArgsMulti &graphArgs)
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
j
][
i
];
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
j
][
i
];
auto
quantParam
=
operandTem
.
quantParam
;
auto
quantParam
=
operandTem
.
quantParam
;
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
operandTem
.
shape
.
data
(),
quantParam
,
operandTem
.
type
};
operandTem
.
shape
.
data
(),
quantParam
,
operandTem
.
type
};
ret
=
OH_NNModel_AddTensor
(
model
,
&
operand
);
ret
=
OH_NNModel_AddTensor
(
model
,
&
operand
);
if
(
ret
!=
OH_NN_SUCCESS
)
{
if
(
ret
!=
OH_NN_SUCCESS
)
{
LOGE
(
"[NNRtTest] OH_NNModel_AddTensor failed! ret=%d
\n
"
,
ret
);
LOGE
(
"[NNRtTest] OH_NNModel_AddTensor failed! ret=%d
\n
"
,
ret
);
...
@@ -84,7 +84,7 @@ int BuildSingleOpGraph(OH_NNModel *model, const OHNNGraphArgs &graphArgs)
...
@@ -84,7 +84,7 @@ int BuildSingleOpGraph(OH_NNModel *model, const OHNNGraphArgs &graphArgs)
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
i
];
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
i
];
auto
quantParam
=
operandTem
.
quantParam
;
auto
quantParam
=
operandTem
.
quantParam
;
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
operandTem
.
shape
.
data
(),
quantParam
,
operandTem
.
type
};
operandTem
.
shape
.
data
(),
quantParam
,
operandTem
.
type
};
ret
=
OH_NNModel_AddTensor
(
model
,
&
operand
);
ret
=
OH_NNModel_AddTensor
(
model
,
&
operand
);
if
(
ret
!=
OH_NN_SUCCESS
)
{
if
(
ret
!=
OH_NN_SUCCESS
)
{
LOGE
(
"[NNRtTest] OH_NNModel_AddTensor failed! ret=%d
\n
"
,
ret
);
LOGE
(
"[NNRtTest] OH_NNModel_AddTensor failed! ret=%d
\n
"
,
ret
);
...
@@ -194,7 +194,7 @@ int CompileGraphMock(OH_NNCompilation *compilation, const OHNNCompileParam &comp
...
@@ -194,7 +194,7 @@ int CompileGraphMock(OH_NNCompilation *compilation, const OHNNCompileParam &comp
int
ExecuteGraphMock
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
int
ExecuteGraphMock
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
float
*
expect
)
float
*
expect
)
{
{
OHOS
::
sptr
<
V1_0
::
MockIDevice
>
device
=
V1_0
::
MockIDevice
::
GetInstance
();
OHOS
::
sptr
<
V1_0
::
MockIDevice
>
device
=
V1_0
::
MockIDevice
::
GetInstance
();
int
ret
=
0
;
int
ret
=
0
;
...
@@ -204,8 +204,8 @@ float* expect)
...
@@ -204,8 +204,8 @@ float* expect)
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
i
];
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
i
];
auto
quantParam
=
operandTem
.
quantParam
;
auto
quantParam
=
operandTem
.
quantParam
;
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
operandTem
.
shape
.
data
(),
operandTem
.
shape
.
data
(),
quantParam
,
operandTem
.
type
};
quantParam
,
operandTem
.
type
};
if
(
std
::
find
(
graphArgs
.
inputIndices
.
begin
(),
graphArgs
.
inputIndices
.
end
(),
i
)
!=
if
(
std
::
find
(
graphArgs
.
inputIndices
.
begin
(),
graphArgs
.
inputIndices
.
end
(),
i
)
!=
graphArgs
.
inputIndices
.
end
())
{
graphArgs
.
inputIndices
.
end
())
{
ret
=
OH_NNExecutor_SetInput
(
executor
,
inputIndex
,
&
operand
,
operandTem
.
data
,
ret
=
OH_NNExecutor_SetInput
(
executor
,
inputIndex
,
&
operand
,
operandTem
.
data
,
...
@@ -234,7 +234,8 @@ float* expect)
...
@@ -234,7 +234,8 @@ float* expect)
return
ret
;
return
ret
;
}
}
int
ExecutorWithMemory
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
OH_NN_Memory
*
OHNNMemory
[],
float
*
expect
)
int
ExecutorWithMemory
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
OH_NN_Memory
*
OHNNMemory
[],
float
*
expect
)
{
{
OHOS
::
sptr
<
V1_0
::
MockIDevice
>
device
=
V1_0
::
MockIDevice
::
GetInstance
();
OHOS
::
sptr
<
V1_0
::
MockIDevice
>
device
=
V1_0
::
MockIDevice
::
GetInstance
();
int
ret
=
0
;
int
ret
=
0
;
...
@@ -244,8 +245,8 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
...
@@ -244,8 +245,8 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
i
];
const
OHNNOperandTest
&
operandTem
=
graphArgs
.
operands
[
i
];
auto
quantParam
=
operandTem
.
quantParam
;
auto
quantParam
=
operandTem
.
quantParam
;
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
OH_NN_Tensor
operand
=
{
operandTem
.
dataType
,
(
uint32_t
)
operandTem
.
shape
.
size
(),
operandTem
.
shape
.
data
(),
operandTem
.
shape
.
data
(),
quantParam
,
operandTem
.
type
};
quantParam
,
operandTem
.
type
};
if
(
std
::
find
(
graphArgs
.
inputIndices
.
begin
(),
graphArgs
.
inputIndices
.
end
(),
i
)
!=
if
(
std
::
find
(
graphArgs
.
inputIndices
.
begin
(),
graphArgs
.
inputIndices
.
end
(),
i
)
!=
graphArgs
.
inputIndices
.
end
())
{
graphArgs
.
inputIndices
.
end
())
{
OH_NN_Memory
*
inputMemory
=
OH_NNExecutor_AllocateInputMemory
(
executor
,
inputIndex
,
OH_NN_Memory
*
inputMemory
=
OH_NNExecutor_AllocateInputMemory
(
executor
,
inputIndex
,
...
@@ -261,7 +262,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
...
@@ -261,7 +262,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
}
else
if
(
std
::
find
(
graphArgs
.
outputIndices
.
begin
(),
graphArgs
.
outputIndices
.
end
(),
i
)
!=
}
else
if
(
std
::
find
(
graphArgs
.
outputIndices
.
begin
(),
graphArgs
.
outputIndices
.
end
(),
i
)
!=
graphArgs
.
outputIndices
.
end
())
{
graphArgs
.
outputIndices
.
end
())
{
OH_NN_Memory
*
outputMemory
=
OH_NNExecutor_AllocateOutputMemory
(
executor
,
outputIndex
,
OH_NN_Memory
*
outputMemory
=
OH_NNExecutor_AllocateOutputMemory
(
executor
,
outputIndex
,
operandTem
.
length
);
operandTem
.
length
);
ret
=
OH_NNExecutor_SetOutputWithMemory
(
executor
,
outputIndex
,
outputMemory
);
ret
=
OH_NNExecutor_SetOutputWithMemory
(
executor
,
outputIndex
,
outputMemory
);
if
(
ret
!=
OH_NN_SUCCESS
)
{
if
(
ret
!=
OH_NN_SUCCESS
)
{
LOGE
(
"[NNRtTest] OH_NNExecutor_SetOutputWithMemory failed! ret=%d
\n
"
,
ret
);
LOGE
(
"[NNRtTest] OH_NNExecutor_SetOutputWithMemory failed! ret=%d
\n
"
,
ret
);
...
...
ai/neural_network_runtime/common/nnrt_utils.h
浏览文件 @
57800320
...
@@ -70,13 +70,13 @@ struct OHNNCompileParam {
...
@@ -70,13 +70,13 @@ struct OHNNCompileParam {
int
BuildSingleOpGraph
(
OH_NNModel
*
modelptr
,
const
OHNNGraphArgs
&
args
);
int
BuildSingleOpGraph
(
OH_NNModel
*
modelptr
,
const
OHNNGraphArgs
&
args
);
int
ExecutorWithMemory
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
OH_NN_Memory
*
OHNNMemory
[],
int
ExecutorWithMemory
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
OH_NN_Memory
*
OHNNMemory
[],
float
*
expect
);
float
*
expect
);
void
Free
(
OH_NNModel
*
model
=
nullptr
,
OH_NNCompilation
*
compilation
=
nullptr
,
OH_NNExecutor
*
executor
=
nullptr
);
void
Free
(
OH_NNModel
*
model
=
nullptr
,
OH_NNCompilation
*
compilation
=
nullptr
,
OH_NNExecutor
*
executor
=
nullptr
);
int
CompileGraphMock
(
OH_NNCompilation
*
compilation
,
const
OHNNCompileParam
&
compileParam
);
int
CompileGraphMock
(
OH_NNCompilation
*
compilation
,
const
OHNNCompileParam
&
compileParam
);
int
ExecuteGraphMock
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
float
*
expect
);
int
ExecuteGraphMock
(
OH_NNExecutor
*
executor
,
const
OHNNGraphArgs
&
graphArgs
,
float
*
expect
);
int
SetDevice
(
OH_NNCompilation
*
compilation
);
int
SetDevice
(
OH_NNCompilation
*
compilation
);
int
BuildMultiOpGraph
(
OH_NNModel
*
model
,
const
OHNNGraphArgsMulti
&
graphArgs
);
int
BuildMultiOpGraph
(
OH_NNModel
*
model
,
const
OHNNGraphArgsMulti
&
graphArgs
);
...
...
ai/neural_network_runtime/interface/src/ExecutorTest.cpp
浏览文件 @
57800320
...
@@ -1204,7 +1204,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function |
...
@@ -1204,7 +1204,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function |
}
}
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNExecutor_Run
(
executor
));
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNExecutor_Run
(
executor
));
// check result
// check result
EXPECT_TRUE
(
CheckOutput
(
static_cast
<
float
*>
(
const_cast
<
void
*>
(
outputMemory
->
data
)),
EXPECT_TRUE
(
CheckOutput
(
static_cast
<
float
*>
(
const_cast
<
void
*>
(
outputMemory
->
data
)),
(
float
*
)
addModel
.
expectValue
));
(
float
*
)
addModel
.
expectValue
));
OH_NNExecutor_DestroyOutputMemory
(
executor
,
0
,
&
outputMemory
);
OH_NNExecutor_DestroyOutputMemory
(
executor
,
0
,
&
outputMemory
);
...
...
ai/neural_network_runtime/interface/src/ModelTest.cpp
浏览文件 @
57800320
...
@@ -854,8 +854,8 @@ HWTEST_F(ModelTest, SUB_AI_NNRt_Func_North_Model_GetSupportedOperation_0400, Fun
...
@@ -854,8 +854,8 @@ HWTEST_F(ModelTest, SUB_AI_NNRt_Func_North_Model_GetSupportedOperation_0400, Fun
uint32_t
devicesCount
{
0
};
uint32_t
devicesCount
{
0
};
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNDevice_GetAllDevicesID
(
&
devicesID
,
&
devicesCount
));
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNDevice_GetAllDevicesID
(
&
devicesID
,
&
devicesCount
));
size_t
targetDevice
=
devicesID
[
0
];
size_t
targetDevice
=
devicesID
[
0
];
ASSERT_EQ
(
OH_NN_INVALID_PARAMETER
,
OH_NNModel_GetAvailableOperations
(
model
,
targetDevice
,
&
realSupported
,
&
opCount
));
ASSERT_EQ
(
OH_NN_INVALID_PARAMETER
,
OH_NNModel_GetAvailableOperations
(
model
,
targetDevice
,
&
realSupported
,
&
opCount
));
Free
(
model
);
Free
(
model
);
}
}
...
@@ -875,8 +875,8 @@ HWTEST_F(ModelTest, SUB_AI_NNRt_Func_North_Model_GetSupportedOperation_0500, Fun
...
@@ -875,8 +875,8 @@ HWTEST_F(ModelTest, SUB_AI_NNRt_Func_North_Model_GetSupportedOperation_0500, Fun
uint32_t
devicesCount
{
0
};
uint32_t
devicesCount
{
0
};
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNDevice_GetAllDevicesID
(
&
devicesID
,
&
devicesCount
));
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNDevice_GetAllDevicesID
(
&
devicesID
,
&
devicesCount
));
size_t
targetDevice
=
devicesID
[
0
];
size_t
targetDevice
=
devicesID
[
0
];
ASSERT_EQ
(
OH_NN_INVALID_PARAMETER
,
OH_NNModel_GetAvailableOperations
(
model
,
targetDevice
,
&
isSupported
,
nullptr
));
ASSERT_EQ
(
OH_NN_INVALID_PARAMETER
,
OH_NNModel_GetAvailableOperations
(
model
,
targetDevice
,
&
isSupported
,
nullptr
));
Free
(
model
);
Free
(
model
);
}
}
...
@@ -898,8 +898,8 @@ HWTEST_F(ModelTest, SUB_AI_NNRt_Func_North_Model_GetSupportedOperation_0600, Fun
...
@@ -898,8 +898,8 @@ HWTEST_F(ModelTest, SUB_AI_NNRt_Func_North_Model_GetSupportedOperation_0600, Fun
uint32_t
devicesCount
{
0
};
uint32_t
devicesCount
{
0
};
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNDevice_GetAllDevicesID
(
&
devicesID
,
&
devicesCount
));
ASSERT_EQ
(
OH_NN_SUCCESS
,
OH_NNDevice_GetAllDevicesID
(
&
devicesID
,
&
devicesCount
));
size_t
targetDevice
=
devicesID
[
0
];
size_t
targetDevice
=
devicesID
[
0
];
ASSERT_EQ
(
OH_NN_OPERATION_FORBIDDEN
,
OH_NNModel_GetAvailableOperations
(
model
,
targetDevice
,
&
isSupported
,
&
opCount
));
ASSERT_EQ
(
OH_NN_OPERATION_FORBIDDEN
,
OH_NNModel_GetAvailableOperations
(
model
,
targetDevice
,
&
isSupported
,
&
opCount
));
Free
(
model
);
Free
(
model
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录