類 OnnxSparseTensor
- java.lang.Object
-
- ai.onnxruntime.OnnxTensorLike
-
- ai.onnxruntime.OnnxSparseTensor
-
- 所有已實現的介面
OnnxValue,java.lang.AutoCloseable
public final class OnnxSparseTensor extends OnnxTensorLike
一個包裝了 OnnxSparseTensor 的 Java 物件。稀疏張量支援多種格式,
getValue()方法會返回一個表示每種型別的不同靜態內部類。
-
-
巢狀類摘要
巢狀類 修飾符和型別 類 描述 靜態類OnnxSparseTensor.BlockSparseTensor塊稀疏張量的 Java 端表示。靜態類OnnxSparseTensor.COOTensorCOO 稀疏張量的 Java 端表示。靜態類OnnxSparseTensor.CSRCTensorCSRC 稀疏張量的 Java 端表示。靜態類OnnxSparseTensor.SparseTensor<T extends java.nio.Buffer>Java 稀疏張量的抽象基類靜態類OnnxSparseTensor.SparseTensorType稀疏張量的型別。-
繼承自介面 ai.onnxruntime.OnnxValue 的巢狀類/介面
OnnxValue.OnnxValueType
-
-
欄位摘要
-
繼承自類 ai.onnxruntime.OnnxTensorLike 的欄位
allocatorHandle, closed, info, nativeHandle
-
-
方法摘要
所有方法 靜態方法 例項方法 具體方法 修飾符和型別 方法 描述 voidclose()關閉 OnnxValue,釋放其原生記憶體。static <T extends java.nio.Buffer>
OnnxSparseTensorcreateSparseTensor(OrtEnvironment env, OnnxSparseTensor.SparseTensor<T> tensor)從 Java 端表示在 ORT 中建立稀疏張量。java.nio.BuffergetIndicesBuffer()獲取索引的副本。long[]getIndicesShape()獲取(外部)索引的形狀。java.nio.LongBuffergetInnerIndicesBuffer()獲取 CSRC 稀疏張量中內部索引的副本。long[]getInnerIndicesShape()獲取 CSRC 稀疏張量中內部索引的形狀。OnnxSparseTensor.SparseTensorTypegetSparseTensorType()返回此 OnnxSparseTensor 的型別。OnnxValue.OnnxValueTypegetType()獲取此 OnnxValue 的型別。OnnxSparseTensor.SparseTensor<? extends java.nio.Buffer>getValue()將值作為 Java 物件返回,並將其從原生堆複製出來。java.nio.BuffergetValuesBuffer()獲取資料緩衝區的副本。long[]getValuesShape()獲取值的形狀。-
繼承自類 ai.onnxruntime.OnnxTensorLike 的方法
checkClosed, getInfo, isClosed
-
-
-
-
方法詳細資訊
-
createSparseTensor
public static <T extends java.nio.Buffer> OnnxSparseTensor createSparseTensor(OrtEnvironment env, OnnxSparseTensor.SparseTensor<T> tensor) throws OrtException
從 Java 端表示在 ORT 中建立稀疏張量。- 型別引數
T- 緩衝區型別。- 引數
env- OrtEnvironment 例項。tensor- Java 端表示。- 返回
- ORT 中的稀疏張量。
- 丟擲
OrtException- 如果張量無法建立或無效。
-
getType
public OnnxValue.OnnxValueType getType()
描述複製自介面:OnnxValue獲取此 OnnxValue 的型別。- 返回
- 值的型別。
-
getValue
public OnnxSparseTensor.SparseTensor<? extends java.nio.Buffer> getValue() throws OrtException
描述複製自介面:OnnxValue將值作為 Java 物件返回,並將其從原生堆複製出來。對於高維張量,此操作可能相當慢,您應優先使用OnnxTensor.getByteBuffer()等方法。如果可用,由子類使用更具體的型別覆蓋此方法。
- 返回
- 值。
- 丟擲
OrtException- 如果讀取值時發生錯誤。
-
close
public void close()
描述複製自介面:OnnxValue關閉 OnnxValue,釋放其原生記憶體。
-
getSparseTensorType
public OnnxSparseTensor.SparseTensorType getSparseTensorType()
返回此 OnnxSparseTensor 的型別。- 返回
- 稀疏型別。
-
getIndicesBuffer
public java.nio.Buffer getIndicesBuffer()
獲取索引的副本。如果它是 CSRC 稀疏張量,這些是外部索引。
如果為 COO 或 CSRC 型別,則為
LongBuffer;如果為 Block Sparse 型別,則為IntBuffer。- 返回
- 索引。
-
getInnerIndicesBuffer
public java.nio.LongBuffer getInnerIndicesBuffer()
獲取 CSRC 稀疏張量中內部索引的副本。如果在不同稀疏張量型別上呼叫,則丟擲
IllegalStateException。- 返回
- 內部索引。
-
getValuesBuffer
public java.nio.Buffer getValuesBuffer()
獲取資料緩衝區的副本。與
OnnxTensor類似,fp16 值會被向上轉換為 fp32 並作為FloatBuffer返回。- 返回
- 資料緩衝區。
-
getIndicesShape
public long[] getIndicesShape()
獲取(外部)索引的形狀。- 返回
- 索引形狀。
-
getInnerIndicesShape
public long[] getInnerIndicesShape()
獲取 CSRC 稀疏張量中內部索引的形狀。- 返回
- 索引形狀。
-
getValuesShape
public long[] getValuesShape()
獲取值的形狀。- 返回
- 值形狀。
-
-