Backends/SiaNet.Backend.TensorSharp/Cuda/ApplyUtils.cs
/// <summary>
/// Determines whether this instance [can use32 bit index math] the specified tensor.
/// </summary>
/// <param name="tensor">The tensor.</param>
/// <returns><c>true</c> if this instance [can use32 bit index math] the specified tensor; otherwise, <c>false</c>.</returns>
Determines whether this instance [can use32 bit index math] the specified tensor.
Determines whether this instance [ can use32 bit index math ] the specified tensor .
public static bool CanUse32BitIndexMath(NDArray tensor)
        {
            var elements = tensor.ElementCount();
            if (elements >= uint.MaxValue)
            {
                return false;
            }
            long offset = 0;
            long linearId = elements - 1;
            for (int i = tensor.DimensionCount - 1; i >= 0; --i)
            {
                var curDimIndex = linearId % tensor.Shape[i];
                var curDimOffset = curDimIndex * tensor.Strides[i];
                offset += curDimOffset;
                linearId /= tensor.Shape[i];
            }
            if (offset >= uint.MaxValue)
            {
                return false;
            }
            return true;
        }
public static bool CanUse32BitIndexMath ( NDArray tensor ) { var elements = tensor . ElementCount ( ) ; if ( elements >= uint . MaxValue ) { return false ; } long offset = 0 ; long linearId = elements - 1 ; for ( int i = tensor . DimensionCount - 1 ; i >= 0 ; -- i ) { var curDimIndex = linearId % tensor . Shape [ i ] ; var curDimOffset = curDimIndex * tensor . Strides [ i ] ; offset += curDimOffset ; linearId /= tensor . Shape [ i ] ; } if ( offset >= uint . MaxValue ) { return false ; } return true ; }
Determines whether this instance [can use32 bit index math] the specified tensor.
Determines whether this instance [ can use32 bit index math ] the specified tensor .
None
tensor
NDArray
None