Backends/SiaNet.Backend.TensorSharp/Core/TensorConcatenation.cs
/// <summary>
/// Concats the size of the tensor.
/// </summary>
/// <param name="ndim">The ndim.</param>
/// <param name="dimension">The dimension.</param>
/// <param name="tensors">The tensors.</param>
/// <returns>System.Int64[].</returns>
/// <exception cref="InvalidOperationException">Inconsistent tensor sizes</exception>
Concats the size of the tensor.
Concats the size of the tensor .
private static long[] ConcatTensorSize(int ndim, int dimension, NDArray[] tensors)
        {
            var result = new long[ndim];
            for (int i = 0; i < ndim; ++i)
            {
                var dimSize = GetDimSize(tensors[0], i);
                if (i == dimension)
                {
                    for (int j = 1; j < tensors.Length; ++j)
                    {
                        dimSize += GetDimSize(tensors[j], i);
                    }
                }
                else
                {
                    for (int j = 1; j < tensors.Length; ++j)
                    {
                        if (dimSize != GetDimSize(tensors[j], i))
                        {
                            throw new InvalidOperationException("Inconsistent tensor sizes");
                        }
                    }
                }
                result[i] = dimSize;
            }
            return result;
        }
private static long [ ] ConcatTensorSize ( int ndim , int dimension , NDArray [ ] tensors ) { var result = new long [ ndim ] ; for ( int i = 0 ; i < ndim ; ++ i ) { var dimSize = GetDimSize ( tensors [ 0 ] , i ) ; if ( i == dimension ) { for ( int j = 1 ; j < tensors . Length ; ++ j ) { dimSize += GetDimSize ( tensors [ j ] , i ) ; } } else { for ( int j = 1 ; j < tensors . Length ; ++ j ) { if ( dimSize != GetDimSize ( tensors [ j ] , i ) ) { throw new InvalidOperationException ( " " ) ; } } } result [ i ] = dimSize ; } return result ; }
Concats the size of the tensor.
Concats the size of the tensor .
None
Inconsistent tensor sizes
Inconsistent tensor sizes
ndim
int
None
dimension
int
None
tensors
NDArray[]
None