def GetPhyBlobNumpy(i, phy_blob_object): name = "{}/{}".format(self.logical_blob_name, i) blob_register.SetObject4BlobName(name, phy_blob_object) return (oneflow_api.EagerPhysicalBlob( name, blob_register, eager_blob_util._GetPhysicalBlobHeaderCache).numpy_list() if self.is_tensor_list else oneflow_api.EagerPhysicalBlob( name, blob_register, eager_blob_util._GetPhysicalBlobHeaderCache).numpy())
def FetchBlobNumpy(blob_object): consistent_blob_name = None def BoxingToSingleDevice(builder): parallel_conf = placement_cfg.ParallelConf() parallel_conf.set_device_tag( blob_object.parallel_desc_symbol.device_tag) parallel_conf.add_device_name("{}:{}".format(0, 0)) tmp_parallel_desc_symbol = builder.GetParallelDescSymbol( parallel_conf) tmp_op_arg_parallel_attr = oneflow_api.OpArgParallelAttribute( tmp_parallel_desc_symbol, str(blob_object.op_arg_parallel_attr.sbp_parallel), str(blob_object.op_arg_parallel_attr.opt_mirrored_parallel), ) with oneflow.scope.placement( self.parallel_conf.device_tag(), list(self.parallel_conf.device_name()), ): tmp_blob_object = boxing_util.BoxingTo( builder, blob_object, tmp_op_arg_parallel_attr) nonlocal consistent_blob_name consistent_blob_name = "{}-consistent".format( self.logical_blob_name) if not blob_register.HasObject4BlobName(consistent_blob_name): blob_register.SetObject4BlobName(consistent_blob_name, tmp_blob_object) vm_util.LogicalRun(BoxingToSingleDevice) return oneflow_api.EagerPhysicalBlob( consistent_blob_name, blob_register, eager_blob_util._GetPhysicalBlobHeaderCache, ).numpy()