diff options
author | Kevin Cheng <kevin.cheng@arm.com> | 2021-06-28 16:23:24 -0700 |
---|---|---|
committer | Kevin Cheng <kevin.cheng@arm.com> | 2021-07-01 10:19:13 -0700 |
commit | d5934146b0b4e18bb6bad213901e48a5a20bef00 (patch) | |
tree | 360ad87112c5d2f35072f57bd1f2ba035cd3a054 /reference_model/src | |
parent | a618557ba688fba16eefd7d9f4c10cc11cb085ef (diff) | |
download | reference_model-d5934146b0b4e18bb6bad213901e48a5a20bef00.tar.gz |
Adding option -Coutput_dir= to control output location.
- If not specified, will be initialized with dirname(test_desc)
- Like -Cflatbuffer_dir, reference model isn't responsible for creating directory.
User need to make sure target directory path exists.
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com>
Change-Id: I9cfcc801cff648e53306f8de8ea8d5eaaf87ea80
Diffstat (limited to 'reference_model/src')
-rw-r--r-- | reference_model/src/func_config.def | 1 | ||||
-rw-r--r-- | reference_model/src/main.cpp | 16 |
2 files changed, 13 insertions, 4 deletions
diff --git a/reference_model/src/func_config.def b/reference_model/src/func_config.def index 8270dbb..cf78ab8 100644 --- a/reference_model/src/func_config.def +++ b/reference_model/src/func_config.def @@ -66,6 +66,7 @@ DEF_OPTION_STR(operator_fbs, "Flat buffer syntax file", FOF_STR_LEN, "tosa.fbs") DEF_OPTION_STR(test_desc, "Json test descriptor", FOF_STR_LEN, "desc.json") DEF_OPTION_STR(flatbuffer_dir, "Flatbuffer directory to load. If not specified, it will be overwritten by dirname(test_desc)", FOF_STR_LEN, "") +DEF_OPTION_STR(output_dir, "Output directory to write. If not specified, it will be overwritten by dirname(test_desc)", FOF_STR_LEN, "") DEF_OPTION_STR(tosa_file, "Flatbuffer file. Support .json or .tosa. Specifying this will overwrite the one initialized by -Ctest_desc.", FOF_STR_LEN, "") DEF_OPTION_STR(ifm_name, "Input tensor name. Comma(,) seperated. Specifying this will overwrite the one initialized by -Ctest_desc.", FOF_STR_LEN, "") DEF_OPTION_STR(ifm_file, "Input tensor numpy Comma(,) seperated. file to initialize with placeholder. Specifying this will overwrite the one initialized by -Ctest_desc.", FOF_STR_LEN, "") diff --git a/reference_model/src/main.cpp b/reference_model/src/main.cpp index 0d6d8a3..412894c 100644 --- a/reference_model/src/main.cpp +++ b/reference_model/src/main.cpp @@ -285,7 +285,7 @@ int writeFinalTensors(SubgraphTraverser& gt, json test_desc) return 1; } - snprintf(filename, sizeof(filename), "%s/%s", g_func_config.flatbuffer_dir, + snprintf(filename, sizeof(filename), "%s/%s", g_func_config.output_dir, test_desc["ofm_file"][i].get<std::string>().c_str()); DEBUG_MED(GT, "Writing output tensor[%d] %s to filename: %s", i, tensor->getName().c_str(), filename); @@ -347,13 +347,21 @@ int initTestDesc(json& test_desc) } } - // Overwrite g_func_config.flatbuffer_dir with dirname(g_func_config.test_desc) if it's not specified. + // Overwrite flatbuffer_dir/output_dir with dirname(g_func_config.test_desc) if it's not specified. std::string flatbuffer_dir_str(g_func_config.flatbuffer_dir); - if (flatbuffer_dir_str.empty()) + std::string output_dir_str(g_func_config.output_dir); + if (flatbuffer_dir_str.empty() || output_dir_str.empty()) { std::string test_path(g_func_config.test_desc); std::string test_dir = test_path.substr(0, test_path.find_last_of("/\\")); - strncpy(g_func_config.flatbuffer_dir, test_dir.c_str(), 1024); + if (flatbuffer_dir_str.empty()) + { + strncpy(g_func_config.flatbuffer_dir, test_dir.c_str(), FOF_STR_LEN); + } + if (output_dir_str.empty()) + { + strncpy(g_func_config.output_dir, test_dir.c_str(), FOF_STR_LEN); + } } // Overwrite test_desc["tosa_file"] if -Ctosa_file= specified. |