Пример #1
0
        public static XArray operator /(double lhs, XArray rhs)
        {
            XArray lhs_t = new XArray(rhs.Shape, rhs.DataType);

            lhs_t.Fill(lhs);
            return(lhs_t / rhs);
        }
Пример #2
0
        public static XArray operator >>(XArray lhs, int rhs)
        {
            XArray rhs_t = new XArray(lhs.Shape, lhs.DataType);

            rhs_t.Fill(rhs);
            return(xt.BitwiseRightShift(lhs, rhs_t));
        }
Пример #3
0
        public static XArray operator ^(XArray lhs, double rhs)
        {
            XArray rhs_t = new XArray(lhs.Shape, lhs.DataType);

            rhs_t.Fill(rhs);
            return(xt.BitwiseXor(lhs, rhs_t));
        }
Пример #4
0
        public XArray Randn(Shape shape, double mean = 0, double std_dev = 1, DType dtype = DType.Float32)
        {
            XArray r = new XArray(shape, dtype);

            NativeWrapper.TS_Random_Randn(r.GetRef(), mean, std_dev);
            return(r);
        }
Пример #5
0
        public static XArray operator /(XArray lhs, double rhs)
        {
            XArray rhs_t = new XArray(lhs.Shape, lhs.DataType);

            rhs_t.Fill(rhs);
            return(lhs / rhs_t);
        }
Пример #6
0
        public static XArray operator ^(double lhs, XArray rhs)
        {
            XArray lhs_t = new XArray(rhs.Shape, rhs.DataType);

            lhs_t.Fill(lhs);
            return(xt.BitwiseXor(lhs_t, rhs));
        }
Пример #7
0
        public static XArray NormLp2P(XArray x, double p, params int[] axes)
        {
            if (axes.Length > 0)
            {
                return(NativeHelper.Reduce(x, axes, p, 0, 0, ReduceFunc.NormLp2P));
            }

            return(NativeHelper.ReduceAll(x, ReduceFunc.NormLp2P, p));
        }
Пример #8
0
        public static XArray NormL0(XArray x, params int[] axes)
        {
            if (axes.Length > 0)
            {
                return(NativeHelper.Reduce(x, axes, 0, 0, 0, ReduceFunc.NormL0));
            }

            return(NativeHelper.ReduceAll(x, ReduceFunc.NormL0));
        }
Пример #9
0
        public static XArray NanCumProd(XArray x, int?axis = null)
        {
            if (axis.HasValue)
            {
                return(NativeHelper.Accumulating(x, axis.Value, ReduceFunc.NanCumProd));
            }

            return(NativeHelper.Accumulating(x, -9999, ReduceFunc.NanCumProd));
        }
Пример #10
0
        internal static XArray FromRef(XArrayRef tensorRef)
        {
            long[] shape_data = new long[tensorRef.dimCount];
            Marshal.Copy(tensorRef.sizes, shape_data, 0, shape_data.Length);
            Shape  shape  = new Shape(shape_data);
            XArray result = new XArray(shape, tensorRef.elementType);

            result.NativePtr = tensorRef.buffer;

            return(result);
        }
Пример #11
0
        internal XArrayRef AllocTensorRef(XArray tensor)
        {
            var tensorRef = new XArrayRef();

            tensorRef.buffer      = GetBufferStart(tensor);
            tensorRef.dimCount    = tensor.Shape.Length;
            tensorRef.sizes       = AllocArray(tensor.Shape.Data);
            tensorRef.strides     = AllocArray(tensor.strides);
            tensorRef.elementType = tensor.DataType;
            return(tensorRef);
        }
Пример #12
0
 public static XArray Remainder(XArray a, XArray b) => NativeHelper.ElementwiseOps(a, b, ElementwiseFunc.Remainder);
Пример #13
0
 public XArray Choice(Shape shape, int n, XArray weight, bool replace = true, DType dtype = DType.Float32)
 {
     return(NativeHelper.RandomChoice(shape, n, weight, replace, dtype));
 }
Пример #14
0
 public static XArray Trapz(XArray x, double dx = 1, int axis = -1)
 {
     return(NativeHelper.Reduce(x, new int[1] {
         0
     }, dx, 0, axis, ReduceFunc.Trapz));
 }
Пример #15
0
 public bool Any(int axis = -1, bool keepdims = true, XArray where = null)
 {
     throw new NotImplementedException();
 }
Пример #16
0
 public XArray SearchSorted(XArray v, string side = "")
 {
     throw new NotImplementedException();
 }
Пример #17
0
 public static XArray Diff(XArray x, int n, int axis = -1)
 {
     return(NativeHelper.Reduce(x, new int[1] {
         0
     }, 0, n, axis, ReduceFunc.Diff));
 }
Пример #18
0
 public static XArray Fma(XArray a, XArray b, XArray c) => NativeHelper.ElementwiseOps(a, b, c, ElementwiseFunc.Fma);
Пример #19
0
 public static XArray FDim(XArray a, XArray b) => NativeHelper.ElementwiseOps(a, b, ElementwiseFunc.FDim);
Пример #20
0
 public static XArray Sign(XArray x) => throw new NotImplementedException();
Пример #21
0
 public IntPtr GetBufferStart(XArray tensor)
 {
     return(PtrAdd(NativePtr, tensor.storageOffset * tensor.DataType.Size()));
 }
Пример #22
0
 public XArray Take(XArray indices, int axis = -1, string mode = "raise")
 {
     throw new NotImplementedException();
 }
Пример #23
0
 public XArray Put(XArray indices, XArray v, string mode = "raise")
 {
     throw new NotImplementedException();
 }
Пример #24
0
 public XArray Choose(XArray choices, string mode = "raise")
 {
     throw new NotImplementedException();
 }
Пример #25
0
 public static XArray Maximum(XArray a, XArray b) => NativeHelper.ElementwiseOps(a, b, ElementwiseFunc.Maximum);
Пример #26
0
 public static XArray Nan2Num(XArray x, int?axis = null)
 {
     return(NativeHelper.ReduceAll(x, ReduceFunc.Nan2Num));
 }
Пример #27
0
 public static XArray Clip(XArray x, double min, double max) => NativeHelper.Clip(x, min, max);
Пример #28
0
 public XArray ArgPartition(XArray kth, int axis = -1)
 {
     throw new NotImplementedException();
 }
Пример #29
0
 public static XArray Abs(XArray x) => NativeHelper.ElementwiseOps(x, ElementwiseFunc.Abs);
Пример #30
0
 public static XArray Where(XArray cond, XArray x, XArray y)
 {
     return(NativeHelper.ElementwiseOps(cond, x, y, ElementwiseFunc.Where));
 }