mirror of
https://github.com/yalue/onnxruntime_go.git
synced 2025-10-05 07:06:51 +08:00
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.
This commit is contained in:
38
onnx_example_application/onnx_example_application.go
Normal file
38
onnx_example_application/onnx_example_application.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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())
|
||||
}
|
Reference in New Issue
Block a user