
Ellipse: Something between PyTorch, karpathy/micrograd and XLA. Maintained by nileAGI.
This guide assumes you have no prior knowledge of C, C++, PyTorch or any other language or deep learning framework.
First you have to download ellipse library from GitHub.
git clone https://github.com/oderoi/ellipse.gitThen create a working directory in your machine/Laptop folder, open ellipse and copy ellipse.h and paste it in your folder you created. Then create a new_file that you will use to code your project.
Then open the new_file in your favorite code editor and start to code.
Start by importing the library.
#include "ellipse.h"Now you are set.
Tensors are the base data structure in ellipse. They are like multi-dimensional array of a specific data type. All higher-level operations in ellipse operate on these tensors.
Tensor can be created from existing data.
Tensor * t1 = tensor((float[]){1, 2, 3, 4, 5, 6}, FLOAT32, (int[]){2, 3}, true);So you might being asking yourself what the heck is that, don't sweat, let's see what the hell is that, and will start by looking one part after the other.
Tensor type multidimensional array like.(float[]){1, 2, 3, 4, 5, 6}: this is the data itself that Tensor * t1 carries and (float[]) is the data type of the array, while the array itself is 1, 2, 3, 4, 5, 6.FLOAT32: this is the Tensor data type, which is supposed to be the same as (float[]).(int[]){2, 3}: is the array dimension. As well here (int[]) is the data type of the dimension array (and Yes, I just say array again, because array data and dimension are both represented using array) and the dimension itself is 2, 3.true: this boolean tell us that this Tensor will carry gradients of it's variable, during back propagation. So it might be true or false, depending on whether you want to calculate gradient correspond of the Tensor.Tensor *x = tensor((int[]){1,2,3,4}, INT, (int[]){2, 2}, false);
print(x);Run
gcc nameOfFile.c -lm
./a.outoutput
Tensor {
dtype: int
dims: [2, 2]
data: [[1, 2],
[3, 4]]
}Tensor *y = tensor((float[]){1,2,3,4,5,6}, FLOAT32, (int[]){3, 2}, true);
print(y);Run
gcc nameOfFile.c -lm
./a.outoutput
Tensor {
dtype: float32
dims: [3, 2]
data: [[1.0000, 2.0000],
[3.0000, 4.0000],
[5.0000, 6.0000]]
grads: [[0.0000e+00, 0.0000e+00],
[0.0000e+00, 0.0000e+00],
[0.0000e+00, 0.0000e+00]]
}Tensor *x = tensor((double[]){1,2,3,4,5,6,7,8}, FLOAT64, (int[]){2, 4}, true);
print(x);Run
gcc nameOfFile.c -lm
./a.outoutput
Tensor {
dtype: float64
dims: [2, 4]
data: [[1.0000, 2.0000, 3.0000, 4.0000],
[5.0000, 6.0000, 7.0000, 8.0000]]
grads: [[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00],
[0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]]
}