-
Notifications
You must be signed in to change notification settings - Fork 66
refactor(ir): extract wrapper-call finders into shared utility + drop InferFunctionCoreType body-walking #1321
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
Hzfengsy
merged 4 commits into
hw-native-sys:main
from
lyfne123:worktree-phase2-codegen-analysis
May 9, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7e502cb
refactor(ir): extract wrapper-call finders into shared IR utility
lyfne123 80dba75
refactor(codegen): drop InferFunctionCoreType body-walking fallback
lyfne123 c1680ff
fix(pr): resolve issues for #1321
lyfne123 fa0865e
fix(pr): resolve issues for #1321
lyfne123 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * Copyright (c) PyPTO Contributors. | ||
| * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| * See LICENSE in the root of the software repository for the full text of the License. | ||
| * ----------------------------------------------------------------------------------------------------------- | ||
| */ | ||
|
|
||
| #ifndef PYPTO_IR_TRANSFORMS_UTILS_WRAPPER_CALL_UTILS_H_ | ||
| #define PYPTO_IR_TRANSFORMS_UTILS_WRAPPER_CALL_UTILS_H_ | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "pypto/ir/expr.h" | ||
| #include "pypto/ir/function.h" | ||
| #include "pypto/ir/program.h" | ||
|
|
||
| namespace pypto { | ||
| namespace ir { | ||
|
|
||
| /** | ||
| * @brief Result of a wrapper / inner-call lookup. | ||
| * | ||
| * Both fields are nullptr if no matching call was found. | ||
| */ | ||
| struct WrapperCallInfo { | ||
| CallPtr inner_call; | ||
| FunctionPtr inner_callee; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Find the first non-builtin Call inside @p wrapper that resolves to a | ||
| * Function in @p program. | ||
| * | ||
| * "Non-builtin" here means the Call's op is a GlobalVar that names an | ||
| * existing user-level Function in the program. Builtin op calls | ||
| * (`tile.*`, `tensor.*`, `system.*`) carry no GlobalVar and are skipped. | ||
| * | ||
| * @return {call, callee} for the first match, or {nullptr, nullptr} if none. | ||
| */ | ||
| WrapperCallInfo FindFirstInnerCall(const FunctionPtr& wrapper, const ProgramPtr& program); | ||
|
|
||
| /** | ||
| * @brief Result of a Group-function callee scan. | ||
| * | ||
| * - `aic_name` / `aiv_name` — the names of the first AIC / AIV callees | ||
| * encountered (empty if none). | ||
| * - `inner_call` / `inner_callee` — the **first** AIC, AIV, or InCore call | ||
| * in source order, regardless of type. Used by orchestration codegen as | ||
| * the parameter-order reference for wrapper arg reconciliation. After | ||
| * `ExpandMixedKernel`, Group bodies are emitted as `AIC → AIV` so the | ||
| * AIC call is naturally first in practice; the function does not enforce | ||
| * a type priority. | ||
| */ | ||
| struct GroupCalleeInfo { | ||
| std::string aic_name; | ||
| std::string aiv_name; | ||
| CallPtr inner_call; | ||
| FunctionPtr inner_callee; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Group-specific scan: locate the AIC / AIV callees and the first | ||
| * AIC/AIV/InCore inner call inside @p group_func. | ||
| * | ||
| * @return aggregated info; any field may be empty / nullptr if not present. | ||
| */ | ||
| GroupCalleeInfo FindGroupCallees(const FunctionPtr& group_func, const ProgramPtr& program); | ||
|
|
||
| /** | ||
| * @brief Collect every Call inside @p wrapper that resolves to a Function | ||
| * of a non-Orchestration, non-Opaque type. | ||
| * | ||
| * Used by cross-function direction propagation in `ComputeGroupEffectiveDirections`. | ||
| * Visits the body in order; each inner Call appears once even if its callee is | ||
| * called from multiple sites. | ||
| */ | ||
| std::vector<WrapperCallInfo> CollectInnerCalls(const FunctionPtr& wrapper, const ProgramPtr& program); | ||
|
|
||
| } // namespace ir | ||
| } // namespace pypto | ||
|
|
||
| #endif // PYPTO_IR_TRANSFORMS_UTILS_WRAPPER_CALL_UTILS_H_ |
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
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.