Backends/SiaNet.Backend.TensorSharp/NDArray.cs
/// <summary>
/// Expand one or more singleton dimensions (dimensions with size 1) by using a stride of 0
/// </summary>
/// <param name="newSizes">The new sizes.</param>
/// <returns>Tensor.</returns>
/// <exception cref="InvalidOperationException">
/// number of elements of newSizes must match the dimension count of tensor
/// or
/// Can only expand singleton dimensions (dimensions of size 1)
/// </exception>
Expand one or more singleton dimensions (dimensions with size 1) by using a stride of 0
Expand one or more singleton dimensions ( dimensions with size 1 ) by using a stride of 0
public NDArray Expand(params long[] newSizes)
        {
            if (newSizes.Length != DimensionCount)
                throw new InvalidOperationException("number of elements of newSizes must match the dimension count of tensor");
            var newStrides = (long[])strides.Clone();
            for (int i = 0; i < newSizes.Length; ++i)
            {
                if (newSizes[i] != Shape[i])
                {
                    if (Shape[i] != 1)
                        throw new InvalidOperationException("Can only expand singleton dimensions (dimensions of size 1)");
                    newStrides[i] = 0;
                }
            }
            return new NDArray(newSizes, newStrides, this.storage, this.storageOffset);
        }
public NDArray Expand ( params long [ ] newSizes ) { if ( newSizes . Length != DimensionCount ) throw new InvalidOperationException ( " " ) ; var newStrides = ( long [ ] ) strides . Clone ( ) ; for ( int i = 0 ; i < newSizes . Length ; ++ i ) { if ( newSizes [ i ] != Shape [ i ] ) { if ( Shape [ i ] != 1 ) throw new InvalidOperationException ( " " ) ; newStrides [ i ] = 0 ; } } return new NDArray ( newSizes , newStrides , this . storage , this . storageOffset ) ; }
Expand one or more singleton dimensions (dimensions with size 1) by using a stride of 0
Expand one or more singleton dimensions ( dimensions with size 1 ) by using a stride of 0
None
number of elements of newSizes must match the dimension count of tensor
or
Can only expand singleton dimensions (dimensions of size 1)
number of elements of newSizes must match the dimension count of tensor or Can only expand singleton dimensions ( dimensions of size 1 )
newSizes
The new sizes.
The new sizes .