Documentation ¶
Index ¶
- Variables
- func CheckInputsOutputs(inputs []*TensorWithType, outputs []*TensorWithType, ...) error
- func ConvertNames(names []string) []*C.char
- func ConvertTensors(tensors []*TensorWithType) []*C.OrtValue
- func DestroyEnvironment() error
- func GetTensorElementDataType[T TensorData]() C.ONNXTensorElementDataType
- func InitializeEnvironment() error
- func IsInitialized() bool
- func NewEmptyTensorWithType(tensorType string, s Shape) (interface{}, error)
- func RandomSelect(probabilities []float64) int
- func Reshape(data []float64, shape []int64) [][]float64
- func SetSharedLibraryPath(path string)
- func Softmax(x []float64) []float64
- func TakeTopP(logs []float64, topP float64) ([]float64, []int)
- type FloatData
- type IntData
- type Log
- type RunV3GenOptions
- type SessionV3
- func (s *SessionV3) Destroy() error
- func (s *SessionV3) GetInputNames() []string
- func (s *SessionV3) GetInputShapes() (shapeTypes []ShapeType)
- func (s *SessionV3) GetInputTypes() []string
- func (s *SessionV3) GetOutputNames() []string
- func (s *SessionV3) GetOutputShapes() (shapeTypes []ShapeType)
- func (s *SessionV3) GetOutputTypes() []string
- func (s *SessionV3) Run(inputs []*TensorWithType) (outputs []*TensorWithType, err error)
- func (s *SessionV3) RunDecoder(inputs []*TensorWithType, opt *RunV3GenOptions) (outTokenIds []int64, err error)
- func (s *SessionV3) RunGen(inputs []*TensorWithType, opt *RunV3GenOptions) (outputs []*TensorWithType, err error)
- func (s *SessionV3) RunMergedDecoder(inputs []*TensorWithType, opt *RunV3GenOptions) (outTokenIds []int64, err error)
- type Shape
- type ShapeType
- type Tensor
- type TensorData
- type TensorWithType
Constants ¶
This section is empty.
Variables ¶
var NotInitializedError error = fmt.Errorf("InitializeRuntime() has either " +
"not yet been called, or did not return successfully")
Functions ¶
func CheckInputsOutputs ¶
func CheckInputsOutputs(inputs []*TensorWithType, outputs []*TensorWithType, inputNames, outputNames []string) error
func ConvertNames ¶
func ConvertTensors ¶
func ConvertTensors(tensors []*TensorWithType) []*C.OrtValue
func DestroyEnvironment ¶
func DestroyEnvironment() error
Call this function to cleanup the internal onnxruntime environment when it is no longer needed.
func GetTensorElementDataType ¶
func GetTensorElementDataType[T TensorData]() C.ONNXTensorElementDataType
Returns the ONNX enum value used to indicate TensorData type T.
func InitializeEnvironment ¶
func InitializeEnvironment() error
Call this function to initialize the internal onnxruntime environment. If this doesn't return an error, the caller will be responsible for calling DestroyEnvironment to free the onnxruntime state when no longer needed.
func IsInitialized ¶
func IsInitialized() bool
Returns false if the onnxruntime package is not initialized. Called internally by several functions, to avoid segfaulting if InitializeEnvironment hasn't been called yet.
func NewEmptyTensorWithType ¶
func RandomSelect ¶
func SetSharedLibraryPath ¶
func SetSharedLibraryPath(path string)
Use this function to set the path to the "onnxruntime.so" or "onnxruntime.dll" function. By default, it will be set to "onnxruntime.so" on non-Windows systems, and "onnxruntime.dll" on Windows. Users wishing to specify a particular location of this library must call this function prior to calling onnxruntime.InitializeEnvironment().
Types ¶
type RunV3GenOptions ¶
type SessionV3 ¶
type SessionV3 struct {
// contains filtered or unexported fields
}
func (*SessionV3) GetInputNames ¶
func (*SessionV3) GetInputShapes ¶
func (*SessionV3) GetInputTypes ¶
func (*SessionV3) GetOutputNames ¶
func (*SessionV3) GetOutputShapes ¶
func (*SessionV3) GetOutputTypes ¶
func (*SessionV3) Run ¶
func (s *SessionV3) Run(inputs []*TensorWithType) (outputs []*TensorWithType, err error)
func (*SessionV3) RunDecoder ¶
func (s *SessionV3) RunDecoder(inputs []*TensorWithType, opt *RunV3GenOptions) (outTokenIds []int64, err error)
func (*SessionV3) RunGen ¶
func (s *SessionV3) RunGen(inputs []*TensorWithType, opt *RunV3GenOptions) (outputs []*TensorWithType, err error)
func (*SessionV3) RunMergedDecoder ¶
func (s *SessionV3) RunMergedDecoder(inputs []*TensorWithType, opt *RunV3GenOptions) (outTokenIds []int64, err error)
type Shape ¶
type Shape []int64
The Shape type holds the shape of the tensors used by the network input and outputs.
func (Shape) FlattenedSize ¶
Returns the total number of elements in a tensor with the given shape.
type Tensor ¶
type Tensor[T TensorData] struct { // contains filtered or unexported fields }
func NewEmptyTensor ¶
func NewEmptyTensor[T TensorData](s Shape) (*Tensor[T], error)
Creates a new empty tensor with the given shape. The shape provided to this function is copied, and is no longer needed after this function returns.
func NewTensor ¶
func NewTensor[T TensorData](s Shape, data []T) (*Tensor[T], error)
Creates a new tensor backed by an existing data slice. The shape provided to this function is copied, and is no longer needed after this function returns. If the data slice is longer than s.FlattenedSize(), then only the first portion of the data will be used.
func (*Tensor[T]) Clone ¶
Makes a deep copy of the tensor, including its ONNXRuntime value. The Tensor returned by this function must be destroyed when no longer needed.
func (*Tensor[T]) GetData ¶
func (t *Tensor[T]) GetData() []T
Returns the slice containing the tensor's underlying data. The contents of the slice can be read or written to get or set the tensor's contents.
type TensorData ¶
This is used as a type constraint for the generic Tensor type.
type TensorWithType ¶
type TensorWithType struct { TensorType string Tensor interface{} }
func (*TensorWithType) Destroy ¶
func (t *TensorWithType) Destroy() error
func (*TensorWithType) GetData ¶
func (t *TensorWithType) GetData() interface{}
func (*TensorWithType) GetShape ¶
func (t *TensorWithType) GetShape() []int64