MCPcopy Index your code
hub / github.com/apache/tvm / parse

Function parse

python/tvm/script/parser/core/doc.py:185–225  ·  view source on GitHub ↗

Parse TVMScript source code str to doc AST. Its interface is consistent with python built-in ast.parse. And it will parse by python 3.8 first if possible, or it will parse with python version in current environment. Parameters ---------- source : str The TVMScript s

(
    source: str,
    filename: str = "<unknown>",
    mode: str = "exec",
)

Source from the content-addressed store, hash-verified

183
184
185def parse(
186 source: str,
187 filename: str = "<unknown>",
188 mode: str = "exec",
189) -> doc.AST:
190 """Parse TVMScript source code str to doc AST.
191
192 Its interface is consistent with python built-in ast.parse.
193 And it will parse by python 3.8 first if possible,
194 or it will parse with python version in current environment.
195
196 Parameters
197 ----------
198 source : str
199 The TVMScript source code.
200
201 filename : str
202 The optional filename of the file where source code locates.
203
204 mode : str
205 The parsing mode for ast.parse.
206
207 Returns
208 -------
209 res : doc.AST
210 The parsed doc AST.
211 """
212 try:
213 program = ast.parse( # pylint: disable=unexpected-keyword-arg
214 source=source,
215 filename=filename,
216 mode=mode,
217 feature_version=(3, 8),
218 )
219 except: # pylint: disable=bare-except
220 program = ast.parse(
221 source=source,
222 filename=filename,
223 mode=mode,
224 )
225 return to_doc(program)
226
227
228class NodeVisitor:

Callers 2

decorator_wrapperFunction · 0.90
decorator_wrapperFunction · 0.50

Calls 2

to_docFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…