graft

module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2024 License: Apache-2.0

README

Graft

tensorflow version build go.dev reference

About

Go language bindings to the TensorFlow C API

Graft contains nightly and release builds of the Go language bindings to the TensorFlow C API, including Go-compiled TensorFlow protocol buffers and generated Go wrappers for TensorFlow operations.

Use Graft exactly as you would use the Go bindings found in the main TensorFlow repo, and with the following import statement: github.com/wamuir/graft/tensorflow

Getting Started

Note: the Go bindings depend on libtensorflow, which should be downloaded (or compiled) and installed first.

Installation is performed using go get:

go get -u github.com/wamuir/graft/tensorflow/...
Hello TensorFlow
package main

import (
	tf "github.com/wamuir/graft/tensorflow"
	"github.com/wamuir/graft/tensorflow/op"
	"fmt"
)

func main() {
	// Construct a graph with an operation that produces a string constant.
	s := op.NewScope()
	c := op.Const(s, "Hello from TensorFlow version " + tf.Version())
	graph, err := s.Finalize()
	if err != nil {
		panic(err)
	}

	// Execute the graph in a session.
	sess, err := tf.NewSession(graph, nil)
	if err != nil {
		panic(err)
	}
	output, err := sess.Run(nil, []tf.Output{c}, nil)
	if err != nil {
		panic(err)
	}
	fmt.Println(output[0].Value())
}

Credits

Graft is a compilation of TensorFlow source code.

Directories

Path Synopsis
Package tensorflow is a Go binding to TensorFlow.
Package tensorflow is a Go binding to TensorFlow.
op
Package op defines functions for adding TensorFlow operations to a Graph.
Package op defines functions for adding TensorFlow operations to a Graph.
tools
genop
Command genop generates a Go source file with functions for TensorFlow ops.
Command genop generates a Go source file with functions for TensorFlow ops.
genop/internal
Package internal generates Go source code with functions for TensorFlow operations.
Package internal generates Go source code with functions for TensorFlow operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL