aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Ge <jerry.ge@arm.com>2024-02-27 22:39:04 +0000
committerJerry Ge <jerry.ge@arm.com>2024-03-05 10:09:24 -0800
commit6db102ca840b3b86a70b65967ae8a49733ba241f (patch)
tree2883f93b3b86a53ac49c0e556436f23e63d848fa
parent140c54010361c711c611666d4d367d71d5c95327 (diff)
downloadreference_model-v0.80.tar.gz
Fix the usage of command line arguments for reference_modelv0.80
- Users have to specify the --test_desc filename argument for using reference_model - Update the initTestDesc function to allow users to use pure command line arguments to specify all test descriptions - Backported a partial path fix for desc.json from the following - https://review.mlplatform.org/c/tosa/reference_model/+/10831 Signed-off-by: Jerry Ge <jerry.ge@arm.com> Change-Id: Ia23d4ba550aace6c3cd202e21bc8fbe6e0be1cf0
-rw-r--r--reference_model/src/main.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/reference_model/src/main.cpp b/reference_model/src/main.cpp
index 3b84ff8..a0b97c1 100644
--- a/reference_model/src/main.cpp
+++ b/reference_model/src/main.cpp
@@ -1,5 +1,5 @@
-// Copyright (c) 2020-2023, ARM Limited.
+// Copyright (c) 2020-2024, ARM Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -573,14 +573,30 @@ int initTestDesc(json& test_desc)
}
else
{
- WARNING("Cannot open input file: %s", g_func_config.test_desc.c_str());
- return 1;
+ // Users can also specify description info using command line arguments
+ // If they miss any info from command line AND no test_desc is provided,
+ // return error code
+ if (g_func_config.tosa_file.empty() || g_func_config.ifm_name.empty() || g_func_config.ifm_file.empty() ||
+ g_func_config.ofm_name.empty() || g_func_config.ofm_file.empty())
+ {
+ WARNING("Cannot open input file: %s", g_func_config.test_desc.c_str());
+ return 1;
+ }
}
// Overwrite flatbuffer_dir/output_dir with dirname(g_func_config.test_desc) if it's not specified.
if (g_func_config.flatbuffer_dir.empty() || g_func_config.output_dir.empty())
{
- std::string test_dir = g_func_config.test_desc.substr(0, g_func_config.test_desc.find_last_of("/\\"));
+ auto slash_pos = g_func_config.test_desc.find_last_of("/\\");
+ std::string test_dir;
+ if (slash_pos != std::string::npos)
+ {
+ test_dir = g_func_config.test_desc.substr(0, slash_pos);
+ }
+ else
+ {
+ test_dir = std::string(".");
+ }
if (g_func_config.flatbuffer_dir.empty())
{
g_func_config.flatbuffer_dir = test_dir;