예제 #1
0
        public NdArray(uint[] shape)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape, (uint)shape.Length, DeviceType.KCpu, 0, 0, out handle));
            _blobPtr = new NdBlob(handle);
        }
예제 #2
0
        public NdArray()
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreateNone(out handle));
            _blobPtr = new NdBlob(handle);
        }
예제 #3
0
        public NdArray(Shape shape, Context context, bool delayAlloc)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape.Data().ToArray(), shape.Ndim(), context.DeviceType,
                                                         context.DeviceId, delayAlloc ? 1 : 0, out handle));
            _blobPtr = new NdBlob(handle);
        }
예제 #4
0
        public NdArray(float[] data)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreateNone(out handle));
            NativeMethods.MXNDArraySyncCopyFromCPU(handle, data, (uint)data.Length);
            _blobPtr = new NdBlob(handle);
        }
예제 #5
0
        public NdArray(uint[] shape, Context context,
                       bool delayAlloc)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape, (uint)shape.Length, context.DeviceType,
                                                         context.DeviceId, delayAlloc ? 1 : 0, out handle));
            _blobPtr = new NdBlob(handle);
        }
예제 #6
0
        public NdArray(float[] data, Shape shape,
                       Context context = null)

        {
            if (context == null)
            {
                context = Context.DefaultCtx;
            }

            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape.Data().ToArray(), shape.Ndim(), context.DeviceType,
                                                         context.DeviceId, 0, out handle));
            NativeMethods.MXNDArraySyncCopyFromCPU(handle, data, shape.Size());
            _blobPtr = new NdBlob(handle);
        }
예제 #7
0
 public NdArray(NDArrayHandle handle, bool writable = true)
 {
     _writable = writable;
     _blobPtr  = new NdBlob(handle);
 }