We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Do not show meta data when printing TIR
Recently I found TVM will print meta when I do 
```python
print(tvm.lower(s, [A, B, C], simple_mode=True))
```

Here is an example output in the tutorial website (https://tvm.apache.org/docs/tutorials/language/schedule_primitives.html)
```
#[version = "0.0.5"]
primfn(A_1: handle, B_1: handle, C_1: handle) -> ()
  attr = {"global_symbol": "main", "tir.noalias": True}
  buffers = {C: Buffer(C_2: Pointer(float32), float32, [m: int32, n: int32], [stride: int32, stride_1: int32], type="auto"),
             B: Buffer(B_2: Pointer(float32), float32, [m, n], [stride_2: int32, stride_3: int32], type="auto"),
             A: Buffer(A_2: Pointer(float32), float32, [m, n], [stride_4: int32, stride_5: int32], type="auto")}
  buffer_map = {A_1: A, B_1: B, C_1: C} {
  for (i: int32, 0, m) {
    for (j: int32, 0, n) {
      C_2[((i*stride) + (j*stride_1))] = ((float32*)A_2[((i*stride_4) + (j*stride_5))]*(float32*)B_2[((i*stride_2) + (j*stride_3))])
    }
  }
}

#[metadata]
{
  "root": 1,
  "nodes": [
    {
      "type_key": ""
    },
    {
      "type_key": "Map",
      "keys": [
        "IntImm"
      ],
      "data": [2]
    },
    {
      "type_key": "Array",
      "data": [3]
    },
    {
      "type_key": "IntImm",
      "attrs": {
        "dtype": "bool",
        "value": "1"
      }
    }
  ],
  "b64ndarrays": [],
  "attrs": {"tvm_version": "0.8.dev0"}
}
```

I found this very annoying.  Why do we print it? Can we disable it for this use case by default?
cc @tqchen @spectrometerHBH @jroesch @junrushao1994 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `python/tvm/ir/module.py`
Content:
```
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements.  See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership.  The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License.  You may obtain a copy of the License at
8 #
9 #   http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied.  See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17 """IRModule that holds the functions and type definitions."""
18 from tvm._ffi.base import string_types
19 import tvm._ffi
20 
21 from .base import Node
22 from . import expr as _expr
23 from . import type as _ty
24 from . import _ffi_api
25 
26 
27 @tvm._ffi.register_object("IRModule")
28 class IRModule(Node):
29     """IRModule that holds functions and type definitions.
30 
31     IRModule is the basic unit for all IR transformations across the stack.
32 
33     Parameters
34     ----------
35     functions: Optional[dict].
36         Map of global var to BaseFunc
37     """
38 
39     def __init__(self, functions=None, type_definitions=None):
40         if functions is None:
41             functions = {}
42         elif isinstance(functions, dict):
43             mapped_funcs = {}
44             for k, v in functions.items():
45                 if isinstance(k, string_types):
46                     k = _expr.GlobalVar(k)
47                 if not isinstance(k, _expr.GlobalVar):
48                     raise TypeError("Expect functions to be Dict[GlobalVar, Function]")
49                 mapped_funcs[k] = v
50             functions = mapped_funcs
51         if type_definitions is None:
52             type_definitions = {}
53         elif isinstance(type_definitions, dict):
54             mapped_type_defs = {}
55             for k, v in type_definitions.items():
56                 if isinstance(k, string_types):
57                     k = _ty.GlobalTypeVar(k)
58                 if not isinstance(k, _ty.GlobalTypeVar):
59                     raise TypeError("Expect type_definitions to be Dict[GlobalTypeVar, Type]")
60                 mapped_type_defs[k] = v
61             type_definitions = mapped_type_defs
62         self.__init_handle_by_constructor__(_ffi_api.IRModule, functions, type_definitions)
63 
64     def __setitem__(self, var, val):
65         """Add a mapping to the module.
66 
67         Parameters
68         ---------
69         var: GlobalVar
70             The global variable.
71 
72         val: Union[Function, Type]
73             The value.
74         """
75         return self._add(var, val, True)
76 
77     def _add(self, var, val, update=True):
78         if isinstance(val, _expr.RelayExpr):
79             if isinstance(var, string_types):
80                 if _ffi_api.Module_ContainGlobalVar(self, var):
81                     var = _ffi_api.Module_GetGlobalVar(self, var)
82                 else:
83                     var = _expr.GlobalVar(var)
84             _ffi_api.Module_Add(self, var, val, update)
85         else:
86             assert isinstance(val, _ty.Type)
87             if isinstance(var, string_types):
88                 var = _ty.GlobalTypeVar(var)
89             _ffi_api.Module_AddDef(self, var, val, update)
90 
91     def __getitem__(self, var):
92         """Lookup a global definition by name or by variable.
93 
94         Parameters
95         ----------
96         var: Union[String, GlobalVar, GlobalTypeVar]
97             The name or global variable.
98 
99         Returns
100         -------
101         val: Union[Function, Type]
102             The definition referenced by :code:`var` (either a function or type).
103         """
104         if isinstance(var, string_types):
105             return _ffi_api.Module_Lookup_str(self, var)
106         if isinstance(var, _expr.GlobalVar):
107             return _ffi_api.Module_Lookup(self, var)
108         return _ffi_api.Module_LookupDef(self, var)
109 
110     def update(self, other):
111         """Insert functions in another Module to current one.
112 
113         Parameters
114         ----------
115         other: IRModule
116             The module to merge into the current Module.
117         """
118         if isinstance(other, dict):
119             other = IRModule(other)
120 
121         return _ffi_api.Module_Update(self, other)
122 
123     def update_func(self, var, func):
124         """Update the function corresponding to a global variable in the
125         module.
126 
127         Parameters
128         ----------
129         var: GlobalVar
130             The global variable.
131 
132         func: tvm.relay.Function
133             The function to be inserted.
134         """
135         return _ffi_api.Module_UpdateFunction(self, var, func)
136 
137     def get_global_var(self, name):
138         """Get a global variable in the function by name.
139 
140         Parameters
141         ----------
142         name: str
143             The name of the global variable.
144 
145         Returns
146         -------
147         global_var: GlobalVar
148             The global variable mapped to :code:`name`.
149 
150         Raises
151         ------
152         tvm.error.TVMError if we cannot find corresponding global var.
153         """
154         return _ffi_api.Module_GetGlobalVar(self, name)
155 
156     def get_global_vars(self):
157         """Collect all global vars defined in this module.
158 
159         Returns
160         -------
161         global_vars: Array[GlobalVar]
162             An array of global vars.
163         """
164         return _ffi_api.Module_GetGlobalVars(self)
165 
166     def get_global_type_vars(self):
167         """Collect all global type vars defined in this module.
168 
169         Returns
170         -------
171         global_type_vars: Array[GlobalTypeVar]
172             An array of global type vars.
173         """
174         return _ffi_api.Module_GetGlobalTypeVars(self)
175 
176     def get_global_type_var(self, name):
177         """Get a global type variable in the function by name.
178 
179         Parameters
180         ----------
181         name: str
182             The name of the global type variable.
183 
184         Returns
185         -------
186         global_type_var: GlobalTypeVar
187             The global variable mapped to :code:`name`.
188 
189         Raises
190         ------
191         tvm.error.TVMError if we cannot find corresponding global type var.
192         """
193         return _ffi_api.Module_GetGlobalTypeVar(self, name)
194 
195     def get_constructor(self, tag):
196         """Look up an ADT constructor by tag.
197 
198         Parameters
199         ----------
200         tag: int
201             The tag for a constructor.
202 
203         Returns
204         -------
205         constructor: Constructor
206            The constructor associated with the given tag,
207 
208         Raises
209         ------
210         tvm.error.TVMError if the corresponding constructor cannot be found.
211         """
212         return _ffi_api.Module_LookupTag(self, tag)
213 
214     def get_type(self, name):
215         ty_var = self.get_global_type_var(name)
216         ty_data = self.type_definitions[ty_var]
217         return tuple([ty_var] + list(ty_data.constructors))
218 
219     @staticmethod
220     def from_expr(expr, functions=None, type_defs=None):
221         """Construct a module from a standalone expression.
222 
223         Parameters
224         ----------
225         expr: RelayExpr
226             The starting expression
227 
228         global_funcs: Optional[dict]
229             Map of global vars to function definitions
230 
231         type_defs: Optional[dict]
232             Map of global type vars to type definitions
233 
234         Returns
235         -------
236         mod: Module
237             A module containing the passed definitions,
238             where expr is set as the entry point
239             (wrapped in a function if necessary)
240         """
241         funcs = functions if functions is not None else {}
242         defs = type_defs if type_defs is not None else {}
243         return _ffi_api.Module_FromExpr(expr, funcs, defs)
244 
245     def _import(self, file_to_import):
246         return _ffi_api.Module_Import(self, file_to_import)
247 
248     def import_from_std(self, file_to_import):
249         # TODO(@jroesch): clean up prelude
250         _ffi_api.Module_ImportFromStd(self, file_to_import)
251         return tvm.relay.transform.InferType()(self)
252 
253     def __str__(self):
254         # TODO(jroesch): why does this hang sometimes?
255         return self.astext()
256 
257     def __repr__(self):
258         return self.astext()
259
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/python/tvm/ir/module.py b/python/tvm/ir/module.py
--- a/python/tvm/ir/module.py
+++ b/python/tvm/ir/module.py
@@ -251,8 +251,7 @@
         return tvm.relay.transform.InferType()(self)
 
     def __str__(self):
-        # TODO(jroesch): why does this hang sometimes?
-        return self.astext()
+        return _ffi_api.PrettyPrint(self)
 
     def __repr__(self):
         return self.astext()

{"golden_diff": "diff --git a/python/tvm/ir/module.py b/python/tvm/ir/module.py\n--- a/python/tvm/ir/module.py\n+++ b/python/tvm/ir/module.py\n@@ -251,8 +251,7 @@\n         return tvm.relay.transform.InferType()(self)\n \n     def __str__(self):\n-        # TODO(jroesch): why does this hang sometimes?\n-        return self.astext()\n+        return _ffi_api.PrettyPrint(self)\n \n     def __repr__(self):\n         return self.astext()\n", "issue": "Do not show meta data when printing TIR\nRecently I found TVM will print meta when I do \r\n```python\r\nprint(tvm.lower(s, [A, B, C], simple_mode=True))\r\n```\r\n\r\nHere is an example output in the tutorial website (https://tvm.apache.org/docs/tutorials/language/schedule_primitives.html)\r\n```\r\n#[version = \"0.0.5\"]\r\nprimfn(A_1: handle, B_1: handle, C_1: handle) -> ()\r\n  attr = {\"global_symbol\": \"main\", \"tir.noalias\": True}\r\n  buffers = {C: Buffer(C_2: Pointer(float32), float32, [m: int32, n: int32], [stride: int32, stride_1: int32], type=\"auto\"),\r\n             B: Buffer(B_2: Pointer(float32), float32, [m, n], [stride_2: int32, stride_3: int32], type=\"auto\"),\r\n             A: Buffer(A_2: Pointer(float32), float32, [m, n], [stride_4: int32, stride_5: int32], type=\"auto\")}\r\n  buffer_map = {A_1: A, B_1: B, C_1: C} {\r\n  for (i: int32, 0, m) {\r\n    for (j: int32, 0, n) {\r\n      C_2[((i*stride) + (j*stride_1))] = ((float32*)A_2[((i*stride_4) + (j*stride_5))]*(float32*)B_2[((i*stride_2) + (j*stride_3))])\r\n    }\r\n  }\r\n}\r\n\r\n#[metadata]\r\n{\r\n  \"root\": 1,\r\n  \"nodes\": [\r\n    {\r\n      \"type_key\": \"\"\r\n    },\r\n    {\r\n      \"type_key\": \"Map\",\r\n      \"keys\": [\r\n        \"IntImm\"\r\n      ],\r\n      \"data\": [2]\r\n    },\r\n    {\r\n      \"type_key\": \"Array\",\r\n      \"data\": [3]\r\n    },\r\n    {\r\n      \"type_key\": \"IntImm\",\r\n      \"attrs\": {\r\n        \"dtype\": \"bool\",\r\n        \"value\": \"1\"\r\n      }\r\n    }\r\n  ],\r\n  \"b64ndarrays\": [],\r\n  \"attrs\": {\"tvm_version\": \"0.8.dev0\"}\r\n}\r\n```\r\n\r\nI found this very annoying.  Why do we print it? Can we disable it for this use case by default?\r\ncc @tqchen @spectrometerHBH @jroesch @junrushao1994 \n", "before_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\"\"\"IRModule that holds the functions and type definitions.\"\"\"\nfrom tvm._ffi.base import string_types\nimport tvm._ffi\n\nfrom .base import Node\nfrom . import expr as _expr\nfrom . import type as _ty\nfrom . import _ffi_api\n\n\n@tvm._ffi.register_object(\"IRModule\")\nclass IRModule(Node):\n    \"\"\"IRModule that holds functions and type definitions.\n\n    IRModule is the basic unit for all IR transformations across the stack.\n\n    Parameters\n    ----------\n    functions: Optional[dict].\n        Map of global var to BaseFunc\n    \"\"\"\n\n    def __init__(self, functions=None, type_definitions=None):\n        if functions is None:\n            functions = {}\n        elif isinstance(functions, dict):\n            mapped_funcs = {}\n            for k, v in functions.items():\n                if isinstance(k, string_types):\n                    k = _expr.GlobalVar(k)\n                if not isinstance(k, _expr.GlobalVar):\n                    raise TypeError(\"Expect functions to be Dict[GlobalVar, Function]\")\n                mapped_funcs[k] = v\n            functions = mapped_funcs\n        if type_definitions is None:\n            type_definitions = {}\n        elif isinstance(type_definitions, dict):\n            mapped_type_defs = {}\n            for k, v in type_definitions.items():\n                if isinstance(k, string_types):\n                    k = _ty.GlobalTypeVar(k)\n                if not isinstance(k, _ty.GlobalTypeVar):\n                    raise TypeError(\"Expect type_definitions to be Dict[GlobalTypeVar, Type]\")\n                mapped_type_defs[k] = v\n            type_definitions = mapped_type_defs\n        self.__init_handle_by_constructor__(_ffi_api.IRModule, functions, type_definitions)\n\n    def __setitem__(self, var, val):\n        \"\"\"Add a mapping to the module.\n\n        Parameters\n        ---------\n        var: GlobalVar\n            The global variable.\n\n        val: Union[Function, Type]\n            The value.\n        \"\"\"\n        return self._add(var, val, True)\n\n    def _add(self, var, val, update=True):\n        if isinstance(val, _expr.RelayExpr):\n            if isinstance(var, string_types):\n                if _ffi_api.Module_ContainGlobalVar(self, var):\n                    var = _ffi_api.Module_GetGlobalVar(self, var)\n                else:\n                    var = _expr.GlobalVar(var)\n            _ffi_api.Module_Add(self, var, val, update)\n        else:\n            assert isinstance(val, _ty.Type)\n            if isinstance(var, string_types):\n                var = _ty.GlobalTypeVar(var)\n            _ffi_api.Module_AddDef(self, var, val, update)\n\n    def __getitem__(self, var):\n        \"\"\"Lookup a global definition by name or by variable.\n\n        Parameters\n        ----------\n        var: Union[String, GlobalVar, GlobalTypeVar]\n            The name or global variable.\n\n        Returns\n        -------\n        val: Union[Function, Type]\n            The definition referenced by :code:`var` (either a function or type).\n        \"\"\"\n        if isinstance(var, string_types):\n            return _ffi_api.Module_Lookup_str(self, var)\n        if isinstance(var, _expr.GlobalVar):\n            return _ffi_api.Module_Lookup(self, var)\n        return _ffi_api.Module_LookupDef(self, var)\n\n    def update(self, other):\n        \"\"\"Insert functions in another Module to current one.\n\n        Parameters\n        ----------\n        other: IRModule\n            The module to merge into the current Module.\n        \"\"\"\n        if isinstance(other, dict):\n            other = IRModule(other)\n\n        return _ffi_api.Module_Update(self, other)\n\n    def update_func(self, var, func):\n        \"\"\"Update the function corresponding to a global variable in the\n        module.\n\n        Parameters\n        ----------\n        var: GlobalVar\n            The global variable.\n\n        func: tvm.relay.Function\n            The function to be inserted.\n        \"\"\"\n        return _ffi_api.Module_UpdateFunction(self, var, func)\n\n    def get_global_var(self, name):\n        \"\"\"Get a global variable in the function by name.\n\n        Parameters\n        ----------\n        name: str\n            The name of the global variable.\n\n        Returns\n        -------\n        global_var: GlobalVar\n            The global variable mapped to :code:`name`.\n\n        Raises\n        ------\n        tvm.error.TVMError if we cannot find corresponding global var.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalVar(self, name)\n\n    def get_global_vars(self):\n        \"\"\"Collect all global vars defined in this module.\n\n        Returns\n        -------\n        global_vars: Array[GlobalVar]\n            An array of global vars.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalVars(self)\n\n    def get_global_type_vars(self):\n        \"\"\"Collect all global type vars defined in this module.\n\n        Returns\n        -------\n        global_type_vars: Array[GlobalTypeVar]\n            An array of global type vars.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalTypeVars(self)\n\n    def get_global_type_var(self, name):\n        \"\"\"Get a global type variable in the function by name.\n\n        Parameters\n        ----------\n        name: str\n            The name of the global type variable.\n\n        Returns\n        -------\n        global_type_var: GlobalTypeVar\n            The global variable mapped to :code:`name`.\n\n        Raises\n        ------\n        tvm.error.TVMError if we cannot find corresponding global type var.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalTypeVar(self, name)\n\n    def get_constructor(self, tag):\n        \"\"\"Look up an ADT constructor by tag.\n\n        Parameters\n        ----------\n        tag: int\n            The tag for a constructor.\n\n        Returns\n        -------\n        constructor: Constructor\n           The constructor associated with the given tag,\n\n        Raises\n        ------\n        tvm.error.TVMError if the corresponding constructor cannot be found.\n        \"\"\"\n        return _ffi_api.Module_LookupTag(self, tag)\n\n    def get_type(self, name):\n        ty_var = self.get_global_type_var(name)\n        ty_data = self.type_definitions[ty_var]\n        return tuple([ty_var] + list(ty_data.constructors))\n\n    @staticmethod\n    def from_expr(expr, functions=None, type_defs=None):\n        \"\"\"Construct a module from a standalone expression.\n\n        Parameters\n        ----------\n        expr: RelayExpr\n            The starting expression\n\n        global_funcs: Optional[dict]\n            Map of global vars to function definitions\n\n        type_defs: Optional[dict]\n            Map of global type vars to type definitions\n\n        Returns\n        -------\n        mod: Module\n            A module containing the passed definitions,\n            where expr is set as the entry point\n            (wrapped in a function if necessary)\n        \"\"\"\n        funcs = functions if functions is not None else {}\n        defs = type_defs if type_defs is not None else {}\n        return _ffi_api.Module_FromExpr(expr, funcs, defs)\n\n    def _import(self, file_to_import):\n        return _ffi_api.Module_Import(self, file_to_import)\n\n    def import_from_std(self, file_to_import):\n        # TODO(@jroesch): clean up prelude\n        _ffi_api.Module_ImportFromStd(self, file_to_import)\n        return tvm.relay.transform.InferType()(self)\n\n    def __str__(self):\n        # TODO(jroesch): why does this hang sometimes?\n        return self.astext()\n\n    def __repr__(self):\n        return self.astext()\n", "path": "python/tvm/ir/module.py"}], "after_files": [{"content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\"\"\"IRModule that holds the functions and type definitions.\"\"\"\nfrom tvm._ffi.base import string_types\nimport tvm._ffi\n\nfrom .base import Node\nfrom . import expr as _expr\nfrom . import type as _ty\nfrom . import _ffi_api\n\n\n@tvm._ffi.register_object(\"IRModule\")\nclass IRModule(Node):\n    \"\"\"IRModule that holds functions and type definitions.\n\n    IRModule is the basic unit for all IR transformations across the stack.\n\n    Parameters\n    ----------\n    functions: Optional[dict].\n        Map of global var to BaseFunc\n    \"\"\"\n\n    def __init__(self, functions=None, type_definitions=None):\n        if functions is None:\n            functions = {}\n        elif isinstance(functions, dict):\n            mapped_funcs = {}\n            for k, v in functions.items():\n                if isinstance(k, string_types):\n                    k = _expr.GlobalVar(k)\n                if not isinstance(k, _expr.GlobalVar):\n                    raise TypeError(\"Expect functions to be Dict[GlobalVar, Function]\")\n                mapped_funcs[k] = v\n            functions = mapped_funcs\n        if type_definitions is None:\n            type_definitions = {}\n        elif isinstance(type_definitions, dict):\n            mapped_type_defs = {}\n            for k, v in type_definitions.items():\n                if isinstance(k, string_types):\n                    k = _ty.GlobalTypeVar(k)\n                if not isinstance(k, _ty.GlobalTypeVar):\n                    raise TypeError(\"Expect type_definitions to be Dict[GlobalTypeVar, Type]\")\n                mapped_type_defs[k] = v\n            type_definitions = mapped_type_defs\n        self.__init_handle_by_constructor__(_ffi_api.IRModule, functions, type_definitions)\n\n    def __setitem__(self, var, val):\n        \"\"\"Add a mapping to the module.\n\n        Parameters\n        ---------\n        var: GlobalVar\n            The global variable.\n\n        val: Union[Function, Type]\n            The value.\n        \"\"\"\n        return self._add(var, val, True)\n\n    def _add(self, var, val, update=True):\n        if isinstance(val, _expr.RelayExpr):\n            if isinstance(var, string_types):\n                if _ffi_api.Module_ContainGlobalVar(self, var):\n                    var = _ffi_api.Module_GetGlobalVar(self, var)\n                else:\n                    var = _expr.GlobalVar(var)\n            _ffi_api.Module_Add(self, var, val, update)\n        else:\n            assert isinstance(val, _ty.Type)\n            if isinstance(var, string_types):\n                var = _ty.GlobalTypeVar(var)\n            _ffi_api.Module_AddDef(self, var, val, update)\n\n    def __getitem__(self, var):\n        \"\"\"Lookup a global definition by name or by variable.\n\n        Parameters\n        ----------\n        var: Union[String, GlobalVar, GlobalTypeVar]\n            The name or global variable.\n\n        Returns\n        -------\n        val: Union[Function, Type]\n            The definition referenced by :code:`var` (either a function or type).\n        \"\"\"\n        if isinstance(var, string_types):\n            return _ffi_api.Module_Lookup_str(self, var)\n        if isinstance(var, _expr.GlobalVar):\n            return _ffi_api.Module_Lookup(self, var)\n        return _ffi_api.Module_LookupDef(self, var)\n\n    def update(self, other):\n        \"\"\"Insert functions in another Module to current one.\n\n        Parameters\n        ----------\n        other: IRModule\n            The module to merge into the current Module.\n        \"\"\"\n        if isinstance(other, dict):\n            other = IRModule(other)\n\n        return _ffi_api.Module_Update(self, other)\n\n    def update_func(self, var, func):\n        \"\"\"Update the function corresponding to a global variable in the\n        module.\n\n        Parameters\n        ----------\n        var: GlobalVar\n            The global variable.\n\n        func: tvm.relay.Function\n            The function to be inserted.\n        \"\"\"\n        return _ffi_api.Module_UpdateFunction(self, var, func)\n\n    def get_global_var(self, name):\n        \"\"\"Get a global variable in the function by name.\n\n        Parameters\n        ----------\n        name: str\n            The name of the global variable.\n\n        Returns\n        -------\n        global_var: GlobalVar\n            The global variable mapped to :code:`name`.\n\n        Raises\n        ------\n        tvm.error.TVMError if we cannot find corresponding global var.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalVar(self, name)\n\n    def get_global_vars(self):\n        \"\"\"Collect all global vars defined in this module.\n\n        Returns\n        -------\n        global_vars: Array[GlobalVar]\n            An array of global vars.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalVars(self)\n\n    def get_global_type_vars(self):\n        \"\"\"Collect all global type vars defined in this module.\n\n        Returns\n        -------\n        global_type_vars: Array[GlobalTypeVar]\n            An array of global type vars.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalTypeVars(self)\n\n    def get_global_type_var(self, name):\n        \"\"\"Get a global type variable in the function by name.\n\n        Parameters\n        ----------\n        name: str\n            The name of the global type variable.\n\n        Returns\n        -------\n        global_type_var: GlobalTypeVar\n            The global variable mapped to :code:`name`.\n\n        Raises\n        ------\n        tvm.error.TVMError if we cannot find corresponding global type var.\n        \"\"\"\n        return _ffi_api.Module_GetGlobalTypeVar(self, name)\n\n    def get_constructor(self, tag):\n        \"\"\"Look up an ADT constructor by tag.\n\n        Parameters\n        ----------\n        tag: int\n            The tag for a constructor.\n\n        Returns\n        -------\n        constructor: Constructor\n           The constructor associated with the given tag,\n\n        Raises\n        ------\n        tvm.error.TVMError if the corresponding constructor cannot be found.\n        \"\"\"\n        return _ffi_api.Module_LookupTag(self, tag)\n\n    def get_type(self, name):\n        ty_var = self.get_global_type_var(name)\n        ty_data = self.type_definitions[ty_var]\n        return tuple([ty_var] + list(ty_data.constructors))\n\n    @staticmethod\n    def from_expr(expr, functions=None, type_defs=None):\n        \"\"\"Construct a module from a standalone expression.\n\n        Parameters\n        ----------\n        expr: RelayExpr\n            The starting expression\n\n        global_funcs: Optional[dict]\n            Map of global vars to function definitions\n\n        type_defs: Optional[dict]\n            Map of global type vars to type definitions\n\n        Returns\n        -------\n        mod: Module\n            A module containing the passed definitions,\n            where expr is set as the entry point\n            (wrapped in a function if necessary)\n        \"\"\"\n        funcs = functions if functions is not None else {}\n        defs = type_defs if type_defs is not None else {}\n        return _ffi_api.Module_FromExpr(expr, funcs, defs)\n\n    def _import(self, file_to_import):\n        return _ffi_api.Module_Import(self, file_to_import)\n\n    def import_from_std(self, file_to_import):\n        # TODO(@jroesch): clean up prelude\n        _ffi_api.Module_ImportFromStd(self, file_to_import)\n        return tvm.relay.transform.InferType()(self)\n\n    def __str__(self):\n        return _ffi_api.PrettyPrint(self)\n\n    def __repr__(self):\n        return self.astext()\n", "path": "python/tvm/ir/module.py"}]}