- Install a recent version of Go (see All Releases)
- Install
ccgxusing the following command:(if$ GOBIN=<target folder> go install github.com/gx-org/ccgx@latestGOBINis not specified, the default is~/go/bin/ccgx) - Install gopjrt, the XLA backend used by GX:
Note that
$ export GOPJRT_NOSUDO=true $ export GOPJRT_INSTALL_DIR=$HOME/gopjrtbin $ export CGO_CFLAGS="-I $GOPJRT_INSTALL_DIR/include" $ export LD_LIBRARY_PATH=$GOPJRT_INSTALL_DIR/lib $ curl -sSf https://raw.githubusercontent.com/gomlx/gopjrt/main/cmd/install_linux_amd64.sh | bashGOPJRT_INSTALL_DIRis going to be used later inCMakeLists.txt.
This example explains how to run the example in ccgx/examples/helloworld.
- Create the project folder:
$ mkdir helloworld $ cd helloworld - Create a minimal
helloworld.gxfile such as:Note thepackage helloworld import _ "github.com/gx-org/xlapjrt/gx" // Hello returns a constant array of two axes of size 2 and 3. func Hello() [2][3]float32 { return [2][3]float32{ {1, 2, 3}, {4, 5, 6}, } }
importwhich adds a dependency to the XLA backend. See ccgx/examples/helloworld/helloworld.gx as a reference. - Run the following command to create
go.modandgo.sum:These files manage all the dependencies of the project and their versions for reproducable builds. After new dependencies are added or removed in GX source files, run:$ ccgx mod init helloworldto update$ ccgx mod tidygo.modfrom the latest imports in the GX source files. - Run the following command to generate a corresponding C++ source and header files:
The files are generated in the
$ ccgx bind --cmakegxdepsfolder. - Create the C++ file helloworld.cc and its CMakeLists.txt
- Compile and run the project with
cmake:$ mkdir build $ cd build $ cmake .. $ make $ ./helloworld
This is not an official Google DeepMind product (experimental or otherwise), it is just code that happens to be owned by Google-DeepMind. GX is experimental and work in progress. As of today, we do not consider any part of the language as stable. Breaking changes will happen on a regular basis.
You are welcome to send PR or to report bugs. We will do our best to answer but there is no guarantee that you will get a response.