update amexec fix issue
This commit is contained in:
+4
-3
@@ -1,8 +1,9 @@
|
||||
g="$1"
|
||||
locate="$2"
|
||||
rm -rf build
|
||||
mkdir -p build/intermediates/host
|
||||
cd build/intermediates/host
|
||||
cmake ../../../src -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_SKIP_RPATH=TRUE
|
||||
cmake ../../../src -DCMAKE_CXX_COMPILER=${g} -DCMAKE_SKIP_RPATH=TRUE
|
||||
make
|
||||
cd ../../../out
|
||||
mv main amexec
|
||||
|
||||
mv main ${locate}/amexec
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
* @brief sample process
|
||||
* @return result
|
||||
*/
|
||||
Result Process(vector<string>& params, vector<string>& inputs);
|
||||
Result Process(map<char,string>& params, vector<string>& inputs);
|
||||
|
||||
private:
|
||||
void DestroyResource();
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{}
|
||||
+23
-14
@@ -20,11 +20,10 @@ int loop = 1;
|
||||
string input_Ftype = ".bin";
|
||||
string model_Ftype = ".om";
|
||||
string check = "";
|
||||
|
||||
|
||||
void InitAndCheckParams(int argc, char* argv[], vector<string>& params, vector<string>& inputs)
|
||||
|
||||
void InitAndCheckParams(int argc, char* argv[], map<char,string>& params, vector<string>& inputs)
|
||||
//void InitAndCheckParams(int argc, char* argv[], vector<string>& params, vector<string>& inputs)
|
||||
{
|
||||
|
||||
const char *optstring="m::i::o::f::hd::p::l::y::";
|
||||
int c,deb,index;
|
||||
struct option opts[]={{"model",required_argument,NULL,'m'},
|
||||
@@ -39,13 +38,13 @@ void InitAndCheckParams(int argc, char* argv[], vector<string>& params, vector<s
|
||||
{0,0,0,0}};
|
||||
while((c=getopt_long(argc,argv,optstring,opts,&index))!=-1)
|
||||
{
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case 'm':
|
||||
check = optarg;
|
||||
if (check.find(model_Ftype) != string::npos){
|
||||
params.push_back(optarg);
|
||||
// params.push_back(optarg);
|
||||
params['m'] = optarg;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
@@ -58,24 +57,30 @@ void InitAndCheckParams(int argc, char* argv[], vector<string>& params, vector<s
|
||||
printf("input data file type is not .bin , please check your input file type!\n");
|
||||
exit(0);
|
||||
}
|
||||
params.push_back(optarg);
|
||||
Utils::SplitString(params[1], inputs, ',');
|
||||
// params.push_back(optarg);
|
||||
params['i'] = optarg;
|
||||
Utils::SplitString(params['i'], inputs, ',');
|
||||
break;
|
||||
case 'o':
|
||||
params.push_back(optarg);
|
||||
// params.push_back(optarg);
|
||||
params['o'] = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
params.push_back(optarg);
|
||||
// params.push_back(optarg);
|
||||
params['f'] = optarg;
|
||||
break;
|
||||
case '?':
|
||||
printf("unknown paramenter\n");
|
||||
printf("Execute sample failed.\n");
|
||||
Utils::printHelpLetter();
|
||||
exit(0);
|
||||
case 'd':
|
||||
params.push_back(optarg);
|
||||
// params.push_back(optarg);
|
||||
params['d'] = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
params.push_back(optarg);
|
||||
// params.push_back(optarg);
|
||||
params['p'] = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
loop = Utils::str2num(optarg);
|
||||
@@ -87,7 +92,8 @@ void InitAndCheckParams(int argc, char* argv[], vector<string>& params, vector<s
|
||||
}
|
||||
break;
|
||||
case 'y':
|
||||
params.push_back(optarg);
|
||||
// params.push_back(optarg);
|
||||
params['y'] = optarg;
|
||||
break;
|
||||
case 1:
|
||||
Utils::printHelpLetter();
|
||||
@@ -95,6 +101,7 @@ void InitAndCheckParams(int argc, char* argv[], vector<string>& params, vector<s
|
||||
default:
|
||||
printf("unknown paramenter\n");
|
||||
printf("Execute sample failed.\n");
|
||||
Utils::printHelpLetter();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +109,8 @@ void InitAndCheckParams(int argc, char* argv[], vector<string>& params, vector<s
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
vector<string> params;
|
||||
map<char,string>params;
|
||||
// vector<string> params;
|
||||
vector<string> inputs;
|
||||
InitAndCheckParams(argc, argv, params, inputs);
|
||||
printf("******************************\n");
|
||||
@@ -112,6 +120,7 @@ int main(int argc, char* argv[])
|
||||
if (params.empty() || inputs.empty()) {
|
||||
printf("Invalid params.\n");
|
||||
printf("Execute sample failed.\n");
|
||||
Utils::printHelpLetter();
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,9 @@ Result ModelProcess::CreateInput(void *inputDataBuffer, size_t bufferSize)
|
||||
inputData = nullptr;
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
size_t aa = aclmdlGetDatasetNumBuffers(input_);
|
||||
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Result SampleProcess::InitResource()
|
||||
{
|
||||
// ACL init
|
||||
const char *aclConfigPath = "";
|
||||
aclError ret = aclInit(aclConfigPath);
|
||||
aclError ret = aclInit(nullptr);
|
||||
if (ret != ACL_ERROR_NONE) {
|
||||
ERROR_LOG("acl init failed");
|
||||
return FAILED;
|
||||
@@ -74,20 +74,20 @@ Result SampleProcess::InitResource()
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Result SampleProcess::Process(vector<string>& params, vector<string>& input_files)
|
||||
Result SampleProcess::Process(map<char,string>& params, vector<string>& input_files)
|
||||
{
|
||||
// model init
|
||||
ModelProcess processModel;
|
||||
const char* omModelPath = params[0].c_str();
|
||||
std::string output_path = params[2].c_str();
|
||||
const char* outfmt = params[3].c_str();
|
||||
const char* omModelPath = params['m'].c_str();
|
||||
std::string output_path = params['o'].c_str();
|
||||
const char* outfmt = params['f'].c_str();
|
||||
const char* fmt_TXT = "TXT";
|
||||
f_isTXT = (strcmp(outfmt,fmt_TXT)==0);
|
||||
const char* dumpConf = params[4].c_str();
|
||||
const char* profConf = params[5].c_str();
|
||||
const char* dymBatch = params[6].c_str();
|
||||
const char* dumpConf = params['d'].c_str();
|
||||
const char* profConf = params['p'].c_str();
|
||||
const char* dymBatch = params['y'].c_str();
|
||||
|
||||
std::string modelPath = params[0].c_str();
|
||||
std::string modelPath = params['m'].c_str();
|
||||
std::string modelName = Utils::modelName(modelPath);
|
||||
|
||||
struct timeval begin;
|
||||
@@ -111,8 +111,7 @@ Result SampleProcess::Process(vector<string>& params, vector<string>& input_file
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
vector<void*> picDevBuffer(input_files.size(),nullptr);
|
||||
|
||||
vector<void*> picDevBuffer(input_files.size(), nullptr);
|
||||
for (size_t index = 0; index < input_files.size(); ++index) {
|
||||
INFO_LOG("start to process file:%s", input_files[index].c_str());
|
||||
// model process
|
||||
@@ -138,7 +137,6 @@ Result SampleProcess::Process(vector<string>& params, vector<string>& input_file
|
||||
ret = processModel.Execute();
|
||||
gettimeofday(&end,NULL);
|
||||
inference_time[t] = 1000*(end.tv_sec - begin.tv_sec) + (end.tv_usec - begin.tv_usec)/1000.000;
|
||||
//std::cout << "usec: " << end.tv_usec - begin.tv_usec << endl;
|
||||
std::cout << "Inference time: "<<inference_time[t] << "ms" << endl;
|
||||
if (ret != SUCCESS) {
|
||||
ERROR_LOG("model execute failed");
|
||||
|
||||
@@ -159,6 +159,8 @@ void Utils::printCurrentTime()
|
||||
}
|
||||
void Utils::printHelpLetter()
|
||||
{
|
||||
cout<< endl;
|
||||
cout<< "Usage:" << endl;
|
||||
cout<< "generate offline model inference output file example:" << endl;
|
||||
cout<< "./amexec --model /home/HwHiAiUser/ljj/colorization.om --input /home/HwHiAiUser/ljj/colorization_input.bin --output /home/HwHiAiUser/ljj/AMEXEC/out/output1 --outfmt TXT --loop 2" << endl << endl;
|
||||
|
||||
@@ -173,10 +175,11 @@ void Utils::printHelpLetter()
|
||||
cout<< " --dymBatch dynamic batch (Do not support now)" << endl << endl << endl;
|
||||
|
||||
|
||||
cout<< "NOTECE: " << endl;
|
||||
cout<< " The order of parameter must follow in --model --input --output --outfmt --loop " << endl;
|
||||
// cout<< "NOTECE: " << endl;
|
||||
// cout<< " The order of parameter must follow in --model --input --output --outfmt --loop " << endl;
|
||||
}
|
||||
|
||||
|
||||
double Utils::printDiffTime(time_t begin, time_t end)
|
||||
{
|
||||
double diffT = difftime(begin, end);
|
||||
|
||||
Reference in New Issue
Block a user