Skip to content

Commit 2b2cb96

Browse files
authored
[TVMScript][Printer] Remove relax prefix for now (#14140)
Remove relax prefix for now This PR cleans up relax prefix in printer for now. While these setups are useful and do not cause any technical debts in the codebase. We remove it given requests. They can be added back to unity branch and later as part of upstream
1 parent 6097df5 commit 2b2cb96

File tree

4 files changed

+4
-69
lines changed

4 files changed

+4
-69
lines changed

include/tvm/node/script_printer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class PrinterConfigNode : public Object {
4343
std::string ir_prefix = "I";
4444
/*! \brief The prefix of TIR nodes */
4545
std::string tir_prefix = "T";
46-
/*! \brief The prefix of Relax nodes */
47-
std::string relax_prefix = "R";
4846
/*! \brief Default data type of TIR buffer */
4947
DataType buffer_dtype = DataType::Float(32);
5048
/*! \brief Default data type of integer literals */

python/tvm/runtime/script_printer.py

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class PrinterConfig(Object):
3232
show_meta: bool
3333
ir_prefix: str
3434
tir_prefix: str
35-
relax_prefix: str
3635
buffer_dtype: str
3736
int_dtype: str
3837
float_dtype: str
@@ -53,7 +52,6 @@ def __init__(
5352
show_meta: bool = False,
5453
ir_prefix: str = "I",
5554
tir_prefix: str = "T",
56-
relax_prefix: str = "R",
5755
buffer_dtype: str = "float32",
5856
int_dtype: str = "int32",
5957
float_dtype: str = "void",
@@ -73,7 +71,6 @@ def __init__(
7371
"show_meta": show_meta,
7472
"ir_prefix": ir_prefix,
7573
"tir_prefix": tir_prefix,
76-
"relax_prefix": relax_prefix,
7774
"buffer_dtype": buffer_dtype,
7875
"int_dtype": int_dtype,
7976
"float_dtype": float_dtype,
@@ -114,7 +111,6 @@ def script(
114111
show_meta: bool = False,
115112
ir_prefix: str = "I",
116113
tir_prefix: str = "T",
117-
relax_prefix: str = "R",
118114
buffer_dtype: str = "float32",
119115
int_dtype: str = "int32",
120116
float_dtype: str = "void",
@@ -140,8 +136,7 @@ def script(
140136
The prefix of AST nodes from tvm.ir
141137
tir_prefix : str = "T"
142138
The prefix of AST nodes from tvm.tir
143-
relax_prefix : str = "R"
144-
The prefix of AST nodes from tvm.relax
139+
145140
buffer_dtype : str = "float32"
146141
The default data type of buffer
147142
int_dtype : str = "int32"
@@ -179,51 +174,6 @@ def script(
179174
show_meta=show_meta,
180175
ir_prefix=ir_prefix,
181176
tir_prefix=tir_prefix,
182-
relax_prefix=relax_prefix,
183-
buffer_dtype=buffer_dtype,
184-
int_dtype=int_dtype,
185-
float_dtype=float_dtype,
186-
verbose_expr=verbose_expr,
187-
indent_spaces=indent_spaces,
188-
print_line_numbers=print_line_numbers,
189-
num_context_lines=num_context_lines,
190-
syntax_sugar=syntax_sugar,
191-
path_to_underline=path_to_underline,
192-
path_to_annotate=path_to_annotate,
193-
obj_to_underline=obj_to_underline,
194-
obj_to_annotate=obj_to_annotate,
195-
),
196-
)
197-
198-
def _relax_script(
199-
self,
200-
*,
201-
name: Optional[str] = None,
202-
show_meta: bool = False,
203-
ir_prefix: str = "I",
204-
tir_prefix: str = "T",
205-
relax_prefix: str = "R",
206-
buffer_dtype: str = "float32",
207-
int_dtype: str = "int32",
208-
float_dtype: str = "void",
209-
verbose_expr: bool = False,
210-
indent_spaces: int = 4,
211-
print_line_numbers: bool = False,
212-
num_context_lines: int = -1,
213-
syntax_sugar: bool = True,
214-
path_to_underline: Optional[List[ObjectPath]] = None,
215-
path_to_annotate: Optional[Dict[ObjectPath, str]] = None,
216-
obj_to_underline: Optional[List[Object]] = None,
217-
obj_to_annotate: Optional[Dict[Object, str]] = None,
218-
) -> str:
219-
return _relax_script(
220-
self,
221-
PrinterConfig(
222-
name=name,
223-
show_meta=show_meta,
224-
ir_prefix=ir_prefix,
225-
tir_prefix=tir_prefix,
226-
relax_prefix=relax_prefix,
227177
buffer_dtype=buffer_dtype,
228178
int_dtype=int_dtype,
229179
float_dtype=float_dtype,
@@ -248,7 +198,6 @@ def show(
248198
show_meta: bool = False,
249199
ir_prefix: str = "I",
250200
tir_prefix: str = "T",
251-
relax_prefix: str = "R",
252201
buffer_dtype: str = "float32",
253202
int_dtype: str = "int32",
254203
float_dtype: str = "void",
@@ -279,8 +228,7 @@ def show(
279228
The prefix of AST nodes from tvm.ir
280229
tir_prefix : str = "T"
281230
The prefix of AST nodes from tvm.tir
282-
relax_prefix : str = "R"
283-
The prefix of AST nodes from tvm.relax
231+
284232
buffer_dtype : str = "float32"
285233
The default data type of buffer
286234
int_dtype : str = "int32"
@@ -316,7 +264,6 @@ def show(
316264
show_meta=show_meta,
317265
ir_prefix=ir_prefix,
318266
tir_prefix=tir_prefix,
319-
relax_prefix=relax_prefix,
320267
buffer_dtype=buffer_dtype,
321268
int_dtype=int_dtype,
322269
float_dtype=float_dtype,

src/node/script_printer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ PrinterConfig::PrinterConfig(Map<String, ObjectRef> config_dict) {
4949
if (auto v = config_dict.Get("tir_prefix")) {
5050
n->tir_prefix = Downcast<String>(v);
5151
}
52-
if (auto v = config_dict.Get("relax_prefix")) {
53-
n->relax_prefix = Downcast<String>(v);
54-
}
52+
5553
if (auto v = config_dict.Get("buffer_dtype")) {
5654
n->buffer_dtype = DataType(runtime::String2DLDataType(Downcast<String>(v)));
5755
}

src/script/printer/utils.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ inline ExprDoc TIR(const IRDocsifier& d, const String& attr) {
103103
return IdDoc(d->cfg->tir_prefix)->Attr(attr);
104104
}
105105

106-
/*! \brief Creates the TIR common prefix, which is by default `T` */
107-
inline ExprDoc Relax(const IRDocsifier& d, const String& attr) {
108-
d->ir_usage.insert("relax");
109-
return IdDoc(d->cfg->relax_prefix)->Attr(attr);
110-
}
111-
112106
inline std::string DType2Str(const runtime::DataType& dtype) {
113107
return dtype.is_void() ? "void" : runtime::DLDataType2String(dtype);
114108
}
@@ -123,9 +117,7 @@ inline Doc HeaderWrapper(const IRDocsifier& d, const Doc& doc) {
123117
if (d->ir_usage.count("tir")) {
124118
stmts.push_back(CommentDoc("from tvm.script import tir as " + d->cfg->tir_prefix));
125119
}
126-
if (d->ir_usage.count("relax")) {
127-
stmts.push_back(CommentDoc("from tvm.script import relax as " + d->cfg->relax_prefix));
128-
}
120+
129121
stmts.push_back(CommentDoc(""));
130122
stmts.push_back(Downcast<StmtDoc>(doc));
131123
return StmtBlockDoc(stmts);

0 commit comments

Comments
 (0)