Class ShapeUtils
This class contains utilities for useful calculations with shape.
Inheritance
System.Object
ShapeUtils
Namespace: Microsoft.ML.OnnxRuntime.Tensors
Assembly: Microsoft.ML.OnnxRuntime.dll
Syntax
public static class ShapeUtils : object
Methods
| Improve this Doc View SourceGetIndex(ReadOnlySpan<Int64>, ReadOnlySpan<Int64>, Int32)
Calculates the 1-d index for n-d indices in layout specified by strides.
Declaration
public static long GetIndex(ReadOnlySpan<long> strides, ReadOnlySpan<long> indices, int startFromDimension = 0)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<><System.Int64> | strides | pre-calculated strides |
ReadOnlySpan<><System.Int64> | indices | Indices. Must have the same length as strides |
System.Int32 | startFromDimension |
Returns
Type | Description |
---|---|
System.Int64 | A 1-d index into the tensor buffer |
GetSizeForShape(ReadOnlySpan<Int64>)
Returns a number of elements in the tensor from the given shape
Declaration
public static long GetSizeForShape(ReadOnlySpan<long> shape)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<><System.Int64> | shape |
Returns
Type | Description |
---|---|
System.Int64 | size |
GetStrides(ReadOnlySpan<Int64>)
Gets the set of strides that can be used to calculate the offset of n-dimensions in a 1-dimensional layout
Declaration
public static long[] GetStrides(ReadOnlySpan<long> dimensions)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<><System.Int64> | dimensions |
Returns
Type | Description |
---|---|
System.Int64[] | an array of strides |