Namespace
Tensor Element Types
TensorElementType Enum
Supported tensor data types:DenseTensor<T>
The main tensor class for dense multi-dimensional arrays.Constructors
DenseTensor(T[], int[])
Creates a tensor from an array and shape.DenseTensor(int[])
Creates an empty tensor with specified dimensions.DenseTensor(Memory<T>, int[])
Creates a tensor backed by Memory<T>.Properties
Dimensions
Gets the tensor dimensions.Length
Gets total number of elements.Rank
Gets the number of dimensions.Methods
Clone
Creates a deep copy of the tensor.Reshape
Reshapes the tensor to new dimensions.ToArray
Converts tensor to flat array.NamedOnnxValue
Wrapper for named tensor inputs/outputs.Creating Named Values
CreateFromTensor
Creates a named value from a tensor.Accessing Tensor Data
AsTensor<T>
Extracts tensor from named value.Common Tensor Operations
Creating Image Tensors
Batch Processing
Working with Sequences
String Tensors
Advanced Tensor Usage
Memory-Efficient Tensors
Slicing Tensors
Type Conversions
Performance Tips
- Reuse tensors: Avoid creating new tensors in hot paths
- Use Memory<T>: For zero-copy scenarios
- Batch operations: Process multiple items together
- Pre-allocate: Create tensors with known sizes upfront
- Avoid ToArray(): Access elements directly when possible