public static void ThrowIfDifferentDevices(params Tensor[] tensors) { var nonNull = tensors.Where(x => x != null); if (!nonNull.Any()) { return; } var device = CudaHelpers.GetDeviceId(nonNull.First()); if (nonNull.Any(x => CudaHelpers.GetDeviceId(x) != device)) { throw new InvalidOperationException("All tensors must reside on the same device"); } }
public CudaContext CudaContextForTensor(Tensor tensor) { return(CudaContextForDevice(CudaHelpers.GetDeviceId(tensor))); }
public PooledObject <CudaBlas> BlasForTensor(Tensor tensor) { return(BlasForDevice(CudaHelpers.GetDeviceId(tensor))); }
/// <summary> /// DNNs for tensor. /// </summary> /// <param name="tensor">The tensor.</param> /// <returns>PooledObject<ManagedCuda.CudaDNN.CudaDNNContext>.</returns> public PooledObject <ManagedCuda.CudaDNN.CudaDNNContext> DNNForTensor(NDArray tensor) { var deviceId = CudaHelpers.GetDeviceId(tensor); return(devices[deviceId].DnnHandles.Get()); }