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

Method getOperators

caffe2/python/docs/generator.py:43–86  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

41 return OperatorEngine(name)
42
43 def getOperators(self):
44 # map: op_name -> operator
45 self.operators = {}
46 # map: op_name -> [engine, engine]
47 self.engines = {}
48
49 def filePriority(x):
50 if x == "caffe2/caffe2/operators":
51 return 0
52 if 'contrib' in x.split('/'):
53 return 2
54 if 'experiments' in x.split('/'):
55 return 3
56 return 1
57
58 for name in core._GetRegisteredOperators():
59 schema = OpSchema.get(name)
60 if schema:
61 priority = filePriority(os.path.dirname(schema.file))
62 operator = self.getOperatorDoc(name, schema, priority)
63 self.operators[name] = operator
64
65 # Engine
66 elif name.find("_ENGINE_") != -1:
67 engine = self.getOperatorEngine(name)
68 if engine.base_op_name in self.engines:
69 self.engines[engine.base_op_name].append(engine)
70 else:
71 self.engines[engine.base_op_name] = [engine]
72
73 # No schema
74 else:
75 priority = 4
76 self.operators[name] = self.getOperatorDoc(name, schema, priority)
77
78 for name, engines in self.engines.items():
79 if name in self.operators:
80 self.operators[name].addEngines(engines)
81
82 # Generate a sorted list of operators
83 return sorted(
84 self.operators.values(),
85 key=lambda op: (op.priority, op.name)
86 )
87
88 def createBody(self):
89 operators = self.getOperators()

Callers 2

createBodyMethod · 0.95
createBodyMethod · 0.80

Calls 8

getOperatorDocMethod · 0.95
getOperatorEngineMethod · 0.95
addEnginesMethod · 0.80
getMethod · 0.45
findMethod · 0.45
appendMethod · 0.45
itemsMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected