MCPcopy Index your code
hub / github.com/pytorch/pytorch / _RectifyInputOutput

Function _RectifyInputOutput

caffe2/python/core.py:330–359  ·  view source on GitHub ↗

A helper function to rectify the input or output of the CreateOperator interface.

(blobs, net=None)

Source from the content-addressed store, hash-verified

328
329
330def _RectifyInputOutput(blobs, net=None):
331 """A helper function to rectify the input or output of the CreateOperator
332 interface.
333 """
334 if isinstance(blobs, (bytes, str)):
335 # If blobs is a single string, prepend scope.CurrentNameScope()
336 # and put it as a list.
337 # TODO(jiayq): enforce using BlobReference instead of raw strings.
338 return [ScopedBlobReference(blobs, net=net)]
339 elif type(blobs) is BlobReference:
340 # If blob is a BlobReference, simply put it as a list.
341 return [blobs]
342 elif type(blobs) in (list, tuple):
343 # If blob is a list, we go through it and type check.
344 rectified = []
345 for blob in blobs:
346 if isinstance(blob, (bytes, str)):
347 rectified.append(ScopedBlobReference(blob, net=net))
348 elif type(blob) is BlobReference:
349 rectified.append(blob)
350 else:
351 raise TypeError(
352 "I/O blob #{} of unsupported type: {} of type {}"
353 .format(len(rectified), str(blob), type(blob)))
354 return rectified
355 else:
356 raise TypeError(
357 "Unknown input/output type: %s of type %s." %
358 (str(blobs), type(blobs))
359 )
360
361
362def CreateOperator(

Callers 2

CreateOperatorFunction · 0.85
_CreateAndAddToSelfMethod · 0.85

Calls 4

isinstanceFunction · 0.85
ScopedBlobReferenceFunction · 0.85
appendMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…