forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix and more test for axis fusion, new workload (#50)
* upd * upd
- Loading branch information
Showing
7 changed files
with
188 additions
and
5 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
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,54 @@ | ||
from dgl.heterograph import DGLHeteroGraph | ||
import tvm | ||
import tvm.testing | ||
import tvm.tir as tir | ||
import scipy.sparse as sp | ||
import numpy as np | ||
import dgl | ||
import dgl.function as fn | ||
import torch as th | ||
from tvm.script import tir as T | ||
from dgl.data.rdf import AIFBDataset, MUTAGDataset, BGSDataset, AMDataset | ||
|
||
|
||
@T.prim_func | ||
def rgcn_hetero_forward( | ||
offset_ntype: T.handle, | ||
w: T.handle, | ||
x: T.handle, | ||
y: T.handle, | ||
indptr_i: T.handle, | ||
indptr_j: T.handle, | ||
indices_j: T.handle, | ||
n: T.int32, | ||
r: T.int32, | ||
feat_size: T.int32, | ||
nnz_i: T.int32, | ||
nnz_j: T.int32 | ||
): | ||
I_flatten = T.dense_fixed(n) | ||
R = T.dense_fixed(r) | ||
I = T.dense_variable(R, (n, nnz_i), indptr_i, "int32") | ||
J = T.sparse_variable(I, (n, nnz_j), (indptr_j, indices_j), "int32") | ||
F_in = T.dense_fixed(feat_size) | ||
F_out = T.dense_fixed(feat_size) | ||
offset = T.match_sparse_buffer(offset_ntype, (R,), "int32") | ||
W = T.match_sparse_buffer(w, (R, F_out, F_in), "float32") | ||
X = T.match_sparse_buffer(x, (I_flatten, F_in), "float32") | ||
Y = T.match_sparse_buffer(y, (I_flatten, R, F_out), "float32") | ||
with T.iter([T.fuse(R, I), F_out, J, F_in], "SSSRR", "rgcn-hetero-forward") as [ | ||
vr, vi, vout, vj, vin | ||
]: | ||
with T.init(): | ||
Y[offset[vr] + vi, vr, vout] = 0. | ||
Y[offset[vr] + vi, vr, vout] = Y[offset[vr] + vi, vr, vout] + W[vr, vout, vin] * X[vj, vin] | ||
|
||
|
||
def test_lower_rgcn_hetero(): | ||
mod = tvm.IRModule.from_expr(rgcn_hetero_forward) | ||
mod = tvm.tir.transform.LowerSparseTIR()(mod) | ||
print(mod["main"].script()) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_lower_rgcn_hetero() |
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 @@ | ||
# TODO |