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

Function to_python_script

python/tvm/script/printer/doc_printer.py:27–60  ·  view source on GitHub ↗

Convert Doc into Python script. Parameters ---------- doc : Doc The doc to convert into Python script indent_spaces : int The number of indent spaces to use in the output print_line_numbers: bool Whether to print line numbers num_context_lines : Optio

(
    doc: Doc,
    indent_spaces: int = 4,
    print_line_numbers: bool = False,
    num_context_lines: int | None = None,
    path_to_underline: list[AccessPath] | None = None,
)

Source from the content-addressed store, hash-verified

25
26
27def to_python_script(
28 doc: Doc,
29 indent_spaces: int = 4,
30 print_line_numbers: bool = False,
31 num_context_lines: int | None = None,
32 path_to_underline: list[AccessPath] | None = None,
33) -> str:
34 """Convert Doc into Python script.
35
36 Parameters
37 ----------
38 doc : Doc
39 The doc to convert into Python script
40 indent_spaces : int
41 The number of indent spaces to use in the output
42 print_line_numbers: bool
43 Whether to print line numbers
44 num_context_lines : Optional[int]
45 Number of context lines to print around the underlined text
46 path_to_underline : Optional[AccessPath]
47 Object path to be underlined
48
49 Returns
50 -------
51 script : str
52 The text representation of Doc in Python syntax
53 """
54 cfg = PrinterConfig(
55 indent_spaces=indent_spaces,
56 print_line_numbers=print_line_numbers,
57 num_context_lines=num_context_lines,
58 path_to_underline=path_to_underline,
59 )
60 return _ffi_api.DocToPythonScript(doc, cfg) # type: ignore # pylint: disable=no-member

Callers 15

test_print_literal_docFunction · 0.90
test_print_id_docFunction · 0.90
test_print_attr_docFunction · 0.90
test_print_index_docFunction · 0.90
test_print_call_docFunction · 0.90
test_print_lambda_docFunction · 0.90
test_print_list_docFunction · 0.90
test_print_tuple_docFunction · 0.90
test_print_dict_docFunction · 0.90

Calls 1

PrinterConfigClass · 0.90

Tested by 15

test_print_literal_docFunction · 0.72
test_print_id_docFunction · 0.72
test_print_attr_docFunction · 0.72
test_print_index_docFunction · 0.72
test_print_call_docFunction · 0.72
test_print_lambda_docFunction · 0.72
test_print_list_docFunction · 0.72
test_print_tuple_docFunction · 0.72
test_print_dict_docFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…