3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
6 from __future__
import unicode_literals
18 def upload(self, content_body):
23 def addHeader(self, text, h=1):
24 self.
addLine(
"\n{header} {text}\n".format(header=h *
'#', text=text),
True)
26 def addDocHeader(self):
28 self.
addLine(
"docid: operators-catalog")
29 self.
addLine(
"title: Operators Catalog")
30 self.
addLine(
"layout: operators")
31 self.
addLine(
"permalink: /docs/operators-catalogue.html")
36 def addTable(self, table, noTitle=False):
38 assert(len(table) > 1)
39 self.
addLine(
' | '.join([
'----------' for i
in range(len(table[0]))]))
40 self.
addLine(
' | '.join(table[0]))
44 def addTableHTML(self, table, noTitle=False):
50 self.
addLine(
"{cell}".format(cell=cell))
55 def getCodeLink(formatter, schema):
56 formatter = formatter.clone()
57 path = os.path.relpath(schema.file,
"caffe2")
58 schemaLink = (
'https://github.com/pytorch/pytorch/blob/master/{path}' 60 formatter.addLink(
'{path}'.format(path=path), schemaLink)
61 return formatter.dump()
65 def generateDoc(self, formatter):
67 formatter.addCode(
'{engine}'.format(engine=self.
engine),
True)
69 formatter.addRaw(
' on ')
70 formatter.addEmphasis(
"{device}".format(device=device), 1)
74 def generateCodeLink(self, formatter):
75 formatter.addHeader(
"Code", 3)
76 formatter.addLinebreak()
77 formatter.addRaw(getCodeLink(formatter, self.
schema))
79 def getInfo(self, formatter, name, impl):
80 formatter = formatter.clone()
82 formatter.addEmphasis(
'{name}'.format(name=name), 1)
84 formatter.addCode(
'{impl}'.format(impl=impl),
True)
85 return formatter.dump()
87 def generateSchema(self, formatter):
88 formatter.addHeader(self.
name, 2)
95 formatter.addLine(
"No schema documented yet.")
99 def getOperatorDoc(self, name, schema, priority):
102 def getOperatorEngine(self, name):
105 def createBody(self):
106 self.formatter.addDocHeader()
109 for operator
in operators:
115 if __name__ ==
"__main__":
116 parser = argparse.ArgumentParser(description=
"Operators catalog generator.")
117 parser.add_argument(
'catalog_path', type=str,
118 help=
'operators-catalogue.md to write out to')
119 args = parser.parse_args()
121 with open(args.catalog_path,
'w')
as fp:
124 fp.write(ops.content_body)
125 print(
"Updated {}!".format(args.catalog_path))
def generateDoc(self, formatter)
def generateCodeLink(self, formatter)
def generateInterface(self, formatter)