-
Notifications
You must be signed in to change notification settings - Fork 646
[Backend Tester] Add CSV report generation #12741
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
Open
GregoryComer
wants to merge
11
commits into
gh/GregoryComer/87/head
Choose a base branch
from
gh/GregoryComer/88/head
base: gh/GregoryComer/87/head
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+198
−15
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
19760fc
Update
GregoryComer 5d437b1
Update
GregoryComer e2ea2a3
Update
GregoryComer 3976629
Update
GregoryComer cdd15c1
Update
GregoryComer bcb697c
Update
GregoryComer de21ac2
Update
GregoryComer 32f54b0
Update
GregoryComer 5cc4941
Update
GregoryComer f1db3a0
Update
GregoryComer c3a24f9
Update
GregoryComer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Tests | ||
|
||
This directory contains meta-tests for the backend test suite. As the test suite contains a non-neglible amount of logic, these tests are useful to ensure that the test suite itself is working correctly. |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import unittest | ||
|
||
from csv import DictReader | ||
from io import StringIO | ||
|
||
import torch | ||
|
||
from ..reporting import ( | ||
generate_csv_report, | ||
RunSummary, | ||
TestCaseSummary, | ||
TestResult, | ||
TestSessionState, | ||
) | ||
|
||
# Test data for simulated test results. | ||
TEST_CASE_SUMMARIES = [ | ||
TestCaseSummary( | ||
backend="backend1", | ||
base_name="test1", | ||
flow="flow1", | ||
name="test1_backend1_flow1", | ||
params=None, | ||
result=TestResult.SUCCESS, | ||
error=None, | ||
), | ||
TestCaseSummary( | ||
backend="backend2", | ||
base_name="test1", | ||
flow="flow1", | ||
name="test1_backend2_flow1", | ||
params=None, | ||
result=TestResult.LOWER_FAIL, | ||
error=None, | ||
), | ||
TestCaseSummary( | ||
backend="backend1", | ||
base_name="test2", | ||
flow="flow1", | ||
name="test2_backend1_flow1", | ||
params={"dtype": torch.float32}, | ||
result=TestResult.SUCCESS_UNDELEGATED, | ||
error=None, | ||
), | ||
TestCaseSummary( | ||
backend="backend2", | ||
base_name="test2", | ||
flow="flow1", | ||
name="test2_backend2_flow1", | ||
params={"use_dynamic_shapes": True}, | ||
result=TestResult.EXPORT_FAIL, | ||
error=None, | ||
), | ||
] | ||
|
||
|
||
class Reporting(unittest.TestCase): | ||
def test_csv_report_simple(self): | ||
# Verify the format of a simple CSV run report. | ||
session_state = TestSessionState() | ||
session_state.test_case_summaries.extend(TEST_CASE_SUMMARIES) | ||
run_summary = RunSummary.from_session(session_state) | ||
|
||
strio = StringIO() | ||
generate_csv_report(run_summary, strio) | ||
|
||
# Attempt to deserialize and validate the CSV report. | ||
report = DictReader(StringIO(strio.getvalue())) | ||
records = list(report) | ||
self.assertEqual(len(records), 4) | ||
|
||
# Validate first record: test1, backend1, SUCCESS | ||
self.assertEqual(records[0]["Test ID"], "test1_backend1_flow1") | ||
self.assertEqual(records[0]["Test Case"], "test1") | ||
self.assertEqual(records[0]["Backend"], "backend1") | ||
self.assertEqual(records[0]["Flow"], "flow1") | ||
self.assertEqual(records[0]["Result"], "Success (Delegated)") | ||
self.assertEqual(records[0]["Dtype"], "") | ||
self.assertEqual(records[0]["Use_dynamic_shapes"], "") | ||
|
||
# Validate second record: test1, backend2, LOWER_FAIL | ||
self.assertEqual(records[1]["Test ID"], "test1_backend2_flow1") | ||
self.assertEqual(records[1]["Test Case"], "test1") | ||
self.assertEqual(records[1]["Backend"], "backend2") | ||
self.assertEqual(records[1]["Flow"], "flow1") | ||
self.assertEqual(records[1]["Result"], "Fail (Lowering)") | ||
self.assertEqual(records[1]["Dtype"], "") | ||
self.assertEqual(records[1]["Use_dynamic_shapes"], "") | ||
|
||
# Validate third record: test2, backend1, SUCCESS_UNDELEGATED with dtype param | ||
self.assertEqual(records[2]["Test ID"], "test2_backend1_flow1") | ||
self.assertEqual(records[2]["Test Case"], "test2") | ||
self.assertEqual(records[2]["Backend"], "backend1") | ||
self.assertEqual(records[2]["Flow"], "flow1") | ||
self.assertEqual(records[2]["Result"], "Success (Undelegated)") | ||
self.assertEqual(records[2]["Dtype"], str(torch.float32)) | ||
self.assertEqual(records[2]["Use_dynamic_shapes"], "") | ||
|
||
# Validate fourth record: test2, backend2, EXPORT_FAIL with use_dynamic_shapes param | ||
self.assertEqual(records[3]["Test ID"], "test2_backend2_flow1") | ||
self.assertEqual(records[3]["Test Case"], "test2") | ||
self.assertEqual(records[3]["Backend"], "backend2") | ||
self.assertEqual(records[3]["Flow"], "flow1") | ||
self.assertEqual(records[3]["Result"], "Fail (Export)") | ||
self.assertEqual(records[3]["Dtype"], "") | ||
self.assertEqual(records[3]["Use_dynamic_shapes"], "True") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: tsv works better usually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on this, personally. Let's chat tomorrow. I'm good to switch it to TSV if you think it would be better.