-
Notifications
You must be signed in to change notification settings - Fork 6
Align pattern support with node-level checks (scoped 15-pattern rules) #1020
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
fangyangci
wants to merge
6
commits into
main
Choose a base branch
from
fangyangci/subgraph_pattern
base: main
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.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c26b180
refactor: stabilize runtime checker rules prefilter and break cyclic …
fangyangci be517f0
Merge branch 'main' into fangyangci/subgraph_pattern
fangyangci 22fe1ab
Merge branch 'main' into fangyangci/subgraph_pattern
fangyangci 591fdf3
Merge branch 'main' of https://github.com/microsoft/winml-cli into fa…
fangyangci d922977
Merge branch 'fangyangci/subgraph_pattern' of https://github.com/micr…
fangyangci 29e3332
remove pre-filter cache
fangyangci 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # -------------------------------------------------------------------------- | ||
| """Rules-based prefilter utilities for runtime-check skip decisions.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from .runtime_checker_query import RuntimeCheckerQuery | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| import onnx | ||
|
|
||
| from ...utils.constants import EPName | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class RuntimeCheckerRulesPrefilter: | ||
| """Fixed rules-prefilter service bound to one EP+device pair.""" | ||
|
|
||
| def __init__(self, ep_name: EPName, device_type: str) -> None: | ||
| self._ep_name = ep_name | ||
| self._device_type = device_type | ||
|
|
||
| def build_skip_check_result_for_rules_all_nodes_compile_run_pass( | ||
| self, | ||
| onnx_model: onnx.ModelProto, | ||
| ) -> dict[str, Any] | None: | ||
| """Build synthetic check_result when rules indicate all nodes pass.""" | ||
| return build_skip_check_result_for_rules_all_nodes_compile_run_pass( | ||
| onnx_model, | ||
| self._ep_name, | ||
| self._device_type, | ||
| ) | ||
|
|
||
|
|
||
| def build_skip_check_result_for_rules_all_nodes_compile_run_pass( | ||
| onnx_model: onnx.ModelProto, | ||
| ep_name: EPName, | ||
| device_type: str, | ||
| ) -> dict[str, Any] | None: | ||
| """Return synthetic check_result when all nodes have rules compile/run pass. | ||
|
|
||
| Returns None when rules data is missing, any node is unsupported, | ||
| or prefilter evaluation fails. Caller should then run real compile/run. | ||
| """ | ||
| try: | ||
| query = RuntimeCheckerQuery( | ||
| model_proto=onnx_model, | ||
| ep_name=ep_name, | ||
| device_type=device_type, | ||
| ) | ||
| node_results = [ | ||
| query.run_for_node(node, run_unknown_op=False) for node in query.model_proto.graph.node | ||
| ] | ||
|
|
||
| if not node_results: | ||
| return None | ||
|
|
||
| all_supported = all( | ||
| result.result.compile and result.result.run and not result.result.no_data | ||
| for result in node_results | ||
| ) | ||
| if not all_supported: | ||
| return None | ||
|
|
||
| reason = f"rules_all_nodes_compile_run_pass_{len(node_results)}_nodes" | ||
| return { | ||
| "compile": { | ||
| "result": {"success": True, "reason": reason}, | ||
| "stdout": "skipped_by_rules_all_nodes_compile_run_pass", | ||
| "stderr": "", | ||
| }, | ||
| "run": { | ||
| "result": {"success": True, "reason": reason}, | ||
| "stdout": "skipped_by_rules_all_nodes_compile_run_pass", | ||
| "stderr": "", | ||
| }, | ||
| } | ||
| except Exception as exc: | ||
| logger.warning("Rules prefilter failed for one case (%s); fallback to ep_checker.", exc) | ||
| return None | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "RuntimeCheckerRulesPrefilter", | ||
|
fangyangci marked this conversation as resolved.
|
||
| "build_skip_check_result_for_rules_all_nodes_compile_run_pass", | ||
| ] | ||
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
10 changes: 10 additions & 0 deletions
10
src/winml/modelkit/analyze/runtime_checker/result_sanitizer.py
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,10 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # -------------------------------------------------------------------------- | ||
| """Backward-compatible re-export for runtime checker result sanitizers.""" | ||
|
|
||
| from ...utils.result_sanitizer import sanitize_check_result_payload, sanitize_result_text | ||
|
fangyangci marked this conversation as resolved.
|
||
|
|
||
|
|
||
| __all__ = ["sanitize_check_result_payload", "sanitize_result_text"] | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.