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

Function _Workspace_feed_blob

caffe2/python/workspace.py:706–729  ·  view source on GitHub ↗
(ws, name, arr, device_option=None)

Source from the content-addressed store, hash-verified

704
705
706def _Workspace_feed_blob(ws, name, arr, device_option=None):
707 if type(arr) is caffe2_pb2.TensorProto:
708 arr = utils.Caffe2TensorToNumpyArray(arr)
709 if type(arr) is np.ndarray and arr.dtype.kind in 'SU':
710 # Plain NumPy strings are weird, let's use objects instead
711 arr = arr.astype(object)
712
713 if device_option is None:
714 device_option = scope.CurrentDeviceScope()
715
716 if device_option and device_option.device_type == caffe2_pb2.CUDA:
717 if arr.dtype == np.dtype('float64'):
718 logger.warning(
719 "CUDA operators do not support 64-bit doubles, " +
720 "please use arr.astype(np.float32) or np.int32 for ints." +
721 " Blob: {}".format(name) +
722 " type: {}".format(str(arr.dtype))
723 )
724
725 name = StringifyBlobName(name)
726 if device_option is not None:
727 return ws.create_blob(name).feed(arr, device_option)
728 else:
729 return ws.create_blob(name).feed(arr)
730
731
732def _Workspace_remove_blob(ws, blob):

Callers 1

FeedBlobFunction · 0.85

Calls 5

StringifyBlobNameFunction · 0.85
astypeMethod · 0.80
warningMethod · 0.80
dtypeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…