{"id":15160162,"url":"https://github.com/unity-technologies/go-tensorgen","last_synced_at":"2025-10-19T07:32:04.760Z","repository":{"id":66531589,"uuid":"256485927","full_name":"Unity-Technologies/go-tensorgen","owner":"Unity-Technologies","description":"Lightweight tool that generates Go structures and Tensorflow inference execution code from SavedModel","archived":false,"fork":false,"pushed_at":"2020-04-27T17:53:53.000Z","size":421,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-29T10:37:10.426Z","etag":null,"topics":["cgo","codegen","codegenerator","go","golang","savedmodel","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Unity-Technologies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-17T11:36:42.000Z","updated_at":"2023-06-14T14:45:19.000Z","dependencies_parsed_at":"2023-03-17T22:01:23.216Z","dependency_job_id":null,"html_url":"https://github.com/Unity-Technologies/go-tensorgen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2Fgo-tensorgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2Fgo-tensorgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2Fgo-tensorgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Unity-Technologies%2Fgo-tensorgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Unity-Technologies","download_url":"https://codeload.github.com/Unity-Technologies/go-tensorgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237088579,"owners_count":19253570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgo","codegen","codegenerator","go","golang","savedmodel","tensorflow"],"created_at":"2024-09-26T22:22:58.079Z","updated_at":"2025-10-19T07:32:04.246Z","avatar_url":"https://github.com/Unity-Technologies.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/Unity-Technologies/go-tensorgen)](https://goreportcard.com/report/github.com/Unity-Technologies/go-tensorgen)\n\n# Tensorgen\n\nLightweight tool that generates Go structures and [Tensorflow](https://www.tensorflow.org/) inference execution code from [SavedModel](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md).\nThe tool is designed to save the developer from the headache of tensors construction when working with Tensorflow from Go.\n\n# Usage\n\nThere are two steps that you need to perform to use this tool:\n* Generate Go code from `SavedModel`.\n* Perform model execution using generated code.\n\n## Code Generating\n\nThe simplest way is to use Docker image that has `libtensorflow` dependencies inside. But if you have `libtensorflow` locally — sky is the limit.\n\n### With Docker\n\nTBD\n\n### Without Docker\n\nTo run Go code `libtensorflow` must be available as dynamic library. It means that `.so` and `.h` files, compatible with used version of [tensorflow/go](https://pkg.go.dev/github.com/tensorflow/tensorflow/tensorflow/go) package, must be provided. More info: [Install TensorFlow for C](https://www.tensorflow.org/install/lang_c)\n\nInstall tool with `go get`\n```\ngo get -u github.com/Unity-Technologies/go-tensorgen\n```\n\nExec `go-tensorgen` with defined SavedModel files directory and output dir, where generated code will be placed.\n```\ngo-tensorgen -model-dir=./savedmodel -output-dir=./mymodel\n```\n\n## Inference execution\n\nFor each available [signature](https://www.tensorflow.org/tfx/serving/signature_defs) separate \"Runner\" will be generated. You can find example, how to use it, below.\n\n```go\nimport (\n\t\"github.com/user/project/mymodel\"\n\ttf \"github.com/tensorflow/tensorflow/tensorflow/go\"\n)\n\ndir := \"./savedmodel\"\nmetaGraph := \"serve\"\nmodel, err := tf.LoadSavedModel(dir, []string{metaGraph}, \u0026tf.SessionOptions{})\nif err != nil { ... }\n\nrunner := mymodel.NewSignatureRunner(model.Graph, model.Session)\n\nerr = runner.LoadOperations()\nif err != nil { ... }\n\nreq := mymodel.SignatureRequest{\n\tFeature: []float32{0.5},\n}\n\nresp, err := runner.Run(ctx, req)\nif err != nil { ... }\n\n// resp - is ready to use go struct\n```\n\n# TODO:\n\n* [ ] Prepare Docker image that includes `libtensorflow`.\n* [ ] Explain how to use binary distributions of `libtensorflow` for local development\n\n# Contributing\n\nPull requests are very much welcomed. Create your pull request, make sure a test or example is included that covers your change and\nyour commits represent coherent changes that include a reason for the change.\n\nUse [golangci-lint](https://github.com/golangci/golangci-lint) to check code with linters:\n```\ngolangci-lint run ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-technologies%2Fgo-tensorgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funity-technologies%2Fgo-tensorgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-technologies%2Fgo-tensorgen/lists"}