forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PASS] add a pass for the specific hardware accelarator when it is no…
…t binded (apache#1999)
- Loading branch information
Showing
6 changed files
with
64 additions
and
1 deletion.
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
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
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,21 @@ | ||
/*! | ||
* Copyright (c) 2018 by Contributors | ||
* \file detect_device.cc | ||
*/ | ||
|
||
#include <tvm/ir_pass.h> | ||
#include <tvm/ir_mutator.h> | ||
#include "../pass/ir_util.h" | ||
|
||
namespace tvm { | ||
namespace ir { | ||
Stmt DecorateDeviceScope(Stmt stmt) { | ||
Stmt body = AttrStmt::make(make_zero(Int(32)), | ||
ir::attr::device_scope, | ||
0, | ||
stmt); | ||
return body; | ||
} | ||
|
||
} // namespace ir | ||
} // namespace tvm |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import tvm | ||
|
||
def test_decorate_device(): | ||
m = tvm.var('m') | ||
l = tvm.var('l') | ||
A = tvm.placeholder((m, l), name='A') | ||
|
||
A1 = tvm.compute((m, l), lambda i, j: A[i, j], name='A1') | ||
A2 = tvm.compute((m, l), lambda i, j: A1[i, j] + 3, name='A2') | ||
|
||
s = tvm.create_schedule(A2.op) | ||
xo, xi = s[A2].split(A2.op.axis[0], factor=8) | ||
s[A1].compute_at(s[A2], xo) | ||
s[A1].set_scope("shared") | ||
|
||
bounds = tvm.schedule.InferBound(s) | ||
stmt = tvm.schedule.ScheduleOps(s, bounds) | ||
stmt1 = tvm.ir_pass.Simplify(stmt) | ||
stmt2 = tvm.ir_pass.DecorateDeviceScope(stmt1) | ||
assert isinstance(stmt2, tvm.stmt.AttrStmt) | ||
assert stmt2.attr_key == "device_scope" | ||
assert stmt1 == stmt2.body | ||
|
||
if __name__ == "__main__": | ||
test_decorate_device() | ||
|