Documentation
¶
Index ¶
- func EnsureRuntime(dataDir string) (string, error)
- func ExtractRuntimeFromTgz(tgzPath, dataDir string) (string, error)
- func InitializeRuntime() error
- func RuntimeLibPath(dataDir string) string
- func RuntimeTgzFilename() string
- func RuntimeTgzMirrors() []string
- func RuntimeTgzURL() string
- func SetDataDir(dataDir string)
- func SetLibraryPath(path string)
- type DynamicSession
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureRuntime ¶
EnsureRuntime downloads the ONNX Runtime shared library if not present. Returns the path to the library file.
func ExtractRuntimeFromTgz ¶
ExtractRuntimeFromTgz extracts the ONNX Runtime dylib from a downloaded tgz file into the onnxruntime subdirectory under dataDir. Returns the dylib path.
func InitializeRuntime ¶
func InitializeRuntime() error
InitializeRuntime initializes the ONNX Runtime environment. Unlike sync.Once, this retries on failure so that downloading the shared library after a failed attempt can succeed.
func RuntimeLibPath ¶
RuntimeLibPath returns the path to the ONNX Runtime shared library in the given data directory, or empty string if not present.
func RuntimeTgzFilename ¶
func RuntimeTgzFilename() string
RuntimeTgzFilename returns the platform-specific tgz filename.
func RuntimeTgzMirrors ¶
func RuntimeTgzMirrors() []string
RuntimeTgzMirrors returns CDN mirror URLs for the ONNX Runtime tgz.
func RuntimeTgzURL ¶
func RuntimeTgzURL() string
RuntimeTgzURL returns the primary GitHub URL for the ONNX Runtime tgz.
func SetDataDir ¶
func SetDataDir(dataDir string)
SetDataDir provides a hint for where to find the ONNX Runtime library. Must be called before the first session creation.
func SetLibraryPath ¶
func SetLibraryPath(path string)
SetLibraryPath sets the ONNX Runtime shared library path. Must be called before any session creation.
Types ¶
type DynamicSession ¶
type DynamicSession struct {
*ort.DynamicAdvancedSession
}
DynamicSession wraps ort.DynamicAdvancedSession with common lifecycle management. Use this for models with variable input shapes (like TTS).
func NewDynamicSession ¶
func NewDynamicSession(modelPath string, inputNames, outputNames []string) (*DynamicSession, error)
NewDynamicSession creates a new ONNX session for dynamic tensor inputs. Use this for models with variable input shapes (like TTS).
func (*DynamicSession) Close ¶
func (s *DynamicSession) Close() error
Close destroys the session and releases resources.
type Session ¶
type Session struct {
*ort.AdvancedSession
}
Session wraps ort.AdvancedSession with common lifecycle management. Use this for models with fixed input/output shapes (like pruner).
func NewSession ¶
func NewSession(modelPath string, inputNames, outputNames []string, inputs, outputs []ort.ArbitraryTensor) (*Session, error)
NewSession creates a new ONNX session with pre-allocated tensors. Use this for models with fixed input/output shapes (like pruner).