Open youkaichao opened 1 year ago
I think it's a good proposal
Using template engine would separate the code string and the variables, which is not as intuitive as it is now. In addition, I have to deal with the various design of how to place the template files. The granularity is also a problem: there are some one-line f-strings, as well as several lines, together with f-strings with dozens of lines. I don't know how to control the granularity of when to use template engines.
Finally, I gave it up. Using a template engine does not bring much benefit.
The next time when I want to write the code myself, there are not many steps actually:
{{
with {
}}
with }
\"
with "
{expression}
with actual values@Jokeren
Currently, the code generation in triton uses python f-string, which has to deal with all the escaping for special characters like
{
and}
.Is it possible to use some template engine like Jinja to make the code generation more maintainable?
I come up with this issue when I tried to understand the generated source code. Copying cpp code in https://github.com/openai/triton/blob/main/python/triton/compiler/make_launcher.py leads to headache. I have to carefully back-escape the code.
If it is acceptable, I can take this PR to do the refactor.
@ptillet