コード例 #1
0
        internal Volume(float[] array, Shape shape) : base(new VolumeStorage(array, shape, GpuContext.Default))
        {
            this._context       = GpuContext.Default;
            this._volumeStorage = this.Storage as VolumeStorage;

            LoadKernels();
        }
コード例 #2
0
        internal Volume(VolumeStorage storage) : base(storage)
        {
            this._context       = storage.Context;
            this._volumeStorage = this.Storage as VolumeStorage;

            LoadKernels();
        }
コード例 #3
0
        public Volume(float[] array, Shape shape, GpuContext context) : base(new VolumeStorage(array, shape, context))
        {
            this._context       = context;
            this._volumeStorage = this.Storage as VolumeStorage;

            LoadKernels();
        }
コード例 #4
0
ファイル: VolumeStorage.cs プロジェクト: NSqda/XCoinTrader
        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;
        }
コード例 #5
0
ファイル: VolumeBuilder.cs プロジェクト: NSqda/XCoinTrader
        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();
        }
コード例 #6
0
ファイル: VolumeBuilder.cs プロジェクト: NSqda/XCoinTrader
        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();
        }
コード例 #7
0
ファイル: VolumeBuilder.cs プロジェクト: NSqda/XCoinTrader
        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();
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        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];
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: VolumeStorage.cs プロジェクト: Neuxz/ConvNetSharp
        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;
        }
コード例 #13
0
        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();
            }
        }
コード例 #14
0
ファイル: Volume.cs プロジェクト: forgotten-boi/ConvNetSharp
 public Volume(VolumeStorage storage) : base(storage)
 {
     this._context       = storage.Context;
     this._volumeStorage = this.Storage as VolumeStorage;
 }
コード例 #15
0
ファイル: VolumeStorage.cs プロジェクト: Neuxz/ConvNetSharp
 public override bool Equals(VolumeStorage <float> other)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
ファイル: Volume.cs プロジェクト: qx-will/ConvNetSharp
 public Volume(VolumeStorage storage) : base(new VolumeStorage(storage, storage.Shape))
 {
     this._context       = storage.Context;
     this._volumeStorage = this.Storage as VolumeStorage;
 }
コード例 #17
0
ファイル: Volume.cs プロジェクト: forgotten-boi/ConvNetSharp
 public Volume(float[] array, Shape shape) : base(new VolumeStorage(array, shape, GpuContext.Default))
 {
     this._context       = GpuContext.Default;
     this._volumeStorage = this.Storage as VolumeStorage;
 }