Example #1
0
 public void Reshape(params int[] dimensions)
 {
     if (_TensorLayout == 2)
     {
         _Shape = new Shape(dimensions);
     }
     else
     {
         ChangeTensorLayout(2);
         _Shape = new Shape(dimensions);
         _Shape.ChangeTensorLayout(2);
         ChangeTensorLayout(1);
     }
 }
Example #2
0
        /// <summary>
        /// Allocate memory by dtype, shape, tensororder (default column wise)
        /// </summary>
        /// <param name="dtype">storage data type</param>
        /// <param name="shape">storage data shape</param>
        /// <param name="tensorOrder">row or column wise</param>
        public void Allocate(Type dtype, IShape shape, int tensorOrder = 1)
        {
            _DType = dtype;
            _Shape = shape;
            _Shape.ChangeTensorLayout(tensorOrder);
            int elementNumber = 1;

            for (int idx = 0; idx < shape.Dimensions.Length; idx++)
            {
                elementNumber *= shape.Dimensions[idx];
            }

            _values       = Array.CreateInstance(dtype, elementNumber);
            _TensorLayout = tensorOrder;
        }