Skip to content

Commit

Permalink
Merge pull request #569 from gizatechxyz/develop
Browse files Browse the repository at this point in the history
Merge Develop into Main
  • Loading branch information
raphaelDkhn authored Feb 11, 2024
2 parents 8ff7389 + 4d4be27 commit 185c1a8
Show file tree
Hide file tree
Showing 718 changed files with 29,880 additions and 915 deletions.
17 changes: 17 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@
"contributions": [
"code"
]
},
{
"login": "tekkac",
"name": "Trunks @ Carbonable",
"avatar_url": "https://avatars.githubusercontent.com/u/98529704?v=4",
"profile": "https://github.com/tekkac",
"contributions": [
"doc"
],
},
"login": "canacechan",
"name": "canacechan",
"avatar_url": "https://avatars.githubusercontent.com/u/127183619?v=4",
"profile": "https://github.com/canacechan",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.4.0"
scarb-version: "2.5.3"
- run: scarb test --workspace && scarb fmt --workspace
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 2.4.0
scarb 2.5.3
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# Orion: An Open-source Framework for Validity and ZK ML ✨
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-29-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-30-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Orion is an open-source, community-driven framework dedicated to Provable Machine Learning. It provides essential components and a new ONNX runtime for building verifiable Machine Learning models using [STARKs](https://starkware.co/stark/).
Expand All @@ -47,7 +47,7 @@ Join the community and help build a safer and transparent AI in our [Discord](ht

## 🚀 Orion Usage
- For an insightful overview of impressive proof of concepts, models, and tutorials created by our community, please visit [Orion Usage](https://github.com/gizatechxyz/orion/blob/main/orion-usage.md).
- Discover a currated list of tutorials and models developed using Orion in [Orion-Hub](https://github.com/gizatechxyz/Orion-Hub).
- Discover a curated list of tutorials and models developed using Orion in [Orion-Hub](https://github.com/gizatechxyz/Orion-Hub).

## ✍️ Authors & contributors

Expand Down Expand Up @@ -106,6 +106,8 @@ Thanks goes to these wonderful people:
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Vid201"><img src="https://avatars.githubusercontent.com/u/38610409?v=4?s=100" width="100px;" alt="Vid Kersic"/><br /><sub><b>Vid Kersic</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=Vid201" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tekkac"><img src="https://avatars.githubusercontent.com/u/98529704?v=4?s=100" width="100px;" alt="Trunks @ Carbonable"/><br /><sub><b>Trunks @ Carbonable</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=tekkac" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/canacechan"><img src="https://avatars.githubusercontent.com/u/127183619?v=4?s=100" width="100px;" alt="canacechan"/><br /><sub><b>canacechan</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=canacechan" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
10 changes: 5 additions & 5 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "orion"
version = "0.2.1"
cairo-version = "2.4.0"
version = "0.2.3"
cairo-version = "2.5.3"
edition = "2023_10"
description = "ONNX Runtime in Cairo for verifiable ML inference using STARK"
homepage = "https://github.com/gizatechxyz/orion"

[dependencies]
alexandria_merkle_tree = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "01a7690" }
alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "01a7690" }
alexandria_sorting = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "01a7690" }
alexandria_merkle_tree = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "800f5ad" }
alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "800f5ad" }
alexandria_sorting = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "800f5ad" }
cubit = { git = "https://github.com/influenceth/cubit.git", rev = "6275608" }

[scripts]
Expand Down
8 changes: 8 additions & 0 deletions docgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ fn main() {
let trait_name: &str = "SVMRegressorTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// SVM CLASSIFIER DOC
let trait_path = "src/operators/ml/svm/svm_classifier.cairo";
let doc_path = "docs/framework/operators/machine-learning/svm-classifier";
let label = "svm_classifier";
let trait_name: &str = "SVMClassifierTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);
}

fn doc_trait(trait_path: &str, doc_path: &str, label: &str) {
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] - 2024-01-17

## Added
- Scatter Nd Operator.
-
## [Unreleased] - 2023-12-25

