Skip to content
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

Make sure IterDomain::resize generates non-symbolic IDs #4007

Merged
merged 4 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion csrc/ir/interface_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,11 @@ class NVF_API TensorView : public Val {
//! Resize an IterDomain by expanding both the left and right sides
//! by given widths. The resulting IterDomain has an extent of
//! (left_expansion + axis->extent() + right_expansion).
TensorView* resize(int64_t axis, Val* left_expansion, Val* right_expansion);
TensorView* resize(
int64_t axis,
Val* left_expansion,
Val* right_expansion,
std::optional<IterType> iter_type = std::nullopt);

// WARNING: rFactor does not return this TensorView, ir returns a new
// tensorview consumed by this!
Expand Down
6 changes: 5 additions & 1 deletion csrc/ir/internal_base_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,11 @@ class TensorDomain : public Val {
SwizzleMode swizzle_mode = SwizzleMode::Data);

// Resize an axis by left_expansion and right_expansion
void resize(int64_t axis, Val* left_expansion, Val* right_expansion);
void resize(
int64_t axis,
Val* left_expansion,
Val* right_expansion,
std::optional<IterType> iter_type = std::nullopt);

// Transform TensorView according to merge and split transformations
TensorDomain* view(const AnalyzeViewResult& view_analysis);
Expand Down
10 changes: 8 additions & 2 deletions csrc/ir/nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3697,13 +3697,19 @@ void TensorDomain::swizzle(
void TensorDomain::resize(
int64_t axis,
Val* left_expansion,
Val* right_expansion) {
Val* right_expansion,
std::optional<IterType> iter_type) {
NVF_ERROR(nDims() > 0, "Tried to do resize on a 0-dim domain");
axis = wrapDim(axis);

IterDomain* id = this->axis(axis);

auto resized_id = IterDomain::resize(id, left_expansion, right_expansion);
auto resized_id = IterDomain::resize(
id,
left_expansion,
right_expansion,
/*mark_as_rfactor=*/false,
iter_type);
loop_domain_.at(axis) = resized_id;
resetDomains();
}
Expand Down
8 changes: 7 additions & 1 deletion csrc/scheduler/tools/loop_domain_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,16 @@ class ReplayForwardTransformOnLoopDomain : OptInConstDispatch {

void handle(const Resize* resize) final {
NVF_ERROR(input_loop_ids_.size() == 1);
NVF_ERROR(
resize->out()->getIterType() != IterType::Symbolic,
"Unexpected to have a symbolic ID: ",
resize->out()->toString());
// Pass the iter type explicitly to avoid generating a symblic ID
tv_->resize(
getLoopIdPosition(input_loop_ids_.at(0)),
resize->leftExpand(),
resize->rightExpand());
resize->rightExpand(),
resize->out()->getIterType());
}

void handle(const Swizzle2D* swizzle_2d) final {
Expand Down
5 changes: 3 additions & 2 deletions csrc/tensor_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ TensorView* TensorView::merge(int64_t axis_o, int64_t axis_i) {
TensorView* TensorView::resize(
int64_t axis,
Val* left_expansion,
Val* right_expansion) {
Val* right_expansion,
std::optional<IterType> iter_type) {
NVF_ERROR(
nDims() > 0,
"Tried to do resize on a 0-dim TensorView. ",
Expand Down Expand Up @@ -560,7 +561,7 @@ TensorView* TensorView::resize(
" Parallelization strategy must be set after calling resize: ",
toString());

domain()->resize(axis, left_expansion, right_expansion);
domain()->resize(axis, left_expansion, right_expansion, iter_type);
return this;
}

Expand Down