Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public NdArray()
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreateNone(out handle));
            _blobPtr = new NdBlob(handle);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
0
 public NdArray(NDArrayHandle handle, bool writable = true)
 {
     _writable = writable;
     _blobPtr  = new NdBlob(handle);
 }