You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/25 00:51:52 UTC
[GitHub] [tvm] wrongtest commented on pull request #11097: [TVMScript] Support TVMScript meta-programming
wrongtest commented on PR #11097:
URL: https://github.com/apache/tvm/pull/11097#issuecomment-1107956829
If we'd like to distinguish variables and other asts in script and variables in host language? For example, use a mustache syntax the case above could be (like the html template of VUE.js)
```python
def matmul_generator(M, N, K, dtype):
@T.prim_func
def matmul(a: T.handle, b: T.handle, c: T.handle) -> None:
A = T.match_buffer(a, [{M}, {K}], dtype={dtype})
B = T.match_buffer(b, [{N}, {K}], dtype={dtype})
C = T.match_buffer(c, [{M}, {N}], dtype={dtype})
for i, j, k in T.grid({M}, {N}, {K}):
with T.block():
vi, vj, vk = T.axis.remap("SSR", [i, j, k])
with T.init():
C[vi, vj] = T.float32(0)
C[vi, vj] = C[vi, vj] + A[vi, vk] * B[vj, vk]
return matmul
```
And we can also write like
```python
T.evaluate({ [call my expr ib builder] })
```
or
```python
for i in range({N}):
{
[call my ib builder to create sequence of stmts]
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org