MCPcopy Create free account
hub / github.com/NVIDIA/DALI / _get_inputs_doc

Function _get_inputs_doc

dali/python/nvidia/dali/ops/_docs.py:50–114  ·  view source on GitHub ↗

Generate numpydoc-formatted docstring section for operator inputs (positional arguments) based on the schema. The inputs are represented in `Args` section using `_numpydoc_formatter`. If schema provides names and docstrings for inputs, they are used, otherwise placeholder text

(schema, api)

Source from the content-addressed store, hash-verified

48
49
50def _get_inputs_doc(schema, api):
51 """
52 Generate numpydoc-formatted docstring section for operator inputs (positional arguments)
53 based on the schema.
54
55 The inputs are represented in `Args` section using `_numpydoc_formatter`.
56
57 If schema provides names and docstrings for inputs, they are used, otherwise placeholder
58 text is used indicating the supported number of inputs.
59
60 Note: The type of input is depends on API type (TensorList or Tensor/Batch) with supported
61 layouts listed. If the API is "dynamic", the type is Tensor/Batch.
62
63 schema : OpSchema
64 Schema of the operator to be documented
65 """
66 # Inputs section
67 if schema.MaxNumInput() == 0:
68 return ""
69 ret = """
70Args
71----
72"""
73 if schema.HasInputDox():
74 for i in range(schema.MaxNumInput()):
75 optional = i >= schema.MinNumInput()
76 input_type_str = schema.GetInputType(i) + _supported_layouts_str(
77 schema.GetSupportedLayouts(i)
78 )
79 dox = schema.GetInputDox(i)
80 input_name = _names._get_input_name(schema, i)
81 dox = _numpydoc_formatter(input_name, input_type_str, dox, optional)
82 dox = _adjust_dox(dox, api)
83 ret += dox + "\n"
84 else:
85 for i in range(schema.MinNumInput()):
86 input_type_str = _input_type(api) + _supported_layouts_str(
87 schema.GetSupportedLayouts(i)
88 )
89 dox = "Input to the operator."
90 input_name = _names._get_input_name(schema, i)
91 dox = _numpydoc_formatter(input_name, input_type_str, dox, False)
92 dox = _adjust_dox(dox, api)
93 ret += dox + "\n"
94
95 extra_opt_args = schema.MaxNumInput() - schema.MinNumInput()
96 if extra_opt_args == 1:
97 i = schema.MinNumInput()
98 input_type_str = _input_type(api) + _supported_layouts_str(
99 schema.GetSupportedLayouts(i)
100 )
101 dox = "Input to the operator."
102 dox = _adjust_dox(dox, api)
103 input_name = _names._get_input_name(schema, i)
104 ret += _numpydoc_formatter(input_name, input_type_str, dox, True) + "\n"
105 elif extra_opt_args > 1:
106 input_type_str = _input_type(api)
107 generic_name = _names._get_variadic_input_name()

Callers 2

_docstring_generator_fnFunction · 0.85

Calls 9

_supported_layouts_strFunction · 0.85
_numpydoc_formatterFunction · 0.85
_adjust_doxFunction · 0.85
_input_typeFunction · 0.85
MaxNumInputMethod · 0.80
HasInputDoxMethod · 0.80
MinNumInputMethod · 0.80
GetInputTypeMethod · 0.80
GetInputDoxMethod · 0.80

Tested by

no test coverage detected