Пример #1
0
        public static void MXPredSetInput(PredictorHandle handle, string key, float[] data, uint size)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            handle.ThrowIfDisposed();

            var ret = NativeMethods.MXPredSetInput(handle.NativePtr, key, data, size);

            if (ret != NativeMethods.OK)
            {
                throw CreateMXNetException($"Failed to input {nameof(handle)}");
            }
        }
Пример #2
0
        public static void MXPredPartialForward(PredictorHandle handle, int step, out int step_left)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            handle.ThrowIfDisposed();

            var ret = NativeMethods.MXPredPartialForward(handle.NativePtr, step, out step_left);

            if (ret != NativeMethods.OK)
            {
                throw CreateMXNetException($"Failed to partial forward {nameof(handle)}");
            }
        }
Пример #3
0
        public static void MXPredGetOutput(PredictorHandle handle, uint index, float[] data, uint size)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            handle.ThrowIfDisposed();

            var ret = NativeMethods.MXPredGetOutput(handle.NativePtr, index, data, size);

            if (ret != NativeMethods.OK)
            {
                throw CreateMXNetException($"Failed to get output from {nameof(handle)}");
            }
        }
Пример #4
0
        public static void MXPredForward(PredictorHandle handle)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            handle.ThrowIfDisposed();

            var ret = NativeMethods.MXPredForward(handle.NativePtr);

            if (ret != NativeMethods.OK)
            {
                throw CreateMXNetException($"Failed to forward {nameof(handle)}");
            }
        }
Пример #5
0
        public static void MXPredGetOutputShape(PredictorHandle handle, uint index, out uint[] shape_data, out uint shape_ndim)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            handle.ThrowIfDisposed();

            var ret = NativeMethods.MXPredGetOutputShape(handle.NativePtr, index, out var shape_data_ptr, out shape_ndim);

            if (ret != NativeMethods.OK)
            {
                throw CreateMXNetException($"Failed to get output shape from {nameof(handle)}");
            }

            shape_data = new uint[shape_ndim];
            NativeMethods.memcpy(shape_data, shape_data_ptr, shape_ndim * sizeof(uint));
        }
Пример #6
0
        public static void MXPredCreate(string symbolJson,
                                        byte[] bytes,
                                        int size,
                                        int type,
                                        int deviceId,
                                        uint inputNodes,
                                        string[] keys,
                                        uint[] inputShapeIndptr,
                                        uint[] inputShapeData,
                                        out PredictorHandle handle)
        {
            var ret = NativeMethods.MXPredCreate(symbolJson, bytes, size, type, deviceId, inputNodes, keys, inputShapeIndptr, inputShapeData, out var @out);

            if (ret != NativeMethods.OK)
            {
                throw CreateMXNetException($"Failed to create {nameof(PredictorHandle)}");
            }

            handle = new PredictorHandle(@out);
        }