Coder Social home page Coder Social logo

gizatechxyz / orion Goto Github PK

View Code? Open in Web Editor NEW
161.0 161.0 81.0 49.06 MB

ONNX Runtime in Cairo 1.0 for verifiable ML inference using STARK

Home Page: https://orion.gizatech.xyz

License: MIT License

Cairo 100.00%
cairo-lang deep-learning machine-learning onnx starknet tensorflow

orion's People

Contributors

0x73e avatar 0xd3bs avatar akhercha avatar allcontributors[bot] avatar andresmayorca avatar bal7hazar avatar bilgin-kocak avatar canacechan avatar chachaleo avatar countrycousin avatar credence0x avatar dincerguner avatar dl-vv avatar ephraim-nonso avatar franalgaba avatar friendlylifeguard avatar gakunt avatar hakymulla avatar happytomatoo avatar hattizai avatar mahmoudmohajer avatar omahs avatar raphaeldkhn avatar raphkhan avatar richwarner avatar roee-87 avatar tadev0 avatar tekkac avatar tsbauer avatar vid201 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

orion's Issues

feat: ArgMin

Feature Request

Describe the Feature Request

Computes the indices of the min elements of the input tensor's element along the provided axis. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. If select_last_index is True (default False), the index of the last occurrence of the min is selected if the min appears more than once in the input. Otherwise the index of the first occurrence is selected. The type of the output tensor is integer.

Full description here: https://github.com/onnx/onnx/blob/main/docs/Operators.md#ArgMin

feat: Linear Layer

Feature Request

Describe the Feature Request

Applies a linear transformation to the incoming tensor.

It should take as parameter:

  • the input Tensor
  • the weights Tensor
  • the bias Tensor

And return the result tensor after linear transformation.

It should panic if:

  • input Tensor shape is not 1D.
  • weights shape do not match input
  • weight shape do not match bias

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

MaxPool

Feature Request

Describe the Feature Request

Implementation of ONNX Operator

Describe Preferred Solution

Implementation following the same Operator interface as defined in ONNX. See Contribution Guidelines

Additional Context

ONNX MaxPool Operator

OneHot

Feature Request

Describe the Feature Request

Implementation of ONNX Operator

Describe Preferred Solution

Implementation following the same Operator interface as defined in ONNX. See Contribution Guidelines

Additional Context

ONNX OneHot Operator

feat: Or Operator

Feature Request

Describe the Feature Request

Or returns the tensor resulted from performing the or logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

Full description here:
https://github.com/onnx/onnx/blob/main/docs/Operators.md#Or

If the feature request is approved, would you be willing to submit a PR?

  • Yes
  • No

feat: XOR Operator

Feature Request

Describe the Feature Request

Returns the tensor resulted from performing the xor logical operation elementwise on the input tensors A and B (with Numpy-style broadcasting support).

This operator supports multidirectional (i.e., Numpy-style) broadcasting.

Link to the full ONNX description of XOR: https://github.com/onnx/onnx/blob/main/docs/Operators.md#xor

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

feat: add threshold parameter to relu_u32

Feature Request

Describe the Feature Request

Add a threshold parameter to the relu_u32 function. Since u32 numbers range from 0 ... 2** 32 -1, without the threshold parameter, relu_u32([original_array]) will always equal [original_array], as if the function was never applied.
Describe Preferred Solution

Added a threshold parameter below which the original values in the array will be mapped to zero

Related Code

relu_u32([original_array],threshold)
Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

fixed point: range check when creating a fixed point + wide-range calcul

Currently, when creating a fixed point, there is no range checking. But we should check the range for security reasons.

However, when using neural networks, we need to perform wide-ranging intermediate calculations with fixed points. But checking will create an error if the result is out of range.

I propose three approaches, but feel free to share yours if you have a better idea:

Approach 1:

Add unsafe parameter as boolean to all FixedTrait ops functions. When unsafe is true, the range of the new fixed point is not checked.
Interesting, but couldn't benefit from arithmetic operators (+-*/), as there's no way to pass the unsafe parameter.

Approach 2:

We implement wide operations (wide_mul, wide_exp, etc.) that return a tuple of fixed types.

Approach 3:

We implement a check_range function in FixedTrait. By default, calculations don't check the range, but we can easily check the result as follows:

(a + b).check_range()

bug: Argmin and Argmax not working with 1D tensor

Bug Report

Current behavior:
Currently Argmin and Argmax panics with 1D tensor.

    let tensor = i32_tensor_1x3_helper();

    let result = tensor.argmin(0,Option::None(()),Option::None(()));

>>>> panicked with [('shape cannot be empty') ]

bug: no range check for FixedType

Bug Report

ONNX-Cairo version:
commit @7bf1e1127bc638a5af4f27834374568535adb3ce

Current behavior:

There is no range check on the magnitude value being passed to any function creating a fixed type
Example: Fixed::new(value,t|f)does not check whether value is within the range of 0 and 2**31 -1

Affected functions seem to be:

trait Fixed {
    fn new(mag: u128, sign: bool) -> FixedType;
    fn new_unscaled(mag: u128, sign: bool) -> FixedType;
    fn from_felt(val: felt252) -> FixedType;
    fn from_unscaled_felt(val: felt252) -> FixedType;
    ...
}

Expected behavior:

Fixed::new(value, t|f) and similar functions should panic where value>=2**31

bug: linear test not running

Bug Report

Orion version:

e2608c1

Current behavior:
Linear tests not running because of improper import

Expected behavior:
All tests should run including tests in the linear_test.cairo file

Steps to reproduce:
scarb run test

Related code:

Other information:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.