diff --git a/lite/backends/imagination_nna/imgdnn_manager.cc b/lite/backends/imagination_nna/imgdnn_manager.cc index 8b83c131089f0c10070544300ac5c5fd42c680b2..93cc7e73cfa721c40e8384c75a97d1e655b38bd5 100644 --- a/lite/backends/imagination_nna/imgdnn_manager.cc +++ b/lite/backends/imagination_nna/imgdnn_manager.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "imgdnn_manager.h" // NOLINT +#include #include #include "ImgdnnManagerConfig.h" @@ -83,6 +84,22 @@ imgdnn_tensor ImgdnnManager::convertQuantTensorType( return converted_tensor; } +bool ImgdnnManager::testConfigFileExists(const std::string &hwconfig, + const std::string &mapconfig) { + if (access(hwconfig.c_str(), F_OK) == -1) goto testConfigFileExistsError; + if (access(mapconfig.c_str(), F_OK) == -1) goto testConfigFileExistsError; + + return true; + +testConfigFileExistsError: + char *pwd = getcwd(NULL, 0); + std::string err_msg{"Could not find Imagination NNA config files: "}; + std::cerr << err_msg << hwconfig << "," << mapconfig << std::endl; + std::cerr << "Please place config files at: " << pwd << std::endl; + free(pwd); + exit(EXIT_FAILURE); +} + imgdnn_tensor ImgdnnManager::createConvolutionLayer( imgdnn_tensor input_tensor, imgdnn_tensor weights_tensor, @@ -321,14 +338,15 @@ imgdnn_network_object ImgdnnManager::createNetworkObject( imgdnn_tensor *outputs) { const imgdnn_network_object_flags flags = 0; - // Add " --dump_debug_binaries enabled" to options_str if need debug info. - std::string options_str; - std::string ddk_root{IMAGINATION_NNA_SDK_ROOT}; - std::string hwconfig = - ddk_root + "nna-tools/config/mirage_hw_config06_23_2_6500_301.json"; - std::string mapconfig = ddk_root + "nna-tools/config/mapconfig_q8a.json"; + const std::string hwconfig = "config/mirage_hw_config06_23_2_6500_301.json"; + const std::string mapconfig = "config/mapconfig_q8a.json"; + + testConfigFileExists(hwconfig, mapconfig) + + std::string options_str; options_str += "-h " + hwconfig; options_str += " -m " + mapconfig; + // Add " --dump_debug_binaries enabled" to options_str if need debug info. net_obj_ = imgdnnCreateNetworkObject(device_, context_, diff --git a/lite/backends/imagination_nna/imgdnn_manager.h b/lite/backends/imagination_nna/imgdnn_manager.h index 579e385de3f123e6cf10a71f97d6cc452943baec..273696f25d6c57c7a6c30cca4ed76b07318c3679 100644 --- a/lite/backends/imagination_nna/imgdnn_manager.h +++ b/lite/backends/imagination_nna/imgdnn_manager.h @@ -14,6 +14,7 @@ #pragma once +#include #include #include #include @@ -56,6 +57,10 @@ class ImgdnnManager { imgdnn_tensor convertQuantTensorType(imgdnn_tensor a_tensor, imgdnn_quant_param *dst_quant_param); + bool testConfigFileExists(const std::string &hwconfig, + const std::string &mapconfig); + { return (access(name.c_str(), F_OK) != -1); } + public: ImgdnnManager();