Skip to content

carck/onnx-runtime-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Go binding for onnx runtime, only support 1 input and 1 output in current phase

Build

  • export CGO_CFLAGS=-I/source/onnxruntime-osx/include
  • export CGO_LDFLAGS=-L/source/onnxruntime-osx/lib

Example

package main

import (
	"github.com/carck/onnx-runtime-go"
	"log"
)

func main() {
	shape := []int64{1, 3, 112, 112}
	inputNames := []string{"input.1"}
	outputNames := []string{"683"}
	model := onnx.NewModel("facenet.onnx", shape, inputNames, outputNames, onnx.CPU)
	defer model.Delete()

	data := make([]float32, 1*3*112*112)
	output := model.RunInference(data)
	defer output.Delete()

	log.Println("num dims: %s", output.NumDims())
	log.Println("dim1: %s", output.Dim(1))
	
	res := make([]float32, 512)
	output.CopyToBuffer(res, 512*4)
	fmt.Printf("%v", res)
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published