This is an automated email from the ASF dual-hosted git repository.
ruihangl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 2b2cb96733 [TVMScript][Printer] Remove relax prefix for now (#14140)
2b2cb96733 is described below
commit 2b2cb96733c8e7b755498650672b6dadd37a4786
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Feb 27 20:14:44 2023 -0500
[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
---
include/tvm/node/script_printer.h | 2 --
python/tvm/runtime/script_printer.py | 57 ++----------------------------------
src/node/script_printer.cc | 4 +--
src/script/printer/utils.h | 10 +------
4 files changed, 4 insertions(+), 69 deletions(-)
diff --git a/include/tvm/node/script_printer.h
b/include/tvm/node/script_printer.h
index e36e37bdf1..f4fec04035 100644
--- a/include/tvm/node/script_printer.h
+++ b/include/tvm/node/script_printer.h
@@ -43,8 +43,6 @@ class PrinterConfigNode : public Object {
std::string ir_prefix = "I";
/*! \brief The prefix of TIR nodes */
std::string tir_prefix = "T";
- /*! \brief The prefix of Relax nodes */
- std::string relax_prefix = "R";
/*! \brief Default data type of TIR buffer */
DataType buffer_dtype = DataType::Float(32);
/*! \brief Default data type of integer literals */
diff --git a/python/tvm/runtime/script_printer.py
b/python/tvm/runtime/script_printer.py
index a2f4cdc331..269cab8e5d 100644
--- a/python/tvm/runtime/script_printer.py
+++ b/python/tvm/runtime/script_printer.py
@@ -32,7 +32,6 @@ class PrinterConfig(Object):
show_meta: bool
ir_prefix: str
tir_prefix: str
- relax_prefix: str
buffer_dtype: str
int_dtype: str
float_dtype: str
@@ -53,7 +52,6 @@ class PrinterConfig(Object):
show_meta: bool = False,
ir_prefix: str = "I",
tir_prefix: str = "T",
- relax_prefix: str = "R",
buffer_dtype: str = "float32",
int_dtype: str = "int32",
float_dtype: str = "void",
@@ -73,7 +71,6 @@ class PrinterConfig(Object):
"show_meta": show_meta,
"ir_prefix": ir_prefix,
"tir_prefix": tir_prefix,
- "relax_prefix": relax_prefix,
"buffer_dtype": buffer_dtype,
"int_dtype": int_dtype,
"float_dtype": float_dtype,
@@ -114,7 +111,6 @@ class Scriptable:
show_meta: bool = False,
ir_prefix: str = "I",
tir_prefix: str = "T",
- relax_prefix: str = "R",
buffer_dtype: str = "float32",
int_dtype: str = "int32",
float_dtype: str = "void",
@@ -140,8 +136,7 @@ class Scriptable:
The prefix of AST nodes from tvm.ir
tir_prefix : str = "T"
The prefix of AST nodes from tvm.tir
- relax_prefix : str = "R"
- The prefix of AST nodes from tvm.relax
+
buffer_dtype : str = "float32"
The default data type of buffer
int_dtype : str = "int32"
@@ -179,51 +174,6 @@ class Scriptable:
show_meta=show_meta,
ir_prefix=ir_prefix,
tir_prefix=tir_prefix,
- relax_prefix=relax_prefix,
- buffer_dtype=buffer_dtype,
- int_dtype=int_dtype,
- float_dtype=float_dtype,
- verbose_expr=verbose_expr,
- indent_spaces=indent_spaces,
- print_line_numbers=print_line_numbers,
- num_context_lines=num_context_lines,
- syntax_sugar=syntax_sugar,
- path_to_underline=path_to_underline,
- path_to_annotate=path_to_annotate,
- obj_to_underline=obj_to_underline,
- obj_to_annotate=obj_to_annotate,
- ),
- )
-
- def _relax_script(
- self,
- *,
- name: Optional[str] = None,
- show_meta: bool = False,
- ir_prefix: str = "I",
- tir_prefix: str = "T",
- relax_prefix: str = "R",
- buffer_dtype: str = "float32",
- int_dtype: str = "int32",
- float_dtype: str = "void",
- verbose_expr: bool = False,
- indent_spaces: int = 4,
- print_line_numbers: bool = False,
- num_context_lines: int = -1,
- syntax_sugar: bool = True,
- path_to_underline: Optional[List[ObjectPath]] = None,
- path_to_annotate: Optional[Dict[ObjectPath, str]] = None,
- obj_to_underline: Optional[List[Object]] = None,
- obj_to_annotate: Optional[Dict[Object, str]] = None,
- ) -> str:
- return _relax_script(
- self,
- PrinterConfig(
- name=name,
- show_meta=show_meta,
- ir_prefix=ir_prefix,
- tir_prefix=tir_prefix,
- relax_prefix=relax_prefix,
buffer_dtype=buffer_dtype,
int_dtype=int_dtype,
float_dtype=float_dtype,
@@ -248,7 +198,6 @@ class Scriptable:
show_meta: bool = False,
ir_prefix: str = "I",
tir_prefix: str = "T",
- relax_prefix: str = "R",
buffer_dtype: str = "float32",
int_dtype: str = "int32",
float_dtype: str = "void",
@@ -279,8 +228,7 @@ class Scriptable:
The prefix of AST nodes from tvm.ir
tir_prefix : str = "T"
The prefix of AST nodes from tvm.tir
- relax_prefix : str = "R"
- The prefix of AST nodes from tvm.relax
+
buffer_dtype : str = "float32"
The default data type of buffer
int_dtype : str = "int32"
@@ -316,7 +264,6 @@ class Scriptable:
show_meta=show_meta,
ir_prefix=ir_prefix,
tir_prefix=tir_prefix,
- relax_prefix=relax_prefix,
buffer_dtype=buffer_dtype,
int_dtype=int_dtype,
float_dtype=float_dtype,
diff --git a/src/node/script_printer.cc b/src/node/script_printer.cc
index 071f427a72..8293af402e 100644
--- a/src/node/script_printer.cc
+++ b/src/node/script_printer.cc
@@ -49,9 +49,7 @@ PrinterConfig::PrinterConfig(Map<String, ObjectRef>
config_dict) {
if (auto v = config_dict.Get("tir_prefix")) {
n->tir_prefix = Downcast<String>(v);
}
- if (auto v = config_dict.Get("relax_prefix")) {
- n->relax_prefix = Downcast<String>(v);
- }
+
if (auto v = config_dict.Get("buffer_dtype")) {
n->buffer_dtype =
DataType(runtime::String2DLDataType(Downcast<String>(v)));
}
diff --git a/src/script/printer/utils.h b/src/script/printer/utils.h
index 90300518b7..10c7aaf4f2 100644
--- a/src/script/printer/utils.h
+++ b/src/script/printer/utils.h
@@ -103,12 +103,6 @@ inline ExprDoc TIR(const IRDocsifier& d, const String&
attr) {
return IdDoc(d->cfg->tir_prefix)->Attr(attr);
}
-/*! \brief Creates the TIR common prefix, which is by default `T` */
-inline ExprDoc Relax(const IRDocsifier& d, const String& attr) {
- d->ir_usage.insert("relax");
- return IdDoc(d->cfg->relax_prefix)->Attr(attr);
-}
-
inline std::string DType2Str(const runtime::DataType& dtype) {
return dtype.is_void() ? "void" : runtime::DLDataType2String(dtype);
}
@@ -123,9 +117,7 @@ inline Doc HeaderWrapper(const IRDocsifier& d, const Doc&
doc) {
if (d->ir_usage.count("tir")) {
stmts.push_back(CommentDoc("from tvm.script import tir as " +
d->cfg->tir_prefix));
}
- if (d->ir_usage.count("relax")) {
- stmts.push_back(CommentDoc("from tvm.script import relax as " +
d->cfg->relax_prefix));
- }
+
stmts.push_back(CommentDoc(""));
stmts.push_back(Downcast<StmtDoc>(doc));
return StmtBlockDoc(stmts);