Files
onnxruntime_go/onnx_example_application/onnx_example_application.go
yalue 75e3434f7e Initial commit
- Sets up the onnxruntime environment, but doesn't load or run networks
   yet.

 - The things builds and run on Windows.

 - Still working on getting the Linux (arm64 for now) test to work.
2023-01-28 13:49:33 -05:00

39 lines
1.0 KiB
Go

// This application loads a test ONNX network and executes it on some fixed
// data. It serves as an example of how to use the onnxruntime wrapper library.
package main
import (
"fmt"
"github.com/yalue/onnxruntime"
"os"
"runtime"
)
func run() int {
if runtime.GOOS == "windows" {
onnxruntime.SetSharedLibraryPath("../test_data/onnxruntime.dll")
} else {
onnxruntime.SetSharedLibraryPath("../test_data/onnxruntime.so")
}
e := onnxruntime.InitializeEnvironment()
if e != nil {
fmt.Printf("Error initializing the onnxruntime environment: %s\n", e)
return 1
}
fmt.Printf("The onnxruntime environment initialized OK.\n")
// Ordinarily, it is probably fine to call this using defer, but we do it
// here just so we can print a status message after the cleanup completes.
e = onnxruntime.CleanupEnvironment()
if e != nil {
fmt.Printf("Error cleaning up the environment: %s\n", e)
return 1
}
fmt.Printf("The onnxruntime environment was cleaned up OK.\n")
return 0
}
func main() {
os.Exit(run())
}