junrushao1994 commented on PR #11097:
URL: https://github.com/apache/tvm/pull/11097#issuecomment-1107898950

   Thanks @Hzfengsy for sharing! Yeah it's completely understandable that 
Siyuan doesn't have enough time lately to do another PR to iterate over this 
one.
   
   I would say the charm of an OSS community is that people enjoy the freedom 
to collaborate publicly without boundary, getting recognition, credit and 
ownership they deserve as they contribute, no matter if the original owner has 
enough bandwidth or not :-)
   
   In fact, our group (@yelite @juda @cyx-6) are going to push for an ambitious 
complete refactoring of TVMScript printer/parser for better extensibility (e.g. 
for Relax and other customized IR), and full-featured metaprogramming (as 
opposed to this limited one), but it would require some non-trivial time (until 
end of Q2). We mentioned this project a couple of time internally, but the full 
text for OSS is still under active construction - happy to share the 
preliminary/immature proposal.
   
   The reason that I pinged Siyuan to submit this quick patch that supports 
only certain degree of limited metaprogramming is that I saw @masahi and 
@Lunderberg have some imminent product needs for this feature (e.g. 
tensorization), and therefore believe that:
   1) sharing is definitely the way to help each other in OSS;
   2) we need to quickly reach consensus on the syntax-side of metaprogramming.
   
   This PR demonstrates the conceptual idea of this preliminary syntax for 
metaprogramming, as Eric and Masa are already familiar with:
   
   ```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
   
   f_1 = matmul_generator(128, 128, 128, "float16")
   f_2 = matmul_generator(256, 256, 256, "float32")
   ```
   
   The action I propose to take:
   - A1. Decide if the syntax is good for @masahi and @Lunderberg's usecase;
   - A2. Adjust the PR title, explicitly saying it's template metaprogramming 
over variables;
   - A3. If we all agree on A1 and A2, would love to invite Eric to coauthor 
this PR or proceed in #11062 (either way works) implementing that idea, with 
both Siyuan and Eric be listed as coauthors.
   
   Let me know what you guys think!


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to