## Added
Expand Down
20 changes: 19 additions & 1 deletion docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,17 @@
* [tensor.reduce\_log\_sum](framework/operators/tensor/tensor.reduce\_log\_sum.md)
* [tensor.unique](framework/operators/tensor/tensor.unique.md)
* [tensor.compress](framework/operators/tensor/tensor.compress.md)
* [tensor.layer\_normalization](framework/operators/tensor/tensor.layer\_normalization.md)
* [tensor.layer_normalization](framework/operators/tensor/tensor.layer_normalization.md)
* [tensor.scatter\_nd](framework/operators/tensor/tensor.scatter\_nd.md)
* [tensor.dynamic_quantize_linear](framework/operators/tensor/tensor.dequantize_linear.md)
* [tensor.optional](framework/operators/tensor/tensor.optional.md)
* [tensor.reverse_sequence](framework/operators/tensor/tensor.reverse_sequence.md)
* [tensor.split_to_sequence](framework/operators/tensor/tensor.split_to_sequence.md)
* [tensor.range](framework/operators/tensor/tensor.range.md)
* [tensor.hann_window](framework/operators/tensor/tensor.hann_window.md)
* [tensor.hamming_window](framework/operators/tensor/tensor.hamming_window.md)
* [tensor.blackman_window](framework/operators/tensor/tensor.blackman_window.md)
* [tensor.random_uniform_like](framework/operators/tensor/tensor.random_uniform_like.md)
* [Neural Network](framework/operators/neural-network/README.md)
* [nn.relu](framework/operators/neural-network/nn.relu.md)
* [nn.leaky\_relu](framework/operators/neural-network/nn.leaky\_relu.md)
Expand All @@ -160,6 +170,12 @@
* [nn.hard\_sigmoid](framework/operators/neural-network/nn.hard\_sigmoid.md)
* [nn.thresholded\_relu](framework/operators/neural-network/nn.thresholded\_relu.md)
* [nn.gemm](framework/operators/neural-network/nn.gemm.md)
* [nn.grid\_sample](framework/operators/neural-network/nn.grid\_sample.md)
* [nn.col2im](framework/operators/neural-network/nn.col2im.md)
* [nn.conv_transpose](framework/operators/neural-network/nn.conv\_transpose.md)
* [nn.conv](framework/operators/neural-network/nn.conv.md)
* [nn.depth_to_space](framework/operators/neural-network/nn.depth_to_space.md)
* [nn.space_to_depth](framework/operators/neural-network/nn.space_to_depth.md)
* [Machine Learning](framework/operators/machine-learning/README.md)
* [Tree Ensemble Classifier](framework/operators/machine-learning/tree-ensemble-classifier/README.md)
* [tree\_ensemble\_classifier.predict](framework/operators/machine-learning/tree-ensemble-classifier/tree\_ensemble\_classifier.predict.md)
Expand All @@ -171,6 +187,8 @@
* [linear\_regressor.predict](framework/operators/machine-learning/linear-regressor/linear\_regressor.predict.md)
* [SVM Regressor](framework/operators/machine-learning/svm-regressor/README.md)
* [svm\_regressor.predict](framework/operators/machine-learning/svm-regressor/svm\_regressor.predict.md)
* [SVM Classifier](framework/operators/machine-learning/svm-classifier/README.md)
* [svm\_classifier.predict](framework/operators/machine-learning/svm-classifier/svm\_classifier.predict.md)
* [Sequence](framework/operators/sequence/README.md)
* [sequence.sequence\_construct](framework/operators/sequence/sequence.sequence\_construct.md)
* [sequence.sequence\_empty](framework/operators/sequence/sequence.sequence\_empty.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ fn normalize_label_data(tensor_data: Tensor<FP16x16>) -> Tensor<FP16x16> {
normalized_array.append(diff / range);
i += 1;
},
Option::None(_) => { break; }
Option::None => { break; }
};
};
// convert normalized array values to tensor format
Expand Down Expand Up @@ -619,7 +619,7 @@ fn add_bias_term(x_feature: Tensor<FP16x16>, axis: u32) -> Tensor<FP16x16> {
result.append(*x_val);
j += 1;
},
Option::None(_) => { break; }
Option::None => { break; }
};
};
result.append(FixedTrait::new(65536, false)); //65536=ONE in FP16x16, change accordingly
Expand Down Expand Up @@ -855,7 +855,7 @@ fn calculate_r_score(Y_values: Tensor<FP16x16>, Y_pred_values: Tensor<FP16x16>)
squared_mean_diff_vals.append(squared_mean_diff);
i += 1;
},
Option::None(_) => { break; }
Option::None => { break; }
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $$

#### Generating the dataset

