diff --git a/.gitignore b/.gitignore
index 20d3f2e..7b86101 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,4 @@ libtch/fake_cuda_dependency.cpp.cpu
libtch/lib.go.cpu
libtch/lib.go
+.ipynb_checkpoints
diff --git a/example/basic/.ipynb_checkpoints/gotch_basic-checkpoint.ipynb b/example/basic/.ipynb_checkpoints/gotch_basic-checkpoint.ipynb
deleted file mode 100644
index df4105b..0000000
--- a/example/basic/.ipynb_checkpoints/gotch_basic-checkpoint.ipynb
+++ /dev/null
@@ -1,266 +0,0 @@
-{
- "nbformat": 4,
- "nbformat_minor": 0,
- "metadata": {
- "accelerator": "GPU",
- "colab": {
- "name": "gotch-basic.ipynb",
- "provenance": [],
- "collapsed_sections": [
- "fsitX3NbLbTB",
- "l6aOKEMarRNH"
- ],
- "toc_visible": true,
- "include_colab_link": true
- },
- "kernelspec": {
- "display_name": "Go",
- "name": "gophernotes"
- }
- },
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "view-in-github",
- "colab_type": "text"
- },
- "source": [
- "
"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "dkq9izrfMXPV"
- },
- "source": [
- "# GoTch (Pytorch C++ APIs Go Binding) - Basic Tensor\n",
- "\n",
- "This notebook using\n",
- "\n",
- "1. [GoTch - Pytorch C++ APIs Go bindind](https://github.com/sugarme/gotch)\n",
- "2. [GopherNotes - Jupyter Notebook Go kernel](https://github.com/gopherdata/gophernotes)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "fsitX3NbLbTB"
- },
- "source": [
- "## Install Go kernel - GopherNotes\n",
- "\n",
- "*NOTE: refresh/reload (browser) after this step.*"
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "caT1iMfshw62",
- "outputId": "7a00b47e-a949-4998-9dc5-bdebaab0cb8d",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "# run this cell first time using python runtime\n",
- "!add-apt-repository ppa:longsleep/golang-backports -y > /dev/null\n",
- "!apt update > /dev/null \n",
- "!apt install golang-go > /dev/null\n",
- "%env GOPATH=/root/go\n",
- "!go get -u github.com/gopherdata/gophernotes\n",
- "!cp ~/go/bin/gophernotes /usr/bin/\n",
- "!mkdir /usr/local/share/jupyter/kernels/gophernotes\n",
- "!cp ~/go/src/github.com/gopherdata/gophernotes/kernel/* \\\n",
- " /usr/local/share/jupyter/kernels/gophernotes\n",
- "# then refresh (browser), it will now use gophernotes. Skip to golang in later cells"
- ],
- "execution_count": null,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "\n",
- "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
- "\n",
- "\n",
- "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n",
- "\n",
- "env: GOPATH=/root/go\n"
- ],
- "name": "stdout"
- }
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "l6aOKEMarRNH"
- },
- "source": [
- "## Install Pytorch C++ APIs and Go binding - GoTch\n",
- "\n",
- "NOTE: `ldconfig` (GLIBC) current version 2.27 is currently broken when linking Libtorch library\n",
- "\n",
- "see issue: https://discuss.pytorch.org/libtorch-c-so-files-truncated-error-when-ldconfig/46404/6\n",
- "\n",
- "Google Colab default settings:\n",
- "```bash\n",
- "LD_LIBRARY_PATH=/usr/lib64-nvidia\n",
- "LIBRARY_PATH=/usr/local/cuda/lib64/stubs\n",
- "```\n",
- "We copy directly `libtorch/lib` to those paths as a hacky way. "
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "0N_jGbVft2Y7",
- "outputId": "3ba03769-5bb0-4026-f8dc-c1929f4b88f2",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "$wget -q --show-progress --progress=bar:force:noscroll -O /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip https://download.pytorch.org/libtorch/cu101/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip\n",
- "$unzip -qq /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip -d /usr/local\n",
- "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/lib64-nvidia/\n",
- "$unzip -qq -j /tmp/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcu101.zip libtorch/lib/* -d /usr/local/cuda/lib64/stubs/"
- ],
- "execution_count": 1,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "/tmp/libtorch-cxx11 99%[==================> ] 758.53M 68.1MB/s eta 0s "
- ],
- "name": "stderr"
- }
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "dVo3An-pGzFE"
- },
- "source": [
- "import(\"os\")\n",
- "os.Setenv(\"CPATH\", \"usr/local/libtorch/lib:/usr/local/libtorch/include:/usr/local/libtorch/include/torch/csrc/api/include\")"
- ],
- "execution_count": 2,
- "outputs": []
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "x_9y6CpZGlPJ",
- "outputId": "465bc1e8-fcbc-44d5-cf5f-0ed8e61bc7b9",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "$rm -f -- go.mod\n",
- "$go mod init github.com/sugarme/playgo\n",
- "$go get github.com/sugarme/gotch@v0.3.2"
- ],
- "execution_count": 3,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "go: creating new go.mod: module github.com/sugarme/playgo\n",
- "go: downloading github.com/sugarme/gotch v0.3.2\n"
- ],
- "name": "stderr"
- }
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "0obqcV4KW013"
- },
- "source": [
- "import(\n",
- " \"fmt\"\n",
- "\n",
- " \"github.com/sugarme/gotch\"\n",
- " ts \"github.com/sugarme/gotch/tensor\"\n",
- ") "
- ],
- "execution_count": null,
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "id": "9fL6QTwbT7kX"
- },
- "source": [
- "## Basic Tensor Operations"
- ]
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "YkLmNrswJHYY",
- "outputId": "1b4c7ac8-17a3-4f66-b295-e3cd3d8ac669",
- "colab": {
- "base_uri": "https://localhost:8080/"
- }
- },
- "source": [
- "device := gotch.NewCuda().CudaIfAvailable()\n",
- "ts1, err := ts.Rand([]int64{3, 4, 5}, gotch.Double, device)\n",
- "if err != nil {fmt.Print(err)}\n",
- "ts2, err := ts.Ones([]int64{5, 3}, gotch.Double, device)\n",
- "if err != nil { fmt.Print(err)}\n",
- "\n",
- "mul, err := ts1.Matmul(ts2, false)\n",
- "if err != nil { fmt.Print(err)}\n",
- "fmt.Printf(\"%.3f\", mul)"
- ],
- "execution_count": 4,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "(1,.,.) =\n",
- "1.372 1.372 1.372 \n",
- "2.774 2.774 2.774 \n",
- "4.150 4.150 4.150 \n",
- "2.442 2.442 2.442 \n",
- "\n",
- "(2,.,.) =\n",
- "1.935 1.935 1.935 \n",
- "2.622 2.622 2.622 \n",
- "2.797 2.797 2.797 \n",
- "2.602 2.602 2.602 \n",
- "\n",
- "(3,.,.) =\n",
- "2.419 2.419 2.419 \n",
- "1.901 1.901 1.901 \n",
- "2.795 2.795 2.795 \n",
- "2.387 2.387 2.387 \n",
- "\n"
- ],
- "name": "stdout"
- },
- {
- "output_type": "execute_result",
- "data": {
- "text/plain": [
- "297 "
- ]
- },
- "metadata": {
- "tags": []
- },
- "execution_count": 4
- }
- ]
- }
- ]
-}
\ No newline at end of file