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

Method _CreateAndAddToNet

caffe2/python/core.py:270–279  ·  view source on GitHub ↗

Internal function that routes the operator generation to the network's __getattr__ function.

(self, op_type, inputs=None, *args, **kwargs)

Source from the content-addressed store, hash-verified

268 return self._name[self._name.rfind(scope._NAMESCOPE_SEPARATOR) + 1:]
269
270 def _CreateAndAddToNet(self, op_type, inputs=None, *args, **kwargs):
271 """Internal function that routes the operator generation to the
272 network's __getattr__ function.
273 """
274 inputs = [] if inputs is None else inputs
275 if isinstance(inputs, BlobReference) or isinstance(inputs, str):
276 inputs = [inputs]
277 # add self to the input list.
278 inputs.insert(0, self)
279 return self._from_net.__getattr__(op_type)(inputs, *args, **kwargs)
280
281 def __getattr__(self, op_type):
282 """A wrapper allowing one to initiate operators from a blob reference.

Callers 1

__getattr__Method · 0.95

Calls 3

isinstanceFunction · 0.85
insertMethod · 0.45
__getattr__Method · 0.45

Tested by

no test coverage detected