file_path
stringlengths
7
180
content
stringlengths
0
811k
repo
stringclasses
11 values
nodegen/node/split_to_sequence.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Split_to_sequence(RunAll): @staticmethod def split_to_sequence_u32(): def split_to_sequence_1D(): x = np.random.randint(0, 255, 6).astype(np.uint32) y = [ ...
https://github.com/gizatechxyz/orion
nodegen/node/sqrt.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Sqrt(RunAll): @staticmethod def sqrt_fp8x23(): x = np.random.uniform(0, 6, (2, 2)).astype(np.float64) y = np.sqrt(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( ...
https://github.com/gizatechxyz/orion
nodegen/node/squeeze.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Squeeze(RunAll): @staticmethod def squeeze_i8(): def squeeze(): x = np.ones((1, 2, 1, 2, 1), dtype=np.int8) y = np.ones((2, 2, 1), dtype=np.int8) ...
https://github.com/gizatechxyz/orion
nodegen/node/sub.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Sub(RunAll): @staticmethod def sub_u32(): def default(): x = np.random.randint(3, 6, (3, 3, 3)).astype(np.uint32) y = np.random.randint(0, 3, (3, 3, 3)).ast...
https://github.com/gizatechxyz/orion
nodegen/node/tanh.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Tanh(RunAll): @staticmethod def tanh_fp8x23(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = np.tanh(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( ...
https://github.com/gizatechxyz/orion
nodegen/node/thresholded_relu.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait class Thresholded_relu(RunAll): @staticmethod def thresholded_relu_fp8x23(): alpha = 1.0 x = np.random.uniform(-5, 7, (2, 2)).astype(np.float64) y = np.clip(x, ...
https://github.com/gizatechxyz/orion
nodegen/node/transpose.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Transpose(RunAll): @staticmethod def transpose_u32(): def transpose_2D(): x = np.random.randint(0, 255, (2, 2)).astype(np.uint32) y = np.transpose(x, [1, 0]...
https://github.com/gizatechxyz/orion
nodegen/node/trilu.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Trilu(RunAll): @staticmethod def trilu_u32(): def tril(): x = np.random.randint(0, 255, (4, 5)).astype(np.uint32) y = np.tril(x) x = Tensor(Dty...
https://github.com/gizatechxyz/orion
nodegen/node/unique.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl from typing import Optional def _unsort_outputs( x: np.ndarray, axis: Optional[int], unique_values: np.ndarray, indices: np.ndarray, inverse_indices: np.ndarray, counts: np.ndarr...
https://github.com/gizatechxyz/orion
nodegen/node/unsqueeze.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Unsqueeze(RunAll): @staticmethod def unsqueeze_u32(): def unsqueeze_2D(): x = np.random.randint(0, 255, (2, 4)).astype(np.uint32) y = np.expand_dims(x, axis...
https://github.com/gizatechxyz/orion
nodegen/node/where.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Where(RunAll): @staticmethod def where_u32(): def default(): cond = np.random.choice([1, 0], (3, 3, 3)).astype(np.uint32) x = np.random.randint(0, 6, (3, 3...
https://github.com/gizatechxyz/orion
nodegen/node/xor.py
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Xor(RunAll): @staticmethod def xor_u32(): def default(): x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32) y = np.random.randint(0, 6, (3, 3, 3)).as...
https://github.com/gizatechxyz/orion
nodegen/test_list.py
import os import glob import subprocess # Directory path where Python files/modules are located directory_path = 'nodegen/node/' # Get all files in the directory all_files = os.listdir(directory_path) # Filter Python files using glob and '*.py' pattern python_files = [file[:-3] for file in all_files if file.endswith...
https://github.com/gizatechxyz/orion
src/lib.cairo
mod operators; mod numbers; mod utils; mod test_helper;
https://github.com/gizatechxyz/orion
src/numbers.cairo
mod fixed_point; mod complex_number; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp8x23::core::{ONE as ONE_fp8x23}; use orion::numbers::fixed_point::implementations::fp16x16::core::{ONE as ONE_fp16x16}; use orion::numbers::fixed_point::implementations::fp64x64::...
https://github.com/gizatechxyz/orion
src/numbers/complex_number.cairo
mod complex_trait; mod complex64;
https://github.com/gizatechxyz/orion
src/numbers/complex_number/complex64.cairo
use core::debug::PrintTrait; use orion::numbers::complex_number::complex_trait::ComplexTrait; use orion::numbers::{FP64x64, FP64x64Impl, FP32x32, FP32x32Impl, FixedTrait}; // ====================== Complex 64 ====================== // complex64 represents a complex number in the Cartesian form z = a + bi where a and...
https://github.com/gizatechxyz/orion
src/numbers/complex_number/complex_trait.cairo
/// Trait /// /// new - Constructs a new `complex_number`. /// from_felt - Creates a new `complex_number` instance from two felt252 values. /// real - Returns the real part of the `complex_number`. /// img - Returns the imaginary part of the `complex_number`. /// conjugate - Returns the conjugate of the `complex_number...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point.cairo
//! Fixed-Point implemented from https://github.com/influenceth/cubit and adjusted to Q8.23 mod core; mod implementations; mod utils;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/core.cairo
/// Trait /// /// new - Constructs a new fixed point instance. /// new_unscaled - Creates a new fixed point instance with the specified unscaled magnitude and sign. /// from_felt - Creates a new fixed point instance from a felt252 value. /// abs - Returns the absolute value of the fixed point number. /// ceil - Returns...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations.cairo
mod fp8x23; mod fp16x16; mod fp64x64; mod fp32x32; mod fp16x16wide; mod fp8x23wide;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16.cairo
mod core; mod math; mod helpers;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/core.cairo
use core::debug::PrintTrait; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp16x16::math::{ core as core_math, trig, hyp, erf }; use orion::numbers::fixed_point::utils; /// A struct representing a fixed point number. #[derive(Serde, Copy, Drop)] struct FP16x1...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/helpers.cairo
use core::debug::PrintTrait; use orion::numbers::fixed_point::implementations::fp16x16::core::{ HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Sub, FP16x16Div, FixedTrait, FP16x16Print }; const DEFAULT_PRECISION: u32 = 7; // 1e-4 // To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`. // To use `custom_pr...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/math.cairo
mod core; mod comp; mod lut; mod trig; mod hyp; mod erf;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/math/comp.cairo
use orion::numbers::fixed_point::implementations::fp16x16::core::{ FP16x16, FixedTrait, FP16x16Impl, FP16x16PartialOrd, FP16x16PartialEq }; fn max(a: FP16x16, b: FP16x16) -> FP16x16 { if a >= b { a } else { b } } fn min(a: FP16x16, b: FP16x16) -> FP16x16 { if a <= b { a ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/math/core.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp16x16::core::{ HALF, ONE, MAX, FP16x16, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul, FP16x16MulEq, FP16x16TryIntoU128, FP16x16PartialEq, FP16x16PartialOrd, FP16x16SubEq, FP16x16Neg, FP16x16Div, FP16x16IntoFelt252, Fixe...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/math/erf.cairo
use orion::numbers::fixed_point::implementations::fp16x16::core::{ONE, FP16x16, FixedTrait}; use orion::numbers::fixed_point::implementations::fp16x16::math::lut::erf_lut; const ERF_COMPUTATIONAL_ACCURACY: u32 = 100; const ROUND_CHECK_NUMBER: u32 = 10; // Values > MAX_ERF_NUMBER return 1 const MAX_ERF_NUMBER: u32 = 22...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/math/hyp.cairo
use orion::numbers::fixed_point::implementations::fp16x16::core::{ HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul, FP16x16MulEq, FP16x16TryIntoU128, FP16x16PartialEq, FP16x16PartialOrd, FP16x16SubEq, FP16x16Neg, FP16x16Div, FP16x16IntoFelt252, FixedTrait }; // Calcul...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/math/lut.cairo
use orion::numbers::fixed_point::implementations::fp16x16::core::ONE; // Calculates the most significant bit fn msb(whole: u32) -> (u32, u32) { if whole < 256 { if whole < 2 { return (0, 1); } if whole < 4 { return (1, 2); } if whole < 8 { ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16/math/trig.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp16x16::math::lut; use orion::numbers::fixed_point::implementations::fp16x16::core::{ HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Add, FP16x16Sub, FP16x16Mul, FP16x16Div, FP16x16IntoFelt252, FixedTrait }; // CONSTANTS const TWO_PI: u32 = 4...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide.cairo
mod core; mod math; mod helpers;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/core.cairo
use core::debug::PrintTrait; use orion::numbers::{fixed_point::core::FixedTrait, FP16x16}; use orion::numbers::fixed_point::implementations::fp16x16wide::math::{ core as core_math, trig, hyp, erf }; use orion::numbers::fixed_point::utils; /// A struct representing a fixed point number. #[derive(Serde, Copy, Drop)...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/helpers.cairo
use core::debug::PrintTrait; use orion::numbers::fixed_point::implementations::fp16x16wide::core::{ HALF, ONE, TWO, FP16x16W, FP16x16WImpl, FP16x16WSub, FP16x16WDiv, FixedTrait, FP16x16WPrint }; const DEFAULT_PRECISION: u64 = 7; // 1e-4 // To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`. // To use `...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/math.cairo
mod core; mod comp; mod lut; mod trig; mod hyp; mod erf;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/math/comp.cairo
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{ FP16x16W, FixedTrait, FP16x16WImpl, FP16x16WPartialOrd, FP16x16WPartialEq }; fn max(a: FP16x16W, b: FP16x16W) -> FP16x16W { if a >= b { a } else { b } } fn min(a: FP16x16W, b: FP16x16W) -> FP16x16W { if a <= b {...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/math/core.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp16x16wide::core::{ HALF, ONE, MAX, FP16x16W, FP16x16WImpl, FP16x16WAdd, FP16x16WAddEq, FP16x16WSub, FP16x16WMul, FP16x16WMulEq, FP16x16WTryIntoU128, FP16x16WPartialEq, FP16x16WPartialOrd, FP16x16WSubEq, FP16x16WNeg, FP16x16WDiv, FP16x16...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/math/erf.cairo
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{ONE, FP16x16W, FixedTrait}; use orion::numbers::fixed_point::implementations::fp16x16wide::math::lut::erf_lut; const ERF_COMPUTATIONAL_ACCURACY: u64 = 100; const ROUND_CHECK_NUMBER: u64 = 10; // Values > MAX_ERF_NUMBER return 1 const MAX_ERF_NUMBER:...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/math/hyp.cairo
use orion::numbers::fixed_point::implementations::fp16x16wide::core::{ HALF, ONE, TWO, FP16x16W, FP16x16WImpl, FP16x16WAdd, FP16x16WAddEq, FP16x16WSub, FP16x16WMul, FP16x16WMulEq, FP16x16WTryIntoU128, FP16x16WPartialEq, FP16x16WPartialOrd, FP16x16WSubEq, FP16x16WNeg, FP16x16WDiv, FP16x16WIntoFelt252, FixedT...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/math/lut.cairo
use orion::numbers::fixed_point::implementations::fp8x23wide::core::ONE; // Calculates the most significant bit fn msb(whole: u64) -> (u64, u64) { if whole < 256 { if whole < 2 { return (0, 1); } if whole < 4 { return (1, 2); } if whole < 8 { ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp16x16wide/math/trig.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp16x16wide::math::lut; use orion::numbers::fixed_point::implementations::fp16x16wide::core::{ HALF, ONE, TWO, FP16x16W, FP16x16WImpl, FP16x16WAdd, FP16x16WSub, FP16x16WMul, FP16x16WDiv, FP16x16WIntoFelt252, FixedTrait }; // CONSTANTS const ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp32x32.cairo
mod core; mod comp; mod erf; mod lut;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp32x32/comp.cairo
use orion::numbers::{FP32x32, FP32x32Impl, FixedTrait}; fn xor(a: FP32x32, b: FP32x32) -> bool { if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) { true } else { false } } fn or(a: FP32x32, b: FP32x32) -> bool { let zero = FixedTrait::new(0, false); ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp32x32/core.cairo
use core::debug::PrintTrait; use cubit::f64 as fp32x32; use cubit::f64::Fixed as FP32x32; use cubit::f64::{ONE, HALF}; use cubit::f64::types::fixed; use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_point::implementations::fp32x32::erf; use orion::numbers::fixed_point::utils; const MAX: ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp32x32/erf.cairo
use cubit::f64::ONE; use orion::numbers::{FP32x32, FixedTrait}; use orion::numbers::fixed_point::implementations::fp32x32::lut::erf_lut; const ERF_COMPUTATIONAL_ACCURACY: u64 = 100; const ROUND_CHECK_NUMBER: u64 = 10; // Values > MAX_ERF_NUMBER return 1 const MAX_ERF_NUMBER: u64 = 15032385536; // Values <= ERF_TRUNCA...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp32x32/lut.cairo
use orion::numbers::fixed_point::implementations::fp32x32::core::ONE; fn erf_lut(x: u64) -> u64 { // Construct the erf lookup table if x <= 386547056 { if x <= 0 { return 0; } if x <= 42949672 { return 48461900; } if x <= 85899345 { re...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp64x64.cairo
mod core; mod comp; mod erf; mod lut;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp64x64/comp.cairo
use orion::numbers::{FP64x64, FixedTrait}; use orion::numbers::FP64x64Impl; fn xor(a: FP64x64, b: FP64x64) -> bool { if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) { true } else { false } } fn or(a: FP64x64, b: FP64x64) -> bool { let zero = FixedTrait...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp64x64/core.cairo
use core::debug::PrintTrait; use cubit::f128 as fp64x64; use cubit::f128::types::Fixed as FP64x64; use cubit::f128::ONE_u128 as ONE; use cubit::f128::ops::MAX_u128 as MAX; use orion::numbers::fixed_point::implementations::fp64x64::erf; use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_poi...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp64x64/erf.cairo
use cubit::f128::ONE_u128 as ONE; use orion::numbers::{FP64x64, FixedTrait}; use orion::numbers::fixed_point::implementations::fp64x64::lut::erf_lut; const ERF_COMPUTATIONAL_ACCURACY: u128 = 100_u128; const ROUND_CHECK_NUMBER: u128 = 10_u128; // Values > MAX_ERF_NUMBER return 1 const MAX_ERF_NUMBER: u128 = 6456360425...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp64x64/lut.cairo
use orion::numbers::fixed_point::implementations::fp64x64::core::ONE; fn erf_lut(x: u128) -> u128 { // Construct the erf lookup table if x <= 1660206966633859584 { if x <= 0 { return 0; } if x <= 184467440737095520 { return 208142279036071072; } i...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23.cairo
mod core; mod math; mod helpers;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/core.cairo
use core::debug::PrintTrait; use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_point::implementations::fp8x23::math::{core as core_math, trig, hyp, erf}; use orion::numbers::fixed_point::utils; /// A struct representing a fixed point number. #[derive(Serde, Copy, Drop)] struct FP8x23 { ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/helpers.cairo
use core::debug::PrintTrait; use orion::numbers::fixed_point::implementations::fp8x23::core::{ HALF, ONE, TWO, FP8x23, FP8x23Sub, FP8x23Div, FixedTrait, FP8x23Print }; const DEFAULT_PRECISION: u32 = 8; // 1e-6 // To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`. // To use `custom_precision` of 430_u3...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/math.cairo
mod core; mod comp; mod lut; mod trig; mod hyp; mod erf;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/math/comp.cairo
use orion::numbers::fixed_point::implementations::fp8x23::core::{ FP8x23, FixedTrait, FP8x23PartialOrd, FP8x23PartialEq }; fn max(a: FP8x23, b: FP8x23) -> FP8x23 { if a >= b { a } else { b } } fn min(a: FP8x23, b: FP8x23) -> FP8x23 { if a <= b { a } else { b ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/math/core.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp8x23::core::{ HALF, ONE, MAX, FP8x23, FP8x23Add, FP8x23Impl, FP8x23AddEq, FP8x23Sub, FP8x23Mul, FP8x23MulEq, FP8x23TryIntoU128, FP8x23PartialEq, FP8x23PartialOrd, FP8x23SubEq, FP8x23Neg, FP8x23Div, FP8x23IntoFelt252, FixedTrait }; use o...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/math/erf.cairo
use orion::numbers::fixed_point::implementations::fp8x23::core::{ONE, FP8x23, FixedTrait}; use orion::numbers::fixed_point::implementations::fp8x23::math::lut::erf_lut; const ERF_COMPUTATIONAL_ACCURACY: u32 = 100; const MAX_ERF_COMPUTATIONAL_ACCURACY: u32 = 10; const ROUND_CHECK_NUMBER: u32 = 1; // Values > MAX_ERF_NU...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/math/hyp.cairo
use core::debug::PrintTrait; use orion::numbers::fixed_point::implementations::fp8x23::core::{ HALF, ONE, TWO, FP8x23, FP8x23Impl, FP8x23Add, FP8x23AddEq, FP8x23Sub, FP8x23Mul, FP8x23MulEq, FP8x23TryIntoU128, FP8x23PartialEq, FP8x23PartialOrd, FP8x23SubEq, FP8x23Neg, FP8x23Div, FP8x23IntoFelt252, FixedTrai...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/math/lut.cairo
use orion::numbers::fixed_point::implementations::fp8x23::core::ONE; // Calculates the most significant bit fn msb(whole: u32) -> (u32, u32) { if whole < 256 { if whole < 2 { return (0, 1); } if whole < 4 { return (1, 2); } if whole < 8 { ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23/math/trig.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp8x23::math::lut; use orion::numbers::fixed_point::implementations::fp8x23::core::{ HALF, ONE, TWO, FP8x23, FP8x23Impl, FP8x23Add, FP8x23Sub, FP8x23Mul, FP8x23Div, FP8x23IntoFelt252, FixedTrait }; // CONSTANTS const TWO_PI: u32 = 52707178; ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide.cairo
mod core; mod math; mod helpers;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/core.cairo
use core::debug::PrintTrait; use orion::numbers::{fixed_point::core::{FixedTrait}, FP8x23}; use orion::numbers::fixed_point::implementations::fp8x23wide::math::{ core as core_math, trig, hyp, erf }; use orion::numbers::fixed_point::utils; /// A struct representing a fixed point number. #[derive(Serde, Copy, Drop)...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/helpers.cairo
use core::debug::PrintTrait; use orion::numbers::fixed_point::implementations::fp8x23wide::core::{ HALF, ONE, TWO, FP8x23W, FP8x23WSub, FP8x23WDiv, FixedTrait, FP8x23WPrint }; const DEFAULT_PRECISION: u64 = 8; // 1e-6 // To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`. // To use `custom_precision` o...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/math.cairo
mod core; mod comp; mod lut; mod trig; mod hyp; mod erf;
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/math/comp.cairo
use orion::numbers::fixed_point::implementations::fp8x23wide::core::{ FP8x23W, FixedTrait, FP8x23WPartialOrd, FP8x23WPartialEq }; fn max(a: FP8x23W, b: FP8x23W) -> FP8x23W { if a >= b { a } else { b } } fn min(a: FP8x23W, b: FP8x23W) -> FP8x23W { if a <= b { a } else { ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/math/core.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp8x23wide::core::{ HALF, ONE, MAX, FP8x23W, FP8x23WAdd, FP8x23WImpl, FP8x23WAddEq, FP8x23WSub, FP8x23WMul, FP8x23WMulEq, FP8x23WTryIntoU128, FP8x23WPartialEq, FP8x23WPartialOrd, FP8x23WSubEq, FP8x23WNeg, FP8x23WDiv, FP8x23WIntoFelt252, F...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/math/erf.cairo
use orion::numbers::fixed_point::implementations::fp8x23wide::core::{ONE, FP8x23W, FixedTrait}; use orion::numbers::fixed_point::implementations::fp8x23wide::math::lut::erf_lut; const ERF_COMPUTATIONAL_ACCURACY: u64 = 100; const MAX_ERF_COMPUTATIONAL_ACCURACY: u64 = 10; const ROUND_CHECK_NUMBER: u64 = 1; // Values > M...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/math/hyp.cairo
use orion::numbers::fixed_point::implementations::fp8x23wide::core::{ HALF, ONE, TWO, FP8x23W, FP8x23WImpl, FP8x23WAdd, FP8x23WAddEq, FP8x23WSub, FP8x23WMul, FP8x23WMulEq, FP8x23WTryIntoU128, FP8x23WPartialEq, FP8x23WPartialOrd, FP8x23WSubEq, FP8x23WNeg, FP8x23WDiv, FP8x23WIntoFelt252, FixedTrait }; // Cal...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/math/lut.cairo
use orion::numbers::fixed_point::implementations::fp8x23wide::core::ONE; // Calculates the most significant bit fn msb(whole: u64) -> (u64, u64) { if whole < 256 { if whole < 2 { return (0, 1); } if whole < 4 { return (1, 2); } if whole < 8 { ...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/implementations/fp8x23wide/math/trig.cairo
use core::integer; use orion::numbers::fixed_point::implementations::fp8x23wide::math::lut; use orion::numbers::fixed_point::implementations::fp8x23wide::core::{ HALF, ONE, TWO, FP8x23W, FP8x23WImpl, FP8x23WAdd, FP8x23WSub, FP8x23WMul, FP8x23WDiv, FP8x23WIntoFelt252, FixedTrait }; // CONSTANTS const TWO_PI: u...
https://github.com/gizatechxyz/orion
src/numbers/fixed_point/utils.cairo
use core::integer; const HALF_PRIME: felt252 = 1809251394333065606848661391547535052811553607665798349986546028067936010240; // Returns the sign of a signed `felt252` as with signed magnitude representation // true = negative // false = positive fn felt_sign(a: felt252) -> bool { integer::u256_from_felt252(a)...
https://github.com/gizatechxyz/orion
src/operators.cairo
mod tensor; mod nn; mod ml; mod matrix; mod vec; mod sequence;
https://github.com/gizatechxyz/orion
src/operators/matrix.cairo
use orion::numbers::NumberTrait; use orion::operators::vec::{VecTrait, NullableVec, NullableVecImpl}; struct MutMatrix<T> { data: NullableVec<T>, rows: usize, cols: usize, } impl MutMatrixDestruct<T, +Drop<T>> of Destruct<MutMatrix<T>> { fn destruct(self: MutMatrix<T>) nopanic { self.data.dest...
https://github.com/gizatechxyz/orion
src/operators/ml.cairo
mod tree_ensemble; mod linear; mod svm; mod normalizer; use orion::operators::ml::tree_ensemble::core::{ TreeEnsemble, TreeEnsembleAttributes, TreeEnsembleImpl, NODE_MODES }; use orion::operators::ml::tree_ensemble::tree_ensemble_classifier::{ TreeEnsembleClassifier, TreeEnsembleClassifierImpl, TreeEnsembleCla...
https://github.com/gizatechxyz/orion
src/operators/ml/linear.cairo
mod linear_regressor; mod linear_classifier;
https://github.com/gizatechxyz/orion
src/operators/ml/linear/linear_classifier.cairo
use core::array::ArrayTrait; use core::array::SpanTrait; use orion::numbers::FP16x16; use orion::operators::tensor::{Tensor, TensorTrait}; use orion::numbers::NumberTrait; use orion::operators::tensor::{I8Tensor, I32Tensor, U32Tensor, FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FP32x32, FP32x32Impl, FixedTr...
https://github.com/gizatechxyz/orion
src/operators/ml/linear/linear_regressor.cairo
use core::array::ArrayTrait; use core::clone::Clone; use core::traits::Into; use core::array::SpanTrait; use core::dict::Felt252DictTrait; use core::dict::Felt252DictEntryTrait; use orion::numbers::FP16x16; use orion::operators::tensor::{Tensor, TensorTrait}; use orion::numbers::NumberTrait; use orion::operators::tens...
https://github.com/gizatechxyz/orion
src/operators/ml/normalizer.cairo
mod normalizer;
https://github.com/gizatechxyz/orion
src/operators/ml/normalizer/normalizer.cairo
use core::array::ArrayTrait; use orion::numbers::NumberTrait; use orion::operators::tensor::{TensorTrait, Tensor}; #[derive(Copy, Drop)] enum NORM { MAX, L1, L2, } /// predict - Returns the normalization of the input, each row of the input is normalized independently. trait NormalizerTrait<T> { /// ...
https://github.com/gizatechxyz/orion
src/operators/ml/svm.cairo
mod core; mod svm_regressor; mod svm_classifier;
https://github.com/gizatechxyz/orion
src/operators/ml/svm/core.cairo
use orion::numbers::NumberTrait; use orion::numbers::{FP16x16, FP16x16Impl, FP32x32, FP32x32Impl, FixedTrait}; use orion::operators::tensor::{ TensorTrait, Tensor, I8Tensor, I32Tensor, U32Tensor, FP16x16Tensor, BoolTensor }; use orion::utils::get_row; #[derive(Copy, Drop)] enum KERNEL_TYPE { LINEAR, POLY, ...
https://github.com/gizatechxyz/orion
src/operators/ml/svm/svm_classifier.cairo
use core::array::ArrayTrait; use orion::numbers::NumberTrait; use orion::operators::tensor::{ TensorTrait, Tensor, I8Tensor, I32Tensor, U32Tensor, FP16x16Tensor, BoolTensor }; use orion::numbers::{FP16x16, FP16x16Impl, FP32x32, FP32x32Impl, FixedTrait}; use orion::operators::vec::{VecTrait, NullableVec, NullableVe...
https://github.com/gizatechxyz/orion
src/operators/ml/svm/svm_regressor.cairo
use core::traits::TryInto; use core::array::ArrayTrait; use core::array::SpanTrait; use core::traits::Into; use orion::numbers::NumberTrait; use orion::operators::tensor::{ TensorTrait, Tensor, I8Tensor, I32Tensor, U32Tensor, FP16x16Tensor, BoolTensor }; use orion::numbers::{FP16x16, FP16x16Impl, FP32x32, FP32x32Im...
https://github.com/gizatechxyz/orion
src/operators/ml/tree_ensemble.cairo
mod core; mod tree_ensemble_classifier; mod tree_ensemble_regressor;
https://github.com/gizatechxyz/orion
src/operators/ml/tree_ensemble/core.cairo
use alexandria_data_structures::array_ext::SpanTraitExt; use alexandria_merkle_tree::merkle_tree::{pedersen::PedersenHasherImpl}; use alexandria_data_structures::array_ext::ArrayTraitExt; use orion::numbers::NumberTrait; use orion::operators::tensor::{Tensor, TensorTrait, U32Tensor}; use orion::utils::get_row; #[deri...
https://github.com/gizatechxyz/orion
src/operators/ml/tree_ensemble/tree_ensemble_classifier.cairo
use core::array::ArrayTrait; use core::clone::Clone; use core::box::BoxTrait; use core::traits::Into; use core::option::OptionTrait; use orion::operators::matrix::MutMatrixTrait; use core::array::SpanTrait; use core::nullable::NullableTrait; use core::dict::Felt252DictTrait; use core::dict::Felt252DictEntryTrait; use c...
https://github.com/gizatechxyz/orion
src/operators/ml/tree_ensemble/tree_ensemble_regressor.cairo
use core::array::ArrayTrait; use core::clone::Clone; use core::box::BoxTrait; use core::traits::Into; use core::option::OptionTrait; use orion::operators::matrix::MutMatrixTrait; use core::array::SpanTrait; use core::nullable::NullableTrait; use core::dict::Felt252DictTrait; use core::dict::Felt252DictEntryTrait; use c...
https://github.com/gizatechxyz/orion
src/operators/nn.cairo
mod core; mod implementations; mod functional; use orion::operators::nn::core::NNTrait; use orion::operators::nn::implementations::nn_fp8x23::FP8x23NN; use orion::operators::nn::implementations::nn_fp16x16::FP16x16NN; use orion::operators::nn::implementations::nn_fp32x32::FP32x32NN; use orion::operators::nn::implemen...
https://github.com/gizatechxyz/orion
src/operators/nn/core.cairo
use orion::operators::tensor::core::Tensor; /// Trait /// /// relu - Applies the rectified linear unit function element-wise. /// leaky_relu - Applies the leaky rectified linear unit (Leaky ReLU) activation function element-wise. /// sigmoid - Applies the Sigmoid function to an n-dimensional input tensor. /// softmax ...
https://github.com/gizatechxyz/orion
src/operators/nn/functional.cairo
mod relu; mod leaky_relu; mod sigmoid; mod softmax; mod softmax_zero; mod softsign; mod softplus; mod linear; mod logsoftmax; mod thresholded_relu; mod hard_sigmoid; mod gemm; mod grid_sample; mod col2im; mod conv_transpose; mod depth_to_space; mod space_to_depth; mod conv;
https://github.com/gizatechxyz/orion
src/operators/nn/functional/col2im.cairo
use orion::numbers::NumberTrait; use orion::operators::tensor::core::{stride}; use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor,}; use orion::operators::vec::{NullableVec, NullableVecImpl}; fn col2im<T, MAG, +TensorTrait<T>, +NumberTrait<T, MAG>, +Copy<T>, +Drop<T>, +Add<T>, +Mul<T>,>( data: @Tensor<T...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/conv.cairo
use core::debug::PrintTrait; use orion::numbers::NumberTrait; use orion::numbers::{U32IntoI32, I32IntoU32, I32Div, I32Number}; use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor,}; use orion::operators::vec::{NullableVec, NullableVecImpl}; use orion::operators::tensor::core::{stride}; #[derive(Copy, Drop)]...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/conv_transpose.cairo
use orion::numbers::NumberTrait; use orion::operators::tensor::core::{stride}; use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor,}; use orion::operators::vec::{NullableVec, NullableVecImpl}; #[derive(Copy, Drop)] enum AUTO_PAD { NOTSET, SAME_UPPER, SAME_LOWER, VALID } fn conv_transpose< ...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/depth_to_space.cairo
use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::NumberTrait; use orion::operators::tensor::core::{Tensor, TensorTrait}; use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; use orion::operators::tensor::math::{reduce_sum::accumulate_sum, arithmetic::div_d...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/gemm.cairo
use core::array::SpanTrait; use orion::numbers::NumberTrait; use orion::operators::tensor::{core::{Tensor, TensorTrait}, math::arithmetic::mul_by_scalar}; /// Cf: NNTrait::gemm docstring fn gemm< T, MAG, impl TTensor: TensorTrait<T>, impl TAddTensor: Add<Tensor<T>>, impl TNumberTrait: NumberTrait<...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/grid_sample.cairo
use core::debug::PrintTrait; use orion::numbers::FP16x16; use orion::numbers::NumberTrait; use orion::operators::tensor::core::{stride}; use orion::operators::tensor::{FP16x16Tensor, TensorTrait, Tensor, U32Tensor,}; use orion::operators::vec::{NullableVec, NullableVecImpl}; #[derive(Copy, Drop)] enum MODE { NEAR...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/hard_sigmoid.cairo
use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::NumberTrait; use orion::operators::tensor::core::{Tensor, TensorTrait}; /// Cf: NNTrait::hard_sigmoid docstring fn hard_sigmoid< T, MAG, impl TNumber: NumberTrait<T, MAG>, impl TTensor: TensorTrait<T>, impl TPartialOrd: PartialO...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/leaky_relu.cairo
use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::NumberTrait; use orion::operators::tensor::core::{Tensor, TensorTrait}; /// Cf: NNTrait::leaky_relu docstring fn leaky_relu< T, MAG, impl FNumber: NumberTrait<T, MAG>, impl FTensor: TensorTrait<T>, impl FPartialOrd: PartialOrd<T...
https://github.com/gizatechxyz/orion
src/operators/nn/functional/linear.cairo
use orion::numbers::NumberTrait; use orion::operators::tensor::core::{Tensor, TensorTrait}; /// Cf: NNTrait::linear docstring fn linear< T, impl TTensor: TensorTrait<T>, impl TAddTensor: Add<Tensor<T>>, impl TCopy: Copy<T>, impl TDrop: Drop<T> >( z: Tensor<T>, weights: Tensor<T>, bias: Tensor<T...
https://github.com/gizatechxyz/orion