IReadOnlyTensor.HasAnyDenseDimensions Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines if the current tensor has any dimension where GetDimensionSpan(int)
will iterate through tensors that would have IsDense be true
.
public:
property bool HasAnyDenseDimensions { bool get(); };
public bool HasAnyDenseDimensions { get; }
member this.HasAnyDenseDimensions : bool
Public ReadOnly Property HasAnyDenseDimensions As Boolean
Property Value
Remarks
This does not include the last dimension, GetDimensionSpan(Rank - 1)
, as it always iterates 1 element at a time and would mean this property always returns true.
An example of a tensor which is not dense but which would have a dense dimension is a 2x2 Tensor where FlattenedLength: 4; Lengths: [2, 2]; Strides: [4, 1]
. In such a scenario, the overall tensor is not dense because the backing storage has a length of at least 6 and so has 2 used elements, 2 unused elements, followed by the last 2 used elements. However, the two slices representing [0..1, ..]
and [1..2, ..]
would themselves be dense; thus GetDimension(0).GetSlice(n)
will iterate dense tensors: FlattenedLength: 2, Length: [2], Strides: [1]
.