Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI option to directly pass reference files when running tests #28446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seowwj
Copy link

@seowwj seowwj commented Jan 15, 2025

Details:

  • Enables user to directly specify reference files to be used in test mode. If none is specified, the current default file scheme (<netname>_ref_out....blob) is used.

Tickets:

  • E#148130

@seowwj seowwj requested review from a team as code owners January 15, 2025 06:53
@github-actions github-actions bot added the category: NPU OpenVINO NPU plugin label Jan 15, 2025
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Jan 15, 2025
@Maxim-Doronin Maxim-Doronin added good first issue Good for newcomers and removed ExternalPR External contributor labels Jan 15, 2025
@@ -127,6 +127,7 @@ DEFINE_string(
ref_dir,
"",
"A directory with reference blobs to compare with in run_test mode. Leave it empty to use the current folder.");
DEFINE_string(ref_results, "", "Reference files used during 'run_test'");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, specify input format in case of several inputs.
Is it --ref_results "file1;file2"?

Are relative paths supported? e.g. --ref_dir /part/of/path/ --ref_results rest/of/path/file.blob?

Are absolute paths supported? e.g. --ref_results /abs/path/file.blob

// Make sure that the number of reference files is the same as the number of input files
if (refFilesPerCase.size() != inputFilesPerCase.size()) {
std::cout << "The number of reference files is not equal to the number of input files."
<< " # Reference Files: " << refFilesPerCase.size()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace # with number of or # of

}

for (const auto& refResult : refFilesPerCase) {
std::vector<std::string> refFilesPerModel = splitStringList(refResult, ',');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR, --network supports only a single model to be loaded. Please explain when we expect several models in a single SIT run.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that it is for batched input scenario when a whole row looks like CASE_0;CASE_1;etc
where
CASE_X is a run of SIT and which contains INPUT_0,INPUT_1,INPUT2,etc,
where
INPUT_0 encompasses data for single input in batch BATCH_0|BATCH_1|etc
which makes sense for separation input data per model

If my understanding is correct that here we need to produce tensors which are belong to output data types. In case of batch, though inputs pictures for every batch line are separated, outputs are printed into unified single file without separation of its lines. So probably we should not use this level with '|' as perFiles separator

}

for (const auto& refResult : refFilesPerCase) {
std::vector<std::string> refFilesPerModel = splitStringList(refResult, ',');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that it is for batched input scenario when a whole row looks like CASE_0;CASE_1;etc
where
CASE_X is a run of SIT and which contains INPUT_0,INPUT_1,INPUT2,etc,
where
INPUT_0 encompasses data for single input in batch BATCH_0|BATCH_1|etc
which makes sense for separation input data per model

If my understanding is correct that here we need to produce tensors which are belong to output data types. In case of batch, though inputs pictures for every batch line are separated, outputs are printed into unified single file without separation of its lines. So probably we should not use this level with '|' as perFiles separator

if (!refFiles.empty()) {
blobFileFullPath = refFiles[numberOfTestCase][outputInd];
} else {
std::ostringstream ostr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:
I'd rather move this into a separate function like 'generate_reference_file_name(...)', which will makes this huge code lesser overwhelming

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick 2:
I wondered whether forming the array refFiles initially regardless either ref_dir or res_output set and stick to it will without this condition checking refFiles.empty() would be more nice or not.
So that we could fill refFiles by using generate_reference_file_name() (because all data to generate is known in the beginning) when ref_dir exist or just parse command line of res_output

Please feel free to ignore this comment as it's arguable

const auto blobFileFullName = fullPath.string();
// If reference files are provided, use them
if (!refFiles.empty()) {
blobFileFullPath = refFiles[numberOfTestCase][outputInd];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that we have already taken numberOfTestCase here https://github.com/openvinotoolkit/openvino/pull/28446/files#diff-32f65067f63ae981b516b3780122e243b0ed1684efd43992f00063f0d458716eR2118
when we had defined refFiles by itself. Probably when use remove '|' parsing level this second numberOfTestCase would not required anymore

: refFilesForOneInfer[numberOfTestCase];
if (!FLAGS_ref_results.empty()) {
OPENVINO_ASSERT(refFiles.size() == outputsInfo.size(), "Number of reference files ", refFiles.size(),
" doesn't match network configuration ", outputsInfo.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+100500 for printing troubleshooting info's!
I'd only suggest emphasize that it must match output count by amending this doesn't match network output count: ', outputsInfo.size()

std::cout << " Reference files direcotry: "
<< (FLAGS_ref_dir.empty() ? "Current directory" : FLAGS_ref_dir) << std::endl;
std::cout << " Reference files directory: "
<< (FLAGS_ref_dir.empty() && FLAGS_ref_results.empty() ? "Current directory" : FLAGS_ref_dir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a context it sounds like these parameters are mutually exclusive so that I presume that printing a message and exiting with an error is more intentional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: NPU OpenVINO NPU plugin good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants