提交 7a450e87 编写于 作者: J Jiansong Wang

Remove the imagination nna sdk root from code, assume hwconf and

mapconf files located at directory where to run the program.
上级 a1c58f52
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
#include "imgdnn_manager.h" // NOLINT #include "imgdnn_manager.h" // NOLINT
#include <unistd.h>
#include <utility> #include <utility>
#include "ImgdnnManagerConfig.h" #include "ImgdnnManagerConfig.h"
...@@ -83,6 +84,22 @@ imgdnn_tensor ImgdnnManager::convertQuantTensorType( ...@@ -83,6 +84,22 @@ imgdnn_tensor ImgdnnManager::convertQuantTensorType(
return converted_tensor; 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 ImgdnnManager::createConvolutionLayer(
imgdnn_tensor input_tensor, imgdnn_tensor input_tensor,
imgdnn_tensor weights_tensor, imgdnn_tensor weights_tensor,
...@@ -321,14 +338,15 @@ imgdnn_network_object ImgdnnManager::createNetworkObject( ...@@ -321,14 +338,15 @@ imgdnn_network_object ImgdnnManager::createNetworkObject(
imgdnn_tensor *outputs) { imgdnn_tensor *outputs) {
const imgdnn_network_object_flags flags = 0; const imgdnn_network_object_flags flags = 0;
// Add " --dump_debug_binaries enabled" to options_str if need debug info. const std::string hwconfig = "config/mirage_hw_config06_23_2_6500_301.json";
std::string options_str; const std::string mapconfig = "config/mapconfig_q8a.json";
std::string ddk_root{IMAGINATION_NNA_SDK_ROOT};
std::string hwconfig = testConfigFileExists(hwconfig, mapconfig)
ddk_root + "nna-tools/config/mirage_hw_config06_23_2_6500_301.json";
std::string mapconfig = ddk_root + "nna-tools/config/mapconfig_q8a.json"; std::string options_str;
options_str += "-h " + hwconfig; options_str += "-h " + hwconfig;
options_str += " -m " + mapconfig; options_str += " -m " + mapconfig;
// Add " --dump_debug_binaries enabled" to options_str if need debug info.
net_obj_ = imgdnnCreateNetworkObject(device_, net_obj_ = imgdnnCreateNetworkObject(device_,
context_, context_,
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#pragma once #pragma once
#include <unistd.h>
#include <cmath> #include <cmath>
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -56,6 +57,10 @@ class ImgdnnManager { ...@@ -56,6 +57,10 @@ class ImgdnnManager {
imgdnn_tensor convertQuantTensorType(imgdnn_tensor a_tensor, imgdnn_tensor convertQuantTensorType(imgdnn_tensor a_tensor,
imgdnn_quant_param *dst_quant_param); 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: public:
ImgdnnManager(); ImgdnnManager();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册