In the following [notebook](https://github.com/gizatechxyz/orion\_tutorials/tree/main/verifiable\_linear\_regression\_model), we will create a synthetic dataset that will serve as the backbone throughout our tutorial.
In the following [notebook](https://github.com/gizatechxyz/orion\_tutorials/tree/main/basic/verifiable\_linear\_regression\_model), we will create a synthetic dataset that will serve as the backbone throughout our tutorial.

```python
import numpy as np
Expand Down Expand Up @@ -152,7 +152,7 @@ test = "scarb cairo-test -f linear_regression_test"

```

#### Gerating the dataset in Cairo
#### Generating the dataset in Cairo

Now let’s generate the files required to begin our transition to Cairo. In our Jupyter Notebook, we will execute the code required to turn our synthetic dataset to fixed point values and represent our X and y values as Fixedpoint Tensors in Orion.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ version = "0.1.0"
orion = { git = "https://github.com/gizatechxyz/orion.git", rev = "v0.1.7" }
```

#### Gerating the dataset in Cairo
#### Generating the dataset in Cairo

Now let's generate the necessary files to begin our transition to Cairo. In our Jupyter Notebook, we will run the necessary code to convert our iris dataset obtained from sklearn.datasets into fixed point values and represent our X, and y values as fixed point tensors in Orion. For the purposes of the tutorial, we will work directly with the Xstd data obtained from python, so we will also convert these to fixed point values.

Expand Down Expand Up @@ -443,7 +443,7 @@ fn div_by_scalar(self: @Tensor<FP16x16>, divisor: u32) -> Tensor<FP16x16> {
Option::Some(elem) => {
data_array.append(FixedTrait::new(*elem.mag / divisor, *elem.sign));
},
Option::None(_) => {
Option::None => {
break TensorTrait::<FP16x16>::new((*self).shape, data_array.span());
}
};
Expand All @@ -457,7 +457,7 @@ fn div_by_fp(self: @Tensor<FP16x16>, divisor: FP16x16) -> Tensor<FP16x16> {
loop {
match data.pop_front() {
Option::Some(elem) => { data_array.append(FP16x16Div::div(*elem, divisor)); },
Option::None(_) => {
Option::None => {
break TensorTrait::<FP16x16>::new((*self).shape, data_array.span());
}
};
Expand Down Expand Up @@ -618,7 +618,7 @@ fn extract_diagonal(self: @Tensor<FP16x16>) -> Tensor<FP16x16> {
Option::Some(elem) => { if x == y {
data_array.append(*elem);
}; },
Option::None(_) => { break; }
Option::None => { break; }
};
y += 1;
};
Expand Down Expand Up @@ -672,7 +672,7 @@ fn update_eigen_values(
y += 1;
index += 1;
},
Option::None(_) => { break; }
Option::None => { break; }
};
};
Expand Down
10 changes: 5 additions & 5 deletions docs/academy/tutorials/verifiable-support-vector-machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<figure><img src="../../.gitbook/assets/orion_banner_tutorial_#4.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Repository and Notebooks can be found [here](https://github.com/gizatechxyz/orion\_tutorials/tree/main/verifiable\_support\_vector\_machine).
Repository and Notebooks can be found [here](https://github.com/gizatechxyz/orion_tutorials/tree/main/basic/verifiable_support_vector_machine).
{% endhint %}

The Support Vector Machines (SVM) model is a supervised learning technique used for classification and regression. It is employed to solve binary classification problems where it identifies the hyperplane that best divides a data set into classes. This hyperplane results from maximizing the margin between the two classes. By determining this optimal hyperplane, predictions can be made for new data points and understand how the input attributes influence classification.
Expand Down Expand Up @@ -177,7 +177,7 @@ version = "0.1.0"
orion = { git = "https://github.com/gizatechxyz/orion.git", rev = "v0.1.0" }
```

### Gerating the dataset in Cairo
### Generating the dataset in Cairo

Now let's generate the necessary files to begin our transition to Cairo. In our Jupyter Notebook, we'll run the necessary code to convert our dataset obtained with make\_blobs from Scikit-learn into fixed-point values and represent our X\_train, y\_train, X\_test, and y\_test values as fixed-point tensors in Orion.

Expand Down Expand Up @@ -363,7 +363,7 @@ fn accuracy(y: @Tensor<FP16x16>, z: @Tensor<FP16x16>) -> FP16x16 {
counter += 1;
};
},
Option::None(_) => {
Option::None => {
break;
}
};
Expand Down Expand Up @@ -407,7 +407,7 @@ fn less(y: @Tensor<FP16x16>, z: @Tensor<FP16x16>) -> Tensor<FP16x16> {

smaller_index = (1 + smaller_index) % smaller_data.len();
},
Option::None(_) => {
Option::None => {
break;
}
};
Expand All @@ -431,7 +431,7 @@ fn sign(z: @Tensor<FP16x16>) -> Tensor<FP16x16> {
};
data_result.append(result);
},
Option::None(_) => {
Option::None => {
break;
}
};
Expand Down
28 changes: 22 additions & 6 deletions docs/framework/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ You can see below the list of current supported ONNX Operators:
| [ThresholdedRelu](operators/neural-network/nn.thresholded\_relu.md) | :white\_check\_mark: |
| [Sigmoid](operators/neural-network/nn.sigmoid.md) | :white\_check\_mark: |
| [Softmax](operators/neural-network/nn.softmax.md) | :white\_check\_mark: |
| [Softmax_zero](operators/neural-network/nn.softmax_zero.md) | :white\_check\_mark: |
| [Softmax_zero](operators/neural-network/nn.softmax_zero.md) | :white\_check\_mark: |
| [LogSoftmax](operators/neural-network/nn.logsoftmax.md) | :white\_check\_mark: |
| [Softsign](operators/neural-network/nn.softsign.md) | :white\_check\_mark: |
| [Softplus](operators/neural-network/nn.softplus.md) | :white\_check\_mark: |
| [Linear](operators/neural-network/nn.linear.md) | :white\_check\_mark: |
| [HardSigmoid](operators/neural-network/nn.hard\_sigmoid.md) | :white\_check\_mark: |
| [GridSample](operators/neural-network/nn.grid\_sample_.md) | :white\_check\_mark: |
| [Col2im](operators/neural-network/nn.col2im\_sigmoid.md) | :white\_check\_mark: |
| [ConvTranspose](operators/neural-network/nn.conv\_transpose_.md) | :white\_check\_mark: |
| [Conv](operators/neural-network/nn.conv.md) | :white\_check\_mark: |
| [Sinh](operators/tensor/tensor.sinh.md) | :white\_check\_mark: |
| [Asinh](operators/tensor/tensor.asinh.md) | :white\_check\_mark: |
| [Atanh](operators/tensor/tensor.atanh.md) | :white\_check\_mark: |
Expand Down Expand Up @@ -103,10 +107,22 @@ You can see below the list of current supported ONNX Operators:
| [IsNaN](operators/tensor/tensor.is\_nan.md) | :white\_check\_mark: |
| [IsInf](operators/tensor/tensor.is\_inf.md) | :white\_check\_mark: |
| [Not](operators/tensor/tensor.not.md) | :white\_check\_mark: |
| [GatherND](operators/tensor/tensor.gather/_nd.md) | :white\_check\_mark: |
| [ReduceLogSum](operators/tensor/tensor.reduce\_log\_sum.md) | :white\_check\_mark: |
| [Erf](operators/tensor/tensor.erf.md) | :white\_check\_mark: |
| [Compress](operators/tensor/tensor.compress.md) | :white\_check\_mark: |
| [GatherND](operators/tensor/tensor.gather/_nd.md) | :white\_check\_mark: |
| [ReduceLogSum](operators/tensor/tensor.reduce\_log\_sum.md) | :white\_check\_mark: |
| [Erf](operators/tensor/tensor.erf.md) | :white\_check\_mark: |
| [Compress](operators/tensor/tensor.compress.md) | :white\_check\_mark: |
| [Layer_normalization](operators/tensor/tensor.layer_normalization.md) | :white\_check\_mark: |
| [ScatterND](operators/tensor/tensor.scatter/_nd.md) | :white\_check\_mark: |
| [DequantizeLinear](operators/tensor/tensor.dequantize_linear.md) | :white\_check\_mark: |
| [SpaceToDepth](operators/neural-network/nn.space_to_depth.md) | :white\_check\_mark: |
| [DepthToSpace](operators/neural-network/nn.depth_to_space.md) | :white\_check\_mark: |
| [Optional](operators/tensor/tensor.optional.md) | :white\_check\_mark: |
| [ReverseSequence](operators/tensor/tensor.reverse_sequence.md) | :white\_check\_mark: |
| [SplitToSequence](operators/tensor/tensor.split_to_sequence.md) | :white\_check\_mark: |
| [Range](operators/tensor/tensor.range.md) | :white\_check\_mark: |
| [HannWindow](operators/tensor/tensor.tensor.hann_window.md) | :white\_check\_mark: |
| [HammingWindow](operators/tensor/tensor.tensor.hamming_window.md) | :white\_check\_mark: |
| [BlackmanWindow](operators/tensor/tensor.tensor.blackman_window.md) | :white\_check\_mark: |
| [RandomUniformLike](operators/tensor/tensor.tensor.random_uniform_like.md) | :white\_check\_mark: |

Current Operators support: **97/156 (62%)**
Current Operators support: **98/156 (62%)**
23 changes: 23 additions & 0 deletions docs/framework/operators/machine-learning/svm-classifier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SVM Classifier

`SVMClassifierTrait` provides a trait definition for svm classification problem.

```rust
use orion::operators::ml::SVMClassifierTrait;
```

### Data types

Orion supports currently only fixed point data types for `SVMClassifierTrait`.

| Data type | dtype |
| -------------------- | ------------------------------------------------------------- |
| Fixed point (signed) | `SVMClassifierTrait<FP8x23 \| FP16x16 \| FP64x64 \| FP32x32>` |


***

| function | description |
| --- | --- |
| [`svm_classifier.predict`](svm_classifier.predict.md) | Returns the top class for each of N inputs. |

Loading

0 comments on commit 185c1a8

Please sign in to comment.