internal Volume(float[] array, Shape shape) : base(new VolumeStorage(array, shape, GpuContext.Default)) { this._context = GpuContext.Default; this._volumeStorage = this.Storage as VolumeStorage; LoadKernels(); }
internal Volume(VolumeStorage storage) : base(storage) { this._context = storage.Context; this._volumeStorage = this.Storage as VolumeStorage; LoadKernels(); }
public Volume(float[] array, Shape shape, GpuContext context) : base(new VolumeStorage(array, shape, context)) { this._context = context; this._volumeStorage = this.Storage as VolumeStorage; LoadKernels(); }
public VolumeStorage(VolumeStorage storage, Shape newShape) : base(newShape) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } if (storage._hostPointer == null) { throw new ArgumentException(); } this._isOwner = false; this._hostPointer = storage._hostPointer; this.Shape = newShape; this.Context = storage.Context; this._allocatedOnDevice = storage._allocatedOnDevice; storage.CopyToDevice(); this.Location = DataLocation.Device; this.DeviceBuffer = new CudaDeviceVariable <float>(storage.DeviceBuffer.DevicePointer); this.ConvolutionBackwardFilterStorage = storage.ConvolutionBackwardFilterStorage; this.ConvolutionBackwardStorage = storage.ConvolutionBackwardStorage; this.ConvolutionStorage = storage.ConvolutionStorage; this.ReductionStorage = storage.ReductionStorage; this.DropoutStorage = storage.DropoutStorage; this.DropoutStateStorage = storage.DropoutStateStorage; }
public override Volume <float> SameAs(VolumeStorage <float> example, float value, Shape shape) { if (example is VolumeStorage gpuStorage) { return(new Volume(new VolumeStorage(new float[shape.TotalLength].Populate(value), shape, gpuStorage.Context))); } throw new NotImplementedException(); }
public override Volume <float> SameAs(VolumeStorage <float> example, Shape shape) { if (example is VolumeStorage gpuStorage) { return(new Volume(new VolumeStorage(shape, gpuStorage.Context))); } throw new NotImplementedException(); }
public override Volume <float> Build(VolumeStorage <float> storage, Shape shape) { if (storage is VolumeStorage gpuStorage) { return(new Volume(new VolumeStorage(gpuStorage, shape))); } throw new NotImplementedException(); }
public override Volume <float> SameAs(VolumeStorage <float> example, Shape shape) { var gpuStorage = example as VolumeStorage; if (gpuStorage != null) { return(new Volume(new VolumeStorage(shape, gpuStorage.Context))); } throw new NotImplementedException(); }
public override Volume <float> Build(VolumeStorage <float> storage, Shape shape) { var gpuStorage = storage as VolumeStorage; if (gpuStorage != null) { return(new Volume(new VolumeStorage(gpuStorage, shape))); } throw new NotImplementedException(); }
public VolumeStorage(VolumeStorage storage, Shape shape) : this(shape, storage.Context, storage.Shape.TotalLength) { // Ensure it is on host storage.CopyToHost(); // Fill host buffer for (var i = 0; i < this.Shape.TotalLength; i++) { this.HostBuffer[i] = storage.HostBuffer[i]; } }
public VolumeStorage(VolumeStorage storage, Shape newShape) : base(newShape) { this._isOwner = false; this._hostPointer = storage._hostPointer; this.Shape = newShape; this.HostBuffer = storage.HostBuffer; this.Context = storage.Context; storage.CopyToDevice(); this.Location = DataLocation.Device; this.DeviceBuffer = new CudaDeviceVariable <float>(storage.DeviceBuffer.DevicePointer); }
public VolumeStorage(VolumeStorage storage, Shape shape) : this(shape, storage.Context, storage.Shape.TotalLength) { this._isOwner = false; this.Location = storage.Location; this.HostBuffer = storage.HostBuffer; this._hostPointer = storage._hostPointer; this._allocatedOnDevice = storage._allocatedOnDevice; storage.CopyToDevice(); this.DeviceBuffer = new CudaDeviceVariable <float>(storage.DeviceBuffer.DevicePointer); this.Location = DataLocation.Device; }
public override void CopyFrom(VolumeStorage <float> source) { Debug.Assert(!this._disposed); var real = source as VolumeStorage; if (!ReferenceEquals(this, real)) { if (this.Shape.TotalLength != real.Shape.TotalLength) { throw new ArgumentException($"{nameof(real)} has different length!"); } real.CopyToDevice(); if (this.DeviceBuffer == null) { this.DeviceBuffer = new CudaDeviceVariable <float>(this.Shape.TotalLength); } var res = DriverAPINativeMethods.SynchronousMemcpy_v2.cuMemcpy( this.DeviceBuffer.DevicePointer, real.DeviceBuffer.DevicePointer, this.Shape.TotalLength * sizeof(float)); if (res != CUResult.Success) { throw new CudaException(res); } this.Location = DataLocation.Device; } else { CopyToDevice(); } }
public Volume(VolumeStorage storage) : base(storage) { this._context = storage.Context; this._volumeStorage = this.Storage as VolumeStorage; }
public override bool Equals(VolumeStorage <float> other) { throw new NotImplementedException(); }
public Volume(VolumeStorage storage) : base(new VolumeStorage(storage, storage.Shape)) { this._context = storage.Context; this._volumeStorage = this.Storage as VolumeStorage; }
public Volume(float[] array, Shape shape) : base(new VolumeStorage(array, shape, GpuContext.Default)) { this._context = GpuContext.Default; this._volumeStorage = this.Storage as VolumeStorage; }