示例#1
0
        public void RecordUpload(Mat mat, VkMat dst, Option option)
        {
            if (mat == null)
            {
                throw new ArgumentNullException(nameof(mat));
            }
            if (dst == null)
            {
                throw new ArgumentNullException(nameof(dst));
            }
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option));
            }

            this.ThrowIfDisposed();
            mat.ThrowIfDisposed();
            dst.ThrowIfDisposed();
            option.ThrowIfDisposed();

            var error = NativeMethods.command_VkCompute_record_upload(this.NativePtr,
                                                                      mat.NativePtr,
                                                                      dst.NativePtr,
                                                                      option.NativePtr);

            if (error != NativeMethods.ErrorType.OK)
            {
                throw new NcnnException("Unknown Exception");
            }
        }
示例#2
0
        public void CreateLike(VkMat mat, VkAllocator allocator, VkAllocator stagingAllocator)
        {
            if (mat == null)
            {
                throw new ArgumentNullException(nameof(mat));
            }
            if (allocator == null)
            {
                throw new ArgumentNullException(nameof(allocator));
            }
            if (stagingAllocator == null)
            {
                throw new ArgumentNullException(nameof(stagingAllocator));
            }

            this.ThrowIfDisposed();
            mat.ThrowIfDisposed();
            allocator.ThrowIfDisposed();
            stagingAllocator.ThrowIfDisposed();

            var error = NativeMethods.mat_VkMat_create_like_vkmat(this.NativePtr,
                                                                  mat.NativePtr,
                                                                  allocator.NativePtr,
                                                                  stagingAllocator.NativePtr);

            if (error != NativeMethods.ErrorType.OK)
            {
                throw new NcnnException("Unknown Exception");
            }
        }
示例#3
0
        public void RecordDownload(VkMat mat)
        {
            if (mat == null)
            {
                throw new ArgumentNullException(nameof(mat));
            }

            this.ThrowIfDisposed();
            mat.ThrowIfDisposed();

            var error = NativeMethods.command_VkCompute_record_download(this.NativePtr, mat.NativePtr);

            if (error != NativeMethods.ErrorType.OK)
            {
                throw new NcnnException("Unknown Exception");
            }
        }
示例#4
0
        public void CreateLike(VkMat mat, Allocator allocator = null)
        {
            if (mat == null)
            {
                throw new ArgumentNullException(nameof(mat));
            }

            this.ThrowIfDisposed();
            mat.ThrowIfDisposed();
            allocator?.ThrowIfDisposed();

            var error = NativeMethods.mat_Mat_create_like_vkmat(this.NativePtr,
                                                                mat.NativePtr,
                                                                allocator?.NativePtr ?? IntPtr.Zero);

            if (error != NativeMethods.ErrorType.OK)
            {
                throw new NcnnException("Unknown Exception");
            }
        }
示例#5
0
        public int Forward(VkMat bottomBlob, VkMat topBlob, VkCompute compute, Option option)
        {
            if (bottomBlob == null)
            {
                throw new ArgumentNullException(nameof(bottomBlob));
            }
            if (topBlob == null)
            {
                throw new ArgumentNullException(nameof(topBlob));
            }
            if (compute == null)
            {
                throw new ArgumentNullException(nameof(compute));
            }
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option));
            }

            this.ThrowIfDisposed();
            bottomBlob.ThrowIfDisposed();
            topBlob.ThrowIfDisposed();
            compute.ThrowIfDisposed();
            option.ThrowIfDisposed();

            var error = NativeMethods.layer_Layer_forward2_vkmat(this.NativePtr,
                                                                 bottomBlob.NativePtr,
                                                                 topBlob.NativePtr,
                                                                 compute.NativePtr,
                                                                 option.NativePtr,
                                                                 out var returnValue);

            if (error != NativeMethods.ErrorType.OK)
            {
                throw new NcnnException("Unknown Exception");
            }

            return(returnValue);
        }