Created
October 7, 2019 07:23
-
-
Save BeMg/feed928b5cd8d5b2f829b57ffe0cfe1c to your computer and use it in GitHub Desktop.
Loop Partition example
This file contains hidden or 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
import tvm | |
import numpy | |
import timeit | |
n = 225 | |
A = tvm.placeholder((n, n), name='Input') | |
B = tvm.placeholder((7, 7), name='Filter') | |
di = tvm.reduce_axis((0, 7), name='di') | |
dj = tvm.reduce_axis((0, 7), name='dj') | |
C = tvm.compute( | |
(n, n), | |
lambda i, j: tvm.sum(A[i + di, j + dj] * B[di, dj], axis=[di, dj]), | |
name='Output') | |
s = tvm.create_schedule(C.op) | |
f = s[C].fuse(di, dj) | |
fo, fi = s[C].split(f, nparts=14) | |
print(tvm.lower(s, [A, B, C], simple_mode=True)) | |
a = tvm.lower(s, [A, B, C], simple_mode=True) | |
a = tvm.ir_pass.LoopPartition(a, True) | |
a = tvm.ir_pass.Simplify(a) | |
print(tvm.lower(s, [A, B, C], simple_mode=True)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment