IReadOnlyTensor.HasAnyDenseDimensions Property

Definition

Gets a value that indicates whether the current tensor has any dimension span where IsDense is true.

public:
 property bool HasAnyDenseDimensions { bool get(); };
public bool HasAnyDenseDimensions { get; }
member this.HasAnyDenseDimensions : bool
Public ReadOnly Property HasAnyDenseDimensions As Boolean

Property Value

true if this tensor has any dense dimensions; otherwise, false.

Remarks

This does not include the last dimension, GetDimensionSpan(Rank - 1), as it always iterates one element at a time and would mean this property always returns true.

An example of a tensor that's not dense but has 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. It has two used elements, two unused elements, followed by the last two used elements. However, the two slices representing [0..1, ..] and [1..2, ..] are dense; thus GetDimension(0).GetSlice(n) will iterate dense tensors: FlattenedLength: 2, Length: [2], Strides: [1].

Applies to