Skip to content

Conversation

@rauletorresc
Copy link
Contributor

@rauletorresc rauletorresc commented Dec 4, 2025

Description of the problem

is_matched_graph implementation is a bit confusing because is not so easy to understand the comparison between the current graph and the properties of the cached graphs. The usage of continue to skip graphs of different sizes, and a combination of a break and a flag to exit the inner loop to simulate a continue in the outer loop, make it very difficult to follow the logic. Moreover, the passed arguments and the function name do not match the intended semantics properly.

Proposed solution

  • Rename the function to is_matched_graph_in_cache to better reflect its intention.
  • Pass only the graph cache list instead of the whole context.
  • Enclose the graph node traversal check inside a lambda to avoid having to use statements that break the control flow arbitrarily.
  • Rename variables in a more meaningful way.
  • Update the corresponding function call.

** Description of the problem **

`is_matched_graph` implementation is a bit confusing because is not
so easy to understand the comparison between the current graph and
the properties of the cached graphs. The usage of `continue` to
skip graphs of different sizes, and a combination of a `break` and
a flag to exit the inner loop to simulate a `continue` in the outer
loop, make it very difficult to follow the logic. Moreover, the
passed arguments and the function name do not match the intended
semantics properly.

** Proposed solution **

* Rename the function to `is_matched_graph_in_cache` to better
  reflect its intention.
* Pass only the graph cache list instead of the whole context.
* Enclose the graph node traversal check inside a lambda to avoid
  having to use statements that break the control flow arbitrarily.
* Rename variables in a more meaningful way.
* Update the corresponding function call.
@github-actions github-actions bot added ggml changes relating to the ggml tensor library for machine learning Ascend NPU issues specific to Ascend NPUs labels Dec 4, 2025
@rauletorresc rauletorresc changed the title Refactor is_matched_graph for better maintainability CANN: Refactor is_matched_graph for better maintainability Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ascend NPU issues specific to Ascend NPUs ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant