-
Notifications
You must be signed in to change notification settings - Fork 58
feat(ir,dsl): add pl.runtime_print for runtime tile/tensor debugging #857
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
Draft
Hzfengsy
wants to merge
5
commits into
hw-native-sys:main
Choose a base branch
from
Hzfengsy:feat/runtime-print
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.
Draft
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
98afb47
feat(ir,dsl): add pl.runtime_print for runtime tile/tensor debugging …
Hzfengsy d3e1a82
fix(pr): resolve review comments and CI failure for #857
Hzfengsy ab24de6
fix(codegen): use proper type annotation in pto.tprint codegen
Hzfengsy b1a954c
fix(codegen): define _DEBUG in kernel header when TPRINT is used
Hzfengsy 95e0728
fix(codegen): use no-op TPRINT fallback instead of _DEBUG define
Hzfengsy 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
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,54 @@ | ||
| /* | ||
| * 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. | ||
| * ----------------------------------------------------------------------------------------------------------- | ||
| */ | ||
|
|
||
| /** | ||
| * @file utility.cpp | ||
| * @brief Utility tensor operations (print) | ||
| * | ||
| * This file implements utility/debugging operations for tensor-level programming. | ||
| */ | ||
|
|
||
| #include <any> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "pypto/core/logging.h" | ||
| #include "pypto/ir/kind_traits.h" | ||
| #include "pypto/ir/op_registry.h" | ||
| #include "pypto/ir/type.h" | ||
|
|
||
| namespace pypto { | ||
| namespace ir { | ||
|
|
||
| TypePtr DeduceTensorPrintType(const std::vector<ExprPtr>& args, | ||
| const std::vector<std::pair<std::string, std::any>>& kwargs, | ||
| const std::string& op_name) { | ||
| CHECK(args.size() == 1) << "The operator " << op_name << " requires 1 argument (tensor), but got " | ||
| << args.size(); | ||
| auto tensor_type = As<TensorType>(args[0]->GetType()); | ||
| CHECK(tensor_type) << "The operator " << op_name << " requires argument to be a TensorType, but got " | ||
| << args[0]->GetType()->TypeName(); | ||
| // Pass-through: returns the input tensor type (print is a side-effect operation) | ||
| return tensor_type; | ||
| } | ||
|
|
||
| REGISTER_OP("tensor.runtime_print") | ||
| .set_op_category("TensorOp") | ||
| .set_description("Print tensor contents for debugging (generates pto.tprint)") | ||
| .add_argument("tensor", "Input tensor to print (TensorType)") | ||
| .f_deduce_type([](const std::vector<ExprPtr>& args, | ||
| const std::vector<std::pair<std::string, std::any>>& kwargs) { | ||
| return DeduceTensorPrintType(args, kwargs, "tensor.runtime_print"); | ||
| }); | ||
|
|
||
| } // namespace ir | ||
| } // namespace pypto |
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,55 @@ | ||
| /* | ||
| * 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. | ||
| * ----------------------------------------------------------------------------------------------------------- | ||
| */ | ||
|
|
||
| /** | ||
| * @file utility.cpp | ||
| * @brief Utility tile operations (print) | ||
| * | ||
| * This file implements utility/debugging operations for tile-level programming. | ||
| */ | ||
|
|
||
| #include <any> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "pypto/core/logging.h" | ||
| #include "pypto/ir/kind_traits.h" | ||
| #include "pypto/ir/op_registry.h" | ||
| #include "pypto/ir/type.h" | ||
|
|
||
| namespace pypto { | ||
| namespace ir { | ||
|
|
||
| TypePtr DeduceTilePrintType(const std::vector<ExprPtr>& args, | ||
| const std::vector<std::pair<std::string, std::any>>& kwargs, | ||
| const std::string& op_name) { | ||
| CHECK(args.size() == 1) << "The operator " << op_name << " requires 1 argument (tile), but got " | ||
| << args.size(); | ||
| auto tile_type = As<TileType>(args[0]->GetType()); | ||
| CHECK(tile_type) << "The operator " << op_name << " requires argument to be a TileType, but got " | ||
| << args[0]->GetType()->TypeName(); | ||
| // Pass-through: returns the input tile type (print is a side-effect operation) | ||
| return tile_type; | ||
| } | ||
|
|
||
| REGISTER_OP("tile.runtime_print") | ||
| .set_op_category("TileOp") | ||
| .set_description("Print tile contents for debugging (generates pto.tprint)") | ||
| .add_argument("tile", "Input tile to print (TileType)") | ||
| .no_memory_spec() | ||
| .f_deduce_type([](const std::vector<ExprPtr>& args, | ||
| const std::vector<std::pair<std::string, std::any>>& kwargs) { | ||
| return DeduceTilePrintType(args, kwargs, "tile.runtime_print"); | ||
| }); | ||
|
|
||
| } // namespace ir | ||
| } // namespace pypto |
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.