Skip to content

Commit

Permalink
IsAffineBinding(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterJH5574 committed May 10, 2021
1 parent 8f25349 commit f9f0389
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/tir/schedule/analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <tvm/tir/op.h>
#include <tvm/tir/schedule/state.h>
#include <tvm/tir/stmt_functor.h>
#include <tvm/arith/iter_affine_map.h>

namespace tvm {
namespace tir {
Expand Down Expand Up @@ -60,7 +61,8 @@ bool IsReductionBlock(const ScheduleState& self, const StmtSRef& block_sref,

/******** Binding ********/
// Todo
bool ValidateBlockBinding(const BlockRealize& realize, const Map<Var, Range>& loop_var_ranges);
bool IsAffineBinding(const BlockRealize& realize, const Map<Var, Range>& loop_var_ranges,
arith::Analyzer* analyzer);

/******** Block-loop relation ********/
/*!
Expand Down
22 changes: 10 additions & 12 deletions src/tir/schedule/analysis/analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,17 @@ bool IsReductionBlock(const ScheduleState& self, const StmtSRef& block_sref,

/******** Binding ********/

bool ValidateBlockBinding(const BlockRealize& realize, const Map<Var, Range>& loop_var_ranges) {
bool IsAffineBinding(const BlockRealize& realize, const Map<Var, Range>& loop_var_ranges,
arith::Analyzer* analyzer) {
if (loop_var_ranges.empty()) {
return true;
}
arith::Analyzer analyzer;
Array<PrimExpr> leaf_iters;
leaf_iters.reserve(static_cast<int64_t>(realize->block->iter_vars.size()));
for (const IterVar& iter_var : realize->block->iter_vars) {
leaf_iters.push_back(iter_var);
}
Array<arith::IterSumExpr> results = arith::DetectIterMap(
/*leaf_iters=*/leaf_iters,
/*bindings=*/realize->iter_values, // Todo
/*root_iters=*/loop_var_ranges,
/*input_pred=*/realize->predicate, /*analyzer=*/&analyzer);
/*indices=*/realize->iter_values,
/*input_iters=*/loop_var_ranges,
/*predicate=*/realize->predicate,
/*require_bijective=*/false,
/*analyzer=*/analyzer);
if (results.empty()) {
return false;
}
Expand Down Expand Up @@ -400,7 +396,9 @@ void UpdateAffineFlag(ScheduleState self, const StmtSRef& block_sref) {
}
}
ICHECK(self->block_info.count(block_sref));
self->block_info[block_sref].affine_binding = ValidateBlockBinding(realize, loop_var_ranges);
arith::Analyzer analyzer;
self->block_info[block_sref].affine_binding =
IsAffineBinding(realize, loop_var_ranges, &analyzer);
}

/******** Pattern Matcher ********/
Expand Down

0 comments on commit f9f0389

Please sign in to comment.