mirror of
				https://github.com/yalue/onnxruntime_go.git
				synced 2025-10-31 10:46:24 +08:00 
			
		
		
		
	 ff910beb76
			
		
	
	ff910beb76
	
	
	
		
			
			- There is now a wrapper to create generic Tensor objects in Go, that should be appropriately backed by the onnxruntime. - Did some minor tests. - Still to do: update the example, and put together a nice API that uses the tensors.
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.1 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 {
 | |
| 		if runtime.GOARCH == "arm64" {
 | |
| 			onnxruntime.SetSharedLibraryPath("../test_data/onnxruntime_arm64.so")
 | |
| 		} 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())
 | |
| }
 |