file_path stringlengths 7 180 | content stringlengths 0 811k | repo stringclasses 11
values |
|---|---|---|
docgen/src/main.rs | use regex::Regex;
use std::fs;
use std::path::Path;
fn main() {
// TENSOR DOC
let trait_path = "src/operators/tensor/core.cairo";
let doc_path = "docs/framework/operators/tensor";
let label = "tensor";
let trait_name = "TensorTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(tra... | https://github.com/gizatechxyz/orion |
nodegen/__init__.py | https://github.com/gizatechxyz/orion | |
nodegen/file_manager.py | import os
from pathlib import Path
BASE_PATH = "./tests/nodes"
class ModFile:
def __init__(self):
"""
Initialize a ModFile object.
This method creates a new file with a .cairo extension in the BASE_PATH directory.
If the directory doesn't exist, it's created. The contents of the... | https://github.com/gizatechxyz/orion |
nodegen/helpers.py | from enum import Enum
import os
from typing import List
from .file_manager import CairoTest, CairoData, ModFile
import numpy as np
class FixedImpl(Enum):
FP8x23 = 'FP8x23'
FP16x16 = 'FP16x16'
FP32x32 = 'FP32x32'
def to_fp(x: np.ndarray, fp_impl: FixedImpl):
match fp_impl:
case FixedIm... | https://github.com/gizatechxyz/orion |
nodegen/node/__init__.py | import argparse
import importlib
import os
import sys
class RunAll:
@classmethod
def run_all(cls):
for method_name in dir(cls):
if method_name.startswith('__') or method_name == 'run_all':
continue
method = getattr(cls, method_name)
if callable(metho... | https://github.com/gizatechxyz/orion |
nodegen/node/abs.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Abs(RunAll):
@staticmethod
def abs_i32():
x = np.random.randint(-127, 127, (2, 2)).astype(np.int32)
y = abs(x)
x = Tensor(Dtype.I32, x.shape, x.flatten())
... | https://github.com/gizatechxyz/orion |
nodegen/node/acos.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Acos(RunAll):
@staticmethod
def acos_fp8x23():
x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64)
y = np.arccos(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(... | https://github.com/gizatechxyz/orion |
nodegen/node/acosh.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Acosh(RunAll):
@staticmethod
def acosh_fp8x23():
x = np.random.uniform(1, 5, (2, 2)).astype(np.float64)
y = np.arccosh(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(
... | https://github.com/gizatechxyz/orion |
nodegen/node/add.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Add(RunAll):
@staticmethod
def add_u32():
def default():
x = np.random.randint(0, 3, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0, 3, (3, 3, 3)).ast... | https://github.com/gizatechxyz/orion |
nodegen/node/and.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class And(RunAll):
@staticmethod
def and_bool():
def default():
x = (np.random.randn(3, 4) > 0).astype(bool)
y = (np.random.randn(3, 4) > 0).astype(bool)
... | https://github.com/gizatechxyz/orion |
nodegen/node/argmax.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
def argmax_use_numpy(data: np.ndarray, axis: int = 0, keepdims: int = 1) -> np.ndarray:
result = np.argmax(data, axis=axis)
if keepdims == 1:
result = np.expand_dims(result, axis)
re... | https://github.com/gizatechxyz/orion |
nodegen/node/argmin.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
def argmin_use_numpy(data: np.ndarray, axis: int = 0, keepdims: int = 1, dtype=np.int64) -> np.ndarray:
result = np.argmin(data, axis=axis)
if keepdims == 1:
result = np.expand_dims(resu... | https://github.com/gizatechxyz/orion |
nodegen/node/array_feature_extractor.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Array_feature_extractor(RunAll):
@staticmethod
def array_feature_extractor_3D():
def array_feature_extractor_i32():
x = np.random.randint(-3, 3, (2, 3, 4)).astype(np.i... | https://github.com/gizatechxyz/orion |
nodegen/node/asin.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Asin(RunAll):
@staticmethod
def asin_fp8x23():
x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64)
y = np.arcsin(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(... | https://github.com/gizatechxyz/orion |
nodegen/node/asinh.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Asinh(RunAll):
@staticmethod
def asinh_fp8x23():
x = np.random.uniform(1, 5, (2, 2)).astype(np.float64)
y = np.arcsinh(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(... | https://github.com/gizatechxyz/orion |
nodegen/node/atan.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Atan(RunAll):
@staticmethod
def atan_fp8x23():
x = np.random.uniform(-10, 127, (2, 2)).astype(np.float64)
y = np.arctan(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(... | https://github.com/gizatechxyz/orion |
nodegen/node/binarizer.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_node, make_test, to_fp, Tensor, Dtype, FixedImpl
class Binarizer(RunAll):
@staticmethod
def binarizer_fp8x23():
x = np.random.uniform(-3, 3, (3, 3, 3)).astype(np.float64)
threshold = np.float64(1)
y = (x > t... | https://github.com/gizatechxyz/orion |
nodegen/node/blackman_window.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait, get_data_statement
def blackman_window(size, output_datatype=None, periodic=None) -> np.ndarray: # type: ignore
if periodic == 1:
N_1 = size
else:
N_1 = size - 1
ni =... | https://github.com/gizatechxyz/orion |
nodegen/node/ceil.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Ceil(RunAll):
@staticmethod
def ceil_fp8x23():
x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64)
y = np.ceil(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.... | https://github.com/gizatechxyz/orion |
nodegen/node/clip.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Clip(RunAll):
@staticmethod
def clip_u32():
def clip_2D():
x = np.random.randint(0, 255, (2, 4)).astype(np.uint32)
y = np.clip(x, np.uint32(10), np.uint32(2... | https://github.com/gizatechxyz/orion |
nodegen/node/col2im.py |
import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def col2im(data, image_shape, block_shape, dilations=None, pads=None, strides=None): # type: ignore
if dilations is None:
dilations = [1 for s in image_shape]
if pads is None:
... | https://github.com/gizatechxyz/orion |
nodegen/node/compress.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Compress(RunAll):
@staticmethod
def compress_fp16x16():
def compress_3D():
def default():
x1 = np.arange(0,27).reshape(3,3,3).astype... | https://github.com/gizatechxyz/orion |
nodegen/node/concat.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
# 687
class Concat(RunAll):
@staticmethod
def concat_u32():
def concat_1D():
x1 = np.arange(0,3).astype(np.uint32)
x2 = np.arange(3,6).astype(np.uint32)
... | https://github.com/gizatechxyz/orion |
nodegen/node/concat_from_sequence.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Concat_from_sequence(RunAll):
@staticmethod
def concat_from_sequence_u32():
def new_axis_zero():
sequence = []
values_array = []
shape =... | https://github.com/gizatechxyz/orion |
nodegen/node/conv.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
import numpy as np
def r_index_check(r_index, shape_out):
for i in range(len(r_index)):
if r_index[i] >= shape_out[i]:
return False
return True
def stride(arr):
... | https://github.com/gizatechxyz/orion |
nodegen/node/conv_transpose.py |
import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def conv_transpose(
X,
W,
B=None,
auto_pad=None,
dilations=None,
group=None,
kernel_shape=None,
output_padding=None,
output_shape=None,
pads=None,
s... | https://github.com/gizatechxyz/orion |
nodegen/node/cos.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Cos(RunAll):
@staticmethod
def cos_fp8x23():
x = np.random.uniform(-10, 127, (2, 2)).astype(np.float64)
y = np.cos(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(
... | https://github.com/gizatechxyz/orion |
nodegen/node/cosh.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Cosh(RunAll):
@staticmethod
def cosh_fp8x23():
x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64)
y = np.cosh(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(
... | https://github.com/gizatechxyz/orion |
nodegen/node/cumsum.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Cumsum(RunAll):
@staticmethod
def cumsum_u32():
def cumsum_1D():
def default():
x = np.array([1, 2, 3, 4, 5]).astype(np.uint32)
y = np.a... | https://github.com/gizatechxyz/orion |
nodegen/node/depth_to_space.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def depth_to_space(data: np.ndarray, blocksize: int = 2, mode = "DCR") -> np.ndarray:
if len(data.shape) != 4:
raise RuntimeError(f"Unexpected shape {data.shape!r}.")
b, c, h, w = ... | https://github.com/gizatechxyz/orion |
nodegen/node/div.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Div(RunAll):
@staticmethod
def div_u32():
def default():
x = np.random.randint(3, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(1, 3, (3, 3, 3)).ast... | https://github.com/gizatechxyz/orion |
nodegen/node/equal.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Equal(RunAll):
@staticmethod
def equal_u32():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0, 6, (3, 3, 3))... | https://github.com/gizatechxyz/orion |
nodegen/node/erf.py | import numpy as np
from math import erf
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Erf(RunAll):
@staticmethod
def erf_fp8x23():
x = np.asarray([0.12, -1.66, 3.4, 4.8, 2.7]).astype(np.float64).reshape(1,5)
y = np.asarray([erf(value) f... | https://github.com/gizatechxyz/orion |
nodegen/node/exp.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Exp(RunAll):
@staticmethod
def exp_fp8x23():
x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64)
y = np.exp(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(
... | https://github.com/gizatechxyz/orion |
nodegen/node/gather.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Gather(RunAll):
@staticmethod
def gather_fp16x16():
def default():
x1 = np.arange(0,27).reshape(3,3,3).astype(np.int64)
x2 = np.array([[... | https://github.com/gizatechxyz/orion |
nodegen/node/gather_elements.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def gather_elements(data, indices, axis=0): # type: ignore
data_swaped = np.swapaxes(data, 0, axis)
index_swaped = np.swapaxes(indices, 0, axis)
gathered = np.choose(index_swaped, dat... | https://github.com/gizatechxyz/orion |
nodegen/node/gather_nd.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
def gather_nd_impl(
data: np.ndarray, indices: np.ndarray, batch_dims: int
) -> np.ndarray:
# Note the data rank - will be reused multiple times later
data_rank = len(data.shape)
# Check... | https://github.com/gizatechxyz/orion |
nodegen/node/gemm.py | from typing import Optional
import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def gemm_reference_implementation(
A: np.ndarray,
B: np.ndarray,
C: Optional[np.ndarray] = None,
alpha: float = 1.0,
beta: float = 1.0,
transA... | https://github.com/gizatechxyz/orion |
nodegen/node/greater.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Greater(RunAll):
@staticmethod
def greater_u32():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0, 6, (3, 3,... | https://github.com/gizatechxyz/orion |
nodegen/node/greater_equal.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Greater_equal(RunAll):
@staticmethod
def greater_equal_u32():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(... | https://github.com/gizatechxyz/orion |
nodegen/node/grid_sample.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
from .resize import _get_all_coords
import numbers
from typing import List
import numpy as np
#from onnx.reference.ops.op_resize import _get_all_coords
def grid_sample(X, grid, mode='linear', pa... | https://github.com/gizatechxyz/orion |
nodegen/node/hamming_window.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait, get_data_statement
def hamming_window(size, output_datatype=None, periodic=None) -> np.ndarray: # type: ignore
if periodic == 1:
N_1 = size
else:
N_1 = size - 1
ni = ... | https://github.com/gizatechxyz/orion |
nodegen/node/hann_window.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait, get_data_statement
def hann_window(size, output_datatype=None, periodic=None) -> np.ndarray: # type: ignore
if periodic == 1:
N_1 = size
else:
N_1 = size - 1
ni = np.... | https://github.com/gizatechxyz/orion |
nodegen/node/hard_sigmoid.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Hard_sigmoid(RunAll):
@staticmethod
def fp8x23():
alpha = 0.2
beta = 0.5
x = np.random.uniform(-3, 3, (2, 2)).astype(np.float32)
y = np.maximum(0, np... | https://github.com/gizatechxyz/orion |
nodegen/node/identity.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Identity(RunAll):
@staticmethod
def identity_fP8x23():
def identity():
x = np.array([[1, 2], [3, 4]])
y = x
x = Tensor(Dtype.FP8x2... | https://github.com/gizatechxyz/orion |
nodegen/node/is_inf.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
INF = 2**32 - 1
class Is_inf(RunAll):
@staticmethod
def is_inf_u32():
def default():
input_0 = np.array([1, 0, INF, 8, -INF, INF], dtype=np.uint32)
output = np.a... | https://github.com/gizatechxyz/orion |
nodegen/node/is_nan.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
# NaN is represented with -0
NaN = -0
class Is_nan(RunAll):
@staticmethod
def is_nan_fp8x23():
def default():
input_0 = np.array([-1.2, 0, NaN, 2.8, NaN, NaN], dtype=np.flo... | https://github.com/gizatechxyz/orion |
nodegen/node/label_encoder.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
# Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
# pylint: disable=R0913,R0914,W0221
def labelEncoder( # type: ignore
x,
default_float=None,
default_int... | https://github.com/gizatechxyz/orion |
nodegen/node/layer_normalization.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
def _layer_normalization(X, W, B, axis=-1, epsilon=1e-5):
X_shape ... | https://github.com/gizatechxyz/orion |
nodegen/node/leaky_relu.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
import tensorflow as tf
class Leaky_relu(RunAll):
@staticmethod
def leaky_relu_fp8x23():
x = np.random.uniform(-5, 7, (2, 2)).astype(np.float64)
layer = tf.keras.layers.... | https://github.com/gizatechxyz/orion |
nodegen/node/less.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Less(RunAll):
@staticmethod
def less_u32():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0, 6, (3, 3, 3)).a... | https://github.com/gizatechxyz/orion |
nodegen/node/less_equal.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Less_equal(RunAll):
@staticmethod
def less_equal_u32():
def default():
x = np.random.randint(0, 6, (2, 2)).astype(np.uint32)
y = np.random.randint(0, 6, (2,... | https://github.com/gizatechxyz/orion |
nodegen/node/linear.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
from typing import Optional
def linear(
i: np.ndarray,
w: np.ndarray,
b: Optional[np.ndarray] = None,
) -> np.ndarray:
return np.dot(i, w.T) + b
class Linear(RunAll):
@sta... | https://github.com/gizatechxyz/orion |
nodegen/node/log.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Log(RunAll):
@staticmethod
def log_fp8x23():
x = np.random.uniform(1, 127, (2, 2)).astype(np.float64)
y = np.log(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(
... | https://github.com/gizatechxyz/orion |
nodegen/node/logsoftmax.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def logsoftmax(x: np.ndarray, axis: int = -1) -> np.ndarray:
x_max = np.max(x, axis=axis, keepdims=True)
tmp = np.exp(x - x_max)
s = np.sum(tmp, axis=axis, keepdims=True)
return (... | https://github.com/gizatechxyz/orion |
nodegen/node/matmul.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Matmul(RunAll):
@staticmethod
def matmul_u32():
def matmul_1D():
a = np.random.randint(0, 255, (3)).astype(np.uint32)
b = np.random.randint(0, 255, (3)).as... | https://github.com/gizatechxyz/orion |
nodegen/node/max.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Max(RunAll):
@staticmethod
def max_u32_two_tensors():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0... | https://github.com/gizatechxyz/orion |
nodegen/node/min.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Min(RunAll):
@staticmethod
def min_u32_two_tensors():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0... | https://github.com/gizatechxyz/orion |
nodegen/node/mul.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Mul(RunAll):
@staticmethod
def mul_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/neg.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Neg(RunAll):
@staticmethod
def neg_i32():
x = np.random.randint(-127, 127, (2, 2)).astype(np.int32)
y = np.negative(x)
x = Tensor(Dtype.I32, x.shape, x.flatten())
... | https://github.com/gizatechxyz/orion |
nodegen/node/nonzero.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Nonzero(RunAll):
@staticmethod
def nonzero_u32():
def nonzero_2D():
x = np.random.randint(0, 255, (2, 4)).astype(np.uint32)
y = np.array(np.nonzero(x), dtyp... | https://github.com/gizatechxyz/orion |
nodegen/node/not.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_node, make_test, Tensor, Dtype
class Not(RunAll):
@staticmethod
def not_bool():
x = np.random.uniform(True, False, (1, 1)).astype(bool)
y = ~(x)
x = Tensor(Dtype.Bool, x.shape, x.flatten())
y = Tensor... | https://github.com/gizatechxyz/orion |
nodegen/node/or.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Or(RunAll):
@staticmethod
def or_u32():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0, 6, (3, 3, 3)).astyp... | https://github.com/gizatechxyz/orion |
nodegen/node/pow.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Pow(RunAll):
@staticmethod
def pow_fp8x23():
def default():
x = np.array([1, 2, 3]).astype(np.float64)
y = np.array([1, 2, 3]).astype(np.float64)
... | https://github.com/gizatechxyz/orion |
nodegen/node/random_uniform_like.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def random_uniform_like(x: np.ndarray, high: int=1,low: int=0,seed: int=25) ->np.ndarray:
dtype = np.float64
if seed is None or np.isnan(seed): # type: ignore
state = np.random.Ra... | https://github.com/gizatechxyz/orion |
nodegen/node/range.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait, get_data_statement
class Range(RunAll):
@staticmethod
# We test here with fp8x23 implementation.
def fp8x23():
args = [1, 5, 0.3]
args_str = get_data_statement... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_l1.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
import numpy as np
class Reduce_l1(RunAll):
@staticmethod
def reduce_l1_fp8x23():
def reduce_l1_export_do_not_keepdims():
shape = [3, 2, 2]
axes = np.array([2], d... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_l2.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_node, make_test, to_fp, Tensor, Dtype, FixedImpl
import numpy as np
class Reduce_l2(RunAll):
@staticmethod
def reduce_l2_fp8x23():
def reduce_l2_export_do_not_keepdims():
shape = [3, 2, 2]
axes = np.... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_log_sum.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Reduce_log_sum(RunAll):
@staticmethod
def reduce_log_sum_fp8x23():
def reduce_log_sum_export_do_not_keepdims():
shape = [3, 2, 2]
axes = np.array([2], dty... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_log_sum_exp.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, Tensor, Dtype, FixedImpl, to_fp
class Reduce_log_sum_exp(RunAll):
@staticmethod
def reduce_log_sum_exp_fp32x32():
def reduce_log_sum_exp_export_do_not_keepdims():
shape = [3, 2, 2]
axes = np.arra... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_mean.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Reduce_mean(RunAll):
@staticmethod
def reduce_mean_u32():
def reduce_mean_1D():
x = np.array([0, 1, 2,]).astype(np.uint32)
y = np.mean(x, keepdims=True).ast... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_min.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Reduce_min(RunAll):
@staticmethod
def reduce_min_u32():
def reduce_min_1D():
x = np.array([0, 1, 2,]).astype(np.uint32)
y = np.minimum.reduce(x, axis=None, ... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_sum.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Reduce_sum(RunAll):
@staticmethod
def reduce_sum_no_keep_dims():
axes = np.array([1], dtype=np.uint32)
keepdims = 0
x = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8... | https://github.com/gizatechxyz/orion |
nodegen/node/reduce_sum_square.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
import numpy as np
class Reduce_sum_square(RunAll):
@staticmethod
def reduce_sum_square_fp8x23():
def reduce_sum_square_export_do_not_keepdims():
shape = [3, 2, 2]
... | https://github.com/gizatechxyz/orion |
nodegen/node/relu.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, Trait, FixedImpl
import tensorflow as tf
class Relu(RunAll):
@staticmethod
def relu_i32():
x = np.random.randint(-5, 9, (2, 2)).astype(np.int32)
layer = tf.keras.layers.ReLU()
y =... | https://github.com/gizatechxyz/orion |
nodegen/node/reshape.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, Tensor, Dtype
original_shape = [2, 3, 4]
data = np.random.random_sample(original_shape).astype(np.int32)
def reshape_reference_implementation(
data: np.ndarray, shape: np.ndarray, allowzero: int = 0
) -> np.ndarray:
# replace... | https://github.com/gizatechxyz/orion |
nodegen/node/resize.py | # Python test implementation from ONNX library : https://github.com/onnx/onnx/blob/main/onnx/reference/ops/op_resize.py
import numpy as np
from typing import Any, Callable
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
def _cartesian(arrays: list[np.ndarray], out: n... | https://github.com/gizatechxyz/orion |
nodegen/node/reverse_sequence.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Reverse_sequence(RunAll):
@staticmethod
def Reverse_sequence_u32():
def reverse_sequence_u32_4x4_batch():
x = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14... | https://github.com/gizatechxyz/orion |
nodegen/node/round.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Round(RunAll):
@staticmethod
def round_fp8x23():
x = np.array([0.1, 0.5, 0.9, 1.2, 1.5, 1.8, 2.3, 2.5, 2.7, -1.1, -1.5, -1.9, -2.2, -2.5, -2.8]).astype(np.float64)
y = n... | https://github.com/gizatechxyz/orion |
nodegen/node/running.py | import os
import glob
# 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('.py')]
fixed =... | https://github.com/gizatechxyz/orion |
nodegen/node/scatter.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
# The below ScatterElements' numpy implementation is from https://stackoverflow.com/a/46204790/11767360
def scatter_elements(data, indices, updates, axis=0, reduction="none"): # type: ignore
... | https://github.com/gizatechxyz/orion |
nodegen/node/scatter_nd.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
def scatter_nd_impl(data, indices, updates, reduction="none"): # type: ignore
# Check tensor shapes
assert indices.shape[-1] <= len(data.shape)
assert updates.shape == indices.shape[:-1] + d... | https://github.com/gizatechxyz/orion |
nodegen/node/sequence_at.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
scalar = lambda x: Tensor(Dtype.I32, (), np.array([x]).astype(np.int32).flatten())
class Sequence_at(RunAll):
@staticmethod
def sequence_at_u32():
def positive_position():
... | https://github.com/gizatechxyz/orion |
nodegen/node/sequence_construct.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Sequence_construct(RunAll):
@staticmethod
def sequence_construct_u32():
sequence = []
tensor_cnt = np.random.randint(1, 10)
shape = np.random.randint(1, 4, ... | https://github.com/gizatechxyz/orion |
nodegen/node/sequence_empty.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, Dtype, Tensor, Trait
class Sequence_empty(RunAll):
@staticmethod
def sequence_empty_u32():
def default():
shape=(0,)
x = np.zeros(shape, dtype=np.uint32)
t = Tensor(Dtype.U32, shape... | https://github.com/gizatechxyz/orion |
nodegen/node/sequence_erase.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
scalar = lambda x: Tensor(Dtype.I32, (), np.array([x]).astype(np.int32).flatten())
class Sequence_erase(RunAll):
@staticmethod
def sequence_erase_u32():
def positive_position()... | https://github.com/gizatechxyz/orion |
nodegen/node/sequence_insert.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
scalar = lambda x: Tensor(Dtype.I32, (), np.array([x]).astype(np.int32).flatten())
class Sequence_insert(RunAll):
@staticmethod
def sequence_insert_u32():
def default():
... | https://github.com/gizatechxyz/orion |
nodegen/node/sequence_length.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
scalar = lambda x: Tensor(Dtype.U32, (), np.array([x]).astype(np.uint32).flatten())
class Sequence_length(RunAll):
@staticmethod
def sequence_length_u32():
def default():
... | https://github.com/gizatechxyz/orion |
nodegen/node/shrink.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
def shrink(input_array: np.ndarray, bias: float, lambd: float) -> np.ndarray:
output_array = np.where(input_array > lambd, input_array - bias,
np.where(input_array < -la... | https://github.com/gizatechxyz/orion |
nodegen/node/sigmoid.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
import tensorflow as tf
class Sigmoid(RunAll):
@staticmethod
def fp8x23():
x = np.random.uniform(-3, 3, (2, 2)).astype(np.float32)
y = tf.keras.activations.sigmoid(x).num... | https://github.com/gizatechxyz/orion |
nodegen/node/sign.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Sign(RunAll):
@staticmethod
def sign_i8():
def sign():
x = np.array(range(-5, 6)).astype(np.int8)
y = np.array([-1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1]).... | https://github.com/gizatechxyz/orion |
nodegen/node/sin.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Sin(RunAll):
@staticmethod
def sin_fp8x23():
x = np.random.uniform(-3, 7, (2, 2)).astype(np.float64)
y = np.sin(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(
... | https://github.com/gizatechxyz/orion |
nodegen/node/sinh.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Sinh(RunAll):
@staticmethod
def sinh_fp8x23():
x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64)
y = np.sinh(x)
x = Tensor(Dtype.FP8x23, x.shape, to_fp(
... | https://github.com/gizatechxyz/orion |
nodegen/node/slice.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Slice(RunAll):
@staticmethod
def slice_u32():
def slice_2D():
x = np.random.randint(0, 255, (2, 4)).astype(np.uint32)
y = x[0:2, 2:4]
x = Tenso... | https://github.com/gizatechxyz/orion |
nodegen/node/softmax.py | import numpy as np
from nodegen.node import RunAll
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)
tmp = np.exp(x - x_max)
s = np.sum(tmp, axis=axis, keepdims=True)
return tmp ... | https://github.com/gizatechxyz/orion |
nodegen/node/softmax_zero.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def softmax_zero(x: np.ndarray, axis: int = -1) -> np.ndarray:
x_max = np.max(x, axis=axis, keepdims=True)
tmp = np.exp(x - x_max)
tmp = np.where(x == 0.0, 0.0, tmp)
s = np.sum(t... | https://github.com/gizatechxyz/orion |
nodegen/node/softplus.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def softplus(x: np.ndarray) -> np.ndarray:
return np.log(np.exp(x) + 1)
class Softplus(RunAll):
@staticmethod
def softplus_fp():
def fp8x23():
x = np.random.uni... | https://github.com/gizatechxyz/orion |
nodegen/node/softsign.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def softsign(x: np.ndarray) -> np.ndarray:
return x / (1 + np.abs(x))
class Softsign(RunAll):
@staticmethod
def softsign_fp():
def fp8x23():
x = np.random.unifo... | https://github.com/gizatechxyz/orion |
nodegen/node/space_to_depth.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
def space_to_depth(data: np.ndarray, blocksize: int = 2) -> np.ndarray:
if len(data.shape) != 4:
raise RuntimeError(f"Unexpected shape {data.shape!r}.")
b, C, H, W = data.shape
... | https://github.com/gizatechxyz/orion |
nodegen/node/split.py | import numpy as np
from nodegen.node import RunAll
from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl
class Split(RunAll):
@staticmethod
def split_u32():
def split_1D():
x = np.random.randint(0, 255, 6).astype(np.uint32)
y = [
np.array(x[0:2]).asty... | https://github.com/gizatechxyz/orion |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.