| 704 | |
| 705 | |
| 706 | def _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 | |
| 732 | def _Workspace_remove_blob(ws, blob): |