Skip to content

Commit

Permalink
Merge branch 'develop' into pr/431
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Nov 21, 2023
2 parents d660f0e + 0c551cf commit d4b128b
Show file tree
Hide file tree
Showing 747 changed files with 23,479 additions and 1,055 deletions.
36 changes: 36 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,42 @@
"contributions": [
"code"
]
},
{
"login": "Ephraim-nonso",
"name": "Ephraim Chukwu",
"avatar_url": "https://avatars.githubusercontent.com/u/68496788?v=4",
"profile": "https://audits.quillhash.com/smart-contract-audit",
"contributions": [
"code"
]
},
{
"login": "Bal7hazar",
"name": "Bal7hazar",
"avatar_url": "https://avatars.githubusercontent.com/u/97087040?v=4",
"profile": "https://github.com/Bal7hazar",
"contributions": [
"bug"
]
},
{
"login": "okhaimie-dev",
"name": "Tony Stark",
"avatar_url": "https://avatars.githubusercontent.com/u/57156589?v=4",
"profile": "https://okhaimie.com",
"contributions": [
"doc"
]
},
{
"login": "bilgin-kocak",
"name": "Bilgin Koçak",
"avatar_url": "https://avatars.githubusercontent.com/u/30844607?v=4",
"profile": "https://www.bilginkocak.com/",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
10 changes: 8 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-21-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-25-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 Down Expand Up @@ -61,7 +61,7 @@ See [LICENSE](https://github.com/franalgaba/onnx-cairo/blob/main/LICENSE/README.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Thanks goes to these wonderful people:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
Expand Down Expand Up @@ -95,6 +95,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://brilliantblocks.io"><img src="https://avatars.githubusercontent.com/u/25390947?v=4?s=100" width="100px;" alt="Thomas S. Bauer"/><br /><sub><b>Thomas S. Bauer</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=TsBauer" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://andresmayorca.github.io"><img src="https://avatars.githubusercontent.com/u/70079260?v=4?s=100" width="100px;" alt="Andres"/><br /><sub><b>Andres</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=andresmayorca" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://audits.quillhash.com/smart-contract-audit"><img src="https://avatars.githubusercontent.com/u/68496788?v=4?s=100" width="100px;" alt="Ephraim Chukwu"/><br /><sub><b>Ephraim Chukwu</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=Ephraim-nonso" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Bal7hazar"><img src="https://avatars.githubusercontent.com/u/97087040?v=4?s=100" width="100px;" alt="Bal7hazar"/><br /><sub><b>Bal7hazar</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/issues?q=author%3ABal7hazar" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://okhaimie.com"><img src="https://avatars.githubusercontent.com/u/57156589?v=4?s=100" width="100px;" alt="Tony Stark"/><br /><sub><b>Tony Stark</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=okhaimie-dev" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.bilginkocak.com/"><img src="https://avatars.githubusercontent.com/u/30844607?v=4?s=100" width="100px;" alt="Bilgin Koçak"/><br /><sub><b>Bilgin Koçak</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=bilgin-kocak" title="Code">💻</a></td>
</tr>
</tbody>
</table>

Expand Down
7 changes: 4 additions & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
name = "orion"
version = "0.1.5"
version = "0.1.7"
description = "ONNX Runtime in Cairo for verifiable ML inference using STARK"
homepage = "https://github.com/gizatechxyz/orion"

[dependencies]
alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "f37d73d" }
cubit = { git = "https://github.com/raphaelDkhn/cubit.git" }
alexandria_sorting = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "f37d73d" }
cubit = { git = "https://github.com/influenceth/cubit.git", rev = "b459053" }

