mirror of
https://gitee.com/openharmony/ai_neural_network_runtime
synced 2024-11-23 07:39:54 +00:00
添加nnrt getdevice
Signed-off-by: w30052974 <wangyifan94@huawei.com>
This commit is contained in:
parent
9fd56d0e8b
commit
12a98d96de
@ -29,7 +29,8 @@
|
||||
"hilog",
|
||||
"hitrace",
|
||||
"ipc",
|
||||
"mindspore"
|
||||
"mindspore",
|
||||
"init"
|
||||
],
|
||||
"third_party": []
|
||||
},
|
||||
|
@ -21,6 +21,7 @@ config("nnrt_config") {
|
||||
"../neural_network_core",
|
||||
"../../../interfaces/innerkits/c",
|
||||
"../../../interfaces/kits/c",
|
||||
"//base/startup/init/interfaces/innerkits/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -190,6 +191,7 @@ ohos_shared_library("libneural_network_runtime") {
|
||||
"hitrace:libhitracechain",
|
||||
"ipc:ipc_core",
|
||||
"mindspore:mindir",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
|
||||
deps = [ "../neural_network_core:libneural_network_core" ]
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "common/log.h"
|
||||
#include "quant_param.h"
|
||||
#include "validation.h"
|
||||
#include "syspara/parameter.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
@ -38,6 +39,11 @@ const std::string EXTENSION_KEY_OP_LAYOUT = "opLayout";
|
||||
const std::string EXTENSION_KEY_INPUT_DIMS = "InputDims";
|
||||
const std::string EXTENSION_KEY_DYNAMIC_DIMS = "DynamicDims";
|
||||
|
||||
const std::string NULL_HARDWARE_NAME = "NULL";
|
||||
const std::string HARDWARE_NAME = "const.ai.nnrt_device";
|
||||
const std::string HARDWARE_VERSION = "v5_0";
|
||||
constexpr size_t HARDWARE_NAME_MAX_LENGTH = 128;
|
||||
|
||||
NNRT_API NN_QuantParam *OH_NNQuantParam_Create()
|
||||
{
|
||||
auto* quantParamImpl = new (std::nothrow) QuantParams();
|
||||
@ -688,3 +694,18 @@ NNRT_API OH_NN_ReturnCode OH_NNModel_GetAvailableOperations(OH_NNModel *model,
|
||||
InnerModel *innerModel = reinterpret_cast<InnerModel*>(model);
|
||||
return innerModel->GetSupportedOperations(deviceID, isAvailable, *opCount);
|
||||
}
|
||||
|
||||
NNRT_API OH_NN_ReturnCode OH_NNModel_GetDevice(const char **nnrtDevice)
|
||||
{
|
||||
const cName[HARDWARE_NAME_MAX_LENGTH] = {0};
|
||||
int ret = GetParameter(HARDWARE_NAME.c_str(), NULL_HARDWARE_NAME.c_str(), cName, HARDWARE_NAME_MAX_LENGTH);
|
||||
// 如果成功获取返回值为硬件名称的字节数
|
||||
if (ret <= 0) {
|
||||
LOGE("GetNNRTDeviceName failed, failed to get parameter.");
|
||||
return OH_NN_FAILED;
|
||||
}
|
||||
|
||||
std::string deviceName = (std::string)cName + "_" + HARDWARE_VERSION;
|
||||
*nnrtDevice = static_cast<const char*>(deviceName.c_str());
|
||||
return OH_NN_SUCCESS;
|
||||
}
|
@ -141,6 +141,18 @@ OH_NN_ReturnCode OH_NNModel_BuildFromMetaGraph(OH_NNModel *model, const void *me
|
||||
*/
|
||||
bool OH_NNModel_HasCache(const char *cacheDir, const char *modelName, uint32_t version);
|
||||
|
||||
/**
|
||||
* @brief 获取NNRt device信息。
|
||||
*
|
||||
* 本接口不作为Neural Network Runtime接口对外开放。\n
|
||||
*
|
||||
* @param nnrtDevice 传出device参数。
|
||||
* @return 函数执行的结果状态,执行成功返回OH_NN_SUCCESS,失败返回具体错误码,参考{@link OH_NN_ReturnCode}。
|
||||
* @since 11
|
||||
* @version 1.0
|
||||
*/
|
||||
OH_NN_ReturnCode OH_NNModel_GetDevice(const char **nnrtDevice);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cpluscplus
|
||||
|
Loading…
Reference in New Issue
Block a user