!13 优化北向demo中help信息输出

* Modify executable file output help message content.
This commit is contained in:
陈前
2022-11-08 08:20:36 +00:00
committed by yangyongjie
parent 3d5a9db75f
commit a26e65cf50
2 changed files with 21 additions and 11 deletions
@@ -41,13 +41,13 @@ namespace delegate {
namespace nnrt {
constexpr int32_t SCALAR_RANK = 1;
#define RETURN_TFLITE_ERROR_IF_NN_ERROR_FOR_COMPILE(code, callDesc) \
#define RETURN_TFLITE_ERROR_IF_NN_ERROR_FOR_COMPILE(code, callDesc) \
do { \
if ( (code) != OH_NN_SUCCESS) { \
const auto errorDesc = NnrtErrorDescription((code)); \
TFLITE_LOG_PROD(TFLITE_LOG_ERROR, "NN API returned error %s at line %d while %s.\n", errorDesc.c_str(), \
const auto errorDesc = NnrtErrorDescription((code)); \
TFLITE_LOG_PROD(TFLITE_LOG_ERROR, "NN API returned error %s at line %d while %s.\n", errorDesc.c_str(), \
__LINE__, (callDesc)); \
m_nnrt->OH_NNCompilation_Destroy(&m_pNnCompilation); \
m_nnrt->OH_NNCompilation_Destroy(&m_pNnCompilation); \
return kTfLiteError; \
} \
} while (0)
@@ -417,4 +417,4 @@ TfLiteStatus NnrtDelegateKernel::SetNnOptions(TfLiteContext* context, const Nnrt
}
} // namespace nnrt
} // namespace delegate
} // tflite
} // tflite
@@ -250,9 +250,9 @@ void InferenceModel(Settings& settings, DelegateProviders& delegateProviders)
void DisplayUsage()
{
LOG(INFO) << "label_classify\n"
LOG(INFO) << "label_classify -m xxx.tflite -i xxx.bmp -l xxx.txt -c 1 -a 1\n"
<< "\t--help, -h: show the usage of the demo\n"
<< "\t--use_nnrt, -a: [0|1], use NNRT or not\n"
<< "\t--use_nnrt, -a: [0|1], 1 refers to use NNRT\n"
<< "\t--input_mean, -b: input mean\n"
<< "\t--count, -c: loop interpreter->Invoke() for certain times\n"
<< "\t--image, -i: image_name.bmp\n"
@@ -266,7 +266,7 @@ void DisplayUsage()
<< "\t--input_shape, -p: Indicates the specified dynamic input node and the corresponding shape.\n";
}
void InitSettings(int32_t argc, char** argv, Settings& settings)
int32_t InitSettings(int32_t argc, char** argv, Settings& settings)
{
// getopt_long stores the option index here.
int32_t optionIndex = 0;
@@ -312,11 +312,13 @@ void InitSettings(int32_t argc, char** argv, Settings& settings)
case '?':
// getopt_long already printed an error message.
DisplayUsage();
return;
return -1;
default:
return;
return -1;
}
}
return 0;
}
int32_t Main(int32_t argc, char** argv)
@@ -327,8 +329,16 @@ int32_t Main(int32_t argc, char** argv)
return EXIT_FAILURE;
}
if (argc <= 1) {
DisplayUsage();
return EXIT_FAILURE;
}
Settings settings;
InitSettings(argc, argv, settings);
if (InitSettings(argc, argv, settings) == -1) {
return EXIT_FAILURE;
};
InferenceModel(settings, delegateProviders);
return 0;
}