# OnnxSparseTensor.SparseTensor (onnxruntime 1.15.0 API)

Package ai.onnxruntime

## Class OnnxSparseTensor.SparseTensor<T extends java.nio.Buffer>

- java.lang.Object
- - ai.onnxruntime.OnnxSparseTensor.SparseTensor<T>

Direct Known Subclasses:
  `OnnxSparseTensor.BlockSparseTensor`, `OnnxSparseTensor.COOTensor`, `OnnxSparseTensor.CSRCTensor`

Enclosing class:
  OnnxSparseTensor

    public abstract static class OnnxSparseTensor.SparseTensor<T extends java.nio.Buffer>
    extends java.lang.Object

Abstract base class for Java sparse tensors

Will be sealed to `OnnxSparseTensor.COOTensor`, `OnnxSparseTensor.CSRCTensor` and `OnnxSparseTensor.BlockSparseTensor` one day.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`long[]` `getDenseShape()` Gets the dense shape of the sparse tensor.
`T` `getIndices()` Get the indices buffer.
`long[]` `getIndicesShape()` Gets the shape of the indices of the sparse tensor.
`abstract OnnxJavaType` `getIndicesType()` The indices type of the sparse tensor.
`long` `getNumNonZeroElements()` The number of non-zero elements.
`abstract OnnxSparseTensor.SparseTensorType` `getSparsityType()` The sparsity type of the sparse tensor.
`OnnxJavaType` `getType()` The data type of the sparse tensor.
`java.nio.Buffer` `getValues()` Get the value buffer.
`long[]` `getValuesShape()` Gets the shape of the values of the sparse tensor.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getDenseShape

    public long[] getDenseShape()

Gets the dense shape of the sparse tensor.

Returns:
  The sparse tensor shape.

#### getType

    public OnnxJavaType getType()

The data type of the sparse tensor.

Returns:
  The sparse tensor data type.

#### getNumNonZeroElements

    public long getNumNonZeroElements()

The number of non-zero elements.

Returns:
  The number of non-zero elements.

#### getIndices

    public T getIndices()

Get the indices buffer.

Returns:
  The indices buffer.

#### getValues

    public java.nio.Buffer getValues()

Get the value buffer.

Returns:
  The value buffer.

#### getValuesShape

    public long[] getValuesShape()

Gets the shape of the values of the sparse tensor.

Returns:
  The sparse tensor value shape.

#### getIndicesShape

    public long[] getIndicesShape()

Gets the shape of the indices of the sparse tensor.

Returns:
  The sparse tensor indices shape.

#### getSparsityType

    public abstract OnnxSparseTensor.SparseTensorType getSparsityType()

The sparsity type of the sparse tensor.

Returns:
  The sparse tensor sparsity type.

#### getIndicesType

    public abstract OnnxJavaType getIndicesType()

The indices type of the sparse tensor.

Only `OnnxJavaType.INT32` and `OnnxJavaType.INT64` are supported.

Returns:
  The sparse tensor indices type.