Skip to content

Add discrepancies when comparing the execution of two models #79

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

Merged
merged 14 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix command line
  • Loading branch information
xadupre committed Feb 28, 2024
commit 6a5bddd4d299550e566e3e21cec7154f2919a262
12 changes: 11 additions & 1 deletion onnx_array_api/_command_lines_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def get_parser_compare() -> ArgumentParser:
default=60,
help="column size when displaying the results",
)
parser.add_argument(
"-d",
"--discrepancies",
default=0,
help="show precise discrepancies when mode is execution",
)
return parser


Expand All @@ -120,7 +126,11 @@ def _cmd_compare(argv: List[Any]):
onx1 = onnx.load(args.model1)
onx2 = onnx.load(args.model2)
res1, res2, align, dc = compare_onnx_execution(
onx1, onx2, verbose=args.verbose, mode=args.mode
onx1,
onx2,
verbose=args.verbose,
mode=args.mode,
keep_tensor=args.discrepancies in (1, "1", "True", True),
)
text = dc.to_str(res1, res2, align, column_size=int(args.column_size))
print(text)
Expand Down
8 changes: 5 additions & 3 deletions onnx_array_api/reference/evaluator_yield.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ def make_summary(value: Any, length: int = 4, modulo: int = 26) -> str:
else:
value2 = value.flatten().astype(np.float64)
value4 = value2.reshape((4, -1)).sum(axis=1)
value4i = value4.astype(np.int64) % modulo
s = "".join([chr(65 + i) for i in value4i])
return s
value4 = np.where(np.abs(value4) < 1e10, value4, np.nan)
s = []
for v in value4:
s.append("?" if np.isnan(v) else (chr(65 + int(v) % modulo)))
return "".join(s)


class YieldEvaluator:
Expand Down