From 23ce29654a299702724939933676c1b1c747d741 Mon Sep 17 00:00:00 2001 From: w30052974 Date: Fri, 14 Jun 2024 17:11:10 +0800 Subject: [PATCH] hdi device add Signed-off-by: w30052974 --- .../native/neural_network_runtime/BUILD.gn | 3 - .../register_hdi_device_v2_1.cpp | 90 ------------------- 2 files changed, 93 deletions(-) delete mode 100644 frameworks/native/neural_network_runtime/register_hdi_device_v2_1.cpp diff --git a/frameworks/native/neural_network_runtime/BUILD.gn b/frameworks/native/neural_network_runtime/BUILD.gn index 34b86af..cf98d69 100644 --- a/frameworks/native/neural_network_runtime/BUILD.gn +++ b/frameworks/native/neural_network_runtime/BUILD.gn @@ -47,9 +47,6 @@ nnrt_sources = [ "ops_builder.cpp", "ops_registry.cpp", "quant_param.cpp", - "register_hdi_device_v1_0.cpp", - "register_hdi_device_v2_0.cpp", - "register_hdi_device_v2_1.cpp", "transform.cpp", ] diff --git a/frameworks/native/neural_network_runtime/register_hdi_device_v2_1.cpp b/frameworks/native/neural_network_runtime/register_hdi_device_v2_1.cpp deleted file mode 100644 index 2f6730d..0000000 --- a/frameworks/native/neural_network_runtime/register_hdi_device_v2_1.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "hdi_device_v2_1.h" -#include "hdi_returncode_utils_v2_1.h" -#include "common/log.h" -#include "common/utils.h" -#include "nnbackend.h" -#include "backend_registrar.h" - -namespace OHOS { -namespace NeuralNetworkRuntime { -void PrintRetLog(int32_t ret, int32_t nnrtSuccess, const std::string& makeName) -{ - if (ret < nnrtSuccess) { - LOGW("%s failed. An error occurred in HDI, errorcode is %{public}d.", makeName.c_str(), ret); - } else { - OHOS::HDI::Nnrt::V2_1::NNRT_ReturnCode nnrtRet = static_cast(ret); - LOGW("%s failed. Errorcode is %{public}s.", makeName.c_str(), ConverterRetToString(nnrtRet).c_str()); - } -} - -std::shared_ptr HDIDeviceV2_1Creator() -{ - std::string deviceName; - std::string vendorName; - std::string version; - - // only one device from HDI now. - OHOS::sptr iDevice = V2_1::INnrtDevice::Get(); - if (iDevice == nullptr) { - LOGW("Get HDI device failed."); - return nullptr; - } - - auto ret = iDevice->GetDeviceName(deviceName); - int32_t nnrtSuccess = static_cast(V2_1::NNRT_ReturnCode::NNRT_SUCCESS); - if (ret != nnrtSuccess) { - std::string makeName = "Get device name"; - PrintRetLog(ret, nnrtSuccess, makeName); - return nullptr; - } - - ret = iDevice->GetVendorName(vendorName); - if (ret != nnrtSuccess) { - std::string makeName = "Get vendor name"; - PrintRetLog(ret, nnrtSuccess, makeName); - return nullptr; - } - - std::pair hdiVersion; - ret = iDevice->GetVersion(hdiVersion.first, hdiVersion.second); - if (ret != nnrtSuccess) { - std::string makeName = "Get version"; - PrintRetLog(ret, nnrtSuccess, makeName); - return nullptr; - } - version = 'v' + std::to_string(hdiVersion.first) + '_' + std::to_string(hdiVersion.second); - const std::string& backendName = GenUniqueName(deviceName, vendorName, version); - - std::shared_ptr device = CreateSharedPtr(iDevice); - if (device == nullptr) { - LOGW("Failed to create device, because fail to create device instance."); - return nullptr; - } - - std::shared_ptr backend = CreateSharedPtr(device, std::hash{}(backendName)); - if (backend == nullptr) { - LOGW("Failed to register backend, because fail to create backend."); - } - return backend; -} - -REGISTER_BACKEND(HDIDeviceV2_1, HDIDeviceV2_1Creator) -} // namespace NeuralNetworkRuntime -} // namespace OHOS -- Gitee