示例#1
0
        public NDArray(uint[] shape)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape, (uint)shape.Length, DeviceType.KCpu, 0, 0, out handle));
            _blob_ptr = new NDBlob(handle);
        }
示例#2
0
        public NDArray()
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreateNone(out handle));
            _blob_ptr = new NDBlob(handle);
        }
示例#3
0
        public NDArray(Shape shape, Context context, bool delay_alloc)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape.Data().ToArray(), shape.Ndim(), context.device_type,
                                                         context.device_id, delay_alloc ? 1 : 0, out handle));
            _blob_ptr = new NDBlob(handle);
        }
示例#4
0
        public NDArray(float[] data)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreateNone(out handle));
            NativeMethods.MXNDArraySyncCopyFromCPU(handle, data, (uint)data.Length);
            _blob_ptr = new NDBlob(handle);
        }
示例#5
0
        public NDArray(uint[] shape, Context context,
                       bool delay_alloc)
        {
            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape, (uint)shape.Length, context.device_type,
                                                         context.device_id, delay_alloc ? 1 : 0, out handle));
            _blob_ptr = new NDBlob(handle);
        }
示例#6
0
        public NDArray(float[] data, Shape shape,
                       Context context = null)

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

            NDArrayHandle handle;

            Util.CallCheck(NativeMethods.MXNDArrayCreate(shape.Data().ToArray(), shape.Ndim(), context.device_type,
                                                         context.device_id, 0, out handle));
            NativeMethods.MXNDArraySyncCopyFromCPU(handle, data, shape.Size());
            _blob_ptr = new NDBlob(handle);
        }
示例#7
0
 public NDArray(NDArrayHandle handle, bool writable = true)
 {
     _writable = writable;
     _blob_ptr = new NDBlob(handle);
 }