[scripts]
sierra = "cairo-compile . -r"
docgen = "cd docgen && cargo run"
nodegen = "python3 nodegen/node/__init__.py"
nodegen = "python3 nodegen/node/__init__.py"
8 changes: 8 additions & 0 deletions docgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ fn main() {
let trait_name: &str = "XGBoostRegressorTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// TREE ENSEMBLE CLASSIFIER DOC
let trait_path = "src/operators/ml/tree_ensemble/tree_ensemble_classifier.cairo";
let doc_path = "docs/framework/operators/machine-learning/tree-ensemble-classifier";
let label = "tree_ensemble_classifier";
let trait_name: &str = "TreeEnsembleClassifierTrait";
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
16 changes: 16 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@ 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] - 2023-11-06

## Added
- Reduce Sum Square Operator.

## [Unreleased] - 2023-11-05

### Added
- ReduceL2 operator.

## [Unreleased] - 2023-11-06

## Added
- Reduce L1 Operator.


## [Unreleased] - 2023-11-03

## Added
- Scatter Elements Operator.


## [Unreleased] - 2023-09-27

## Added
Expand Down
13 changes: 13 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,19 @@
* [tensor.identity](framework/operators/tensor/tensor.identity.md)
* [tensor.and](framework/operators/tensor/tensor.and.md)
* [tensor.where](framework/operators/tensor/tensor.where.md)
* [tensor.bitwise_and](framework/operators/tensor/tensor.bitwise_and.md)
* [tensor.round](framework/operators/tensor/tensor.round.md)
* [tensor.scatter](framework/operators/tensor/tensor.scatter.md)
* [tensor.array_feature_extractor](framework/operators/tensor/tensor.array\_feature\_extractor.md)
* [tensor.binarizer](framework/operators/tensor/tensor.binarizer.md)
* [tensor.reduce\_sum\_square](framework/operators/tensor/tensor.reduce\_sum\_square.md)
* [tensor.reduce\_l2](framework/operators/tensor/tensor.reduce\_l2.md)
* [tensor.reduce\_l1](framework/operators/tensor/tensor.reduce\_l1.md)
* [tensor.reduce\_min](framework/operators/tensor/tensor.reduce\_min.md)
* [tensor.sequence\_construct](framework/operators/tensor/tensor.sequence\_construct.md)
* [tensor.shrink](framework/operators/tensor/tensor.shrink.md)
* [tensor.sequence\_empty](framework/operators/tensor/tensor.sequence\_empty.md)
* [tensor.reduce_mean](framework/operators/tensor/tensor.reduce\_mean.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 @@ -110,6 +121,8 @@
* [nn.thresholded\_relu](framework/operators/neural-network/nn.thresholded_relu.md)
* [nn.gemm](framework/operators/neural-network/nn.gemm.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)
* [Tree Regressor](framework/operators/machine-learning/tree-regressor/README.md)
* [tree.predict](framework/operators/machine-learning/tree-regressor/tree.predict.md)
* [Tree Classifier](framework/operators/machine-learning/tree-classifier/README.md)
Expand Down
5 changes: 1 addition & 4 deletions docs/academy/tutorials/implement-new-operators-in-orion.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Finally, we create a Softmax class, containing tests for each dtypes.
```python
import numpy as np
from nodegen.node import RunAll
from ..helpers import make_node, make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait

def softmax(x: np.ndarray, axis: int = -1) -> np.ndarray:
x_max = np.max(x, axis=axis, keepdims=True)
Expand All @@ -293,8 +293,6 @@ class Softmax(RunAll):

# Define the name of the generated folder.
name = "softmax_fp8x23"
# Invoke `make_node` method to generate Cairo representation of `x` and `y`:
make_node([x], [y], name)
# Invoke `make_test` method to generate corresponding Cairo tests:
make_test(
[x], # List of input tensors.
Expand All @@ -316,7 +314,6 @@ class Softmax(RunAll):
y.flatten(), FixedImpl.FP16x16))

name = "softmax_fp16x16"
make_node([x], [y], name)
make_test([x], y, "NNTrait::softmax(@input_0, 1)",
name, Trait.NN)
```
Expand Down
22 changes: 17 additions & 5 deletions docs/framework/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,24 @@ You can see below the list of current supported ONNX Operators:
| [Xor](operators/tensor/tensor.xor.md) | :white\_check\_mark: |
| [Or](operators/tensor/tensor.or.md) | :white\_check\_mark: |
| [Gemm](operators/neural-network/nn.gemm.md) | :white\_check\_mark: |
| [MinInTensor](operators/tensor/tensor.min\_in\_tensor.md) | :white\_check\_mark: |
| [MinInTensor](operators/tensor/tensor.min\_in\_tensor.md) | :white\_check\_mark: |
| [Min](operators/tensor/tensor.min.md) | :white\_check\_mark: |
| [Where](operators/tensor/tensor.where.md) | :white\_check\_mark: |
| [Round](operators/tensor/tensor.round.md) | :white\_check\_mark: |
| [Where](operators/tensor/tensor.where.md) | :white\_check\_mark: |
| [BitwiseAnd](operators/tensor/tensor.bitwise_and.md) | :white\_check\_mark: |
| [Round](operators/tensor/tensor.round.md) | :white\_check\_mark: |
| [MaxInTensor](operators/tensor/tensor.max\_in\_tensor.md) | :white\_check\_mark: |
| [Max](operators/tensor/tensor.max.md) | :white\_check\_mark: |
| [Max](operators/tensor/tensor.max.md) | :white\_check\_mark: |
| [ReduceSumSquare](operators/tensor/tensor.reduce\_sum\_square.md) | :white\_check\_mark: |
| [Trilu](operators/tensor/tensor.trilu.md) | :white\_check\_mark: |
| [Scatter](operators/tensor/scatter.max.md) | :white\_check\_mark: |
| [ArrayFeatureExtractor](operators/tensor/tensor.array\_feature\_extractor.md) | :white\_check\_mark: |
| [Binarizer](operators/tensor/tensor.binarizer.md) | :white\_check\_mark: |
| [ConstantOfShape](operators/tensor/tensor.constant_of_shape.md) | :white\_check\_mark: |
| [ReduceL1](operators/tensor/tensor.reduce\_l1.md) | :white\_check\_mark: |
| [ReduceL2](operators/tensor/tensor.reduce\_l2.md) | :white\_check\_mark: |
| [SequenceConstruct](operators/tensor/tensor.sequence\_construct.md) | :white\_check\_mark: |
| [Shrink](operators/tensor/tensor.shrink.md) | :white\_check\_mark: |
| [SequenceEmpty](operators/tensor/tensor.sequence\_empty.md) | :white\_check\_mark: |
| [ReduceL2](operators/tensor/tensor.reduce\_l2.md) | :white\_check\_mark: |

Current Operators support: **68/156 (43%)**
Current Operators support: **81/156 (52%)**
2 changes: 1 addition & 1 deletion docs/framework/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Orion supports <mark style="color:orange;">**Cairo and Scarb v2.3.0**</mark>

**Step 1: Install Cairo**

There are different ways to install Cairo. Use the one that suits you best: [Cairo installer](https://cairo-book.github.io/ch01-01-installation.html).
There are different ways to install Cairo. Use the one that suits you best: [Cairo installer.](https://book.cairo-lang.org/ch01-01-installation.html)

**Step 2: Setup Language Server**

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Tree Ensemble Classifier

`TreeEnsembleClassifierTrait` provides a trait definition for tree ensemble classification problem.

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

### Data types

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

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

### How to construct `TreeEnsembleClassifier`

You can utilize [this notebook](https://colab.research.google.com/drive/1qem56rUKJcNongXsLZ16_869q8395prz#scrollTo=V3qGW_kfXudk) to translate parameters from your ONNX TreeEnsembleClassifier model into Cairo code. Efforts are underway to integrate this functionality into Giza-CLI, aiming to enhance the user experience.


***

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

Loading

0 comments on commit d4b128b

Please sign in to comment.