MCPcopy Create free account
hub / github.com/pytorch/pytorch / OperatorDoc

Class OperatorDoc

caffe2/python/docs/generator.py:119–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118
119class OperatorDoc:
120 def __init__(self, name, schema, priority):
121 self.name = name
122 self.schema = schema
123 self.priority = priority
124 print("Gathering docs for {}...".format(self.name))
125 self.engines = []
126
127 def addEngines(self, engines):
128 self.engines = engines
129
130 def generateDoc(self, formatter):
131 if self.schema.doc:
132 formatter.parseAndAdd(self.schema.doc)
133 formatter.addLinebreak()
134 else:
135 formatter.addLine("No documentation yet.")
136
137 def generateTable(self, formatter, tuples, title_row, title):
138 if tuples:
139 if title:
140 formatter.addHeader(title, 3)
141 table = []
142 if title_row:
143 table = [title_row]
144 for name, doc in tuples:
145 table.append([name, doc or ''])
146 formatter.addTable(table, (table == []))
147
148 def generateInterface(self, formatter):
149 def makeDesc(title, args):
150 f = formatter.clone()
151 f.addEmphasis(title, 1)
152 out = [(f.dump(), '')]
153 for arg in args:
154 f = formatter.clone()
155 if isinstance(arg, tuple):
156 name = arg[0]
157 if len(arg) > 1:
158 description = arg[1] or ''
159 else:
160 description = ''
161 else:
162 name = arg.name
163 description = arg.description or ''
164 f.addCode(name, inline=True)
165 out.append((f.dump(), description or ''))
166 return out
167
168 tuples = []
169
170 if self.schema.args:
171 tuples += makeDesc('Arguments', self.schema.args)
172
173 if self.schema.input_desc:
174 tuples += makeDesc('Inputs', self.schema.input_desc)
175
176 if self.schema.output_desc:

Callers 1

getOperatorDocMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…