Skip to content

Commit

Permalink
Merge branch 'develop' into pr/585
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Apr 21, 2024
2 parents 5b0cdc0 + b0bd747 commit b9a80bc
Show file tree
Hide file tree
Showing 744 changed files with 16,471 additions and 16,704 deletions.
Binary file added .DS_Store
Binary file not shown.
30 changes: 29 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,43 @@
"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"
]
},
{
"login": "TAdev0",
"name": "Tristan",
"avatar_url": "https://avatars.githubusercontent.com/u/122918260?v=4",
"profile": "https://nodeguardians.io/character/98995858fd55 ",
"contributions": [
"code"
]
},
{
"login": "Gakunt",
"name": "Kugo",
"avatar_url": "https://avatars.githubusercontent.com/u/153402253?v=4",
"profile": "https://github.com/Gakunt",
"contributions": [
"doc"
]
},
{
"login": "FriendlyLifeguard",
"name": "Beeyoung",
"avatar_url": "https://avatars.githubusercontent.com/u/55970530?v=4",
"profile": "http://alankang.xyz",
"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.5.3"
scarb-version: "2.6.4"
- 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.5.3
scarb 2.6.4
7 changes: 5 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-30-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-32-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 @@ -57,7 +57,7 @@ For a full list of all authors and contributors, see [the contributors page](htt

This project is licensed under the **MIT license**.

See [LICENSE](https://github.com/franalgaba/onnx-cairo/blob/main/LICENSE/README.md) for more information.
See [LICENSE](https://github.com/franalgaba/onnx-cairo/blob/main/LICENSE) for more information.

## Contributors ✨

Expand Down Expand Up @@ -108,6 +108,9 @@ Thanks goes to these wonderful people:
<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>
<td align="center" valign="top" width="14.28%"><a href="https://nodeguardians.io/character/98995858fd55 "><img src="https://avatars.githubusercontent.com/u/122918260?v=4?s=100" width="100px;" alt="Tristan"/><br /><sub><b>Tristan</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=TAdev0" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Gakunt"><img src="https://avatars.githubusercontent.com/u/153402253?v=4?s=100" width="100px;" alt="Kugo"/><br /><sub><b>Kugo</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=Gakunt" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://alankang.xyz"><img src="https://avatars.githubusercontent.com/u/55970530?v=4?s=100" width="100px;" alt="Beeyoung"/><br /><sub><b>Beeyoung</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=FriendlyLifeguard" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orion"
version = "0.2.3"
version = "0.2.5"
cairo-version = "2.5.3"
edition = "2023_10"
description = "ONNX Runtime in Cairo for verifiable ML inference using STARK"
Expand Down
16 changes: 16 additions & 0 deletions docgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ fn main() {
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// TREE ENSEMBLE DOC
let trait_path = "src/operators/ml/tree_ensemble/tree_ensemble.cairo";
let doc_path = "docs/framework/operators/machine-learning/tree-ensemble";
let label = "tree_ensemble";
let trait_name: &str = "TreeEnsembleTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// LINEAR REGRESSOR DOC
let trait_path = "src/operators/ml/linear/linear_regressor.cairo";
let doc_path = "docs/framework/operators/machine-learning/linear-regressor";
Expand Down Expand Up @@ -90,6 +98,14 @@ fn main() {
let trait_name: &str = "SVMClassifierTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// NORMALIZER DOC
let trait_path = "src/operators/ml/normalizer/normalizer.cairo";
let doc_path = "docs/framework/operators/machine-learning/normalizer";
let label = "normalizer";
let trait_name: &str = "NormalizerTrait";
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
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +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-02-21

## Added
- Label Encoder.
-
## [Unreleased] - 2024-01-17

## Added
Expand Down
4 changes: 4 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
* [tensor.not](framework/operators/tensor/tensor.not.md)
* [tensor.erf](framework/operators/tensor/tensor.erf.md)
* [tensor.reduce\_log\_sum](framework/operators/tensor/tensor.reduce\_log\_sum.md)
* [tensor.reduce\_log\_sum\_exp](framework/operators/tensor/tensor.reduce\_log\_sum\_exp.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)
Expand All @@ -157,6 +158,7 @@
* [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)
* [tensor.label_encoder](framework/operators/tensor/tensor.label_encoder.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 Down Expand Up @@ -199,6 +201,8 @@
* [sequence.sequence\_erase](framework/operators/sequence/sequence.sequence\_erase.md)
* [sequence.sequence\_insert](framework/operators/sequence/sequence.sequence\_insert.md)
* [sequence.concat\_from\_sequence](framework/operators/sequence/sequence.concat\_from\_sequence.md)
* [Normalizer](framework/operators/machine-learning/normalizer/README.md)
* [normalize.predict](framework/operators/machine-learning/normalizer/normalizer.predict.md)

## 🏛 Hub

Expand Down
6 changes: 4 additions & 2 deletions docs/framework/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ You can see below the list of current supported ONNX Operators:
| [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: |
| [Scatter](operators/tensor/tensor.scatter.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: |
Expand All @@ -112,6 +112,7 @@ You can see below the list of current supported ONNX Operators:
| [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: |
| [ReduceLogSumExp](operators/tensor/tensor.reduce\_log\_sum\_exp.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: |
Expand All @@ -125,5 +126,6 @@ You can see below the list of current supported ONNX Operators:
| [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: |
| [LabelEncoder](operators/tensor/tensor.label_encoder.md) | :white\_check\_mark: |

Current Operators support: **117/156 (75%)**
Current Operators support: **118/156 (75%)**
1 change: 1 addition & 0 deletions docs/framework/numbers/fixed-point/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ use orion::numbers::fixed_point::core::FixedTrait;
| [`fp.sinh`](fp.sinh.md) | Returns the value of the hyperbolic sine of the fixed point number. |
| [`fp.tanh`](fp.tanh.md) | Returns the value of the hyperbolic tangent of the fixed point number. |
| [`fp.sign`](fp.sign.md) | Returns the element-wise indication of the sign of the input fixed point number. |
| [`fp.erf`](fp.erf.md) | Returns the error function of the input fixed point number computed element-wise. |

### Arithmetic & Comparison operators

Expand Down
23 changes: 23 additions & 0 deletions docs/framework/operators/machine-learning/normalizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Normalizer

`NormalizerTrait` computes the normalization of the input, each row of the input is normalized independently.

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

### Data types

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

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


***

| function | description |
| --- | --- |
| [`normalizer.predict`](normalizer.predict.md) | Returns the normalization of the input, each row of the input is normalized independently. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Normalizer::predict

```rust
fn predict(X: Tensor<T>, norm: NORM) -> Tensor<T>;
```

Returns the normalized input.
Tree different types of normalization can be performed and are defined as follow :
MAX: $Y = \frac{X}{max(X)}$
L1: $Y = \frac{X}{sum(X)}$
L2: $Y = \frac{X}\sqrt{{sum(X²)}}$
For batches, that is, [N,C] tensors, normalization is done along the C axis. In other words, each row of the batch is normalized independently.

## Args

* `X`(`@Tensor<T>`) - Input 2D tensor.
* `norm`(`NORM`) - NORM::MAX, NORM::L1 or NORM::L2


## Returns

* Tensor<T> - output tensor

## Examples

```rust
use orion::numbers::FP16x16;
use orion::operators::tensor::{Tensor, TensorTrait, FP16x16Tensor, FP16x16TensorDiv, FP16x16TensorPartialEq};

use orion::operators::ml::normalizer::normalizer::{
NormalizerTrait, NORM
};



fn normalizer_max() -> Tensor<FP16x16> {
let mut shape = ArrayTrait::<usize>::new();
shape.append(3);
shape.append(3);

let mut data = ArrayTrait::new();
data.append(FP16x16 { mag: 65536, sign: true });
data.append(FP16x16 { mag: 52428, sign: true });
data.append(FP16x16 { mag: 39321, sign: true });
data.append(FP16x16 { mag: 26214, sign: true });
data.append(FP16x16 { mag: 13107, sign: true });
data.append(FP16x16 { mag: 0, sign: false });
data.append(FP16x16 { mag: 13107, sign: false });
data.append(FP16x16 { mag: 26214, sign: false });
data.append(FP16x16 { mag: 39321, sign: false });

let X = TensorTrait::new(shape.span(), data.span());

return NormalizerTrait::predict(X, NORM::MAX);
}
>>> [[-1. -0.8 -0.6 ]
[-1. -0.5 0. ]
[ 0.3333333 0.6666666 1. ]]

```

22 changes: 22 additions & 0 deletions docs/framework/operators/machine-learning/tree-ensemble/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Tree Ensemble

`TreeEnsembleTrait` provides a trait definition for tree ensemble problem.

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

### Data types

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

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


***

| function | description |
| --- | --- |
| [`tree_ensemble.predict`](tree_ensemble.predict.md) | Returns the regressed values for each input in a batch. |
Loading

0 comments on commit b9a80bc

Please sign in to comment.