-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented bounded analyzer which traverses tree and for reduce/for
statements binds the bound of the analyzer. Later this is used to simplify expressions. Inspired from ir_mutator_with_analyzer Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
- Loading branch information
1 parent
8e19998
commit cb8614a
Showing
4 changed files
with
82 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
#include <tvm/arithmetic.h> | ||
#include <tvm/ir.h> | ||
#include <tvm/ir_visitor.h> | ||
|
||
namespace tvm { | ||
namespace ir { | ||
|
||
class BoundedAnalyzer final : public IRVisitor { | ||
public: | ||
void Visit_(const For* op) { | ||
analyzer.Bind(op->loop_var, | ||
Range::make_by_min_extent(op->min, op->extent)); | ||
return IRVisitor::Visit_(op); | ||
} | ||
|
||
void Visit_(const AttrStmt* op) { | ||
if (op->attr_key == attr::thread_extent || | ||
op->attr_key == attr::virtual_thread) { | ||
IterVar iv(op->node.node_); | ||
CHECK_NE(iv->thread_tag.length(), 0U); | ||
analyzer.Bind(iv->var, | ||
Range::make_by_min_extent(0, op->value)); | ||
IRVisitor::Visit_(op); | ||
} else { | ||
IRVisitor::Visit_(op); | ||
} | ||
} | ||
|
||
void Visit_(const Reduce* op) { | ||
// Setup the domain information before simplification. | ||
for (const IterVar& iv : op->axis) { | ||
analyzer.Bind(iv->var, iv->dom); | ||
} | ||
// Recursively call simplification when necessary. | ||
IRVisitor::Visit_(op); | ||
} | ||
|
||
/*! \brief internal analyzer field. */ | ||
arith::Analyzer analyzer; | ||
}; | ||
|
||
} // namespace ir | ||
} // namespace tvm |
This file was deleted.
Oops, something went wrong.
This file contains 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 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