Show / Hide Table of Contents

Class ShapeUtils

This class contains utilities for useful calculations with shape.

Inheritance
object
ShapeUtils
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Microsoft.ML.OnnxRuntime.Tensors
Assembly: Microsoft.ML.OnnxRuntime.dll
Syntax
public static class ShapeUtils

Methods

| Improve this Doc View Source

GetIndex(ReadOnlySpan<long>, ReadOnlySpan<long>, int)

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<long> strides

pre-calculated strides

ReadOnlySpan<long> indices

Indices. Must have the same length as strides

int startFromDimension
Returns
Type Description
long

A 1-d index into the tensor buffer

| Improve this Doc View Source

GetSizeForShape(ReadOnlySpan<long>)

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<long> shape
Returns
Type Description
long

size

Exceptions
Type Condition
ArgumentOutOfRangeException
| Improve this Doc View Source

GetStrides(ReadOnlySpan<long>)

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<long> dimensions
Returns
Type Description
long[]

an array of strides

  • Improve this Doc
  • View Source
In This Article
Back to top