From 02a7c9ccf00226f370edeec3dd4996d8129972c5 Mon Sep 17 00:00:00 2001 From: bemtg Date: Sat, 30 Mar 2024 23:27:51 +0000 Subject: [PATCH 1/9] adding main instance_normalization logic --- .../tensor/math/instance_normalization.cairo | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 src/operators/tensor/math/instance_normalization.cairo diff --git a/src/operators/tensor/math/instance_normalization.cairo b/src/operators/tensor/math/instance_normalization.cairo new file mode 100644 index 000000000..98daccaa8 --- /dev/null +++ b/src/operators/tensor/math/instance_normalization.cairo @@ -0,0 +1,174 @@ +use core::traits::TryInto; +use core::array::ArrayTrait; +use core::array::SpanTrait; +use core::option::OptionTrait; +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, FP32x32Impl, FixedTrait}; +use core::debug::PrintTrait; +use orion::operators::vec::{VecTrait, NullableVec, NullableVecImpl}; + + +fn instance_normalization, + +NumberTrait, + +PartialEq, + +Copy, + +Drop, + +Add, + +Mul, + +Div, + +Sub, + +Neg, + +PrintTrait, + +Div>, + +Sub>, + +Add>, + +Mul>, + +Into,> + ( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option,) -> Tensor { + + + let dim_x = (*self).shape.len(); + let zero = NumberTrait::zero() ; + + let mut epsilon = match epsilon { + Option::Some(epsilon) => epsilon, + Option::None => zero + }; + + let mut axis: Array = array![]; + let mut i: usize = 2; + loop { + if (i >= dim_x) { + break; + } + axis.append(i); + i += 1; + }; + + let mut noop_with_empty_axes = Option::Some((false)); + let mut axis_input = Option::Some(axis.span()); + + if axis.len() == 0 { + axis_input = Option::None(()); + noop_with_empty_axes = Option::Some((true)); + } + + let mut mean = self.reduce_mean( axes: axis_input, + keepdims: Option::Some((true)), + noop_with_empty_axes: noop_with_empty_axes ); + + + + let x_diff = (*self) - mean; + let x_diff_squared = x_diff * x_diff; + let mut variance = x_diff_squared.reduce_mean(axes: axis_input, + keepdims: Option::Some((true)), + noop_with_empty_axes: noop_with_empty_axes); + + let mut dim_ones: Array = array![]; + let mut i: usize = 0; + loop { + if i >= dim_x - 2 { + break; + } + dim_ones.append(1); + i += 1; + }; + + let mut dim_ones_clone = dim_ones.clone(); + + let mut new_scale_shape: Array = array![]; + new_scale_shape.append(*(*scale.shape).at(0)); + let mut i: usize = 0; + loop { + if i >= dim_ones.len() { + break; + } + new_scale_shape.append(*dim_ones.at(i)); + + i += 1; + }; + + // bias and scale should have same shape + let mut scale = scale.reshape(target_shape: new_scale_shape.span()); + // let new_bias_shape = new_scale_shape.clone(); + let mut bias = bias.reshape(target_shape: new_scale_shape.span()); // since bias and scale have same shape + + + // adjust shape of epsilon tensor to match the shape of variance tensor + let mut epsilon = TensorTrait::new(shape: array![].span(), data: array![epsilon].span()); + let mut epsilon_shape: Array = array![]; + let mut i: usize = 0; + loop { + if (i >= variance.shape.len()) { + break; + } + epsilon_shape.append(1); + i += 1; + }; + epsilon = epsilon.reshape(target_shape: epsilon_shape.span()); + let mut std = (variance + epsilon).sqrt(); + + let mut zero_vals_in_tensor = false; + let mut i: usize = 0; + loop { + if (i >= std.data.len()) { + break; + } + if *std.data.at(i) == zero { + zero_vals_in_tensor = true; + } + i += 1; + }; + + if zero_vals_in_tensor == true { + // clip values to min_std_val to avoid possible division by zero errors + let mut a: usize = 500; + let mut min_std_val = NumberTrait::::half() / NumberTrait::::new_unscaled(a.into(), false); + std = std.clip(min: Option::Some((min_std_val)), max: Option::None(()), ); + }; + + let mut x_normalized = x_diff / std; + + // expanding the the dims accordingly to complete arthmetic ops for tensors of different shapes + let mut expanded_new_scale_shape: Array = array![]; + if new_scale_shape.len() != x_normalized.shape.len() { + let shape_diff = x_normalized.shape.len() - new_scale_shape.len(); + let mut i: usize = 0; + loop { + if i >= shape_diff { + break; + } + expanded_new_scale_shape.append(1); + i += 1; + }; + expanded_new_scale_shape.append(*scale.shape.at(0)); + + let mut i: usize = 0; + loop { + if i >= dim_ones_clone.len() { + break; + } + expanded_new_scale_shape.append(*dim_ones_clone.at(i)); + + i += 1; + }; + + let expanded_new_bias_shape = expanded_new_scale_shape.clone(); + + scale = scale.reshape(target_shape: expanded_new_scale_shape.span()); + bias = bias.reshape(target_shape: expanded_new_bias_shape.span()); + } + + return x_normalized * scale + bias; +} From 365602563538a1235c0747ac5d0b73920af48c67 Mon Sep 17 00:00:00 2001 From: bemtg Date: Sat, 30 Mar 2024 23:33:53 +0000 Subject: [PATCH 2/9] adding instance_norm implementations --- src/operators/tensor/implementations/tensor_bool.cairo | 9 +++++++++ .../tensor/implementations/tensor_complex64.cairo | 9 +++++++++ .../tensor/implementations/tensor_fp16x16.cairo | 9 +++++++++ .../tensor/implementations/tensor_fp16x16wide.cairo | 9 +++++++++ .../tensor/implementations/tensor_fp32x32.cairo | 9 +++++++++ .../tensor/implementations/tensor_fp64x64.cairo | 9 +++++++++ src/operators/tensor/implementations/tensor_fp8x23.cairo | 9 +++++++++ .../tensor/implementations/tensor_fp8x23wide.cairo | 9 +++++++++ src/operators/tensor/implementations/tensor_i32.cairo | 9 +++++++++ src/operators/tensor/implementations/tensor_i8.cairo | 9 +++++++++ src/operators/tensor/implementations/tensor_u32.cairo | 9 +++++++++ 11 files changed, 99 insertions(+) diff --git a/src/operators/tensor/implementations/tensor_bool.cairo b/src/operators/tensor/implementations/tensor_bool.cairo index e8ca7e2d8..f3209faa3 100644 --- a/src/operators/tensor/implementations/tensor_bool.cairo +++ b/src/operators/tensor/implementations/tensor_bool.cairo @@ -453,6 +453,15 @@ impl BoolTensor of TensorTrait { math::compress::compress(self, condition, axis) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + panic(array!['not supported!']) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_complex64.cairo b/src/operators/tensor/implementations/tensor_complex64.cairo index 8acb0891e..375c0adef 100644 --- a/src/operators/tensor/implementations/tensor_complex64.cairo +++ b/src/operators/tensor/implementations/tensor_complex64.cairo @@ -484,6 +484,15 @@ impl Complex64Tensor of TensorTrait { math::reduce_log_sum_exp::reduce_log_sum_exp(self, axis, keepdims) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + panic(array!['not supported!']) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_fp16x16.cairo b/src/operators/tensor/implementations/tensor_fp16x16.cairo index 27f853df5..3e6ff7749 100644 --- a/src/operators/tensor/implementations/tensor_fp16x16.cairo +++ b/src/operators/tensor/implementations/tensor_fp16x16.cairo @@ -514,6 +514,15 @@ impl FP16x16Tensor of TensorTrait { manipulation::unique::unique(self, axis, sorted) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + math::instance_normalization::instance_normalization(self, scale, bias, epsilon) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_fp16x16wide.cairo b/src/operators/tensor/implementations/tensor_fp16x16wide.cairo index 61485bae6..44e30b44a 100644 --- a/src/operators/tensor/implementations/tensor_fp16x16wide.cairo +++ b/src/operators/tensor/implementations/tensor_fp16x16wide.cairo @@ -491,6 +491,15 @@ impl FP16x16WTensor of TensorTrait { math::compress::compress(self, condition, axis) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + math::instance_normalization::instance_normalization(self, scale, bias, epsilon) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_fp32x32.cairo b/src/operators/tensor/implementations/tensor_fp32x32.cairo index 6ea3c7d94..4e29de7f3 100644 --- a/src/operators/tensor/implementations/tensor_fp32x32.cairo +++ b/src/operators/tensor/implementations/tensor_fp32x32.cairo @@ -510,6 +510,15 @@ impl FP32x32Tensor of TensorTrait { manipulation::unique::unique(self, axis, sorted) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + math::instance_normalization::instance_normalization(self, scale, bias, epsilon) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_fp64x64.cairo b/src/operators/tensor/implementations/tensor_fp64x64.cairo index af955fff1..0ed9ec6db 100644 --- a/src/operators/tensor/implementations/tensor_fp64x64.cairo +++ b/src/operators/tensor/implementations/tensor_fp64x64.cairo @@ -510,6 +510,15 @@ impl FP64x64Tensor of TensorTrait { manipulation::unique::unique(self, axis, sorted) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + math::instance_normalization::instance_normalization(self, scale, bias, epsilon) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_fp8x23.cairo b/src/operators/tensor/implementations/tensor_fp8x23.cairo index 19681e641..da8c0cfb8 100644 --- a/src/operators/tensor/implementations/tensor_fp8x23.cairo +++ b/src/operators/tensor/implementations/tensor_fp8x23.cairo @@ -506,6 +506,15 @@ impl FP8x23Tensor of TensorTrait { manipulation::unique::unique(self, axis, sorted) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + math::instance_normalization::instance_normalization(self, scale, bias, epsilon) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_fp8x23wide.cairo b/src/operators/tensor/implementations/tensor_fp8x23wide.cairo index ef65871d4..c3318519d 100644 --- a/src/operators/tensor/implementations/tensor_fp8x23wide.cairo +++ b/src/operators/tensor/implementations/tensor_fp8x23wide.cairo @@ -465,6 +465,15 @@ impl FP8x23WTensor of TensorTrait { manipulation::unique::unique(self, axis, sorted) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + math::instance_normalization::instance_normalization(self, scale, bias, epsilon) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_i32.cairo b/src/operators/tensor/implementations/tensor_i32.cairo index 924a6b1fd..b5570d84e 100644 --- a/src/operators/tensor/implementations/tensor_i32.cairo +++ b/src/operators/tensor/implementations/tensor_i32.cairo @@ -523,6 +523,15 @@ impl I32Tensor of TensorTrait { math::compress::compress(self, condition, axis) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + panic(array!['not supported!']) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_i8.cairo b/src/operators/tensor/implementations/tensor_i8.cairo index f523c47b2..5bb526cbd 100644 --- a/src/operators/tensor/implementations/tensor_i8.cairo +++ b/src/operators/tensor/implementations/tensor_i8.cairo @@ -526,6 +526,15 @@ impl I8Tensor of TensorTrait { math::compress::compress(self, condition, axis) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + panic(array!['not supported!']) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, diff --git a/src/operators/tensor/implementations/tensor_u32.cairo b/src/operators/tensor/implementations/tensor_u32.cairo index 7aa2ade26..d9f9774a9 100644 --- a/src/operators/tensor/implementations/tensor_u32.cairo +++ b/src/operators/tensor/implementations/tensor_u32.cairo @@ -470,6 +470,15 @@ impl U32Tensor of TensorTrait { math::compress::compress(self, condition, axis) } + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor { + panic(array!['not supported!']) + } + fn layer_normalization( self: @Tensor, scale: @Tensor, From c7023a805175a78330f785aa7aeb2f77484fb3c8 Mon Sep 17 00:00:00 2001 From: bemtg Date: Sat, 30 Mar 2024 23:39:35 +0000 Subject: [PATCH 3/9] making instance_norm fn accessible --- src/operators/tensor/core.cairo | 114 ++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/src/operators/tensor/core.cairo b/src/operators/tensor/core.cairo index 02f9cc6e4..ad32c2d41 100644 --- a/src/operators/tensor/core.cairo +++ b/src/operators/tensor/core.cairo @@ -5096,6 +5096,120 @@ trait TensorTrait { /// ``` /// fn compress(self: @Tensor, condition: Tensor, axis: Option) -> Tensor; + /// # tensor.instance_normalization + /// + /// ```rust + /// fn instance_normalization( + /// self: @Tensor, + /// scale: @Tensor, + /// bias: @Tensor, + /// epsilon: Option, + /// ) -> Tensor; + /// ``` + /// + /// Computes instance normalization on the input tensor. + /// + /// The overall computation has two stages: + /// 1. The first stage normalizes the elements to have zero mean and unit variance for each instance. + /// 2. The second stage scales and shifts the results of the first stage using the provided scale and bias tensors. + /// + /// ## Args + /// + /// * `self` (`@Tensor`) - The input tensor with dimensions `(N x C x D1 x D2 ... Dn)`, where `N` is the batch size, + /// `C` is the number of channels, and `D1`, `D2`, ..., `Dn` are the remaining dimensions. + /// * `scale` (`@Tensor`) - Scale tensor of shape `(C)`. + /// * `bias` (`Option<@Tensor>`) - Bias tensor of shape `(C)`. If `None`, no bias is applied. + /// * `epsilon` (`Option`) (default is 1e-5) - The epsilon value to use to avoid division by zero. + /// + /// ## Panics + /// + /// * Panics if the scale tensor's shape is not `(C)`. + /// * Panics if the bias tensor is provided and its shape is not `(C)`. + /// + /// ## Returns + /// + /// A new tensor `Tensor` with the same shape as the input tensor, after applying instance normalization. + /// + /// ## Example + /// + /// ```rust + /// use orion::operators::tensor::{TensorTrait, Tensor}; + /// use orion::operators::tensor::FP16x16TensorPartialEq; + /// use core::array::{ArrayTrait, SpanTrait}; + /// use orion::operators::tensor::FP16x16Tensor; + /// use orion::numbers::{FixedTrait, FP16x16}; + /// + /// fn instance_normalization_example() -> Tensor { + /// + /// let epsilon = Option::Some( FixedTrait::new(6554, false)); + /// + /// let mut shape = ArrayTrait::::new(); + /// shape.append(2); + /// shape.append(3); + /// shape.append(2); + /// shape.append(1); + /// + /// let mut data = ArrayTrait::new(); + /// data.append(FP16x16 { mag: 24149, sign: false }); + /// data.append(FP16x16 { mag: 35894, sign: false }); + /// data.append(FP16x16 { mag: 38633, sign: true }); + /// data.append(FP16x16 { mag: 37793, sign: true }); + /// data.append(FP16x16 { mag: 23838, sign: false }); + /// data.append(FP16x16 { mag: 5937, sign: false }); + /// data.append(FP16x16 { mag: 13047, sign: true }); + /// data.append(FP16x16 { mag: 55527, sign: false }); + /// data.append(FP16x16 { mag: 97165, sign: true }); + /// data.append(FP16x16 { mag: 77657, sign: false }); + /// data.append(FP16x16 { mag: 7142, sign: false }); + /// data.append(FP16x16 { mag: 96338, sign: false }); + /// data.append(FP16x16 { mag: 24716, sign: true }); + /// let X = TensorTrait::new(shape.span(), data.span()); + /// + /// let mut shape = ArrayTrait::::new(); + /// shape.append(3); + /// let mut data = ArrayTrait::new(); + /// data.append(FP16x16 { mag: 41865, sign: true }); + /// data.append(FP16x16 { mag: 81535, sign: false }); + /// data.append(FP16x16 { mag: 81322, sign: true }); + /// let scale = TensorTrait::new(shape.span(), data.span()); + /// + /// let mut shape = ArrayTrait::::new(); + /// shape.append(3); + /// let mut data = ArrayTrait::new(); + /// data.append(FP16x16 { mag: 11243, sign: true }); + /// data.append(FP16x16 { mag: 122125, sign: false }); + /// data.append(FP16x16 { mag: 97543, sign: false }); + /// let bias = TensorTrait::new(shape.span(), data.span()); + /// + /// + /// return X.instance_normalization(@scale,@bias, epsilon); + /// } + /// >>> + /// [[[[-0.72982788], + /// [ 0.38671875]], + /// + /// [[ 0.83106995], + /// [ 2.89585876]], + /// + /// [[ 0.97167969], + /// [ 2.00509644]]], + /// + /// [[[-0.78804016], + /// [ 0.44493103]], + /// + /// [[ 2.93608093], + /// [ 0.79092407]], + /// + /// [[ 0.31443787], + /// [ 2.66233826]]]] + /// ``` + /// + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, + ) -> Tensor ; /// # tensor.layer_normalization /// /// ```rust From ef52c574e7f07c85f1093b66cd89b7c9b82bd53d Mon Sep 17 00:00:00 2001 From: bemtg Date: Sat, 30 Mar 2024 23:41:57 +0000 Subject: [PATCH 4/9] instance_norm testcases --- nodegen/node/instance_normalization.py | 656 +++++++++++++++++++++++++ 1 file changed, 656 insertions(+) create mode 100644 nodegen/node/instance_normalization.py diff --git a/nodegen/node/instance_normalization.py b/nodegen/node/instance_normalization.py new file mode 100644 index 000000000..ecb3568ea --- /dev/null +++ b/nodegen/node/instance_normalization.py @@ -0,0 +1,656 @@ +import numpy as np +from nodegen.node import RunAll +from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl + + +def _instancenorm_test_mode(x, s, bias, epsilon=1e-5): # type: ignore + dims_x = len(x.shape) + axis = tuple(range(2, dims_x)) + mean = np.mean(x, axis=axis, keepdims=True) + var = np.var(x, axis=axis, keepdims=True) + dim_ones = (1,) * (dims_x - 2) + s = s.reshape(-1, *dim_ones) + bias = bias.reshape(-1, *dim_ones) + return s * (x - mean) / np.sqrt(var + epsilon) + bias + +class Instance_normalization(RunAll): + @staticmethod + def instance_normalization_fp16x16(): + def instance_normalization_fp16x16_4D(): + b = 1 + c = 2 + h = 1 + w = 3 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_4D" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + def instance_normalization_fp16x16_4D_epsilon(): + b = 2 + c = 3 + h = 4 + w = 5 + epsilon = 1e-1 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon ).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_4D_epsilon" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) )", name) + + + def instance_normalization_fp16x16_4D_single_batch(): + b = 1 + c = 3 + h = 4 + w = 5 + epsilon = 1e-1 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon ).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_4D_single_batch" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) )", name) + + + def instance_normalization_fp16x16_4D_eq_batch_channel(): + b = 2 + c = 2 + h = 3 + w = 4 + epsilon = 1e-1 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon ).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_4D_eq_batch_channel" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) )", name) + + + def instance_normalization_fp16x16_3D(): + b = 4 + c = 2 + n1 = 5 + x = np.random.randn(b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_3D" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + def instance_normalization_fp16x16_3D_epsilon(): + b = 2 + c = 5 + n1 = 5 + epsilon = 1e-1 + x = np.random.randn(b, c, n1,).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_3D_epsilon" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) )", name) + + + def instance_normalization_fp16x16_3D_single_batch(): + b = 1 + c = 5 + n1 = 4 + x = np.random.randn(b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_3D_single_batch" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + def instance_normalization_fp16x16_3D_eq_batch_channel(): + b = 2 + c = 2 + n1 = 4 + x = np.random.randn(b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_3D_eq_batch_channel" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + + + def instance_normalization_fp16x16_2D(): + b = 4 + c = 5 + x = np.random.randn(b, c, ).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_2D" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + + def instance_normalization_fp16x16_2D_epsilon(): + b = 3 + c = 5 + epsilon = 1e-1 + x = np.random.randn(b, c, ).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_2D_epsilon" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) )", name) + + + def instance_normalization_fp16x16_2D_single_batch(): + b = 1 + c = 5 + epsilon = 1e-1 + x = np.random.randn(b, c, ).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_2D_single_batch" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) )", name) + + + def instance_normalization_fp16x16_2D_eq_batch_channel(): + b = 2 + c = 2 + n1 = 4 + x = np.random.randn(b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) + + name = "instance_normalization_fp16x16_2D_eq_batch_channel" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + def instance_normalization_fp16x16_highdim(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = np.random.randint(1,5) + c = 3 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)); + + name = "instance_normalization_fp16x16_highdim" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + def instance_normalization_fp16x16_highdim_epsilon(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = np.random.randint(1,5) + c = 3 + epsilon = 1e-1 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)); + + name = "instance_normalization_fp16x16_highdim_epsilon" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) )", name) + + + def instance_normalization_fp16x16_highdim_batch_eq_channels(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = 2 + c = 2 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)); + + name = "instance_normalization_fp16x16_highdim_batch_eq_channels" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + def instance_normalization_fp16x16_highdim_single_batch(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = 1 + c = 2 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + _scale = Tensor(Dtype.FP16x16, scale.shape, to_fp(scale.flatten(), FixedImpl.FP16x16)) + _bias = Tensor(Dtype.FP16x16, bias.shape, to_fp(bias.flatten(), FixedImpl.FP16x16)) + _y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)); + + name = "instance_normalization_fp16x16_highdim_single_batch" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + instance_normalization_fp16x16_4D() + instance_normalization_fp16x16_4D_epsilon() + instance_normalization_fp16x16_4D_single_batch() + instance_normalization_fp16x16_4D_eq_batch_channel() + + instance_normalization_fp16x16_3D() + instance_normalization_fp16x16_3D_epsilon() + instance_normalization_fp16x16_3D_single_batch() + instance_normalization_fp16x16_3D_eq_batch_channel() + + instance_normalization_fp16x16_2D() + instance_normalization_fp16x16_2D_epsilon() + instance_normalization_fp16x16_2D_single_batch() + instance_normalization_fp16x16_2D_eq_batch_channel() + + instance_normalization_fp16x16_highdim() + instance_normalization_fp16x16_highdim_epsilon() + instance_normalization_fp16x16_highdim_batch_eq_channels() + instance_normalization_fp16x16_highdim_single_batch() + + + + + + @staticmethod + def instance_normalization_fp8x23(): + def instance_normalization_fp8x23_4D(): + b = 1 + c = 2 + h = 1 + w = 3 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_4D" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()))", name) + + def instance_normalization_fp8x23_4D_epsilon(): + b = 2 + c = 3 + h = 4 + w = 5 + epsilon = 1e-1 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_4D_epsilon" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + + + def instance_normalization_fp8x23_4D_single_batch(): + b = 1 + c = 3 + h = 4 + w = 5 + epsilon = 1e-1 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_4D_single_batch" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + def instance_normalization_fp8x23_4D_eq_batch_channel(): + b = 2 + c = 2 + h = 3 + w = 4 + epsilon = 1e-1 + x = np.random.randn(b, c, h, w).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_4D_eq_batch_channel" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + + def instance_normalization_fp8x23_3D(): + b = 2 + c = 4 + n1 = 5 + x = np.random.randn( b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_3D" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()))", name) + + + def instance_normalization_fp8x23_3D_epsilon(): + b = 4 + c = 3 + n1 = 5 + epsilon = 1e-1 + x = np.random.randn( b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_3D_epsilon" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + + def instance_normalization_fp8x23_3D_single_batch(): + b = 1 + c = 4 + n1 = 5 + x = np.random.randn( b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_3D_single_batch" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()))", name) + + + def instance_normalization_fp8x23_3D_eq_batch_channel(): + b = 2 + c = 2 + n1 = 4 + epsilon = 1e-1 + x = np.random.randn( b, c, n1).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_3D_eq_batch_channel" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + + def instance_normalization_fp8x23_2D(): + b = 5 + c = 4 + x = np.random.randn( b, c,).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_2D_epsilon" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()))) )", name) + + + def instance_normalization_fp8x23_2D_epsilon(): + b = 5 + c = 5 + epsilon = 1e-1 + x = np.random.randn( b, c,).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_2D_epsilon" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + + + def instance_normalization_fp8x23_2D_single_batch(): + b = 1 + c = 5 + epsilon = 1e-1 + x = np.random.randn( b, c,).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_2D_epsilon" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + def instance_normalization_fp8x23_2D_eq_batch_channel(): + b = 2 + c = 2 + epsilon = 1e-1 + x = np.random.randn( b, c,).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_2D_eq_batch_channel" + make_test([_x, _scale, _bias,], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + + def instance_normalization_fp8x23_highdim(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = np.random.randint(1,5) + c = 3 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_highdim" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + def instance_normalization_fp8x23_highdim_epsilon(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = np.random.randint(1,5) + c = 3 + epsilon = 1e-1 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias, epsilon).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_highdim_epsilon" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) )", name) + + + def instance_normalization_fp8x23_highdim_batch_eq_channels(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = 2 + c = 2 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_highdim_batch_eq_channels" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + + def instance_normalization_fp8x23_highdim_single_batch(): + extra_dims =[ np.random.randint(1,4) for i in range(1, np.random.randint(4,7))] + b = 1 + c = 2 + x = np.random.randn( b, c, *extra_dims).astype(np.float32) + scale = np.random.randn(c).astype(np.float32) + bias = np.random.randn(c).astype(np.float32) + y = _instancenorm_test_mode(x, scale, bias).astype(np.float32) + + _x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + _scale = Tensor(Dtype.FP8x23, scale.shape, to_fp(scale.flatten(), FixedImpl.FP8x23)) + _bias = Tensor(Dtype.FP8x23, bias.shape, to_fp(bias.flatten(), FixedImpl.FP8x23)) + _y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + name = "instance_normalization_fp8x23_highdim_single_batch" + make_test([_x, _scale, _bias], _y, f"input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) )", name) + + instance_normalization_fp8x23_4D() + instance_normalization_fp8x23_4D_epsilon() + instance_normalization_fp8x23_4D_single_batch() + instance_normalization_fp8x23_4D_eq_batch_channel() + + instance_normalization_fp8x23_3D() + instance_normalization_fp8x23_3D_epsilon() + instance_normalization_fp8x23_3D_single_batch() + instance_normalization_fp8x23_3D_eq_batch_channel() + + instance_normalization_fp8x23_2D() + instance_normalization_fp8x23_2D_epsilon() + instance_normalization_fp8x23_2D_single_batch() + instance_normalization_fp8x23_2D_eq_batch_channel() + + instance_normalization_fp8x23_highdim() + instance_normalization_fp8x23_highdim_epsilon() + instance_normalization_fp8x23_highdim_batch_eq_channels() + instance_normalization_fp8x23_highdim_single_batch() + From 0fd35bf4a4548288bd42f60abdde8dc8621d38e0 Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 1 Apr 2024 20:01:46 +0100 Subject: [PATCH 5/9] passed test cases --- src/operators/tensor/math.cairo | 1 + .../tensor/math/instance_normalization.cairo | 60 ++--- tests/nodes.cairo | 30 +++ .../instance_normalization_fp16x16_2D.cairo | 24 ++ .../input_0.cairo | 33 +++ .../input_1.cairo | 17 ++ .../input_2.cairo | 17 ++ .../output_0.cairo | 33 +++ ...nce_normalization_fp16x16_2D_epsilon.cairo | 25 ++ .../input_0.cairo | 28 +++ .../input_1.cairo | 17 ++ .../input_2.cairo | 17 ++ .../output_0.cairo | 28 +++ ...lization_fp16x16_2D_eq_batch_channel.cairo | 24 ++ .../input_0.cairo | 30 +++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 30 +++ ...ormalization_fp16x16_2D_single_batch.cairo | 25 ++ .../input_0.cairo | 18 ++ .../input_1.cairo | 17 ++ .../input_2.cairo | 17 ++ .../output_0.cairo | 18 ++ .../instance_normalization_fp16x16_3D.cairo | 24 ++ .../input_0.cairo | 54 ++++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 54 ++++ ...nce_normalization_fp16x16_3D_epsilon.cairo | 25 ++ .../input_0.cairo | 64 +++++ .../input_1.cairo | 17 ++ .../input_2.cairo | 17 ++ .../output_0.cairo | 64 +++++ ...lization_fp16x16_3D_eq_batch_channel.cairo | 24 ++ .../input_0.cairo | 30 +++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 30 +++ ...ormalization_fp16x16_3D_single_batch.cairo | 24 ++ .../input_0.cairo | 34 +++ .../input_1.cairo | 17 ++ .../input_2.cairo | 17 ++ .../output_0.cairo | 34 +++ .../instance_normalization_fp16x16_4D.cairo | 24 ++ .../input_0.cairo | 21 ++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 21 ++ ...nce_normalization_fp16x16_4D_epsilon.cairo | 25 ++ .../input_0.cairo | 135 ++++++++++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 135 ++++++++++ ...lization_fp16x16_4D_eq_batch_channel.cairo | 25 ++ .../input_0.cairo | 63 +++++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 63 +++++ ...ormalization_fp16x16_4D_single_batch.cairo | 25 ++ .../input_0.cairo | 75 ++++++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 75 ++++++ ...stance_normalization_fp16x16_highdim.cairo | 24 ++ .../input_0.cairo | 34 +++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 34 +++ ...on_fp16x16_highdim_batch_eq_channels.cairo | 24 ++ .../input_0.cairo | 41 ++++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 41 ++++ ...ormalization_fp16x16_highdim_epsilon.cairo | 25 ++ .../input_0.cairo | 125 ++++++++++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 125 ++++++++++ ...ization_fp16x16_highdim_single_batch.cairo | 24 ++ .../input_0.cairo | 28 +++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 28 +++ ...ance_normalization_fp8x23_2D_epsilon.cairo | 26 ++ .../input_0.cairo | 18 ++ .../input_1.cairo | 17 ++ .../input_2.cairo | 17 ++ .../output_0.cairo | 18 ++ ...alization_fp8x23_2D_eq_batch_channel.cairo | 26 ++ .../input_0.cairo | 17 ++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 17 ++ .../instance_normalization_fp8x23_3D.cairo | 24 ++ .../input_0.cairo | 54 ++++ .../input_1.cairo | 16 ++ .../input_2.cairo | 16 ++ .../output_0.cairo | 54 ++++ ...ance_normalization_fp8x23_3D_epsilon.cairo | 26 ++ .../input_0.cairo | 74 ++++++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 74 ++++++ ...alization_fp8x23_3D_eq_batch_channel.cairo | 26 ++ .../input_0.cairo | 30 +++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 30 +++ ...normalization_fp8x23_3D_single_batch.cairo | 24 ++ .../input_0.cairo | 34 +++ .../input_1.cairo | 16 ++ .../input_2.cairo | 16 ++ .../output_0.cairo | 34 +++ .../instance_normalization_fp8x23_4D.cairo | 24 ++ .../input_0.cairo | 21 ++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 21 ++ ...ance_normalization_fp8x23_4D_epsilon.cairo | 26 ++ .../input_0.cairo | 135 ++++++++++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 135 ++++++++++ ...alization_fp8x23_4D_eq_batch_channel.cairo | 26 ++ .../input_0.cairo | 63 +++++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 63 +++++ ...normalization_fp8x23_4D_single_batch.cairo | 26 ++ .../input_0.cairo | 75 ++++++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 75 ++++++ ...nstance_normalization_fp8x23_highdim.cairo | 24 ++ .../input_0.cairo | 232 ++++++++++++++++++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 232 ++++++++++++++++++ ...ion_fp8x23_highdim_batch_eq_channels.cairo | 24 ++ .../input_0.cairo | 42 ++++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 42 ++++ ...normalization_fp8x23_highdim_epsilon.cairo | 25 ++ .../input_0.cairo | 19 ++ .../input_1.cairo | 15 ++ .../input_2.cairo | 15 ++ .../output_0.cairo | 19 ++ ...lization_fp8x23_highdim_single_batch.cairo | 24 ++ .../input_0.cairo | 19 ++ .../input_1.cairo | 14 ++ .../input_2.cairo | 14 ++ .../output_0.cairo | 19 ++ 153 files changed, 4997 insertions(+), 30 deletions(-) create mode 100644 tests/nodes/instance_normalization_fp16x16_2D.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_single_batch.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_2D_single_batch/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_single_batch.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_3D_single_batch/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_single_batch.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_4D_single_batch/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_single_batch.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp16x16_highdim_single_batch/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_single_batch.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_3D_single_batch/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_single_batch.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_4D_single_batch/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_epsilon.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_epsilon/output_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_single_batch.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_0.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_1.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_2.cairo create mode 100644 tests/nodes/instance_normalization_fp8x23_highdim_single_batch/output_0.cairo diff --git a/src/operators/tensor/math.cairo b/src/operators/tensor/math.cairo index b73f6d102..401a9c09d 100644 --- a/src/operators/tensor/math.cairo +++ b/src/operators/tensor/math.cairo @@ -68,3 +68,4 @@ mod hann_window; mod hamming_window; mod blackman_window; mod scatter_nd; +mod instance_normalization; diff --git a/src/operators/tensor/math/instance_normalization.cairo b/src/operators/tensor/math/instance_normalization.cairo index 98daccaa8..0b9ef8a85 100644 --- a/src/operators/tensor/math/instance_normalization.cairo +++ b/src/operators/tensor/math/instance_normalization.cairo @@ -3,7 +3,7 @@ use core::array::ArrayTrait; use core::array::SpanTrait; use core::option::OptionTrait; use core::traits::Into; -use orion::numbers::NumberTrait; +use orion::numbers::{NumberTrait, U32IntoI32}; use orion::operators::tensor::{ TensorTrait, Tensor, I8Tensor, I32Tensor, U32Tensor, FP16x16Tensor, BoolTensor }; @@ -19,12 +19,8 @@ fn instance_normalization, +Copy, +Drop, - +Add, +Mul, +Div, - +Sub, - +Neg, - +PrintTrait, +Div>, +Sub>, +Add>, @@ -36,6 +32,8 @@ fn instance_normalization, epsilon: Option,) -> Tensor { + assert((*scale.data).len() == *(*self.shape).at(1), 'scale must match channel dim'); + assert((*bias.data).len() == *(*self.shape).at(1), 'bias must match channel dim'); let dim_x = (*self).shape.len(); let zero = NumberTrait::zero() ; @@ -45,8 +43,8 @@ fn instance_normalization zero }; - let mut axis: Array = array![]; - let mut i: usize = 2; + let mut axis = array![]; + let mut i = 2; loop { if (i >= dim_x) { break; @@ -75,8 +73,8 @@ fn instance_normalization = array![]; - let mut i: usize = 0; + let mut dim_ones = array![]; + let mut i = 0; loop { if i >= dim_x - 2 { break; @@ -87,28 +85,30 @@ fn instance_normalization = array![]; - new_scale_shape.append(*(*scale.shape).at(0)); - let mut i: usize = 0; + let mut scale_clone = scale.clone(); + + let mut new_scale_shape: Array = array![]; + new_scale_shape.append((*scale_clone.shape.at(0)).into()); + let mut i = 0; loop { if i >= dim_ones.len() { break; } - new_scale_shape.append(*dim_ones.at(i)); + new_scale_shape.append(*dim_ones.at(i).into()); i += 1; - }; + }; // bias and scale should have same shape - let mut scale = scale.reshape(target_shape: new_scale_shape.span()); - // let new_bias_shape = new_scale_shape.clone(); - let mut bias = bias.reshape(target_shape: new_scale_shape.span()); // since bias and scale have same shape + let mut scale = scale.reshape(new_scale_shape.span(), false); + let new_bias_shape = new_scale_shape.clone(); + let mut bias = bias.reshape(new_bias_shape.span(), false); // adjust shape of epsilon tensor to match the shape of variance tensor let mut epsilon = TensorTrait::new(shape: array![].span(), data: array![epsilon].span()); - let mut epsilon_shape: Array = array![]; - let mut i: usize = 0; + let mut epsilon_shape= array![]; + let mut i = 0; loop { if (i >= variance.shape.len()) { break; @@ -116,11 +116,11 @@ fn instance_normalization= std.data.len()) { break; @@ -133,18 +133,18 @@ fn instance_normalization::half() / NumberTrait::::new_unscaled(a.into(), false); std = std.clip(min: Option::Some((min_std_val)), max: Option::None(()), ); }; let mut x_normalized = x_diff / std; - // expanding the the dims accordingly to complete arthmetic ops for tensors of different shapes - let mut expanded_new_scale_shape: Array = array![]; + // expand dims to complete arthmetic ops for tensors of different shapes + let mut expanded_new_scale_shape: Array = array![]; if new_scale_shape.len() != x_normalized.shape.len() { - let shape_diff = x_normalized.shape.len() - new_scale_shape.len(); - let mut i: usize = 0; + let shape_diff = x_normalized.shape.len()- new_scale_shape.len(); + let mut i = 0; loop { if i >= shape_diff { break; @@ -152,9 +152,9 @@ fn instance_normalization= dim_ones_clone.len() { break; @@ -166,8 +166,8 @@ fn instance_normalization Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 34675, sign: false }); + data.append(FP16x16 { mag: 7603, sign: true }); + data.append(FP16x16 { mag: 76758, sign: true }); + data.append(FP16x16 { mag: 69921, sign: true }); + data.append(FP16x16 { mag: 15866, sign: true }); + data.append(FP16x16 { mag: 108268, sign: false }); + data.append(FP16x16 { mag: 34420, sign: false }); + data.append(FP16x16 { mag: 70631, sign: false }); + data.append(FP16x16 { mag: 43834, sign: true }); + data.append(FP16x16 { mag: 23480, sign: false }); + data.append(FP16x16 { mag: 34940, sign: true }); + data.append(FP16x16 { mag: 120870, sign: false }); + data.append(FP16x16 { mag: 103977, sign: true }); + data.append(FP16x16 { mag: 7361, sign: true }); + data.append(FP16x16 { mag: 138907, sign: true }); + data.append(FP16x16 { mag: 3623, sign: false }); + data.append(FP16x16 { mag: 1419, sign: true }); + data.append(FP16x16 { mag: 35921, sign: true }); + data.append(FP16x16 { mag: 99392, sign: true }); + data.append(FP16x16 { mag: 89624, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_2D/input_1.cairo new file mode 100644 index 000000000..7b288da9f --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D/input_1.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 18620, sign: false }); + data.append(FP16x16 { mag: 7228, sign: true }); + data.append(FP16x16 { mag: 63469, sign: false }); + data.append(FP16x16 { mag: 10376, sign: false }); + data.append(FP16x16 { mag: 1387, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_2D/input_2.cairo new file mode 100644 index 000000000..8b4c8592b --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D/input_2.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 28914, sign: true }); + data.append(FP16x16 { mag: 110973, sign: true }); + data.append(FP16x16 { mag: 9270, sign: true }); + data.append(FP16x16 { mag: 43470, sign: true }); + data.append(FP16x16 { mag: 18273, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_2D/output_0.cairo new file mode 100644 index 000000000..ebe3bc6d1 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D/output_0.cairo @@ -0,0 +1,33 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 28914, sign: true }); + data.append(FP16x16 { mag: 110973, sign: true }); + data.append(FP16x16 { mag: 9270, sign: true }); + data.append(FP16x16 { mag: 43470, sign: true }); + data.append(FP16x16 { mag: 18273, sign: false }); + data.append(FP16x16 { mag: 28914, sign: true }); + data.append(FP16x16 { mag: 110973, sign: true }); + data.append(FP16x16 { mag: 9270, sign: true }); + data.append(FP16x16 { mag: 43470, sign: true }); + data.append(FP16x16 { mag: 18273, sign: false }); + data.append(FP16x16 { mag: 28914, sign: true }); + data.append(FP16x16 { mag: 110973, sign: true }); + data.append(FP16x16 { mag: 9270, sign: true }); + data.append(FP16x16 { mag: 43470, sign: true }); + data.append(FP16x16 { mag: 18273, sign: false }); + data.append(FP16x16 { mag: 28914, sign: true }); + data.append(FP16x16 { mag: 110973, sign: true }); + data.append(FP16x16 { mag: 9270, sign: true }); + data.append(FP16x16 { mag: 43470, sign: true }); + data.append(FP16x16 { mag: 18273, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_epsilon.cairo b/tests/nodes/instance_normalization_fp16x16_2D_epsilon.cairo new file mode 100644 index 000000000..fa38933af --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_epsilon.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::numbers::{FP16x16,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_2D_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_0.cairo new file mode 100644 index 000000000..d8bf7becf --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_0.cairo @@ -0,0 +1,28 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 98908, sign: true }); + data.append(FP16x16 { mag: 12461, sign: false }); + data.append(FP16x16 { mag: 3163, sign: false }); + data.append(FP16x16 { mag: 6984, sign: false }); + data.append(FP16x16 { mag: 4140, sign: true }); + data.append(FP16x16 { mag: 47930, sign: false }); + data.append(FP16x16 { mag: 18732, sign: false }); + data.append(FP16x16 { mag: 72156, sign: false }); + data.append(FP16x16 { mag: 12344, sign: false }); + data.append(FP16x16 { mag: 70537, sign: true }); + data.append(FP16x16 { mag: 177184, sign: false }); + data.append(FP16x16 { mag: 23585, sign: true }); + data.append(FP16x16 { mag: 73750, sign: true }); + data.append(FP16x16 { mag: 28809, sign: false }); + data.append(FP16x16 { mag: 107918, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_1.cairo new file mode 100644 index 000000000..43dffa43c --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_1.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 49720, sign: false }); + data.append(FP16x16 { mag: 130140, sign: true }); + data.append(FP16x16 { mag: 4590, sign: true }); + data.append(FP16x16 { mag: 86674, sign: false }); + data.append(FP16x16 { mag: 27027, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_2.cairo new file mode 100644 index 000000000..1e4e3c309 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/input_2.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 52227, sign: true }); + data.append(FP16x16 { mag: 93793, sign: true }); + data.append(FP16x16 { mag: 58000, sign: false }); + data.append(FP16x16 { mag: 100075, sign: false }); + data.append(FP16x16 { mag: 31814, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/output_0.cairo new file mode 100644 index 000000000..ed2a062d0 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_epsilon/output_0.cairo @@ -0,0 +1,28 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 52227, sign: true }); + data.append(FP16x16 { mag: 93793, sign: true }); + data.append(FP16x16 { mag: 58000, sign: false }); + data.append(FP16x16 { mag: 100075, sign: false }); + data.append(FP16x16 { mag: 31814, sign: false }); + data.append(FP16x16 { mag: 52227, sign: true }); + data.append(FP16x16 { mag: 93793, sign: true }); + data.append(FP16x16 { mag: 58000, sign: false }); + data.append(FP16x16 { mag: 100075, sign: false }); + data.append(FP16x16 { mag: 31814, sign: false }); + data.append(FP16x16 { mag: 52227, sign: true }); + data.append(FP16x16 { mag: 93793, sign: true }); + data.append(FP16x16 { mag: 58000, sign: false }); + data.append(FP16x16 { mag: 100075, sign: false }); + data.append(FP16x16 { mag: 31814, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel.cairo b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel.cairo new file mode 100644 index 000000000..3e9e7fe15 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_2D_eq_batch_channel() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_0.cairo new file mode 100644 index 000000000..7a0022f39 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_0.cairo @@ -0,0 +1,30 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 26118, sign: false }); + data.append(FP16x16 { mag: 105279, sign: true }); + data.append(FP16x16 { mag: 46181, sign: true }); + data.append(FP16x16 { mag: 87446, sign: true }); + data.append(FP16x16 { mag: 100793, sign: true }); + data.append(FP16x16 { mag: 38742, sign: true }); + data.append(FP16x16 { mag: 92288, sign: false }); + data.append(FP16x16 { mag: 12953, sign: true }); + data.append(FP16x16 { mag: 35879, sign: false }); + data.append(FP16x16 { mag: 50306, sign: false }); + data.append(FP16x16 { mag: 16435, sign: true }); + data.append(FP16x16 { mag: 88971, sign: false }); + data.append(FP16x16 { mag: 53396, sign: true }); + data.append(FP16x16 { mag: 115527, sign: true }); + data.append(FP16x16 { mag: 6641, sign: false }); + data.append(FP16x16 { mag: 107852, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_1.cairo new file mode 100644 index 000000000..c0228047f --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 1895, sign: true }); + data.append(FP16x16 { mag: 34502, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_2.cairo new file mode 100644 index 000000000..07625abb1 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 61040, sign: false }); + data.append(FP16x16 { mag: 20743, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/output_0.cairo new file mode 100644 index 000000000..b20084d7e --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_eq_batch_channel/output_0.cairo @@ -0,0 +1,30 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 58066, sign: false }); + data.append(FP16x16 { mag: 62993, sign: false }); + data.append(FP16x16 { mag: 60777, sign: false }); + data.append(FP16x16 { mag: 62324, sign: false }); + data.append(FP16x16 { mag: 63180, sign: true }); + data.append(FP16x16 { mag: 32469, sign: true }); + data.append(FP16x16 { mag: 32381, sign: false }); + data.append(FP16x16 { mag: 19706, sign: true }); + data.append(FP16x16 { mag: 61231, sign: false }); + data.append(FP16x16 { mag: 60506, sign: false }); + data.append(FP16x16 { mag: 63857, sign: false }); + data.append(FP16x16 { mag: 58566, sign: false }); + data.append(FP16x16 { mag: 10803, sign: true }); + data.append(FP16x16 { mag: 54490, sign: true }); + data.append(FP16x16 { mag: 31412, sign: false }); + data.append(FP16x16 { mag: 49093, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_single_batch.cairo b/tests/nodes/instance_normalization_fp16x16_2D_single_batch.cairo new file mode 100644 index 000000000..43d591e3c --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_single_batch.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::numbers::{FP16x16,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_2D_single_batch() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_0.cairo new file mode 100644 index 000000000..e3e31a5b3 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_0.cairo @@ -0,0 +1,18 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 99266, sign: false }); + data.append(FP16x16 { mag: 2539, sign: false }); + data.append(FP16x16 { mag: 27765, sign: true }); + data.append(FP16x16 { mag: 106225, sign: true }); + data.append(FP16x16 { mag: 83195, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_1.cairo new file mode 100644 index 000000000..a99c319a3 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_1.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 156658, sign: false }); + data.append(FP16x16 { mag: 92579, sign: true }); + data.append(FP16x16 { mag: 123988, sign: true }); + data.append(FP16x16 { mag: 118741, sign: false }); + data.append(FP16x16 { mag: 98281, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_2.cairo new file mode 100644 index 000000000..5be8a87dc --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/input_2.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 29824, sign: true }); + data.append(FP16x16 { mag: 48933, sign: true }); + data.append(FP16x16 { mag: 23720, sign: true }); + data.append(FP16x16 { mag: 145178, sign: false }); + data.append(FP16x16 { mag: 36572, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_2D_single_batch/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/output_0.cairo new file mode 100644 index 000000000..70c087f33 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_2D_single_batch/output_0.cairo @@ -0,0 +1,18 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 29824, sign: true }); + data.append(FP16x16 { mag: 48933, sign: true }); + data.append(FP16x16 { mag: 23720, sign: true }); + data.append(FP16x16 { mag: 145178, sign: false }); + data.append(FP16x16 { mag: 36572, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D.cairo b/tests/nodes/instance_normalization_fp16x16_3D.cairo new file mode 100644 index 000000000..277a0bcc6 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_3D() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D/input_0.cairo new file mode 100644 index 000000000..20ca08410 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D/input_0.cairo @@ -0,0 +1,54 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(2); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 24324, sign: true }); + data.append(FP16x16 { mag: 40415, sign: true }); + data.append(FP16x16 { mag: 69653, sign: false }); + data.append(FP16x16 { mag: 30839, sign: false }); + data.append(FP16x16 { mag: 61645, sign: false }); + data.append(FP16x16 { mag: 80064, sign: false }); + data.append(FP16x16 { mag: 65586, sign: true }); + data.append(FP16x16 { mag: 32775, sign: true }); + data.append(FP16x16 { mag: 46004, sign: true }); + data.append(FP16x16 { mag: 23206, sign: false }); + data.append(FP16x16 { mag: 15017, sign: false }); + data.append(FP16x16 { mag: 47416, sign: false }); + data.append(FP16x16 { mag: 6910, sign: true }); + data.append(FP16x16 { mag: 138625, sign: false }); + data.append(FP16x16 { mag: 119926, sign: false }); + data.append(FP16x16 { mag: 25243, sign: false }); + data.append(FP16x16 { mag: 110184, sign: false }); + data.append(FP16x16 { mag: 43054, sign: true }); + data.append(FP16x16 { mag: 116187, sign: true }); + data.append(FP16x16 { mag: 3371, sign: true }); + data.append(FP16x16 { mag: 71501, sign: true }); + data.append(FP16x16 { mag: 123235, sign: true }); + data.append(FP16x16 { mag: 23436, sign: false }); + data.append(FP16x16 { mag: 4438, sign: false }); + data.append(FP16x16 { mag: 44590, sign: false }); + data.append(FP16x16 { mag: 22327, sign: true }); + data.append(FP16x16 { mag: 46064, sign: false }); + data.append(FP16x16 { mag: 93234, sign: true }); + data.append(FP16x16 { mag: 5227, sign: false }); + data.append(FP16x16 { mag: 90602, sign: true }); + data.append(FP16x16 { mag: 85854, sign: false }); + data.append(FP16x16 { mag: 36001, sign: false }); + data.append(FP16x16 { mag: 77769, sign: false }); + data.append(FP16x16 { mag: 21352, sign: false }); + data.append(FP16x16 { mag: 115104, sign: true }); + data.append(FP16x16 { mag: 2269, sign: true }); + data.append(FP16x16 { mag: 85752, sign: false }); + data.append(FP16x16 { mag: 57450, sign: false }); + data.append(FP16x16 { mag: 48540, sign: false }); + data.append(FP16x16 { mag: 47360, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_3D/input_1.cairo new file mode 100644 index 000000000..50365b5a3 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 11552, sign: true }); + data.append(FP16x16 { mag: 99245, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_3D/input_2.cairo new file mode 100644 index 000000000..c690ae755 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 38232, sign: false }); + data.append(FP16x16 { mag: 9714, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D/output_0.cairo new file mode 100644 index 000000000..6772a5aab --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D/output_0.cairo @@ -0,0 +1,54 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(2); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 49587, sign: false }); + data.append(FP16x16 { mag: 53758, sign: false }); + data.append(FP16x16 { mag: 25226, sign: false }); + data.append(FP16x16 { mag: 35287, sign: false }); + data.append(FP16x16 { mag: 27302, sign: false }); + data.append(FP16x16 { mag: 155257, sign: true }); + data.append(FP16x16 { mag: 116915, sign: false }); + data.append(FP16x16 { mag: 55602, sign: false }); + data.append(FP16x16 { mag: 80322, sign: false }); + data.append(FP16x16 { mag: 49009, sign: true }); + data.append(FP16x16 { mag: 47876, sign: false }); + data.append(FP16x16 { mag: 41339, sign: false }); + data.append(FP16x16 { mag: 52300, sign: false }); + data.append(FP16x16 { mag: 22937, sign: false }); + data.append(FP16x16 { mag: 26709, sign: false }); + data.append(FP16x16 { mag: 30978, sign: true }); + data.append(FP16x16 { mag: 143639, sign: true }); + data.append(FP16x16 { mag: 59608, sign: false }); + data.append(FP16x16 { mag: 156608, sign: false }); + data.append(FP16x16 { mag: 6975, sign: false }); + data.append(FP16x16 { mag: 46855, sign: false }); + data.append(FP16x16 { mag: 56336, sign: false }); + data.append(FP16x16 { mag: 29455, sign: false }); + data.append(FP16x16 { mag: 32937, sign: false }); + data.append(FP16x16 { mag: 25578, sign: false }); + data.append(FP16x16 { mag: 6083, sign: true }); + data.append(FP16x16 { mag: 131044, sign: true }); + data.append(FP16x16 { mag: 123470, sign: false }); + data.append(FP16x16 { mag: 56430, sign: true }); + data.append(FP16x16 { mag: 118661, sign: false }); + data.append(FP16x16 { mag: 27906, sign: false }); + data.append(FP16x16 { mag: 35865, sign: false }); + data.append(FP16x16 { mag: 29196, sign: false }); + data.append(FP16x16 { mag: 38204, sign: false }); + data.append(FP16x16 { mag: 59990, sign: false }); + data.append(FP16x16 { mag: 74018, sign: false }); + data.append(FP16x16 { mag: 110398, sign: true }); + data.append(FP16x16 { mag: 51101, sign: true }); + data.append(FP16x16 { mag: 32435, sign: true }); + data.append(FP16x16 { mag: 168491, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_epsilon.cairo b/tests/nodes/instance_normalization_fp16x16_3D_epsilon.cairo new file mode 100644 index 000000000..2549bc3e3 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_epsilon.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::numbers::{FP16x16,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_3D_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_0.cairo new file mode 100644 index 000000000..cb0cc6037 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_0.cairo @@ -0,0 +1,64 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(5); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 27612, sign: true }); + data.append(FP16x16 { mag: 81599, sign: false }); + data.append(FP16x16 { mag: 66666, sign: false }); + data.append(FP16x16 { mag: 162759, sign: true }); + data.append(FP16x16 { mag: 93840, sign: false }); + data.append(FP16x16 { mag: 51461, sign: false }); + data.append(FP16x16 { mag: 1998, sign: false }); + data.append(FP16x16 { mag: 68704, sign: true }); + data.append(FP16x16 { mag: 82522, sign: true }); + data.append(FP16x16 { mag: 70977, sign: false }); + data.append(FP16x16 { mag: 34351, sign: false }); + data.append(FP16x16 { mag: 43964, sign: false }); + data.append(FP16x16 { mag: 126088, sign: true }); + data.append(FP16x16 { mag: 42506, sign: true }); + data.append(FP16x16 { mag: 90827, sign: false }); + data.append(FP16x16 { mag: 61551, sign: true }); + data.append(FP16x16 { mag: 15536, sign: false }); + data.append(FP16x16 { mag: 66408, sign: true }); + data.append(FP16x16 { mag: 94118, sign: false }); + data.append(FP16x16 { mag: 40857, sign: false }); + data.append(FP16x16 { mag: 102879, sign: true }); + data.append(FP16x16 { mag: 56182, sign: true }); + data.append(FP16x16 { mag: 55046, sign: false }); + data.append(FP16x16 { mag: 18917, sign: true }); + data.append(FP16x16 { mag: 1330, sign: true }); + data.append(FP16x16 { mag: 79173, sign: true }); + data.append(FP16x16 { mag: 24120, sign: false }); + data.append(FP16x16 { mag: 7453, sign: true }); + data.append(FP16x16 { mag: 2433, sign: true }); + data.append(FP16x16 { mag: 75776, sign: false }); + data.append(FP16x16 { mag: 85060, sign: false }); + data.append(FP16x16 { mag: 87878, sign: true }); + data.append(FP16x16 { mag: 32152, sign: false }); + data.append(FP16x16 { mag: 63894, sign: true }); + data.append(FP16x16 { mag: 40342, sign: false }); + data.append(FP16x16 { mag: 43222, sign: false }); + data.append(FP16x16 { mag: 34448, sign: false }); + data.append(FP16x16 { mag: 14147, sign: true }); + data.append(FP16x16 { mag: 41328, sign: true }); + data.append(FP16x16 { mag: 4751, sign: true }); + data.append(FP16x16 { mag: 92668, sign: false }); + data.append(FP16x16 { mag: 56970, sign: true }); + data.append(FP16x16 { mag: 88578, sign: false }); + data.append(FP16x16 { mag: 61276, sign: true }); + data.append(FP16x16 { mag: 9218, sign: false }); + data.append(FP16x16 { mag: 157400, sign: false }); + data.append(FP16x16 { mag: 89821, sign: true }); + data.append(FP16x16 { mag: 3214, sign: false }); + data.append(FP16x16 { mag: 140912, sign: true }); + data.append(FP16x16 { mag: 57527, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_1.cairo new file mode 100644 index 000000000..2cc9ff3f3 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_1.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 1448, sign: false }); + data.append(FP16x16 { mag: 32209, sign: false }); + data.append(FP16x16 { mag: 26762, sign: false }); + data.append(FP16x16 { mag: 15168, sign: false }); + data.append(FP16x16 { mag: 69183, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_2.cairo new file mode 100644 index 000000000..4d0365b60 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/input_2.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 71725, sign: false }); + data.append(FP16x16 { mag: 76672, sign: true }); + data.append(FP16x16 { mag: 31327, sign: false }); + data.append(FP16x16 { mag: 59428, sign: false }); + data.append(FP16x16 { mag: 40644, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/output_0.cairo new file mode 100644 index 000000000..0fdfd27a7 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_epsilon/output_0.cairo @@ -0,0 +1,64 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(5); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 71168, sign: false }); + data.append(FP16x16 { mag: 72770, sign: false }); + data.append(FP16x16 { mag: 72551, sign: false }); + data.append(FP16x16 { mag: 69186, sign: false }); + data.append(FP16x16 { mag: 72950, sign: false }); + data.append(FP16x16 { mag: 48582, sign: true }); + data.append(FP16x16 { mag: 73035, sign: true }); + data.append(FP16x16 { mag: 107989, sign: true }); + data.append(FP16x16 { mag: 114820, sign: true }); + data.append(FP16x16 { mag: 38934, sign: true }); + data.append(FP16x16 { mag: 42925, sign: false }); + data.append(FP16x16 { mag: 46181, sign: false }); + data.append(FP16x16 { mag: 11416, sign: true }); + data.append(FP16x16 { mag: 16893, sign: false }); + data.append(FP16x16 { mag: 62054, sign: false }); + data.append(FP16x16 { mag: 43971, sign: false }); + data.append(FP16x16 { mag: 62008, sign: false }); + data.append(FP16x16 { mag: 42835, sign: false }); + data.append(FP16x16 { mag: 80394, sign: false }); + data.append(FP16x16 { mag: 67932, sign: false }); + data.append(FP16x16 { mag: 54221, sign: true }); + data.append(FP16x16 { mag: 2553, sign: false }); + data.append(FP16x16 { mag: 137786, sign: false }); + data.append(FP16x16 { mag: 47860, sign: false }); + data.append(FP16x16 { mag: 69243, sign: false }); + data.append(FP16x16 { mag: 69557, sign: false }); + data.append(FP16x16 { mag: 72310, sign: false }); + data.append(FP16x16 { mag: 71469, sign: false }); + data.append(FP16x16 { mag: 71602, sign: false }); + data.append(FP16x16 { mag: 73687, sign: false }); + data.append(FP16x16 { mag: 37536, sign: true }); + data.append(FP16x16 { mag: 118201, sign: true }); + data.append(FP16x16 { mag: 62214, sign: true }); + data.append(FP16x16 { mag: 107014, sign: true }); + data.append(FP16x16 { mag: 58394, sign: true }); + data.append(FP16x16 { mag: 59601, sign: false }); + data.append(FP16x16 { mag: 53358, sign: false }); + data.append(FP16x16 { mag: 18777, sign: false }); + data.append(FP16x16 { mag: 563, sign: true }); + data.append(FP16x16 { mag: 25463, sign: false }); + data.append(FP16x16 { mag: 76336, sign: false }); + data.append(FP16x16 { mag: 43992, sign: false }); + data.append(FP16x16 { mag: 75452, sign: false }); + data.append(FP16x16 { mag: 43061, sign: false }); + data.append(FP16x16 { mag: 58299, sign: false }); + data.append(FP16x16 { mag: 161413, sign: false }); + data.append(FP16x16 { mag: 1800, sign: true }); + data.append(FP16x16 { mag: 59621, sign: false }); + data.append(FP16x16 { mag: 35530, sign: true }); + data.append(FP16x16 { mag: 19519, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel.cairo b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel.cairo new file mode 100644 index 000000000..60b60408d --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_3D_eq_batch_channel() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_0.cairo new file mode 100644 index 000000000..e4a4d34de --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_0.cairo @@ -0,0 +1,30 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 77953, sign: true }); + data.append(FP16x16 { mag: 90788, sign: false }); + data.append(FP16x16 { mag: 60665, sign: true }); + data.append(FP16x16 { mag: 161420, sign: false }); + data.append(FP16x16 { mag: 117803, sign: true }); + data.append(FP16x16 { mag: 8294, sign: true }); + data.append(FP16x16 { mag: 62509, sign: false }); + data.append(FP16x16 { mag: 82682, sign: false }); + data.append(FP16x16 { mag: 17836, sign: true }); + data.append(FP16x16 { mag: 44675, sign: false }); + data.append(FP16x16 { mag: 25750, sign: true }); + data.append(FP16x16 { mag: 19300, sign: false }); + data.append(FP16x16 { mag: 6538, sign: false }); + data.append(FP16x16 { mag: 131324, sign: true }); + data.append(FP16x16 { mag: 110452, sign: false }); + data.append(FP16x16 { mag: 114639, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_1.cairo new file mode 100644 index 000000000..70bf2f0a5 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 58183, sign: false }); + data.append(FP16x16 { mag: 9236, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_2.cairo new file mode 100644 index 000000000..b7575c615 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 29902, sign: false }); + data.append(FP16x16 { mag: 27714, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/output_0.cairo new file mode 100644 index 000000000..a26bdbff5 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_eq_batch_channel/output_0.cairo @@ -0,0 +1,30 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 31342, sign: true }); + data.append(FP16x16 { mag: 65832, sign: false }); + data.append(FP16x16 { mag: 21387, sign: true }); + data.append(FP16x16 { mag: 106508, sign: false }); + data.append(FP16x16 { mag: 13277, sign: false }); + data.append(FP16x16 { mag: 26174, sign: false }); + data.append(FP16x16 { mag: 34514, sign: false }); + data.append(FP16x16 { mag: 36889, sign: false }); + data.append(FP16x16 { mag: 16939, sign: true }); + data.append(FP16x16 { mag: 110741, sign: false }); + data.append(FP16x16 { mag: 33103, sign: true }); + data.append(FP16x16 { mag: 58912, sign: false }); + data.append(FP16x16 { mag: 26004, sign: false }); + data.append(FP16x16 { mag: 13289, sign: false }); + data.append(FP16x16 { mag: 35588, sign: false }); + data.append(FP16x16 { mag: 35974, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_single_batch.cairo b/tests/nodes/instance_normalization_fp16x16_3D_single_batch.cairo new file mode 100644 index 000000000..5c0e64063 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_single_batch.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_3D_single_batch() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_0.cairo new file mode 100644 index 000000000..482d6a087 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_0.cairo @@ -0,0 +1,34 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(5); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 147540, sign: false }); + data.append(FP16x16 { mag: 126989, sign: true }); + data.append(FP16x16 { mag: 30444, sign: false }); + data.append(FP16x16 { mag: 51163, sign: false }); + data.append(FP16x16 { mag: 57418, sign: true }); + data.append(FP16x16 { mag: 6674, sign: true }); + data.append(FP16x16 { mag: 5225, sign: false }); + data.append(FP16x16 { mag: 17319, sign: true }); + data.append(FP16x16 { mag: 100931, sign: true }); + data.append(FP16x16 { mag: 148297, sign: true }); + data.append(FP16x16 { mag: 8755, sign: false }); + data.append(FP16x16 { mag: 103665, sign: false }); + data.append(FP16x16 { mag: 8492, sign: true }); + data.append(FP16x16 { mag: 163528, sign: true }); + data.append(FP16x16 { mag: 51308, sign: true }); + data.append(FP16x16 { mag: 7822, sign: true }); + data.append(FP16x16 { mag: 8571, sign: true }); + data.append(FP16x16 { mag: 7942, sign: true }); + data.append(FP16x16 { mag: 21883, sign: false }); + data.append(FP16x16 { mag: 8928, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_1.cairo new file mode 100644 index 000000000..23ffd58b5 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_1.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 40842, sign: true }); + data.append(FP16x16 { mag: 44234, sign: false }); + data.append(FP16x16 { mag: 104026, sign: true }); + data.append(FP16x16 { mag: 153669, sign: false }); + data.append(FP16x16 { mag: 44242, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_2.cairo new file mode 100644 index 000000000..9117cb482 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/input_2.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 40318, sign: true }); + data.append(FP16x16 { mag: 43778, sign: false }); + data.append(FP16x16 { mag: 6158, sign: false }); + data.append(FP16x16 { mag: 91116, sign: false }); + data.append(FP16x16 { mag: 46482, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_3D_single_batch/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/output_0.cairo new file mode 100644 index 000000000..83fe55766 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_3D_single_batch/output_0.cairo @@ -0,0 +1,34 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(5); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 90891, sign: true }); + data.append(FP16x16 { mag: 22909, sign: false }); + data.append(FP16x16 { mag: 42351, sign: true }); + data.append(FP16x16 { mag: 50940, sign: true }); + data.append(FP16x16 { mag: 28307, sign: true }); + data.append(FP16x16 { mag: 67021, sign: false }); + data.append(FP16x16 { mag: 89376, sign: false }); + data.append(FP16x16 { mag: 47022, sign: false }); + data.append(FP16x16 { mag: 77077, sign: false }); + data.append(FP16x16 { mag: 127415, sign: false }); + data.append(FP16x16 { mag: 39495, sign: true }); + data.append(FP16x16 { mag: 140364, sign: true }); + data.append(FP16x16 { mag: 210334, sign: false }); + data.append(FP16x16 { mag: 164609, sign: true }); + data.append(FP16x16 { mag: 106786, sign: false }); + data.append(FP16x16 { mag: 211953, sign: false }); + data.append(FP16x16 { mag: 4139, sign: false }); + data.append(FP16x16 { mag: 6330, sign: false }); + data.append(FP16x16 { mag: 110311, sign: false }); + data.append(FP16x16 { mag: 65149, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D.cairo b/tests/nodes/instance_normalization_fp16x16_4D.cairo new file mode 100644 index 000000000..5f79878c0 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_4D() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D/input_0.cairo new file mode 100644 index 000000000..1182e3ae0 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D/input_0.cairo @@ -0,0 +1,21 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 21977, sign: false }); + data.append(FP16x16 { mag: 43336, sign: true }); + data.append(FP16x16 { mag: 37383, sign: false }); + data.append(FP16x16 { mag: 44745, sign: true }); + data.append(FP16x16 { mag: 107958, sign: false }); + data.append(FP16x16 { mag: 13941, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_4D/input_1.cairo new file mode 100644 index 000000000..f34047798 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 45037, sign: false }); + data.append(FP16x16 { mag: 27852, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_4D/input_2.cairo new file mode 100644 index 000000000..95099901d --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 11907, sign: true }); + data.append(FP16x16 { mag: 36350, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D/output_0.cairo new file mode 100644 index 000000000..f1597e570 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D/output_0.cairo @@ -0,0 +1,21 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 9504, sign: false }); + data.append(FP16x16 { mag: 74561, sign: true }); + data.append(FP16x16 { mag: 29334, sign: false }); + data.append(FP16x16 { mag: 5146, sign: false }); + data.append(FP16x16 { mag: 72769, sign: false }); + data.append(FP16x16 { mag: 31135, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_epsilon.cairo b/tests/nodes/instance_normalization_fp16x16_4D_epsilon.cairo new file mode 100644 index 000000000..dfb5ae169 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_epsilon.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::numbers::{FP16x16,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_4D_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_0.cairo new file mode 100644 index 000000000..09322d48f --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_0.cairo @@ -0,0 +1,135 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 51959, sign: false }); + data.append(FP16x16 { mag: 46644, sign: false }); + data.append(FP16x16 { mag: 47150, sign: true }); + data.append(FP16x16 { mag: 12220, sign: true }); + data.append(FP16x16 { mag: 18568, sign: false }); + data.append(FP16x16 { mag: 843, sign: true }); + data.append(FP16x16 { mag: 20078, sign: true }); + data.append(FP16x16 { mag: 49766, sign: true }); + data.append(FP16x16 { mag: 91875, sign: true }); + data.append(FP16x16 { mag: 55182, sign: false }); + data.append(FP16x16 { mag: 46744, sign: true }); + data.append(FP16x16 { mag: 125832, sign: true }); + data.append(FP16x16 { mag: 57751, sign: false }); + data.append(FP16x16 { mag: 50053, sign: true }); + data.append(FP16x16 { mag: 18138, sign: true }); + data.append(FP16x16 { mag: 7091, sign: false }); + data.append(FP16x16 { mag: 46680, sign: false }); + data.append(FP16x16 { mag: 25965, sign: true }); + data.append(FP16x16 { mag: 64088, sign: false }); + data.append(FP16x16 { mag: 11736, sign: true }); + data.append(FP16x16 { mag: 53188, sign: false }); + data.append(FP16x16 { mag: 99080, sign: false }); + data.append(FP16x16 { mag: 5503, sign: false }); + data.append(FP16x16 { mag: 52557, sign: false }); + data.append(FP16x16 { mag: 55386, sign: true }); + data.append(FP16x16 { mag: 53168, sign: false }); + data.append(FP16x16 { mag: 89184, sign: false }); + data.append(FP16x16 { mag: 93658, sign: false }); + data.append(FP16x16 { mag: 19353, sign: false }); + data.append(FP16x16 { mag: 95595, sign: false }); + data.append(FP16x16 { mag: 12568, sign: false }); + data.append(FP16x16 { mag: 24968, sign: false }); + data.append(FP16x16 { mag: 38888, sign: true }); + data.append(FP16x16 { mag: 78386, sign: false }); + data.append(FP16x16 { mag: 35509, sign: true }); + data.append(FP16x16 { mag: 121737, sign: false }); + data.append(FP16x16 { mag: 15954, sign: false }); + data.append(FP16x16 { mag: 44639, sign: false }); + data.append(FP16x16 { mag: 81762, sign: true }); + data.append(FP16x16 { mag: 118140, sign: true }); + data.append(FP16x16 { mag: 41311, sign: false }); + data.append(FP16x16 { mag: 101635, sign: true }); + data.append(FP16x16 { mag: 66988, sign: true }); + data.append(FP16x16 { mag: 2256, sign: true }); + data.append(FP16x16 { mag: 114044, sign: false }); + data.append(FP16x16 { mag: 35637, sign: true }); + data.append(FP16x16 { mag: 50868, sign: false }); + data.append(FP16x16 { mag: 6081, sign: true }); + data.append(FP16x16 { mag: 19649, sign: true }); + data.append(FP16x16 { mag: 70155, sign: false }); + data.append(FP16x16 { mag: 47564, sign: false }); + data.append(FP16x16 { mag: 21604, sign: false }); + data.append(FP16x16 { mag: 138761, sign: true }); + data.append(FP16x16 { mag: 7428, sign: true }); + data.append(FP16x16 { mag: 34668, sign: true }); + data.append(FP16x16 { mag: 29217, sign: false }); + data.append(FP16x16 { mag: 95910, sign: false }); + data.append(FP16x16 { mag: 111358, sign: false }); + data.append(FP16x16 { mag: 29292, sign: true }); + data.append(FP16x16 { mag: 45203, sign: false }); + data.append(FP16x16 { mag: 18201, sign: true }); + data.append(FP16x16 { mag: 125739, sign: true }); + data.append(FP16x16 { mag: 145057, sign: true }); + data.append(FP16x16 { mag: 25057, sign: true }); + data.append(FP16x16 { mag: 147315, sign: false }); + data.append(FP16x16 { mag: 19732, sign: false }); + data.append(FP16x16 { mag: 82921, sign: false }); + data.append(FP16x16 { mag: 16492, sign: true }); + data.append(FP16x16 { mag: 39504, sign: false }); + data.append(FP16x16 { mag: 71266, sign: true }); + data.append(FP16x16 { mag: 191439, sign: true }); + data.append(FP16x16 { mag: 130563, sign: true }); + data.append(FP16x16 { mag: 27774, sign: false }); + data.append(FP16x16 { mag: 313, sign: false }); + data.append(FP16x16 { mag: 42676, sign: false }); + data.append(FP16x16 { mag: 23526, sign: true }); + data.append(FP16x16 { mag: 20762, sign: false }); + data.append(FP16x16 { mag: 8251, sign: true }); + data.append(FP16x16 { mag: 57819, sign: true }); + data.append(FP16x16 { mag: 44527, sign: true }); + data.append(FP16x16 { mag: 48880, sign: false }); + data.append(FP16x16 { mag: 37920, sign: false }); + data.append(FP16x16 { mag: 11111, sign: false }); + data.append(FP16x16 { mag: 8647, sign: false }); + data.append(FP16x16 { mag: 71562, sign: true }); + data.append(FP16x16 { mag: 92304, sign: false }); + data.append(FP16x16 { mag: 26158, sign: false }); + data.append(FP16x16 { mag: 29367, sign: false }); + data.append(FP16x16 { mag: 9289, sign: false }); + data.append(FP16x16 { mag: 36816, sign: true }); + data.append(FP16x16 { mag: 54622, sign: true }); + data.append(FP16x16 { mag: 11704, sign: false }); + data.append(FP16x16 { mag: 100754, sign: false }); + data.append(FP16x16 { mag: 24939, sign: false }); + data.append(FP16x16 { mag: 53691, sign: false }); + data.append(FP16x16 { mag: 22561, sign: false }); + data.append(FP16x16 { mag: 140473, sign: false }); + data.append(FP16x16 { mag: 50638, sign: false }); + data.append(FP16x16 { mag: 43474, sign: false }); + data.append(FP16x16 { mag: 127031, sign: false }); + data.append(FP16x16 { mag: 66122, sign: true }); + data.append(FP16x16 { mag: 26704, sign: false }); + data.append(FP16x16 { mag: 5885, sign: false }); + data.append(FP16x16 { mag: 32287, sign: false }); + data.append(FP16x16 { mag: 22073, sign: false }); + data.append(FP16x16 { mag: 93329, sign: true }); + data.append(FP16x16 { mag: 128961, sign: true }); + data.append(FP16x16 { mag: 15702, sign: true }); + data.append(FP16x16 { mag: 184232, sign: false }); + data.append(FP16x16 { mag: 114242, sign: true }); + data.append(FP16x16 { mag: 65355, sign: false }); + data.append(FP16x16 { mag: 55109, sign: false }); + data.append(FP16x16 { mag: 78994, sign: false }); + data.append(FP16x16 { mag: 78125, sign: true }); + data.append(FP16x16 { mag: 109378, sign: false }); + data.append(FP16x16 { mag: 801, sign: false }); + data.append(FP16x16 { mag: 34361, sign: false }); + data.append(FP16x16 { mag: 52467, sign: true }); + data.append(FP16x16 { mag: 72749, sign: false }); + data.append(FP16x16 { mag: 154190, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_1.cairo new file mode 100644 index 000000000..48f536131 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 1634, sign: true }); + data.append(FP16x16 { mag: 104410, sign: true }); + data.append(FP16x16 { mag: 95633, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_2.cairo new file mode 100644 index 000000000..001579d27 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 50899, sign: true }); + data.append(FP16x16 { mag: 37867, sign: true }); + data.append(FP16x16 { mag: 109998, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/output_0.cairo new file mode 100644 index 000000000..e87e5ecf2 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_epsilon/output_0.cairo @@ -0,0 +1,135 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 52667, sign: true }); + data.append(FP16x16 { mag: 52509, sign: true }); + data.append(FP16x16 { mag: 49727, sign: true }); + data.append(FP16x16 { mag: 50763, sign: true }); + data.append(FP16x16 { mag: 51676, sign: true }); + data.append(FP16x16 { mag: 51100, sign: true }); + data.append(FP16x16 { mag: 50530, sign: true }); + data.append(FP16x16 { mag: 49649, sign: true }); + data.append(FP16x16 { mag: 48400, sign: true }); + data.append(FP16x16 { mag: 52763, sign: true }); + data.append(FP16x16 { mag: 49739, sign: true }); + data.append(FP16x16 { mag: 47393, sign: true }); + data.append(FP16x16 { mag: 52839, sign: true }); + data.append(FP16x16 { mag: 49641, sign: true }); + data.append(FP16x16 { mag: 50587, sign: true }); + data.append(FP16x16 { mag: 51336, sign: true }); + data.append(FP16x16 { mag: 52510, sign: true }); + data.append(FP16x16 { mag: 50355, sign: true }); + data.append(FP16x16 { mag: 53027, sign: true }); + data.append(FP16x16 { mag: 50777, sign: true }); + data.append(FP16x16 { mag: 79526, sign: true }); + data.append(FP16x16 { mag: 151141, sign: true }); + data.append(FP16x16 { mag: 5113, sign: true }); + data.append(FP16x16 { mag: 78541, sign: true }); + data.append(FP16x16 { mag: 89905, sign: false }); + data.append(FP16x16 { mag: 79495, sign: true }); + data.append(FP16x16 { mag: 135697, sign: true }); + data.append(FP16x16 { mag: 142679, sign: true }); + data.append(FP16x16 { mag: 26726, sign: true }); + data.append(FP16x16 { mag: 145702, sign: true }); + data.append(FP16x16 { mag: 16138, sign: true }); + data.append(FP16x16 { mag: 35488, sign: true }); + data.append(FP16x16 { mag: 64161, sign: false }); + data.append(FP16x16 { mag: 118847, sign: true }); + data.append(FP16x16 { mag: 58887, sign: false }); + data.append(FP16x16 { mag: 186497, sign: true }); + data.append(FP16x16 { mag: 21422, sign: true }); + data.append(FP16x16 { mag: 66186, sign: true }); + data.append(FP16x16 { mag: 131065, sign: false }); + data.append(FP16x16 { mag: 187834, sign: false }); + data.append(FP16x16 { mag: 65312, sign: false }); + data.append(FP16x16 { mag: 264491, sign: false }); + data.append(FP16x16 { mag: 216215, sign: false }); + data.append(FP16x16 { mag: 126019, sign: false }); + data.append(FP16x16 { mag: 36030, sign: true }); + data.append(FP16x16 { mag: 172531, sign: false }); + data.append(FP16x16 { mag: 51996, sign: false }); + data.append(FP16x16 { mag: 131349, sign: false }); + data.append(FP16x16 { mag: 150254, sign: false }); + data.append(FP16x16 { mag: 25123, sign: false }); + data.append(FP16x16 { mag: 56601, sign: false }); + data.append(FP16x16 { mag: 92772, sign: false }); + data.append(FP16x16 { mag: 316222, sign: false }); + data.append(FP16x16 { mag: 133226, sign: false }); + data.append(FP16x16 { mag: 171182, sign: false }); + data.append(FP16x16 { mag: 82164, sign: false }); + data.append(FP16x16 { mag: 10763, sign: true }); + data.append(FP16x16 { mag: 32288, sign: true }); + data.append(FP16x16 { mag: 163690, sign: false }); + data.append(FP16x16 { mag: 59890, sign: false }); + data.append(FP16x16 { mag: 51012, sign: true }); + data.append(FP16x16 { mag: 48861, sign: true }); + data.append(FP16x16 { mag: 48475, sign: true }); + data.append(FP16x16 { mag: 50875, sign: true }); + data.append(FP16x16 { mag: 54323, sign: true }); + data.append(FP16x16 { mag: 51771, sign: true }); + data.append(FP16x16 { mag: 53035, sign: true }); + data.append(FP16x16 { mag: 51046, sign: true }); + data.append(FP16x16 { mag: 52167, sign: true }); + data.append(FP16x16 { mag: 49951, sign: true }); + data.append(FP16x16 { mag: 47547, sign: true }); + data.append(FP16x16 { mag: 48765, sign: true }); + data.append(FP16x16 { mag: 51932, sign: true }); + data.append(FP16x16 { mag: 51383, sign: true }); + data.append(FP16x16 { mag: 52230, sign: true }); + data.append(FP16x16 { mag: 50906, sign: true }); + data.append(FP16x16 { mag: 51792, sign: true }); + data.append(FP16x16 { mag: 51211, sign: true }); + data.append(FP16x16 { mag: 50220, sign: true }); + data.append(FP16x16 { mag: 50486, sign: true }); + data.append(FP16x16 { mag: 65704, sign: true }); + data.append(FP16x16 { mag: 45477, sign: true }); + data.append(FP16x16 { mag: 4001, sign: false }); + data.append(FP16x16 { mag: 8548, sign: false }); + data.append(FP16x16 { mag: 156582, sign: false }); + data.append(FP16x16 { mag: 145847, sign: true }); + data.append(FP16x16 { mag: 23769, sign: true }); + data.append(FP16x16 { mag: 29691, sign: true }); + data.append(FP16x16 { mag: 7362, sign: false }); + data.append(FP16x16 { mag: 92456, sign: false }); + data.append(FP16x16 { mag: 125319, sign: false }); + data.append(FP16x16 { mag: 2905, sign: false }); + data.append(FP16x16 { mag: 161442, sign: true }); + data.append(FP16x16 { mag: 21519, sign: true }); + data.append(FP16x16 { mag: 74583, sign: true }); + data.append(FP16x16 { mag: 17130, sign: true }); + data.append(FP16x16 { mag: 234746, sign: true }); + data.append(FP16x16 { mag: 68950, sign: true }); + data.append(FP16x16 { mag: 55728, sign: true }); + data.append(FP16x16 { mag: 209939, sign: true }); + data.append(FP16x16 { mag: 199761, sign: false }); + data.append(FP16x16 { mag: 96612, sign: false }); + data.append(FP16x16 { mag: 119746, sign: false }); + data.append(FP16x16 { mag: 90408, sign: false }); + data.append(FP16x16 { mag: 101758, sign: false }); + data.append(FP16x16 { mag: 229994, sign: false }); + data.append(FP16x16 { mag: 269588, sign: false }); + data.append(FP16x16 { mag: 143735, sign: false }); + data.append(FP16x16 { mag: 78431, sign: true }); + data.append(FP16x16 { mag: 253232, sign: false }); + data.append(FP16x16 { mag: 53664, sign: false }); + data.append(FP16x16 { mag: 65049, sign: false }); + data.append(FP16x16 { mag: 38508, sign: false }); + data.append(FP16x16 { mag: 213099, sign: false }); + data.append(FP16x16 { mag: 4745, sign: false }); + data.append(FP16x16 { mag: 125395, sign: false }); + data.append(FP16x16 { mag: 88104, sign: false }); + data.append(FP16x16 { mag: 184588, sign: false }); + data.append(FP16x16 { mag: 45447, sign: false }); + data.append(FP16x16 { mag: 45048, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel.cairo b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel.cairo new file mode 100644 index 000000000..cebc770a1 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::numbers::{FP16x16,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_4D_eq_batch_channel() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_0.cairo new file mode 100644 index 000000000..8b2c91345 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_0.cairo @@ -0,0 +1,63 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(3); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 13088, sign: false }); + data.append(FP16x16 { mag: 1941, sign: true }); + data.append(FP16x16 { mag: 16329, sign: false }); + data.append(FP16x16 { mag: 27945, sign: false }); + data.append(FP16x16 { mag: 92374, sign: false }); + data.append(FP16x16 { mag: 65017, sign: true }); + data.append(FP16x16 { mag: 105680, sign: false }); + data.append(FP16x16 { mag: 12836, sign: false }); + data.append(FP16x16 { mag: 26380, sign: true }); + data.append(FP16x16 { mag: 45587, sign: false }); + data.append(FP16x16 { mag: 75387, sign: false }); + data.append(FP16x16 { mag: 60678, sign: false }); + data.append(FP16x16 { mag: 56858, sign: true }); + data.append(FP16x16 { mag: 17139, sign: false }); + data.append(FP16x16 { mag: 4019, sign: true }); + data.append(FP16x16 { mag: 36633, sign: false }); + data.append(FP16x16 { mag: 12833, sign: false }); + data.append(FP16x16 { mag: 93188, sign: false }); + data.append(FP16x16 { mag: 959, sign: false }); + data.append(FP16x16 { mag: 72267, sign: true }); + data.append(FP16x16 { mag: 38087, sign: false }); + data.append(FP16x16 { mag: 5068, sign: true }); + data.append(FP16x16 { mag: 130186, sign: false }); + data.append(FP16x16 { mag: 3762, sign: true }); + data.append(FP16x16 { mag: 6449, sign: true }); + data.append(FP16x16 { mag: 163157, sign: false }); + data.append(FP16x16 { mag: 18058, sign: false }); + data.append(FP16x16 { mag: 100557, sign: false }); + data.append(FP16x16 { mag: 10462, sign: true }); + data.append(FP16x16 { mag: 106372, sign: true }); + data.append(FP16x16 { mag: 15430, sign: false }); + data.append(FP16x16 { mag: 40549, sign: false }); + data.append(FP16x16 { mag: 15027, sign: false }); + data.append(FP16x16 { mag: 18634, sign: true }); + data.append(FP16x16 { mag: 14835, sign: false }); + data.append(FP16x16 { mag: 24513, sign: false }); + data.append(FP16x16 { mag: 30790, sign: true }); + data.append(FP16x16 { mag: 50245, sign: false }); + data.append(FP16x16 { mag: 15277, sign: true }); + data.append(FP16x16 { mag: 67974, sign: true }); + data.append(FP16x16 { mag: 66017, sign: true }); + data.append(FP16x16 { mag: 54954, sign: true }); + data.append(FP16x16 { mag: 60844, sign: false }); + data.append(FP16x16 { mag: 77744, sign: false }); + data.append(FP16x16 { mag: 1513, sign: true }); + data.append(FP16x16 { mag: 11329, sign: false }); + data.append(FP16x16 { mag: 24917, sign: true }); + data.append(FP16x16 { mag: 22642, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_1.cairo new file mode 100644 index 000000000..63de5bda0 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 88450, sign: true }); + data.append(FP16x16 { mag: 116936, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_2.cairo new file mode 100644 index 000000000..2a56d1cc5 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 25707, sign: false }); + data.append(FP16x16 { mag: 30306, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/output_0.cairo new file mode 100644 index 000000000..3f9eda5ef --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_eq_batch_channel/output_0.cairo @@ -0,0 +1,63 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(3); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 54178, sign: false }); + data.append(FP16x16 { mag: 79916, sign: false }); + data.append(FP16x16 { mag: 48628, sign: false }); + data.append(FP16x16 { mag: 28736, sign: false }); + data.append(FP16x16 { mag: 81596, sign: true }); + data.append(FP16x16 { mag: 187930, sign: false }); + data.append(FP16x16 { mag: 104380, sign: true }); + data.append(FP16x16 { mag: 54608, sign: false }); + data.append(FP16x16 { mag: 121767, sign: false }); + data.append(FP16x16 { mag: 1475, sign: true }); + data.append(FP16x16 { mag: 52505, sign: true }); + data.append(FP16x16 { mag: 27318, sign: true }); + data.append(FP16x16 { mag: 177713, sign: true }); + data.append(FP16x16 { mag: 27149, sign: true }); + data.append(FP16x16 { mag: 70200, sign: true }); + data.append(FP16x16 { mag: 12515, sign: false }); + data.append(FP16x16 { mag: 35910, sign: true }); + data.append(FP16x16 { mag: 127589, sign: false }); + data.append(FP16x16 { mag: 60070, sign: true }); + data.append(FP16x16 { mag: 209068, sign: true }); + data.append(FP16x16 { mag: 15473, sign: false }); + data.append(FP16x16 { mag: 72335, sign: true }); + data.append(FP16x16 { mag: 202871, sign: false }); + data.append(FP16x16 { mag: 69679, sign: true }); + data.append(FP16x16 { mag: 62482, sign: false }); + data.append(FP16x16 { mag: 165988, sign: true }); + data.append(FP16x16 { mag: 29469, sign: false }); + data.append(FP16x16 { mag: 81661, sign: true }); + data.append(FP16x16 { mag: 67888, sign: false }); + data.append(FP16x16 { mag: 197084, sign: false }); + data.append(FP16x16 { mag: 33009, sign: false }); + data.append(FP16x16 { mag: 827, sign: true }); + data.append(FP16x16 { mag: 33551, sign: false }); + data.append(FP16x16 { mag: 78897, sign: false }); + data.append(FP16x16 { mag: 33810, sign: false }); + data.append(FP16x16 { mag: 20774, sign: false }); + data.append(FP16x16 { mag: 84808, sign: true }); + data.append(FP16x16 { mag: 100789, sign: false }); + data.append(FP16x16 { mag: 49278, sign: true }); + data.append(FP16x16 { mag: 169970, sign: true }); + data.append(FP16x16 { mag: 165489, sign: true }); + data.append(FP16x16 { mag: 140151, sign: true }); + data.append(FP16x16 { mag: 125062, sign: false }); + data.append(FP16x16 { mag: 163768, sign: false }); + data.append(FP16x16 { mag: 17755, sign: true }); + data.append(FP16x16 { mag: 11658, sign: false }); + data.append(FP16x16 { mag: 71356, sign: true }); + data.append(FP16x16 { mag: 66147, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_single_batch.cairo b/tests/nodes/instance_normalization_fp16x16_4D_single_batch.cairo new file mode 100644 index 000000000..f43db2c51 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_single_batch.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::numbers::{FP16x16,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_4D_single_batch() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_0.cairo new file mode 100644 index 000000000..032c1afb2 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_0.cairo @@ -0,0 +1,75 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 73829, sign: false }); + data.append(FP16x16 { mag: 17448, sign: false }); + data.append(FP16x16 { mag: 99412, sign: false }); + data.append(FP16x16 { mag: 63882, sign: false }); + data.append(FP16x16 { mag: 52115, sign: false }); + data.append(FP16x16 { mag: 119986, sign: true }); + data.append(FP16x16 { mag: 86405, sign: true }); + data.append(FP16x16 { mag: 3958, sign: false }); + data.append(FP16x16 { mag: 1378, sign: true }); + data.append(FP16x16 { mag: 42192, sign: true }); + data.append(FP16x16 { mag: 22045, sign: true }); + data.append(FP16x16 { mag: 83595, sign: true }); + data.append(FP16x16 { mag: 63852, sign: false }); + data.append(FP16x16 { mag: 75685, sign: false }); + data.append(FP16x16 { mag: 19929, sign: true }); + data.append(FP16x16 { mag: 21586, sign: false }); + data.append(FP16x16 { mag: 65003, sign: false }); + data.append(FP16x16 { mag: 8528, sign: false }); + data.append(FP16x16 { mag: 22845, sign: true }); + data.append(FP16x16 { mag: 38805, sign: false }); + data.append(FP16x16 { mag: 22697, sign: true }); + data.append(FP16x16 { mag: 45799, sign: false }); + data.append(FP16x16 { mag: 21349, sign: true }); + data.append(FP16x16 { mag: 96657, sign: true }); + data.append(FP16x16 { mag: 10964, sign: true }); + data.append(FP16x16 { mag: 74702, sign: true }); + data.append(FP16x16 { mag: 90606, sign: true }); + data.append(FP16x16 { mag: 202, sign: true }); + data.append(FP16x16 { mag: 33029, sign: false }); + data.append(FP16x16 { mag: 63079, sign: true }); + data.append(FP16x16 { mag: 13119, sign: true }); + data.append(FP16x16 { mag: 8320, sign: true }); + data.append(FP16x16 { mag: 44950, sign: true }); + data.append(FP16x16 { mag: 57949, sign: true }); + data.append(FP16x16 { mag: 35925, sign: false }); + data.append(FP16x16 { mag: 74561, sign: true }); + data.append(FP16x16 { mag: 54997, sign: true }); + data.append(FP16x16 { mag: 13991, sign: true }); + data.append(FP16x16 { mag: 83922, sign: false }); + data.append(FP16x16 { mag: 125645, sign: true }); + data.append(FP16x16 { mag: 105910, sign: true }); + data.append(FP16x16 { mag: 37917, sign: true }); + data.append(FP16x16 { mag: 67453, sign: true }); + data.append(FP16x16 { mag: 41589, sign: false }); + data.append(FP16x16 { mag: 131373, sign: true }); + data.append(FP16x16 { mag: 11602, sign: true }); + data.append(FP16x16 { mag: 16487, sign: true }); + data.append(FP16x16 { mag: 38064, sign: true }); + data.append(FP16x16 { mag: 31720, sign: false }); + data.append(FP16x16 { mag: 3417, sign: false }); + data.append(FP16x16 { mag: 94047, sign: true }); + data.append(FP16x16 { mag: 68509, sign: false }); + data.append(FP16x16 { mag: 63795, sign: false }); + data.append(FP16x16 { mag: 25409, sign: false }); + data.append(FP16x16 { mag: 22745, sign: false }); + data.append(FP16x16 { mag: 2941, sign: false }); + data.append(FP16x16 { mag: 16716, sign: true }); + data.append(FP16x16 { mag: 102833, sign: true }); + data.append(FP16x16 { mag: 98086, sign: false }); + data.append(FP16x16 { mag: 11165, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_1.cairo new file mode 100644 index 000000000..340efc6fd --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 42295, sign: true }); + data.append(FP16x16 { mag: 87627, sign: true }); + data.append(FP16x16 { mag: 157607, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_2.cairo new file mode 100644 index 000000000..3d03e4215 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 1115, sign: true }); + data.append(FP16x16 { mag: 12366, sign: true }); + data.append(FP16x16 { mag: 59691, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_4D_single_batch/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/output_0.cairo new file mode 100644 index 000000000..449393a84 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_4D_single_batch/output_0.cairo @@ -0,0 +1,75 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 44989, sign: true }); + data.append(FP16x16 { mag: 6663, sign: true }); + data.append(FP16x16 { mag: 62379, sign: true }); + data.append(FP16x16 { mag: 38227, sign: true }); + data.append(FP16x16 { mag: 30228, sign: true }); + data.append(FP16x16 { mag: 86759, sign: false }); + data.append(FP16x16 { mag: 63932, sign: false }); + data.append(FP16x16 { mag: 2506, sign: false }); + data.append(FP16x16 { mag: 6134, sign: false }); + data.append(FP16x16 { mag: 33877, sign: false }); + data.append(FP16x16 { mag: 20182, sign: false }); + data.append(FP16x16 { mag: 62021, sign: false }); + data.append(FP16x16 { mag: 38206, sign: true }); + data.append(FP16x16 { mag: 46250, sign: true }); + data.append(FP16x16 { mag: 18744, sign: false }); + data.append(FP16x16 { mag: 9476, sign: true }); + data.append(FP16x16 { mag: 38989, sign: true }); + data.append(FP16x16 { mag: 600, sign: true }); + data.append(FP16x16 { mag: 20726, sign: false }); + data.append(FP16x16 { mag: 21181, sign: true }); + data.append(FP16x16 { mag: 21905, sign: true }); + data.append(FP16x16 { mag: 129739, sign: true }); + data.append(FP16x16 { mag: 24026, sign: true }); + data.append(FP16x16 { mag: 94531, sign: false }); + data.append(FP16x16 { mag: 40376, sign: true }); + data.append(FP16x16 { mag: 59967, sign: false }); + data.append(FP16x16 { mag: 85005, sign: false }); + data.append(FP16x16 { mag: 57318, sign: true }); + data.append(FP16x16 { mag: 109636, sign: true }); + data.append(FP16x16 { mag: 41669, sign: false }); + data.append(FP16x16 { mag: 36983, sign: true }); + data.append(FP16x16 { mag: 44537, sign: true }); + data.append(FP16x16 { mag: 13127, sign: false }); + data.append(FP16x16 { mag: 33593, sign: false }); + data.append(FP16x16 { mag: 114194, sign: true }); + data.append(FP16x16 { mag: 59745, sign: false }); + data.append(FP16x16 { mag: 28944, sign: false }); + data.append(FP16x16 { mag: 35611, sign: true }); + data.append(FP16x16 { mag: 189756, sign: true }); + data.append(FP16x16 { mag: 140165, sign: false }); + data.append(FP16x16 { mag: 286714, sign: true }); + data.append(FP16x16 { mag: 121198, sign: true }); + data.append(FP16x16 { mag: 193099, sign: true }); + data.append(FP16x16 { mag: 72347, sign: false }); + data.append(FP16x16 { mag: 348700, sign: true }); + data.append(FP16x16 { mag: 57138, sign: true }); + data.append(FP16x16 { mag: 69029, sign: true }); + data.append(FP16x16 { mag: 121556, sign: true }); + data.append(FP16x16 { mag: 48322, sign: false }); + data.append(FP16x16 { mag: 20575, sign: true }); + data.append(FP16x16 { mag: 257835, sign: true }); + data.append(FP16x16 { mag: 137880, sign: false }); + data.append(FP16x16 { mag: 126404, sign: false }); + data.append(FP16x16 { mag: 32959, sign: false }); + data.append(FP16x16 { mag: 26475, sign: false }); + data.append(FP16x16 { mag: 21732, sign: true }); + data.append(FP16x16 { mag: 69586, sign: true }); + data.append(FP16x16 { mag: 279224, sign: true }); + data.append(FP16x16 { mag: 209879, sign: false }); + data.append(FP16x16 { mag: 1714, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim.cairo b/tests/nodes/instance_normalization_fp16x16_highdim.cairo new file mode 100644 index 000000000..b943a64fe --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_highdim() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim/input_0.cairo new file mode 100644 index 000000000..df730bd26 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim/input_0.cairo @@ -0,0 +1,34 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(2); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 112724, sign: true }); + data.append(FP16x16 { mag: 25837, sign: false }); + data.append(FP16x16 { mag: 22833, sign: true }); + data.append(FP16x16 { mag: 47427, sign: false }); + data.append(FP16x16 { mag: 8940, sign: true }); + data.append(FP16x16 { mag: 24887, sign: false }); + data.append(FP16x16 { mag: 64545, sign: true }); + data.append(FP16x16 { mag: 14314, sign: true }); + data.append(FP16x16 { mag: 31958, sign: false }); + data.append(FP16x16 { mag: 54180, sign: false }); + data.append(FP16x16 { mag: 57433, sign: false }); + data.append(FP16x16 { mag: 127513, sign: false }); + data.append(FP16x16 { mag: 82422, sign: false }); + data.append(FP16x16 { mag: 35150, sign: true }); + data.append(FP16x16 { mag: 10746, sign: true }); + data.append(FP16x16 { mag: 36624, sign: true }); + data.append(FP16x16 { mag: 53123, sign: true }); + data.append(FP16x16 { mag: 55981, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_highdim/input_1.cairo new file mode 100644 index 000000000..b72438a79 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 72698, sign: true }); + data.append(FP16x16 { mag: 104309, sign: false }); + data.append(FP16x16 { mag: 50461, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_highdim/input_2.cairo new file mode 100644 index 000000000..361f7294a --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 67877, sign: false }); + data.append(FP16x16 { mag: 55040, sign: true }); + data.append(FP16x16 { mag: 1560, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim/output_0.cairo new file mode 100644 index 000000000..351d7ad1e --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim/output_0.cairo @@ -0,0 +1,34 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(2); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 213497, sign: false }); + data.append(FP16x16 { mag: 21331, sign: false }); + data.append(FP16x16 { mag: 88830, sign: false }); + data.append(FP16x16 { mag: 8610, sign: true }); + data.append(FP16x16 { mag: 69563, sign: false }); + data.append(FP16x16 { mag: 22649, sign: false }); + data.append(FP16x16 { mag: 222453, sign: true }); + data.append(FP16x16 { mag: 135385, sign: true }); + data.append(FP16x16 { mag: 55177, sign: true }); + data.append(FP16x16 { mag: 16659, sign: true }); + data.append(FP16x16 { mag: 11020, sign: true }); + data.append(FP16x16 { mag: 110453, sign: false }); + data.append(FP16x16 { mag: 83090, sign: false }); + data.append(FP16x16 { mag: 33861, sign: true }); + data.append(FP16x16 { mag: 9586, sign: true }); + data.append(FP16x16 { mag: 35327, sign: true }); + data.append(FP16x16 { mag: 51739, sign: true }); + data.append(FP16x16 { mag: 56788, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels.cairo new file mode 100644 index 000000000..f1a8268ab --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_highdim_batch_eq_channels() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_0.cairo new file mode 100644 index 000000000..c16137663 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_0.cairo @@ -0,0 +1,41 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(2); + shape.append(1); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 28963, sign: true }); + data.append(FP16x16 { mag: 40315, sign: true }); + data.append(FP16x16 { mag: 98072, sign: false }); + data.append(FP16x16 { mag: 15541, sign: false }); + data.append(FP16x16 { mag: 23259, sign: false }); + data.append(FP16x16 { mag: 104825, sign: false }); + data.append(FP16x16 { mag: 4156, sign: false }); + data.append(FP16x16 { mag: 10319, sign: false }); + data.append(FP16x16 { mag: 102523, sign: true }); + data.append(FP16x16 { mag: 85995, sign: true }); + data.append(FP16x16 { mag: 64059, sign: false }); + data.append(FP16x16 { mag: 15066, sign: true }); + data.append(FP16x16 { mag: 37326, sign: false }); + data.append(FP16x16 { mag: 2589, sign: false }); + data.append(FP16x16 { mag: 38698, sign: true }); + data.append(FP16x16 { mag: 191669, sign: false }); + data.append(FP16x16 { mag: 79835, sign: true }); + data.append(FP16x16 { mag: 81296, sign: false }); + data.append(FP16x16 { mag: 38760, sign: false }); + data.append(FP16x16 { mag: 2552, sign: false }); + data.append(FP16x16 { mag: 98397, sign: true }); + data.append(FP16x16 { mag: 36264, sign: false }); + data.append(FP16x16 { mag: 28751, sign: true }); + data.append(FP16x16 { mag: 4126, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_1.cairo new file mode 100644 index 000000000..5d5560f47 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 71705, sign: true }); + data.append(FP16x16 { mag: 67695, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_2.cairo new file mode 100644 index 000000000..bb3cfd273 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 30830, sign: true }); + data.append(FP16x16 { mag: 55514, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/output_0.cairo new file mode 100644 index 000000000..686456b16 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_batch_eq_channels/output_0.cairo @@ -0,0 +1,41 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(2); + shape.append(1); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 42889, sign: false }); + data.append(FP16x16 { mag: 57394, sign: false }); + data.append(FP16x16 { mag: 119416, sign: true }); + data.append(FP16x16 { mag: 13971, sign: true }); + data.append(FP16x16 { mag: 23832, sign: true }); + data.append(FP16x16 { mag: 128044, sign: true }); + data.append(FP16x16 { mag: 26022, sign: true }); + data.append(FP16x16 { mag: 18751, sign: true }); + data.append(FP16x16 { mag: 151881, sign: true }); + data.append(FP16x16 { mag: 132381, sign: true }); + data.append(FP16x16 { mag: 44651, sign: false }); + data.append(FP16x16 { mag: 48700, sign: true }); + data.append(FP16x16 { mag: 34857, sign: true }); + data.append(FP16x16 { mag: 6509, sign: true }); + data.append(FP16x16 { mag: 27184, sign: false }); + data.append(FP16x16 { mag: 160813, sign: true }); + data.append(FP16x16 { mag: 60755, sign: false }); + data.append(FP16x16 { mag: 70740, sign: true }); + data.append(FP16x16 { mag: 14223, sign: false }); + data.append(FP16x16 { mag: 38701, sign: true }); + data.append(FP16x16 { mag: 186260, sign: true }); + data.append(FP16x16 { mag: 10575, sign: false }); + data.append(FP16x16 { mag: 84458, sign: true }); + data.append(FP16x16 { mag: 48464, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_epsilon.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon.cairo new file mode 100644 index 000000000..6fc76249f --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::numbers::{FP16x16,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_highdim_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(6554, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_0.cairo new file mode 100644 index 000000000..cd80f32d3 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_0.cairo @@ -0,0 +1,125 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + shape.append(3); + shape.append(3); + shape.append(2); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 53874, sign: true }); + data.append(FP16x16 { mag: 59063, sign: true }); + data.append(FP16x16 { mag: 43796, sign: true }); + data.append(FP16x16 { mag: 40092, sign: false }); + data.append(FP16x16 { mag: 14252, sign: true }); + data.append(FP16x16 { mag: 82715, sign: true }); + data.append(FP16x16 { mag: 25288, sign: true }); + data.append(FP16x16 { mag: 24236, sign: false }); + data.append(FP16x16 { mag: 98696, sign: false }); + data.append(FP16x16 { mag: 51425, sign: false }); + data.append(FP16x16 { mag: 862, sign: true }); + data.append(FP16x16 { mag: 63216, sign: false }); + data.append(FP16x16 { mag: 57103, sign: true }); + data.append(FP16x16 { mag: 28180, sign: false }); + data.append(FP16x16 { mag: 127924, sign: true }); + data.append(FP16x16 { mag: 110873, sign: true }); + data.append(FP16x16 { mag: 4202, sign: false }); + data.append(FP16x16 { mag: 109734, sign: true }); + data.append(FP16x16 { mag: 58352, sign: false }); + data.append(FP16x16 { mag: 2096, sign: false }); + data.append(FP16x16 { mag: 2567, sign: false }); + data.append(FP16x16 { mag: 14814, sign: false }); + data.append(FP16x16 { mag: 121344, sign: false }); + data.append(FP16x16 { mag: 69196, sign: false }); + data.append(FP16x16 { mag: 25377, sign: true }); + data.append(FP16x16 { mag: 71089, sign: false }); + data.append(FP16x16 { mag: 13097, sign: false }); + data.append(FP16x16 { mag: 103649, sign: true }); + data.append(FP16x16 { mag: 16301, sign: false }); + data.append(FP16x16 { mag: 86127, sign: true }); + data.append(FP16x16 { mag: 74903, sign: true }); + data.append(FP16x16 { mag: 48875, sign: true }); + data.append(FP16x16 { mag: 148920, sign: false }); + data.append(FP16x16 { mag: 100086, sign: true }); + data.append(FP16x16 { mag: 78656, sign: true }); + data.append(FP16x16 { mag: 88330, sign: true }); + data.append(FP16x16 { mag: 31023, sign: true }); + data.append(FP16x16 { mag: 45983, sign: true }); + data.append(FP16x16 { mag: 7032, sign: false }); + data.append(FP16x16 { mag: 14496, sign: true }); + data.append(FP16x16 { mag: 5568, sign: false }); + data.append(FP16x16 { mag: 24943, sign: false }); + data.append(FP16x16 { mag: 88344, sign: false }); + data.append(FP16x16 { mag: 48515, sign: true }); + data.append(FP16x16 { mag: 15847, sign: false }); + data.append(FP16x16 { mag: 82457, sign: false }); + data.append(FP16x16 { mag: 60849, sign: false }); + data.append(FP16x16 { mag: 39584, sign: false }); + data.append(FP16x16 { mag: 215793, sign: true }); + data.append(FP16x16 { mag: 13022, sign: true }); + data.append(FP16x16 { mag: 138286, sign: true }); + data.append(FP16x16 { mag: 70340, sign: true }); + data.append(FP16x16 { mag: 34596, sign: false }); + data.append(FP16x16 { mag: 10217, sign: false }); + data.append(FP16x16 { mag: 117039, sign: false }); + data.append(FP16x16 { mag: 41386, sign: true }); + data.append(FP16x16 { mag: 36822, sign: true }); + data.append(FP16x16 { mag: 92331, sign: false }); + data.append(FP16x16 { mag: 148841, sign: true }); + data.append(FP16x16 { mag: 25572, sign: true }); + data.append(FP16x16 { mag: 137420, sign: true }); + data.append(FP16x16 { mag: 141869, sign: true }); + data.append(FP16x16 { mag: 25888, sign: true }); + data.append(FP16x16 { mag: 48694, sign: false }); + data.append(FP16x16 { mag: 84119, sign: true }); + data.append(FP16x16 { mag: 15875, sign: true }); + data.append(FP16x16 { mag: 132951, sign: true }); + data.append(FP16x16 { mag: 12722, sign: false }); + data.append(FP16x16 { mag: 7196, sign: false }); + data.append(FP16x16 { mag: 106882, sign: true }); + data.append(FP16x16 { mag: 9504, sign: true }); + data.append(FP16x16 { mag: 91408, sign: true }); + data.append(FP16x16 { mag: 68874, sign: true }); + data.append(FP16x16 { mag: 41067, sign: true }); + data.append(FP16x16 { mag: 64620, sign: true }); + data.append(FP16x16 { mag: 2601, sign: false }); + data.append(FP16x16 { mag: 120094, sign: false }); + data.append(FP16x16 { mag: 22517, sign: false }); + data.append(FP16x16 { mag: 67674, sign: true }); + data.append(FP16x16 { mag: 108362, sign: true }); + data.append(FP16x16 { mag: 61, sign: true }); + data.append(FP16x16 { mag: 37783, sign: false }); + data.append(FP16x16 { mag: 24756, sign: true }); + data.append(FP16x16 { mag: 16700, sign: false }); + data.append(FP16x16 { mag: 85404, sign: false }); + data.append(FP16x16 { mag: 10297, sign: true }); + data.append(FP16x16 { mag: 112551, sign: true }); + data.append(FP16x16 { mag: 11576, sign: false }); + data.append(FP16x16 { mag: 97585, sign: false }); + data.append(FP16x16 { mag: 62710, sign: false }); + data.append(FP16x16 { mag: 40460, sign: true }); + data.append(FP16x16 { mag: 75018, sign: true }); + data.append(FP16x16 { mag: 202727, sign: false }); + data.append(FP16x16 { mag: 16380, sign: true }); + data.append(FP16x16 { mag: 97625, sign: true }); + data.append(FP16x16 { mag: 13669, sign: false }); + data.append(FP16x16 { mag: 30042, sign: false }); + data.append(FP16x16 { mag: 96459, sign: false }); + data.append(FP16x16 { mag: 7657, sign: true }); + data.append(FP16x16 { mag: 50655, sign: false }); + data.append(FP16x16 { mag: 59784, sign: false }); + data.append(FP16x16 { mag: 14558, sign: true }); + data.append(FP16x16 { mag: 24459, sign: false }); + data.append(FP16x16 { mag: 13992, sign: true }); + data.append(FP16x16 { mag: 29331, sign: false }); + data.append(FP16x16 { mag: 15359, sign: true }); + data.append(FP16x16 { mag: 38377, sign: true }); + data.append(FP16x16 { mag: 15857, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_1.cairo new file mode 100644 index 000000000..635b6b04f --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 41927, sign: false }); + data.append(FP16x16 { mag: 62140, sign: true }); + data.append(FP16x16 { mag: 73995, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_2.cairo new file mode 100644 index 000000000..4d4117f9b --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 67799, sign: false }); + data.append(FP16x16 { mag: 170915, sign: true }); + data.append(FP16x16 { mag: 38518, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/output_0.cairo new file mode 100644 index 000000000..a1f251103 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_epsilon/output_0.cairo @@ -0,0 +1,125 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + shape.append(3); + shape.append(3); + shape.append(2); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 46936, sign: false }); + data.append(FP16x16 { mag: 43656, sign: false }); + data.append(FP16x16 { mag: 53304, sign: false }); + data.append(FP16x16 { mag: 106314, sign: false }); + data.append(FP16x16 { mag: 71973, sign: false }); + data.append(FP16x16 { mag: 28711, sign: false }); + data.append(FP16x16 { mag: 64999, sign: false }); + data.append(FP16x16 { mag: 96294, sign: false }); + data.append(FP16x16 { mag: 143346, sign: false }); + data.append(FP16x16 { mag: 113475, sign: false }); + data.append(FP16x16 { mag: 80434, sign: false }); + data.append(FP16x16 { mag: 120926, sign: false }); + data.append(FP16x16 { mag: 44895, sign: false }); + data.append(FP16x16 { mag: 98787, sign: false }); + data.append(FP16x16 { mag: 143, sign: false }); + data.append(FP16x16 { mag: 10917, sign: false }); + data.append(FP16x16 { mag: 83635, sign: false }); + data.append(FP16x16 { mag: 11637, sign: false }); + data.append(FP16x16 { mag: 221444, sign: true }); + data.append(FP16x16 { mag: 176506, sign: true }); + data.append(FP16x16 { mag: 176882, sign: true }); + data.append(FP16x16 { mag: 186665, sign: true }); + data.append(FP16x16 { mag: 271763, sign: true }); + data.append(FP16x16 { mag: 230106, sign: true }); + data.append(FP16x16 { mag: 154559, sign: true }); + data.append(FP16x16 { mag: 231618, sign: true }); + data.append(FP16x16 { mag: 185293, sign: true }); + data.append(FP16x16 { mag: 92034, sign: true }); + data.append(FP16x16 { mag: 187853, sign: true }); + data.append(FP16x16 { mag: 106031, sign: true }); + data.append(FP16x16 { mag: 114996, sign: true }); + data.append(FP16x16 { mag: 135788, sign: true }); + data.append(FP16x16 { mag: 293791, sign: true }); + data.append(FP16x16 { mag: 94880, sign: true }); + data.append(FP16x16 { mag: 111999, sign: true }); + data.append(FP16x16 { mag: 104271, sign: true }); + data.append(FP16x16 { mag: 19559, sign: true }); + data.append(FP16x16 { mag: 4988, sign: true }); + data.append(FP16x16 { mag: 56623, sign: true }); + data.append(FP16x16 { mag: 35655, sign: true }); + data.append(FP16x16 { mag: 55197, sign: true }); + data.append(FP16x16 { mag: 74066, sign: true }); + data.append(FP16x16 { mag: 135815, sign: true }); + data.append(FP16x16 { mag: 2523, sign: true }); + data.append(FP16x16 { mag: 65207, sign: true }); + data.append(FP16x16 { mag: 130081, sign: true }); + data.append(FP16x16 { mag: 109037, sign: true }); + data.append(FP16x16 { mag: 88326, sign: true }); + data.append(FP16x16 { mag: 160393, sign: false }); + data.append(FP16x16 { mag: 37091, sign: true }); + data.append(FP16x16 { mag: 84906, sign: false }); + data.append(FP16x16 { mag: 18732, sign: false }); + data.append(FP16x16 { mag: 83468, sign: true }); + data.append(FP16x16 { mag: 59725, sign: true }); + data.append(FP16x16 { mag: 150505, sign: false }); + data.append(FP16x16 { mag: 67085, sign: false }); + data.append(FP16x16 { mag: 69488, sign: false }); + data.append(FP16x16 { mag: 137494, sign: false }); + data.append(FP16x16 { mag: 10505, sign: false }); + data.append(FP16x16 { mag: 75412, sign: false }); + data.append(FP16x16 { mag: 16518, sign: false }); + data.append(FP16x16 { mag: 14176, sign: false }); + data.append(FP16x16 { mag: 75245, sign: false }); + data.append(FP16x16 { mag: 114517, sign: false }); + data.append(FP16x16 { mag: 44584, sign: false }); + data.append(FP16x16 { mag: 80518, sign: false }); + data.append(FP16x16 { mag: 18872, sign: false }); + data.append(FP16x16 { mag: 95576, sign: false }); + data.append(FP16x16 { mag: 92667, sign: false }); + data.append(FP16x16 { mag: 32598, sign: false }); + data.append(FP16x16 { mag: 83873, sign: false }); + data.append(FP16x16 { mag: 40746, sign: false }); + data.append(FP16x16 { mag: 110877, sign: true }); + data.append(FP16x16 { mag: 135951, sign: true }); + data.append(FP16x16 { mag: 114712, sign: true }); + data.append(FP16x16 { mag: 175330, sign: true }); + data.append(FP16x16 { mag: 281279, sign: true }); + data.append(FP16x16 { mag: 193289, sign: true }); + data.append(FP16x16 { mag: 111959, sign: true }); + data.append(FP16x16 { mag: 75268, sign: true }); + data.append(FP16x16 { mag: 172928, sign: true }); + data.append(FP16x16 { mag: 207055, sign: true }); + data.append(FP16x16 { mag: 150660, sign: true }); + data.append(FP16x16 { mag: 188044, sign: true }); + data.append(FP16x16 { mag: 249997, sign: true }); + data.append(FP16x16 { mag: 163699, sign: true }); + data.append(FP16x16 { mag: 71491, sign: true }); + data.append(FP16x16 { mag: 183423, sign: true }); + data.append(FP16x16 { mag: 260981, sign: true }); + data.append(FP16x16 { mag: 229534, sign: true }); + data.append(FP16x16 { mag: 15433, sign: false }); + data.append(FP16x16 { mag: 52716, sign: false }); + data.append(FP16x16 { mag: 246937, sign: true }); + data.append(FP16x16 { mag: 10546, sign: true }); + data.append(FP16x16 { mag: 77106, sign: false }); + data.append(FP16x16 { mag: 42966, sign: true }); + data.append(FP16x16 { mag: 60631, sign: true }); + data.append(FP16x16 { mag: 132286, sign: true }); + data.append(FP16x16 { mag: 19957, sign: true }); + data.append(FP16x16 { mag: 82869, sign: true }); + data.append(FP16x16 { mag: 92718, sign: true }); + data.append(FP16x16 { mag: 12511, sign: true }); + data.append(FP16x16 { mag: 54607, sign: true }); + data.append(FP16x16 { mag: 13122, sign: true }); + data.append(FP16x16 { mag: 59864, sign: true }); + data.append(FP16x16 { mag: 11647, sign: true }); + data.append(FP16x16 { mag: 13186, sign: false }); + data.append(FP16x16 { mag: 11110, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_single_batch.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch.cairo new file mode 100644 index 000000000..09327011e --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp16x16_highdim_single_batch() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_0.cairo new file mode 100644 index 000000000..2dc8f57da --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_0.cairo @@ -0,0 +1,28 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 125788, sign: false }); + data.append(FP16x16 { mag: 29301, sign: false }); + data.append(FP16x16 { mag: 50693, sign: false }); + data.append(FP16x16 { mag: 43193, sign: false }); + data.append(FP16x16 { mag: 61038, sign: false }); + data.append(FP16x16 { mag: 49566, sign: true }); + data.append(FP16x16 { mag: 46456, sign: true }); + data.append(FP16x16 { mag: 7004, sign: false }); + data.append(FP16x16 { mag: 70178, sign: true }); + data.append(FP16x16 { mag: 91824, sign: true }); + data.append(FP16x16 { mag: 147137, sign: false }); + data.append(FP16x16 { mag: 2698, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_1.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_1.cairo new file mode 100644 index 000000000..bd575f553 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 38043, sign: false }); + data.append(FP16x16 { mag: 16003, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_2.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_2.cairo new file mode 100644 index 000000000..e8329e93e --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 64797, sign: false }); + data.append(FP16x16 { mag: 33713, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/output_0.cairo b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/output_0.cairo new file mode 100644 index 000000000..f32c77574 --- /dev/null +++ b/tests/nodes/instance_normalization_fp16x16_highdim_single_batch/output_0.cairo @@ -0,0 +1,28 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::numbers::{FixedTrait, FP16x16}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 125498, sign: false }); + data.append(FP16x16 { mag: 54402, sign: false }); + data.append(FP16x16 { mag: 70165, sign: false }); + data.append(FP16x16 { mag: 64638, sign: false }); + data.append(FP16x16 { mag: 77787, sign: false }); + data.append(FP16x16 { mag: 3710, sign: true }); + data.append(FP16x16 { mag: 41451, sign: false }); + data.append(FP16x16 { mag: 30523, sign: false }); + data.append(FP16x16 { mag: 46300, sign: false }); + data.append(FP16x16 { mag: 50725, sign: false }); + data.append(FP16x16 { mag: 1879, sign: false }); + data.append(FP16x16 { mag: 31403, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_epsilon.cairo b/tests/nodes/instance_normalization_fp8x23_2D_epsilon.cairo new file mode 100644 index 000000000..4a8c224cf --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_epsilon.cairo @@ -0,0 +1,26 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_2D_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_0.cairo new file mode 100644 index 000000000..193c58f2a --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_0.cairo @@ -0,0 +1,18 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 1606779, sign: false }); + data.append(FP8x23 { mag: 19632498, sign: false }); + data.append(FP8x23 { mag: 524185, sign: true }); + data.append(FP8x23 { mag: 1011053, sign: false }); + data.append(FP8x23 { mag: 23798, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_1.cairo new file mode 100644 index 000000000..569981ed5 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_1.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 16960484, sign: false }); + data.append(FP8x23 { mag: 2604308, sign: true }); + data.append(FP8x23 { mag: 17884380, sign: true }); + data.append(FP8x23 { mag: 10159515, sign: false }); + data.append(FP8x23 { mag: 678914, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_2.cairo new file mode 100644 index 000000000..149a64353 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/input_2.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 14389910, sign: false }); + data.append(FP8x23 { mag: 634668, sign: true }); + data.append(FP8x23 { mag: 21061910, sign: true }); + data.append(FP8x23 { mag: 52644, sign: true }); + data.append(FP8x23 { mag: 1324035, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/output_0.cairo new file mode 100644 index 000000000..c69ba3789 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_epsilon/output_0.cairo @@ -0,0 +1,18 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 14389910, sign: false }); + data.append(FP8x23 { mag: 634668, sign: true }); + data.append(FP8x23 { mag: 21061910, sign: true }); + data.append(FP8x23 { mag: 52644, sign: true }); + data.append(FP8x23 { mag: 1324035, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel.cairo b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel.cairo new file mode 100644 index 000000000..a8aababf2 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel.cairo @@ -0,0 +1,26 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_2D_eq_batch_channel() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_0.cairo new file mode 100644 index 000000000..43a28425d --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_0.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 1381500, sign: true }); + data.append(FP8x23 { mag: 1138616, sign: false }); + data.append(FP8x23 { mag: 4552750, sign: false }); + data.append(FP8x23 { mag: 854236, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_1.cairo new file mode 100644 index 000000000..49f642a0d --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 6274976, sign: true }); + data.append(FP8x23 { mag: 1224120, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_2.cairo new file mode 100644 index 000000000..1680b7691 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 858990, sign: false }); + data.append(FP8x23 { mag: 10095601, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/output_0.cairo new file mode 100644 index 000000000..1b9295696 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_2D_eq_batch_channel/output_0.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 858990, sign: false }); + data.append(FP8x23 { mag: 10095601, sign: true }); + data.append(FP8x23 { mag: 858990, sign: false }); + data.append(FP8x23 { mag: 10095601, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D.cairo b/tests/nodes/instance_normalization_fp8x23_3D.cairo new file mode 100644 index 000000000..9ee1374e3 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_3D() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(())); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D/input_0.cairo new file mode 100644 index 000000000..a46b21817 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D/input_0.cairo @@ -0,0 +1,54 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 8540492, sign: false }); + data.append(FP8x23 { mag: 9382786, sign: true }); + data.append(FP8x23 { mag: 6586859, sign: false }); + data.append(FP8x23 { mag: 17804984, sign: false }); + data.append(FP8x23 { mag: 1660556, sign: false }); + data.append(FP8x23 { mag: 2773353, sign: false }); + data.append(FP8x23 { mag: 3068045, sign: false }); + data.append(FP8x23 { mag: 976243, sign: false }); + data.append(FP8x23 { mag: 573526, sign: false }); + data.append(FP8x23 { mag: 7273832, sign: false }); + data.append(FP8x23 { mag: 1552350, sign: true }); + data.append(FP8x23 { mag: 7584258, sign: true }); + data.append(FP8x23 { mag: 5499422, sign: true }); + data.append(FP8x23 { mag: 11491652, sign: true }); + data.append(FP8x23 { mag: 3165269, sign: false }); + data.append(FP8x23 { mag: 5968577, sign: true }); + data.append(FP8x23 { mag: 3539512, sign: false }); + data.append(FP8x23 { mag: 8542260, sign: false }); + data.append(FP8x23 { mag: 5040973, sign: false }); + data.append(FP8x23 { mag: 4504122, sign: true }); + data.append(FP8x23 { mag: 22596482, sign: false }); + data.append(FP8x23 { mag: 12034543, sign: true }); + data.append(FP8x23 { mag: 11339130, sign: true }); + data.append(FP8x23 { mag: 3209119, sign: true }); + data.append(FP8x23 { mag: 11559511, sign: false }); + data.append(FP8x23 { mag: 214059, sign: false }); + data.append(FP8x23 { mag: 24245974, sign: true }); + data.append(FP8x23 { mag: 5981880, sign: true }); + data.append(FP8x23 { mag: 7071770, sign: true }); + data.append(FP8x23 { mag: 7802461, sign: true }); + data.append(FP8x23 { mag: 2514734, sign: false }); + data.append(FP8x23 { mag: 3869380, sign: true }); + data.append(FP8x23 { mag: 1170766, sign: false }); + data.append(FP8x23 { mag: 11821055, sign: false }); + data.append(FP8x23 { mag: 4197997, sign: true }); + data.append(FP8x23 { mag: 15530508, sign: false }); + data.append(FP8x23 { mag: 10691257, sign: false }); + data.append(FP8x23 { mag: 60018, sign: false }); + data.append(FP8x23 { mag: 5375578, sign: false }); + data.append(FP8x23 { mag: 2139229, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_3D/input_1.cairo new file mode 100644 index 000000000..4d3dddaab --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 16383248, sign: true }); + data.append(FP8x23 { mag: 5402514, sign: false }); + data.append(FP8x23 { mag: 1517624, sign: false }); + data.append(FP8x23 { mag: 3852624, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_3D/input_2.cairo new file mode 100644 index 000000000..1f03fac90 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D/input_2.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 14756260, sign: false }); + data.append(FP8x23 { mag: 802394, sign: false }); + data.append(FP8x23 { mag: 1317196, sign: false }); + data.append(FP8x23 { mag: 10877915, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D/output_0.cairo new file mode 100644 index 000000000..1709e643e --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D/output_0.cairo @@ -0,0 +1,54 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 8324193, sign: false }); + data.append(FP8x23 { mag: 41276796, sign: false }); + data.append(FP8x23 { mag: 11916018, sign: false }); + data.append(FP8x23 { mag: 8708916, sign: true }); + data.append(FP8x23 { mag: 20973208, sign: false }); + data.append(FP8x23 { mag: 439772, sign: false }); + data.append(FP8x23 { mag: 1109136, sign: false }); + data.append(FP8x23 { mag: 3642192, sign: true }); + data.append(FP8x23 { mag: 4556924, sign: true }); + data.append(FP8x23 { mag: 10662183, sign: false }); + data.append(FP8x23 { mag: 2233377, sign: false }); + data.append(FP8x23 { mag: 415587, sign: false }); + data.append(FP8x23 { mag: 1043878, sign: false }); + data.append(FP8x23 { mag: 761953, sign: true }); + data.append(FP8x23 { mag: 3655090, sign: false }); + data.append(FP8x23 { mag: 5875499, sign: true }); + data.append(FP8x23 { mag: 12392297, sign: true }); + data.append(FP8x23 { mag: 15821156, sign: true }); + data.append(FP8x23 { mag: 13421392, sign: true }); + data.append(FP8x23 { mag: 6879230, sign: true }); + data.append(FP8x23 { mag: 10755278, sign: true }); + data.append(FP8x23 { mag: 31152384, sign: false }); + data.append(FP8x23 { mag: 30310852, sign: false }); + data.append(FP8x23 { mag: 20472572, sign: false }); + data.append(FP8x23 { mag: 2600771, sign: false }); + data.append(FP8x23 { mag: 6900111, sign: false }); + data.append(FP8x23 { mag: 9326585, sign: true }); + data.append(FP8x23 { mag: 2789747, sign: false }); + data.append(FP8x23 { mag: 2066718, sign: false }); + data.append(FP8x23 { mag: 1581980, sign: false }); + data.append(FP8x23 { mag: 1585287, sign: false }); + data.append(FP8x23 { mag: 81403, sign: true }); + data.append(FP8x23 { mag: 1234419, sign: false }); + data.append(FP8x23 { mag: 4014873, sign: false }); + data.append(FP8x23 { mag: 167194, sign: true }); + data.append(FP8x23 { mag: 16841552, sign: true }); + data.append(FP8x23 { mag: 13551288, sign: true }); + data.append(FP8x23 { mag: 6322981, sign: true }); + data.append(FP8x23 { mag: 9937094, sign: true }); + data.append(FP8x23 { mag: 7736661, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_epsilon.cairo b/tests/nodes/instance_normalization_fp8x23_3D_epsilon.cairo new file mode 100644 index 000000000..f8f7d43a5 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_epsilon.cairo @@ -0,0 +1,26 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_3D_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_0.cairo new file mode 100644 index 000000000..d50c8bd72 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_0.cairo @@ -0,0 +1,74 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(3); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 1485105, sign: false }); + data.append(FP8x23 { mag: 8139804, sign: true }); + data.append(FP8x23 { mag: 505632, sign: true }); + data.append(FP8x23 { mag: 3524873, sign: false }); + data.append(FP8x23 { mag: 12547296, sign: false }); + data.append(FP8x23 { mag: 3066367, sign: true }); + data.append(FP8x23 { mag: 11771262, sign: false }); + data.append(FP8x23 { mag: 16829198, sign: true }); + data.append(FP8x23 { mag: 4920415, sign: false }); + data.append(FP8x23 { mag: 5833319, sign: true }); + data.append(FP8x23 { mag: 9474739, sign: true }); + data.append(FP8x23 { mag: 3886224, sign: true }); + data.append(FP8x23 { mag: 18421974, sign: false }); + data.append(FP8x23 { mag: 2839674, sign: true }); + data.append(FP8x23 { mag: 436436, sign: false }); + data.append(FP8x23 { mag: 10713571, sign: true }); + data.append(FP8x23 { mag: 8793141, sign: false }); + data.append(FP8x23 { mag: 5123473, sign: false }); + data.append(FP8x23 { mag: 9696612, sign: false }); + data.append(FP8x23 { mag: 9923880, sign: false }); + data.append(FP8x23 { mag: 5115723, sign: false }); + data.append(FP8x23 { mag: 2650021, sign: false }); + data.append(FP8x23 { mag: 4861247, sign: false }); + data.append(FP8x23 { mag: 885435, sign: true }); + data.append(FP8x23 { mag: 3226459, sign: false }); + data.append(FP8x23 { mag: 200267, sign: false }); + data.append(FP8x23 { mag: 7737790, sign: true }); + data.append(FP8x23 { mag: 2966069, sign: false }); + data.append(FP8x23 { mag: 6111422, sign: true }); + data.append(FP8x23 { mag: 12128619, sign: false }); + data.append(FP8x23 { mag: 1683875, sign: true }); + data.append(FP8x23 { mag: 12544055, sign: true }); + data.append(FP8x23 { mag: 10206470, sign: false }); + data.append(FP8x23 { mag: 2879952, sign: true }); + data.append(FP8x23 { mag: 8388377, sign: true }); + data.append(FP8x23 { mag: 8797144, sign: true }); + data.append(FP8x23 { mag: 11155784, sign: false }); + data.append(FP8x23 { mag: 2695435, sign: false }); + data.append(FP8x23 { mag: 822510, sign: false }); + data.append(FP8x23 { mag: 3356466, sign: true }); + data.append(FP8x23 { mag: 10311828, sign: true }); + data.append(FP8x23 { mag: 264148, sign: true }); + data.append(FP8x23 { mag: 932946, sign: true }); + data.append(FP8x23 { mag: 11882466, sign: false }); + data.append(FP8x23 { mag: 25814742, sign: true }); + data.append(FP8x23 { mag: 11712535, sign: false }); + data.append(FP8x23 { mag: 1606493, sign: false }); + data.append(FP8x23 { mag: 7249278, sign: false }); + data.append(FP8x23 { mag: 474603, sign: true }); + data.append(FP8x23 { mag: 1364510, sign: true }); + data.append(FP8x23 { mag: 5651374, sign: true }); + data.append(FP8x23 { mag: 1726983, sign: false }); + data.append(FP8x23 { mag: 7766450, sign: false }); + data.append(FP8x23 { mag: 3416472, sign: false }); + data.append(FP8x23 { mag: 17276614, sign: true }); + data.append(FP8x23 { mag: 2352631, sign: true }); + data.append(FP8x23 { mag: 264548, sign: false }); + data.append(FP8x23 { mag: 12652767, sign: false }); + data.append(FP8x23 { mag: 5511194, sign: true }); + data.append(FP8x23 { mag: 6094439, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_1.cairo new file mode 100644 index 000000000..74c4c76ab --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2246569, sign: false }); + data.append(FP8x23 { mag: 6869432, sign: false }); + data.append(FP8x23 { mag: 547782, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_2.cairo new file mode 100644 index 000000000..6f7cfdcea --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 3030109, sign: true }); + data.append(FP8x23 { mag: 6156579, sign: true }); + data.append(FP8x23 { mag: 1444686, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/output_0.cairo new file mode 100644 index 000000000..8db6cdf02 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_epsilon/output_0.cairo @@ -0,0 +1,74 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(3); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 3123099, sign: true }); + data.append(FP8x23 { mag: 6133990, sign: true }); + data.append(FP8x23 { mag: 3745847, sign: true }); + data.append(FP8x23 { mag: 2485013, sign: true }); + data.append(FP8x23 { mag: 337405, sign: false }); + data.append(FP8x23 { mag: 7014320, sign: true }); + data.append(FP8x23 { mag: 3094973, sign: false }); + data.append(FP8x23 { mag: 16391325, sign: true }); + data.append(FP8x23 { mag: 1572701, sign: true }); + data.append(FP8x23 { mag: 8899523, sign: true }); + data.append(FP8x23 { mag: 888874, sign: true }); + data.append(FP8x23 { mag: 1199295, sign: true }); + data.append(FP8x23 { mag: 2438433, sign: true }); + data.append(FP8x23 { mag: 1257427, sign: true }); + data.append(FP8x23 { mag: 1439403, sign: true }); + data.append(FP8x23 { mag: 7181135, sign: true }); + data.append(FP8x23 { mag: 1881266, sign: true }); + data.append(FP8x23 { mag: 2878295, sign: true }); + data.append(FP8x23 { mag: 1635797, sign: true }); + data.append(FP8x23 { mag: 1574050, sign: true }); + data.append(FP8x23 { mag: 1890903, sign: true }); + data.append(FP8x23 { mag: 6847212, sign: true }); + data.append(FP8x23 { mag: 2402426, sign: true }); + data.append(FP8x23 { mag: 13953836, sign: true }); + data.append(FP8x23 { mag: 5688514, sign: true }); + data.append(FP8x23 { mag: 1438270, sign: true }); + data.append(FP8x23 { mag: 865258, sign: true }); + data.append(FP8x23 { mag: 1637921, sign: true }); + data.append(FP8x23 { mag: 982658, sign: true }); + data.append(FP8x23 { mag: 2299324, sign: true }); + data.append(FP8x23 { mag: 2650960, sign: true }); + data.append(FP8x23 { mag: 5647594, sign: true }); + data.append(FP8x23 { mag: 629925, sign: false }); + data.append(FP8x23 { mag: 2980992, sign: true }); + data.append(FP8x23 { mag: 4500924, sign: true }); + data.append(FP8x23 { mag: 15104139, sign: true }); + data.append(FP8x23 { mag: 4090226, sign: false }); + data.append(FP8x23 { mag: 4048479, sign: true }); + data.append(FP8x23 { mag: 5850200, sign: true }); + data.append(FP8x23 { mag: 9870302, sign: true }); + data.append(FP8x23 { mag: 1221331, sign: true }); + data.append(FP8x23 { mag: 1650959, sign: true }); + data.append(FP8x23 { mag: 1622362, sign: true }); + data.append(FP8x23 { mag: 2170336, sign: true }); + data.append(FP8x23 { mag: 558443, sign: true }); + data.append(FP8x23 { mag: 139431, sign: false }); + data.append(FP8x23 { mag: 3881244, sign: true }); + data.append(FP8x23 { mag: 1636269, sign: true }); + data.append(FP8x23 { mag: 4709206, sign: true }); + data.append(FP8x23 { mag: 5063255, sign: true }); + data.append(FP8x23 { mag: 8888995, sign: true }); + data.append(FP8x23 { mag: 3362108, sign: true }); + data.append(FP8x23 { mag: 1161857, sign: false }); + data.append(FP8x23 { mag: 2096567, sign: true }); + data.append(FP8x23 { mag: 17597084, sign: true }); + data.append(FP8x23 { mag: 1085035, sign: true }); + data.append(FP8x23 { mag: 1290453, sign: true }); + data.append(FP8x23 { mag: 2262787, sign: true }); + data.append(FP8x23 { mag: 837124, sign: true }); + data.append(FP8x23 { mag: 1748033, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel.cairo b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel.cairo new file mode 100644 index 000000000..2f25b694f --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel.cairo @@ -0,0 +1,26 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_3D_eq_batch_channel() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_0.cairo new file mode 100644 index 000000000..eb31fd683 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_0.cairo @@ -0,0 +1,30 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 12787712, sign: true }); + data.append(FP8x23 { mag: 2215503, sign: true }); + data.append(FP8x23 { mag: 2956106, sign: false }); + data.append(FP8x23 { mag: 17330078, sign: true }); + data.append(FP8x23 { mag: 5947315, sign: true }); + data.append(FP8x23 { mag: 3395557, sign: true }); + data.append(FP8x23 { mag: 5349690, sign: true }); + data.append(FP8x23 { mag: 2202011, sign: true }); + data.append(FP8x23 { mag: 2904789, sign: true }); + data.append(FP8x23 { mag: 558183, sign: false }); + data.append(FP8x23 { mag: 15797489, sign: false }); + data.append(FP8x23 { mag: 8109657, sign: false }); + data.append(FP8x23 { mag: 3956818, sign: true }); + data.append(FP8x23 { mag: 13018541, sign: false }); + data.append(FP8x23 { mag: 7774233, sign: true }); + data.append(FP8x23 { mag: 7510892, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_1.cairo new file mode 100644 index 000000000..15e96701c --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 11459990, sign: true }); + data.append(FP8x23 { mag: 3293437, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_2.cairo new file mode 100644 index 000000000..c26a26225 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2373654, sign: false }); + data.append(FP8x23 { mag: 11806108, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/output_0.cairo new file mode 100644 index 000000000..66b9593bb --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_eq_batch_channel/output_0.cairo @@ -0,0 +1,30 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 9701290, sign: false }); + data.append(FP8x23 { mag: 4530453, sign: true }); + data.append(FP8x23 { mag: 11492202, sign: true }); + data.append(FP8x23 { mag: 15815982, sign: false }); + data.append(FP8x23 { mag: 13668626, sign: true }); + data.append(FP8x23 { mag: 10911318, sign: true }); + data.append(FP8x23 { mag: 13022861, sign: true }); + data.append(FP8x23 { mag: 9621627, sign: true }); + data.append(FP8x23 { mag: 14749122, sign: false }); + data.append(FP8x23 { mag: 9582600, sign: false }); + data.append(FP8x23 { mag: 13153414, sign: true }); + data.append(FP8x23 { mag: 1683689, sign: true }); + data.append(FP8x23 { mag: 14106367, sign: true }); + data.append(FP8x23 { mag: 7763758, sign: true }); + data.append(FP8x23 { mag: 15532692, sign: true }); + data.append(FP8x23 { mag: 9821615, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_single_batch.cairo b/tests/nodes/instance_normalization_fp8x23_3D_single_batch.cairo new file mode 100644 index 000000000..bad73104f --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_single_batch.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_3D_single_batch() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(())); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_0.cairo new file mode 100644 index 000000000..98fb8ab83 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_0.cairo @@ -0,0 +1,34 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 1551343, sign: false }); + data.append(FP8x23 { mag: 3645780, sign: true }); + data.append(FP8x23 { mag: 19168982, sign: false }); + data.append(FP8x23 { mag: 17625466, sign: false }); + data.append(FP8x23 { mag: 7313506, sign: false }); + data.append(FP8x23 { mag: 340718, sign: true }); + data.append(FP8x23 { mag: 17950070, sign: false }); + data.append(FP8x23 { mag: 3596672, sign: true }); + data.append(FP8x23 { mag: 3351185, sign: true }); + data.append(FP8x23 { mag: 14032929, sign: true }); + data.append(FP8x23 { mag: 9837649, sign: true }); + data.append(FP8x23 { mag: 14232717, sign: false }); + data.append(FP8x23 { mag: 603129, sign: false }); + data.append(FP8x23 { mag: 12666451, sign: false }); + data.append(FP8x23 { mag: 847016, sign: false }); + data.append(FP8x23 { mag: 4107616, sign: false }); + data.append(FP8x23 { mag: 2414115, sign: false }); + data.append(FP8x23 { mag: 12068298, sign: true }); + data.append(FP8x23 { mag: 5929889, sign: false }); + data.append(FP8x23 { mag: 6687957, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_1.cairo new file mode 100644 index 000000000..d03026ab7 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 17907188, sign: true }); + data.append(FP8x23 { mag: 2671899, sign: false }); + data.append(FP8x23 { mag: 5820368, sign: true }); + data.append(FP8x23 { mag: 6729278, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_2.cairo new file mode 100644 index 000000000..8486ef944 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/input_2.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 12407424, sign: false }); + data.append(FP8x23 { mag: 4449134, sign: true }); + data.append(FP8x23 { mag: 6948388, sign: true }); + data.append(FP8x23 { mag: 3260532, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_3D_single_batch/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/output_0.cairo new file mode 100644 index 000000000..00e5a080c --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_3D_single_batch/output_0.cairo @@ -0,0 +1,34 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 26223756, sign: false }); + data.append(FP8x23 { mag: 36704184, sign: false }); + data.append(FP8x23 { mag: 9303670, sign: true }); + data.append(FP8x23 { mag: 6191044, sign: true }); + data.append(FP8x23 { mag: 14603878, sign: false }); + data.append(FP8x23 { mag: 4363463, sign: true }); + data.append(FP8x23 { mag: 334204, sign: false }); + data.append(FP8x23 { mag: 5199698, sign: true }); + data.append(FP8x23 { mag: 5136649, sign: true }); + data.append(FP8x23 { mag: 7880067, sign: true }); + data.append(FP8x23 { mag: 1948209, sign: false }); + data.append(FP8x23 { mag: 13867496, sign: true }); + data.append(FP8x23 { mag: 4912022, sign: true }); + data.append(FP8x23 { mag: 12838364, sign: true }); + data.append(FP8x23 { mag: 5072270, sign: true }); + data.append(FP8x23 { mag: 1950714, sign: false }); + data.append(FP8x23 { mag: 306832, sign: false }); + data.append(FP8x23 { mag: 13751253, sign: true }); + data.append(FP8x23 { mag: 3719595, sign: false }); + data.append(FP8x23 { mag: 8528553, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D.cairo b/tests/nodes/instance_normalization_fp8x23_4D.cairo new file mode 100644 index 000000000..d3b376f19 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_4D() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(())); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D/input_0.cairo new file mode 100644 index 000000000..f869dcc3e --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D/input_0.cairo @@ -0,0 +1,21 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 13077381, sign: false }); + data.append(FP8x23 { mag: 414936, sign: true }); + data.append(FP8x23 { mag: 5248434, sign: true }); + data.append(FP8x23 { mag: 1062998, sign: true }); + data.append(FP8x23 { mag: 5055835, sign: true }); + data.append(FP8x23 { mag: 3133557, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_4D/input_1.cairo new file mode 100644 index 000000000..7a13d64bf --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 4984729, sign: true }); + data.append(FP8x23 { mag: 3554362, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_4D/input_2.cairo new file mode 100644 index 000000000..39cedafed --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 11139928, sign: true }); + data.append(FP8x23 { mag: 3526276, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D/output_0.cairo new file mode 100644 index 000000000..06eaa9103 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D/output_0.cairo @@ -0,0 +1,21 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 17957324, sign: true }); + data.append(FP8x23 { mag: 9284678, sign: true }); + data.append(FP8x23 { mag: 6177783, sign: true }); + data.append(FP8x23 { mag: 3454093, sign: true }); + data.append(FP8x23 { mag: 790232, sign: false }); + data.append(FP8x23 { mag: 7914969, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_epsilon.cairo b/tests/nodes/instance_normalization_fp8x23_4D_epsilon.cairo new file mode 100644 index 000000000..28af7432d --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_epsilon.cairo @@ -0,0 +1,26 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_4D_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_0.cairo new file mode 100644 index 000000000..51a141547 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_0.cairo @@ -0,0 +1,135 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 3133589, sign: true }); + data.append(FP8x23 { mag: 7032963, sign: false }); + data.append(FP8x23 { mag: 16554200, sign: true }); + data.append(FP8x23 { mag: 4060123, sign: false }); + data.append(FP8x23 { mag: 328692, sign: false }); + data.append(FP8x23 { mag: 9200119, sign: false }); + data.append(FP8x23 { mag: 2663073, sign: true }); + data.append(FP8x23 { mag: 17450826, sign: false }); + data.append(FP8x23 { mag: 4704582, sign: false }); + data.append(FP8x23 { mag: 5438557, sign: true }); + data.append(FP8x23 { mag: 10715645, sign: false }); + data.append(FP8x23 { mag: 13196459, sign: false }); + data.append(FP8x23 { mag: 1522958, sign: true }); + data.append(FP8x23 { mag: 6395932, sign: false }); + data.append(FP8x23 { mag: 10920096, sign: false }); + data.append(FP8x23 { mag: 3364558, sign: false }); + data.append(FP8x23 { mag: 7768399, sign: true }); + data.append(FP8x23 { mag: 6836564, sign: false }); + data.append(FP8x23 { mag: 1802185, sign: false }); + data.append(FP8x23 { mag: 4389054, sign: false }); + data.append(FP8x23 { mag: 4496084, sign: true }); + data.append(FP8x23 { mag: 2928888, sign: false }); + data.append(FP8x23 { mag: 3586400, sign: true }); + data.append(FP8x23 { mag: 7703169, sign: true }); + data.append(FP8x23 { mag: 8730053, sign: true }); + data.append(FP8x23 { mag: 8926770, sign: false }); + data.append(FP8x23 { mag: 2499943, sign: true }); + data.append(FP8x23 { mag: 11369465, sign: false }); + data.append(FP8x23 { mag: 13469180, sign: true }); + data.append(FP8x23 { mag: 18336386, sign: false }); + data.append(FP8x23 { mag: 11421686, sign: false }); + data.append(FP8x23 { mag: 1249762, sign: true }); + data.append(FP8x23 { mag: 11846786, sign: true }); + data.append(FP8x23 { mag: 19102078, sign: false }); + data.append(FP8x23 { mag: 5577813, sign: true }); + data.append(FP8x23 { mag: 2648246, sign: true }); + data.append(FP8x23 { mag: 8459948, sign: true }); + data.append(FP8x23 { mag: 337882, sign: true }); + data.append(FP8x23 { mag: 10591919, sign: false }); + data.append(FP8x23 { mag: 6489752, sign: false }); + data.append(FP8x23 { mag: 8124069, sign: false }); + data.append(FP8x23 { mag: 3203748, sign: true }); + data.append(FP8x23 { mag: 4619139, sign: false }); + data.append(FP8x23 { mag: 3829870, sign: true }); + data.append(FP8x23 { mag: 15147607, sign: true }); + data.append(FP8x23 { mag: 9089219, sign: true }); + data.append(FP8x23 { mag: 10858520, sign: false }); + data.append(FP8x23 { mag: 365250, sign: true }); + data.append(FP8x23 { mag: 13336044, sign: true }); + data.append(FP8x23 { mag: 6628172, sign: true }); + data.append(FP8x23 { mag: 5946713, sign: true }); + data.append(FP8x23 { mag: 7422906, sign: false }); + data.append(FP8x23 { mag: 4063879, sign: true }); + data.append(FP8x23 { mag: 1804311, sign: false }); + data.append(FP8x23 { mag: 7265404, sign: true }); + data.append(FP8x23 { mag: 3881180, sign: false }); + data.append(FP8x23 { mag: 6632442, sign: false }); + data.append(FP8x23 { mag: 393120, sign: false }); + data.append(FP8x23 { mag: 19162070, sign: true }); + data.append(FP8x23 { mag: 2773050, sign: true }); + data.append(FP8x23 { mag: 16010446, sign: true }); + data.append(FP8x23 { mag: 345814, sign: true }); + data.append(FP8x23 { mag: 4125008, sign: false }); + data.append(FP8x23 { mag: 9319185, sign: false }); + data.append(FP8x23 { mag: 3373175, sign: false }); + data.append(FP8x23 { mag: 16165701, sign: true }); + data.append(FP8x23 { mag: 11687790, sign: false }); + data.append(FP8x23 { mag: 1271191, sign: false }); + data.append(FP8x23 { mag: 61170, sign: false }); + data.append(FP8x23 { mag: 8644436, sign: false }); + data.append(FP8x23 { mag: 9010877, sign: true }); + data.append(FP8x23 { mag: 4055603, sign: false }); + data.append(FP8x23 { mag: 2612932, sign: false }); + data.append(FP8x23 { mag: 4821033, sign: false }); + data.append(FP8x23 { mag: 4396992, sign: true }); + data.append(FP8x23 { mag: 4255802, sign: true }); + data.append(FP8x23 { mag: 10108081, sign: true }); + data.append(FP8x23 { mag: 15039529, sign: true }); + data.append(FP8x23 { mag: 390312, sign: false }); + data.append(FP8x23 { mag: 516595, sign: false }); + data.append(FP8x23 { mag: 4686479, sign: true }); + data.append(FP8x23 { mag: 5877804, sign: true }); + data.append(FP8x23 { mag: 2949147, sign: false }); + data.append(FP8x23 { mag: 8693131, sign: false }); + data.append(FP8x23 { mag: 4402836, sign: false }); + data.append(FP8x23 { mag: 6275148, sign: false }); + data.append(FP8x23 { mag: 2611540, sign: true }); + data.append(FP8x23 { mag: 2962203, sign: false }); + data.append(FP8x23 { mag: 4834611, sign: true }); + data.append(FP8x23 { mag: 2111516, sign: true }); + data.append(FP8x23 { mag: 5955993, sign: true }); + data.append(FP8x23 { mag: 7159665, sign: false }); + data.append(FP8x23 { mag: 7937740, sign: false }); + data.append(FP8x23 { mag: 15912214, sign: true }); + data.append(FP8x23 { mag: 817347, sign: false }); + data.append(FP8x23 { mag: 1334203, sign: true }); + data.append(FP8x23 { mag: 8239843, sign: true }); + data.append(FP8x23 { mag: 6966748, sign: true }); + data.append(FP8x23 { mag: 1873036, sign: true }); + data.append(FP8x23 { mag: 16354116, sign: true }); + data.append(FP8x23 { mag: 4222179, sign: false }); + data.append(FP8x23 { mag: 13799656, sign: false }); + data.append(FP8x23 { mag: 16730587, sign: false }); + data.append(FP8x23 { mag: 1824846, sign: false }); + data.append(FP8x23 { mag: 7710635, sign: false }); + data.append(FP8x23 { mag: 8561923, sign: false }); + data.append(FP8x23 { mag: 3260162, sign: true }); + data.append(FP8x23 { mag: 2993343, sign: false }); + data.append(FP8x23 { mag: 6782697, sign: true }); + data.append(FP8x23 { mag: 6552867, sign: true }); + data.append(FP8x23 { mag: 19202292, sign: true }); + data.append(FP8x23 { mag: 9655219, sign: true }); + data.append(FP8x23 { mag: 7289486, sign: false }); + data.append(FP8x23 { mag: 7730876, sign: true }); + data.append(FP8x23 { mag: 7616205, sign: true }); + data.append(FP8x23 { mag: 3014480, sign: true }); + data.append(FP8x23 { mag: 10592741, sign: false }); + data.append(FP8x23 { mag: 10669127, sign: false }); + data.append(FP8x23 { mag: 5763810, sign: true }); + data.append(FP8x23 { mag: 950928, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_1.cairo new file mode 100644 index 000000000..ff03c9319 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 6115111, sign: false }); + data.append(FP8x23 { mag: 12015304, sign: false }); + data.append(FP8x23 { mag: 5564954, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_2.cairo new file mode 100644 index 000000000..1a5c4e8d7 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 5352831, sign: true }); + data.append(FP8x23 { mag: 13838313, sign: false }); + data.append(FP8x23 { mag: 5515528, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/output_0.cairo new file mode 100644 index 000000000..ab72e69d2 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_epsilon/output_0.cairo @@ -0,0 +1,135 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 10075708, sign: true }); + data.append(FP8x23 { mag: 2453541, sign: true }); + data.append(FP8x23 { mag: 20137540, sign: true }); + data.append(FP8x23 { mag: 4682368, sign: true }); + data.append(FP8x23 { mag: 7479933, sign: true }); + data.append(FP8x23 { mag: 828760, sign: true }); + data.append(FP8x23 { mag: 9722948, sign: true }); + data.append(FP8x23 { mag: 5357040, sign: false }); + data.append(FP8x23 { mag: 4199198, sign: true }); + data.append(FP8x23 { mag: 11803812, sign: true }); + data.append(FP8x23 { mag: 307474, sign: false }); + data.append(FP8x23 { mag: 2167414, sign: false }); + data.append(FP8x23 { mag: 8868171, sign: true }); + data.append(FP8x23 { mag: 2931143, sign: true }); + data.append(FP8x23 { mag: 460757, sign: false }); + data.append(FP8x23 { mag: 5203854, sign: true }); + data.append(FP8x23 { mag: 13550564, sign: true }); + data.append(FP8x23 { mag: 2600788, sign: true }); + data.append(FP8x23 { mag: 6375211, sign: true }); + data.append(FP8x23 { mag: 4435759, sign: true }); + data.append(FP8x23 { mag: 7212333, sign: false }); + data.append(FP8x23 { mag: 16282429, sign: false }); + data.append(FP8x23 { mag: 8323571, sign: false }); + data.append(FP8x23 { mag: 3294665, sign: false }); + data.append(FP8x23 { mag: 2040258, sign: false }); + data.append(FP8x23 { mag: 23609238, sign: false }); + data.append(FP8x23 { mag: 9650751, sign: false }); + data.append(FP8x23 { mag: 26593152, sign: false }); + data.append(FP8x23 { mag: 3748899, sign: true }); + data.append(FP8x23 { mag: 35103708, sign: false }); + data.append(FP8x23 { mag: 26656944, sign: false }); + data.append(FP8x23 { mag: 11177930, sign: false }); + data.append(FP8x23 { mag: 1767037, sign: true }); + data.append(FP8x23 { mag: 36039052, sign: false }); + data.append(FP8x23 { mag: 5890929, sign: false }); + data.append(FP8x23 { mag: 9469588, sign: false }); + data.append(FP8x23 { mag: 2370209, sign: false }); + data.append(FP8x23 { mag: 12291851, sign: false }); + data.append(FP8x23 { mag: 25643328, sign: false }); + data.append(FP8x23 { mag: 20632260, sign: false }); + data.append(FP8x23 { mag: 12506777, sign: true }); + data.append(FP8x23 { mag: 4948385, sign: true }); + data.append(FP8x23 { mag: 10168142, sign: true }); + data.append(FP8x23 { mag: 4530610, sign: true }); + data.append(FP8x23 { mag: 3021055, sign: false }); + data.append(FP8x23 { mag: 1021353, sign: true }); + data.append(FP8x23 { mag: 14331317, sign: true }); + data.append(FP8x23 { mag: 6842349, sign: true }); + data.append(FP8x23 { mag: 1812305, sign: false }); + data.append(FP8x23 { mag: 2663466, sign: true }); + data.append(FP8x23 { mag: 3118164, sign: true }); + data.append(FP8x23 { mag: 12038932, sign: true }); + data.append(FP8x23 { mag: 4374470, sign: true }); + data.append(FP8x23 { mag: 8289971, sign: true }); + data.append(FP8x23 { mag: 2238278, sign: true }); + data.append(FP8x23 { mag: 9675745, sign: true }); + data.append(FP8x23 { mag: 11511501, sign: true }); + data.append(FP8x23 { mag: 7348365, sign: true }); + data.append(FP8x23 { mag: 5699674, sign: false }); + data.append(FP8x23 { mag: 5235764, sign: true }); + data.append(FP8x23 { mag: 15970369, sign: true }); + data.append(FP8x23 { mag: 4723200, sign: true }); + data.append(FP8x23 { mag: 1513159, sign: true }); + data.append(FP8x23 { mag: 2216247, sign: false }); + data.append(FP8x23 { mag: 2052974, sign: true }); + data.append(FP8x23 { mag: 16081842, sign: true }); + data.append(FP8x23 { mag: 3916901, sign: false }); + data.append(FP8x23 { mag: 3562193, sign: true }); + data.append(FP8x23 { mag: 4430986, sign: true }); + data.append(FP8x23 { mag: 1731779, sign: false }); + data.append(FP8x23 { mag: 10944695, sign: true }); + data.append(FP8x23 { mag: 1562992, sign: true }); + data.append(FP8x23 { mag: 2598827, sign: true }); + data.append(FP8x23 { mag: 1013415, sign: true }); + data.append(FP8x23 { mag: 7631937, sign: true }); + data.append(FP8x23 { mag: 7530562, sign: true }); + data.append(FP8x23 { mag: 11732484, sign: true }); + data.append(FP8x23 { mag: 15273253, sign: true }); + data.append(FP8x23 { mag: 4194662, sign: true }); + data.append(FP8x23 { mag: 4103991, sign: true }); + data.append(FP8x23 { mag: 9154384, sign: false }); + data.append(FP8x23 { mag: 7235798, sign: false }); + data.append(FP8x23 { mag: 21451284, sign: false }); + data.append(FP8x23 { mag: 30701760, sign: false }); + data.append(FP8x23 { mag: 23792396, sign: false }); + data.append(FP8x23 { mag: 26807688, sign: false }); + data.append(FP8x23 { mag: 12495998, sign: false }); + data.append(FP8x23 { mag: 21472310, sign: false }); + data.append(FP8x23 { mag: 8915824, sign: false }); + data.append(FP8x23 { mag: 13301269, sign: false }); + data.append(FP8x23 { mag: 7109878, sign: false }); + data.append(FP8x23 { mag: 28232170, sign: false }); + data.append(FP8x23 { mag: 29485232, sign: false }); + data.append(FP8x23 { mag: 8924255, sign: true }); + data.append(FP8x23 { mag: 18018098, sign: false }); + data.append(FP8x23 { mag: 14553103, sign: false }); + data.append(FP8x23 { mag: 3431821, sign: false }); + data.append(FP8x23 { mag: 5482094, sign: false }); + data.append(FP8x23 { mag: 13685332, sign: false }); + data.append(FP8x23 { mag: 9635921, sign: true }); + data.append(FP8x23 { mag: 7605404, sign: true }); + data.append(FP8x23 { mag: 13277306, sign: true }); + data.append(FP8x23 { mag: 15013040, sign: true }); + data.append(FP8x23 { mag: 6185674, sign: true }); + data.append(FP8x23 { mag: 9671312, sign: true }); + data.append(FP8x23 { mag: 10175456, sign: true }); + data.append(FP8x23 { mag: 3174268, sign: true }); + data.append(FP8x23 { mag: 6877672, sign: true }); + data.append(FP8x23 { mag: 1088179, sign: true }); + data.append(FP8x23 { mag: 1224287, sign: true }); + data.append(FP8x23 { mag: 6266861, sign: false }); + data.append(FP8x23 { mag: 612964, sign: false }); + data.append(FP8x23 { mag: 9421902, sign: true }); + data.append(FP8x23 { mag: 526655, sign: true }); + data.append(FP8x23 { mag: 594565, sign: true }); + data.append(FP8x23 { mag: 3319764, sign: true }); + data.append(FP8x23 { mag: 11378131, sign: true }); + data.append(FP8x23 { mag: 11423368, sign: true }); + data.append(FP8x23 { mag: 1691576, sign: true }); + data.append(FP8x23 { mag: 4541825, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel.cairo b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel.cairo new file mode 100644 index 000000000..7407e2f58 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel.cairo @@ -0,0 +1,26 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_4D_eq_batch_channel() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_0.cairo new file mode 100644 index 000000000..25759edbd --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_0.cairo @@ -0,0 +1,63 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(3); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 1502806, sign: false }); + data.append(FP8x23 { mag: 1978742, sign: false }); + data.append(FP8x23 { mag: 5998221, sign: true }); + data.append(FP8x23 { mag: 4979683, sign: false }); + data.append(FP8x23 { mag: 10885031, sign: true }); + data.append(FP8x23 { mag: 7721962, sign: true }); + data.append(FP8x23 { mag: 7074007, sign: false }); + data.append(FP8x23 { mag: 6887467, sign: false }); + data.append(FP8x23 { mag: 1943013, sign: false }); + data.append(FP8x23 { mag: 11266698, sign: false }); + data.append(FP8x23 { mag: 13776885, sign: true }); + data.append(FP8x23 { mag: 2314267, sign: false }); + data.append(FP8x23 { mag: 825861, sign: true }); + data.append(FP8x23 { mag: 12286829, sign: false }); + data.append(FP8x23 { mag: 9914517, sign: false }); + data.append(FP8x23 { mag: 6782641, sign: true }); + data.append(FP8x23 { mag: 11695628, sign: true }); + data.append(FP8x23 { mag: 4307465, sign: true }); + data.append(FP8x23 { mag: 1597108, sign: true }); + data.append(FP8x23 { mag: 5696566, sign: false }); + data.append(FP8x23 { mag: 15898063, sign: false }); + data.append(FP8x23 { mag: 4080563, sign: false }); + data.append(FP8x23 { mag: 4244004, sign: false }); + data.append(FP8x23 { mag: 522209, sign: false }); + data.append(FP8x23 { mag: 3531723, sign: true }); + data.append(FP8x23 { mag: 2138510, sign: true }); + data.append(FP8x23 { mag: 708831, sign: true }); + data.append(FP8x23 { mag: 12028612, sign: true }); + data.append(FP8x23 { mag: 5255836, sign: false }); + data.append(FP8x23 { mag: 1022816, sign: true }); + data.append(FP8x23 { mag: 830132, sign: false }); + data.append(FP8x23 { mag: 1878013, sign: false }); + data.append(FP8x23 { mag: 561735, sign: false }); + data.append(FP8x23 { mag: 2252019, sign: true }); + data.append(FP8x23 { mag: 19980708, sign: true }); + data.append(FP8x23 { mag: 6631170, sign: true }); + data.append(FP8x23 { mag: 8164964, sign: false }); + data.append(FP8x23 { mag: 12309388, sign: false }); + data.append(FP8x23 { mag: 1244762, sign: true }); + data.append(FP8x23 { mag: 14615450, sign: true }); + data.append(FP8x23 { mag: 9643049, sign: false }); + data.append(FP8x23 { mag: 4067024, sign: true }); + data.append(FP8x23 { mag: 3861240, sign: false }); + data.append(FP8x23 { mag: 2640336, sign: true }); + data.append(FP8x23 { mag: 9457470, sign: true }); + data.append(FP8x23 { mag: 3785345, sign: false }); + data.append(FP8x23 { mag: 594208, sign: false }); + data.append(FP8x23 { mag: 4482994, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_1.cairo new file mode 100644 index 000000000..91525f04e --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 6205393, sign: false }); + data.append(FP8x23 { mag: 1179758, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_2.cairo new file mode 100644 index 000000000..b35484a8d --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 5751856, sign: true }); + data.append(FP8x23 { mag: 2032744, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/output_0.cairo new file mode 100644 index 000000000..8d848af26 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_eq_batch_channel/output_0.cairo @@ -0,0 +1,63 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(3); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 4546062, sign: true }); + data.append(FP8x23 { mag: 4173193, sign: true }); + data.append(FP8x23 { mag: 10422706, sign: true }); + data.append(FP8x23 { mag: 1822120, sign: true }); + data.append(FP8x23 { mag: 14251254, sign: true }); + data.append(FP8x23 { mag: 11773163, sign: true }); + data.append(FP8x23 { mag: 181332, sign: true }); + data.append(FP8x23 { mag: 327476, sign: true }); + data.append(FP8x23 { mag: 4201185, sign: true }); + data.append(FP8x23 { mag: 3103412, sign: false }); + data.append(FP8x23 { mag: 16516863, sign: true }); + data.append(FP8x23 { mag: 3910327, sign: true }); + data.append(FP8x23 { mag: 1581872, sign: true }); + data.append(FP8x23 { mag: 3481641, sign: true }); + data.append(FP8x23 { mag: 3137940, sign: true }); + data.append(FP8x23 { mag: 718853, sign: true }); + data.append(FP8x23 { mag: 7059, sign: true }); + data.append(FP8x23 { mag: 1077457, sign: true }); + data.append(FP8x23 { mag: 1470134, sign: true }); + data.append(FP8x23 { mag: 2526843, sign: true }); + data.append(FP8x23 { mag: 4004837, sign: true }); + data.append(FP8x23 { mag: 2292716, sign: true }); + data.append(FP8x23 { mag: 2316395, sign: true }); + data.append(FP8x23 { mag: 1777181, sign: true }); + data.append(FP8x23 { mag: 5943457, sign: true }); + data.append(FP8x23 { mag: 4717080, sign: true }); + data.append(FP8x23 { mag: 3458604, sign: true }); + data.append(FP8x23 { mag: 13422854, sign: true }); + data.append(FP8x23 { mag: 1791802, sign: false }); + data.append(FP8x23 { mag: 3734989, sign: true }); + data.append(FP8x23 { mag: 2103929, sign: true }); + data.append(FP8x23 { mag: 1181530, sign: true }); + data.append(FP8x23 { mag: 2340185, sign: true }); + data.append(FP8x23 { mag: 4816997, sign: true }); + data.append(FP8x23 { mag: 20422696, sign: true }); + data.append(FP8x23 { mag: 8671750, sign: true }); + data.append(FP8x23 { mag: 3106938, sign: true }); + data.append(FP8x23 { mag: 3719844, sign: true }); + data.append(FP8x23 { mag: 1715363, sign: true }); + data.append(FP8x23 { mag: 261986, sign: false }); + data.append(FP8x23 { mag: 3325528, sign: true }); + data.append(FP8x23 { mag: 1297987, sign: true }); + data.append(FP8x23 { mag: 2470474, sign: true }); + data.append(FP8x23 { mag: 1508976, sign: true }); + data.append(FP8x23 { mag: 500811, sign: true }); + data.append(FP8x23 { mag: 2459250, sign: true }); + data.append(FP8x23 { mag: 1987322, sign: true }); + data.append(FP8x23 { mag: 2562423, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_single_batch.cairo b/tests/nodes/instance_normalization_fp8x23_4D_single_batch.cairo new file mode 100644 index 000000000..deb1ded01 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_single_batch.cairo @@ -0,0 +1,26 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_4D_single_batch() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_0.cairo new file mode 100644 index 000000000..26c76f735 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_0.cairo @@ -0,0 +1,75 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 7924942, sign: false }); + data.append(FP8x23 { mag: 13246850, sign: false }); + data.append(FP8x23 { mag: 2702202, sign: false }); + data.append(FP8x23 { mag: 10258009, sign: true }); + data.append(FP8x23 { mag: 1097270, sign: true }); + data.append(FP8x23 { mag: 3170256, sign: false }); + data.append(FP8x23 { mag: 11933079, sign: true }); + data.append(FP8x23 { mag: 7332484, sign: true }); + data.append(FP8x23 { mag: 10518663, sign: false }); + data.append(FP8x23 { mag: 2040333, sign: false }); + data.append(FP8x23 { mag: 11555977, sign: false }); + data.append(FP8x23 { mag: 192783, sign: true }); + data.append(FP8x23 { mag: 8410969, sign: false }); + data.append(FP8x23 { mag: 10253807, sign: false }); + data.append(FP8x23 { mag: 4451078, sign: false }); + data.append(FP8x23 { mag: 6128150, sign: false }); + data.append(FP8x23 { mag: 3066136, sign: true }); + data.append(FP8x23 { mag: 1979188, sign: false }); + data.append(FP8x23 { mag: 12213890, sign: true }); + data.append(FP8x23 { mag: 4054431, sign: false }); + data.append(FP8x23 { mag: 10368026, sign: false }); + data.append(FP8x23 { mag: 21004994, sign: true }); + data.append(FP8x23 { mag: 3484058, sign: true }); + data.append(FP8x23 { mag: 11422819, sign: false }); + data.append(FP8x23 { mag: 4590602, sign: false }); + data.append(FP8x23 { mag: 934665, sign: false }); + data.append(FP8x23 { mag: 13626899, sign: true }); + data.append(FP8x23 { mag: 2017121, sign: false }); + data.append(FP8x23 { mag: 3778004, sign: false }); + data.append(FP8x23 { mag: 12333339, sign: true }); + data.append(FP8x23 { mag: 6452644, sign: true }); + data.append(FP8x23 { mag: 23139458, sign: false }); + data.append(FP8x23 { mag: 9962093, sign: true }); + data.append(FP8x23 { mag: 28057456, sign: false }); + data.append(FP8x23 { mag: 4096432, sign: false }); + data.append(FP8x23 { mag: 1746466, sign: false }); + data.append(FP8x23 { mag: 3400610, sign: false }); + data.append(FP8x23 { mag: 1694851, sign: false }); + data.append(FP8x23 { mag: 14762852, sign: true }); + data.append(FP8x23 { mag: 11193272, sign: false }); + data.append(FP8x23 { mag: 3271310, sign: false }); + data.append(FP8x23 { mag: 8257251, sign: true }); + data.append(FP8x23 { mag: 5549365, sign: true }); + data.append(FP8x23 { mag: 1609902, sign: false }); + data.append(FP8x23 { mag: 9788646, sign: false }); + data.append(FP8x23 { mag: 4905918, sign: false }); + data.append(FP8x23 { mag: 7275039, sign: false }); + data.append(FP8x23 { mag: 15450536, sign: false }); + data.append(FP8x23 { mag: 7493020, sign: true }); + data.append(FP8x23 { mag: 5102934, sign: true }); + data.append(FP8x23 { mag: 4473274, sign: false }); + data.append(FP8x23 { mag: 12556968, sign: true }); + data.append(FP8x23 { mag: 10195289, sign: false }); + data.append(FP8x23 { mag: 15666986, sign: true }); + data.append(FP8x23 { mag: 5094279, sign: false }); + data.append(FP8x23 { mag: 17021828, sign: true }); + data.append(FP8x23 { mag: 6281825, sign: false }); + data.append(FP8x23 { mag: 3457968, sign: false }); + data.append(FP8x23 { mag: 4515889, sign: false }); + data.append(FP8x23 { mag: 3445940, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_1.cairo new file mode 100644 index 000000000..07582b315 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 5116323, sign: true }); + data.append(FP8x23 { mag: 4992772, sign: true }); + data.append(FP8x23 { mag: 3543240, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_2.cairo new file mode 100644 index 000000000..16e8faa04 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 1285666, sign: false }); + data.append(FP8x23 { mag: 458259, sign: false }); + data.append(FP8x23 { mag: 24824282, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_4D_single_batch/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/output_0.cairo new file mode 100644 index 000000000..98c2c32be --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_4D_single_batch/output_0.cairo @@ -0,0 +1,75 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2495318, sign: true }); + data.append(FP8x23 { mag: 5901343, sign: true }); + data.append(FP8x23 { mag: 847239, sign: false }); + data.append(FP8x23 { mag: 9141784, sign: false }); + data.append(FP8x23 { mag: 3278904, sign: false }); + data.append(FP8x23 { mag: 547683, sign: false }); + data.append(FP8x23 { mag: 10213830, sign: false }); + data.append(FP8x23 { mag: 7269445, sign: false }); + data.append(FP8x23 { mag: 4155301, sign: true }); + data.append(FP8x23 { mag: 1270835, sign: false }); + data.append(FP8x23 { mag: 4819184, sign: true }); + data.append(FP8x23 { mag: 2700032, sign: false }); + data.append(FP8x23 { mag: 2806376, sign: true }); + data.append(FP8x23 { mag: 3985794, sign: true }); + data.append(FP8x23 { mag: 272043, sign: true }); + data.append(FP8x23 { mag: 1345370, sign: true }); + data.append(FP8x23 { mag: 4538980, sign: false }); + data.append(FP8x23 { mag: 1309968, sign: false }); + data.append(FP8x23 { mag: 10393550, sign: false }); + data.append(FP8x23 { mag: 18188, sign: true }); + data.append(FP8x23 { mag: 3250001, sign: true }); + data.append(FP8x23 { mag: 9496190, sign: false }); + data.append(FP8x23 { mag: 2377806, sign: false }); + data.append(FP8x23 { mag: 3678541, sign: true }); + data.append(FP8x23 { mag: 902757, sign: true }); + data.append(FP8x23 { mag: 582572, sign: false }); + data.append(FP8x23 { mag: 6498626, sign: false }); + data.append(FP8x23 { mag: 142793, sign: false }); + data.append(FP8x23 { mag: 572615, sign: true }); + data.append(FP8x23 { mag: 5973080, sign: false }); + data.append(FP8x23 { mag: 3583878, sign: false }); + data.append(FP8x23 { mag: 8438763, sign: true }); + data.append(FP8x23 { mag: 5009694, sign: false }); + data.append(FP8x23 { mag: 10436841, sign: true }); + data.append(FP8x23 { mag: 701986, sign: true }); + data.append(FP8x23 { mag: 252754, sign: false }); + data.append(FP8x23 { mag: 419288, sign: true }); + data.append(FP8x23 { mag: 273724, sign: false }); + data.append(FP8x23 { mag: 6960140, sign: false }); + data.append(FP8x23 { mag: 3585281, sign: true }); + data.append(FP8x23 { mag: 23580736, sign: false }); + data.append(FP8x23 { mag: 28046828, sign: false }); + data.append(FP8x23 { mag: 26997810, sign: false }); + data.append(FP8x23 { mag: 24224356, sign: false }); + data.append(FP8x23 { mag: 21055962, sign: false }); + data.append(FP8x23 { mag: 22947500, sign: false }); + data.append(FP8x23 { mag: 22029716, sign: false }); + data.append(FP8x23 { mag: 18862580, sign: false }); + data.append(FP8x23 { mag: 27750770, sign: false }); + data.append(FP8x23 { mag: 26824866, sign: false }); + data.append(FP8x23 { mag: 23115104, sign: false }); + data.append(FP8x23 { mag: 29712512, sign: false }); + data.append(FP8x23 { mag: 20898430, sign: false }); + data.append(FP8x23 { mag: 30917312, sign: false }); + data.append(FP8x23 { mag: 22874530, sign: false }); + data.append(FP8x23 { mag: 31442170, sign: false }); + data.append(FP8x23 { mag: 22414482, sign: false }); + data.append(FP8x23 { mag: 23508426, sign: false }); + data.append(FP8x23 { mag: 23098594, sign: false }); + data.append(FP8x23 { mag: 26182956, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim.cairo b/tests/nodes/instance_normalization_fp8x23_highdim.cairo new file mode 100644 index 000000000..90f01cf47 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_highdim() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim/input_0.cairo new file mode 100644 index 000000000..c21da7d97 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim/input_0.cairo @@ -0,0 +1,232 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(3); + shape.append(3); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 8615189, sign: true }); + data.append(FP8x23 { mag: 13843869, sign: true }); + data.append(FP8x23 { mag: 6199610, sign: false }); + data.append(FP8x23 { mag: 7565028, sign: false }); + data.append(FP8x23 { mag: 2175676, sign: true }); + data.append(FP8x23 { mag: 3669002, sign: true }); + data.append(FP8x23 { mag: 14011270, sign: false }); + data.append(FP8x23 { mag: 4204646, sign: false }); + data.append(FP8x23 { mag: 8648335, sign: false }); + data.append(FP8x23 { mag: 8041893, sign: true }); + data.append(FP8x23 { mag: 8077161, sign: false }); + data.append(FP8x23 { mag: 6824857, sign: false }); + data.append(FP8x23 { mag: 9522169, sign: false }); + data.append(FP8x23 { mag: 2284876, sign: true }); + data.append(FP8x23 { mag: 8964412, sign: false }); + data.append(FP8x23 { mag: 4439500, sign: false }); + data.append(FP8x23 { mag: 11415579, sign: true }); + data.append(FP8x23 { mag: 2328789, sign: true }); + data.append(FP8x23 { mag: 7605321, sign: true }); + data.append(FP8x23 { mag: 11320651, sign: true }); + data.append(FP8x23 { mag: 3826606, sign: true }); + data.append(FP8x23 { mag: 7014419, sign: true }); + data.append(FP8x23 { mag: 1366663, sign: true }); + data.append(FP8x23 { mag: 5059289, sign: false }); + data.append(FP8x23 { mag: 9771766, sign: false }); + data.append(FP8x23 { mag: 10658026, sign: true }); + data.append(FP8x23 { mag: 10033455, sign: false }); + data.append(FP8x23 { mag: 4581109, sign: true }); + data.append(FP8x23 { mag: 10577480, sign: false }); + data.append(FP8x23 { mag: 6821589, sign: true }); + data.append(FP8x23 { mag: 4376148, sign: false }); + data.append(FP8x23 { mag: 17000618, sign: false }); + data.append(FP8x23 { mag: 10515941, sign: true }); + data.append(FP8x23 { mag: 1323477, sign: true }); + data.append(FP8x23 { mag: 11082417, sign: true }); + data.append(FP8x23 { mag: 5731332, sign: false }); + data.append(FP8x23 { mag: 19306702, sign: true }); + data.append(FP8x23 { mag: 5652656, sign: false }); + data.append(FP8x23 { mag: 6135979, sign: false }); + data.append(FP8x23 { mag: 11169098, sign: false }); + data.append(FP8x23 { mag: 6666770, sign: true }); + data.append(FP8x23 { mag: 315837, sign: true }); + data.append(FP8x23 { mag: 13027189, sign: true }); + data.append(FP8x23 { mag: 4435095, sign: false }); + data.append(FP8x23 { mag: 7413224, sign: true }); + data.append(FP8x23 { mag: 2244295, sign: true }); + data.append(FP8x23 { mag: 3984564, sign: true }); + data.append(FP8x23 { mag: 3666108, sign: true }); + data.append(FP8x23 { mag: 1673161, sign: true }); + data.append(FP8x23 { mag: 13975039, sign: true }); + data.append(FP8x23 { mag: 8301784, sign: false }); + data.append(FP8x23 { mag: 14228879, sign: true }); + data.append(FP8x23 { mag: 21743736, sign: true }); + data.append(FP8x23 { mag: 9347717, sign: false }); + data.append(FP8x23 { mag: 7457550, sign: false }); + data.append(FP8x23 { mag: 737489, sign: false }); + data.append(FP8x23 { mag: 13867310, sign: true }); + data.append(FP8x23 { mag: 11790952, sign: false }); + data.append(FP8x23 { mag: 6328724, sign: false }); + data.append(FP8x23 { mag: 17239326, sign: false }); + data.append(FP8x23 { mag: 6383621, sign: true }); + data.append(FP8x23 { mag: 2719690, sign: true }); + data.append(FP8x23 { mag: 2755830, sign: true }); + data.append(FP8x23 { mag: 10593386, sign: true }); + data.append(FP8x23 { mag: 12603489, sign: true }); + data.append(FP8x23 { mag: 444857, sign: true }); + data.append(FP8x23 { mag: 10883054, sign: true }); + data.append(FP8x23 { mag: 7292660, sign: true }); + data.append(FP8x23 { mag: 14018901, sign: false }); + data.append(FP8x23 { mag: 579901, sign: true }); + data.append(FP8x23 { mag: 976987, sign: true }); + data.append(FP8x23 { mag: 4606541, sign: false }); + data.append(FP8x23 { mag: 8602742, sign: true }); + data.append(FP8x23 { mag: 6624645, sign: false }); + data.append(FP8x23 { mag: 6945138, sign: true }); + data.append(FP8x23 { mag: 11076332, sign: false }); + data.append(FP8x23 { mag: 5659320, sign: false }); + data.append(FP8x23 { mag: 2614670, sign: false }); + data.append(FP8x23 { mag: 3798373, sign: false }); + data.append(FP8x23 { mag: 9741228, sign: false }); + data.append(FP8x23 { mag: 10751984, sign: true }); + data.append(FP8x23 { mag: 6210553, sign: false }); + data.append(FP8x23 { mag: 7512974, sign: true }); + data.append(FP8x23 { mag: 2684115, sign: true }); + data.append(FP8x23 { mag: 2238084, sign: false }); + data.append(FP8x23 { mag: 19252570, sign: true }); + data.append(FP8x23 { mag: 13431907, sign: false }); + data.append(FP8x23 { mag: 4966150, sign: true }); + data.append(FP8x23 { mag: 10463041, sign: true }); + data.append(FP8x23 { mag: 820989, sign: true }); + data.append(FP8x23 { mag: 11291874, sign: false }); + data.append(FP8x23 { mag: 4444127, sign: false }); + data.append(FP8x23 { mag: 664279, sign: true }); + data.append(FP8x23 { mag: 4954894, sign: true }); + data.append(FP8x23 { mag: 4624772, sign: true }); + data.append(FP8x23 { mag: 4880284, sign: false }); + data.append(FP8x23 { mag: 4174028, sign: false }); + data.append(FP8x23 { mag: 3755864, sign: true }); + data.append(FP8x23 { mag: 1398017, sign: false }); + data.append(FP8x23 { mag: 4824730, sign: false }); + data.append(FP8x23 { mag: 3555999, sign: false }); + data.append(FP8x23 { mag: 7306685, sign: false }); + data.append(FP8x23 { mag: 2346436, sign: true }); + data.append(FP8x23 { mag: 540702, sign: false }); + data.append(FP8x23 { mag: 1187786, sign: true }); + data.append(FP8x23 { mag: 6617700, sign: false }); + data.append(FP8x23 { mag: 7460337, sign: false }); + data.append(FP8x23 { mag: 6230235, sign: true }); + data.append(FP8x23 { mag: 4705592, sign: false }); + data.append(FP8x23 { mag: 6919157, sign: false }); + data.append(FP8x23 { mag: 13282042, sign: false }); + data.append(FP8x23 { mag: 5095691, sign: true }); + data.append(FP8x23 { mag: 6896715, sign: true }); + data.append(FP8x23 { mag: 1783602, sign: false }); + data.append(FP8x23 { mag: 5596222, sign: false }); + data.append(FP8x23 { mag: 9123875, sign: true }); + data.append(FP8x23 { mag: 7944612, sign: false }); + data.append(FP8x23 { mag: 13959193, sign: true }); + data.append(FP8x23 { mag: 17255610, sign: true }); + data.append(FP8x23 { mag: 426614, sign: false }); + data.append(FP8x23 { mag: 239827, sign: true }); + data.append(FP8x23 { mag: 10100329, sign: true }); + data.append(FP8x23 { mag: 4791640, sign: false }); + data.append(FP8x23 { mag: 1253075, sign: false }); + data.append(FP8x23 { mag: 5060302, sign: false }); + data.append(FP8x23 { mag: 4911612, sign: false }); + data.append(FP8x23 { mag: 9699553, sign: true }); + data.append(FP8x23 { mag: 7218042, sign: true }); + data.append(FP8x23 { mag: 9917648, sign: false }); + data.append(FP8x23 { mag: 5902858, sign: true }); + data.append(FP8x23 { mag: 8878660, sign: false }); + data.append(FP8x23 { mag: 17546502, sign: true }); + data.append(FP8x23 { mag: 6252563, sign: false }); + data.append(FP8x23 { mag: 1484624, sign: true }); + data.append(FP8x23 { mag: 17485674, sign: true }); + data.append(FP8x23 { mag: 16625594, sign: true }); + data.append(FP8x23 { mag: 6933322, sign: false }); + data.append(FP8x23 { mag: 8946157, sign: false }); + data.append(FP8x23 { mag: 3720024, sign: true }); + data.append(FP8x23 { mag: 6432625, sign: true }); + data.append(FP8x23 { mag: 11092056, sign: false }); + data.append(FP8x23 { mag: 19295340, sign: false }); + data.append(FP8x23 { mag: 1320644, sign: false }); + data.append(FP8x23 { mag: 775593, sign: true }); + data.append(FP8x23 { mag: 12696445, sign: true }); + data.append(FP8x23 { mag: 1148832, sign: false }); + data.append(FP8x23 { mag: 3160466, sign: true }); + data.append(FP8x23 { mag: 7771077, sign: true }); + data.append(FP8x23 { mag: 114579, sign: false }); + data.append(FP8x23 { mag: 4537147, sign: true }); + data.append(FP8x23 { mag: 106502, sign: false }); + data.append(FP8x23 { mag: 8815457, sign: true }); + data.append(FP8x23 { mag: 2227922, sign: false }); + data.append(FP8x23 { mag: 11518746, sign: true }); + data.append(FP8x23 { mag: 4251468, sign: true }); + data.append(FP8x23 { mag: 2336994, sign: false }); + data.append(FP8x23 { mag: 7852724, sign: false }); + data.append(FP8x23 { mag: 14246196, sign: false }); + data.append(FP8x23 { mag: 6729087, sign: true }); + data.append(FP8x23 { mag: 10117270, sign: true }); + data.append(FP8x23 { mag: 13770523, sign: true }); + data.append(FP8x23 { mag: 10662850, sign: false }); + data.append(FP8x23 { mag: 27230034, sign: true }); + data.append(FP8x23 { mag: 18128698, sign: true }); + data.append(FP8x23 { mag: 5260016, sign: true }); + data.append(FP8x23 { mag: 15242745, sign: true }); + data.append(FP8x23 { mag: 8132696, sign: true }); + data.append(FP8x23 { mag: 5305342, sign: true }); + data.append(FP8x23 { mag: 11546314, sign: false }); + data.append(FP8x23 { mag: 577838, sign: true }); + data.append(FP8x23 { mag: 2313191, sign: false }); + data.append(FP8x23 { mag: 3005259, sign: false }); + data.append(FP8x23 { mag: 17659694, sign: false }); + data.append(FP8x23 { mag: 2725524, sign: true }); + data.append(FP8x23 { mag: 27817424, sign: false }); + data.append(FP8x23 { mag: 3008138, sign: true }); + data.append(FP8x23 { mag: 7293572, sign: false }); + data.append(FP8x23 { mag: 3695913, sign: true }); + data.append(FP8x23 { mag: 4193237, sign: true }); + data.append(FP8x23 { mag: 8059706, sign: true }); + data.append(FP8x23 { mag: 425078, sign: true }); + data.append(FP8x23 { mag: 507898, sign: true }); + data.append(FP8x23 { mag: 3146153, sign: true }); + data.append(FP8x23 { mag: 2554205, sign: true }); + data.append(FP8x23 { mag: 13532536, sign: false }); + data.append(FP8x23 { mag: 626121, sign: false }); + data.append(FP8x23 { mag: 2028041, sign: false }); + data.append(FP8x23 { mag: 7660259, sign: false }); + data.append(FP8x23 { mag: 5151542, sign: false }); + data.append(FP8x23 { mag: 2173263, sign: true }); + data.append(FP8x23 { mag: 361902, sign: false }); + data.append(FP8x23 { mag: 5944286, sign: false }); + data.append(FP8x23 { mag: 4376971, sign: false }); + data.append(FP8x23 { mag: 6411897, sign: false }); + data.append(FP8x23 { mag: 1478819, sign: true }); + data.append(FP8x23 { mag: 8267605, sign: true }); + data.append(FP8x23 { mag: 1754369, sign: false }); + data.append(FP8x23 { mag: 3697503, sign: false }); + data.append(FP8x23 { mag: 2020718, sign: false }); + data.append(FP8x23 { mag: 6057125, sign: true }); + data.append(FP8x23 { mag: 17836126, sign: false }); + data.append(FP8x23 { mag: 6199525, sign: true }); + data.append(FP8x23 { mag: 2588670, sign: false }); + data.append(FP8x23 { mag: 5652720, sign: true }); + data.append(FP8x23 { mag: 1306936, sign: true }); + data.append(FP8x23 { mag: 6012971, sign: true }); + data.append(FP8x23 { mag: 3802170, sign: true }); + data.append(FP8x23 { mag: 9214082, sign: false }); + data.append(FP8x23 { mag: 2304384, sign: true }); + data.append(FP8x23 { mag: 15064143, sign: true }); + data.append(FP8x23 { mag: 7552500, sign: false }); + data.append(FP8x23 { mag: 550620, sign: false }); + data.append(FP8x23 { mag: 5693790, sign: false }); + data.append(FP8x23 { mag: 5190193, sign: true }); + data.append(FP8x23 { mag: 9433340, sign: false }); + data.append(FP8x23 { mag: 4004863, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_highdim/input_1.cairo new file mode 100644 index 000000000..f20ee068d --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 922292, sign: true }); + data.append(FP8x23 { mag: 2258631, sign: true }); + data.append(FP8x23 { mag: 1582123, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_highdim/input_2.cairo new file mode 100644 index 000000000..c32ca7608 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2892897, sign: false }); + data.append(FP8x23 { mag: 7617228, sign: true }); + data.append(FP8x23 { mag: 9136188, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim/output_0.cairo new file mode 100644 index 000000000..ad3bc9e57 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim/output_0.cairo @@ -0,0 +1,232 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(3); + shape.append(3); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 4059800, sign: false }); + data.append(FP8x23 { mag: 4666044, sign: false }); + data.append(FP8x23 { mag: 2342084, sign: false }); + data.append(FP8x23 { mag: 2183769, sign: false }); + data.append(FP8x23 { mag: 3313164, sign: false }); + data.append(FP8x23 { mag: 3486310, sign: false }); + data.append(FP8x23 { mag: 1436353, sign: false }); + data.append(FP8x23 { mag: 2573392, sign: false }); + data.append(FP8x23 { mag: 2058164, sign: false }); + data.append(FP8x23 { mag: 3993329, sign: false }); + data.append(FP8x23 { mag: 2124389, sign: false }); + data.append(FP8x23 { mag: 2269589, sign: false }); + data.append(FP8x23 { mag: 1956847, sign: false }); + data.append(FP8x23 { mag: 3325826, sign: false }); + data.append(FP8x23 { mag: 2021516, sign: false }); + data.append(FP8x23 { mag: 2546162, sign: false }); + data.append(FP8x23 { mag: 4384494, sign: false }); + data.append(FP8x23 { mag: 3330917, sign: false }); + data.append(FP8x23 { mag: 5818544, sign: true }); + data.append(FP8x23 { mag: 4843202, sign: true }); + data.append(FP8x23 { mag: 6810527, sign: true }); + data.append(FP8x23 { mag: 5973667, sign: true }); + data.append(FP8x23 { mag: 7456307, sign: true }); + data.append(FP8x23 { mag: 9143239, sign: true }); + data.append(FP8x23 { mag: 10380351, sign: true }); + data.append(FP8x23 { mag: 5017153, sign: true }); + data.append(FP8x23 { mag: 10449049, sign: true }); + data.append(FP8x23 { mag: 6612456, sign: true }); + data.append(FP8x23 { mag: 10591866, sign: true }); + data.append(FP8x23 { mag: 6024288, sign: true }); + data.append(FP8x23 { mag: 8963902, sign: true }); + data.append(FP8x23 { mag: 12278058, sign: true }); + data.append(FP8x23 { mag: 5054453, sign: true }); + data.append(FP8x23 { mag: 7467644, sign: true }); + data.append(FP8x23 { mag: 4905742, sign: true }); + data.append(FP8x23 { mag: 9319662, sign: true }); + data.append(FP8x23 { mag: 6563249, sign: true }); + data.append(FP8x23 { mag: 10628917, sign: true }); + data.append(FP8x23 { mag: 10707646, sign: true }); + data.append(FP8x23 { mag: 11527499, sign: true }); + data.append(FP8x23 { mag: 8622187, sign: true }); + data.append(FP8x23 { mag: 9656700, sign: true }); + data.append(FP8x23 { mag: 7586128, sign: true }); + data.append(FP8x23 { mag: 10430587, sign: true }); + data.append(FP8x23 { mag: 8500595, sign: true }); + data.append(FP8x23 { mag: 9342570, sign: true }); + data.append(FP8x23 { mag: 9059095, sign: true }); + data.append(FP8x23 { mag: 9110969, sign: true }); + data.append(FP8x23 { mag: 9435603, sign: true }); + data.append(FP8x23 { mag: 7431731, sign: true }); + data.append(FP8x23 { mag: 11060438, sign: true }); + data.append(FP8x23 { mag: 7390383, sign: true }); + data.append(FP8x23 { mag: 6166276, sign: true }); + data.append(FP8x23 { mag: 11230811, sign: true }); + data.append(FP8x23 { mag: 2084191, sign: false }); + data.append(FP8x23 { mag: 2777191, sign: false }); + data.append(FP8x23 { mag: 4283298, sign: false }); + data.append(FP8x23 { mag: 1637313, sign: false }); + data.append(FP8x23 { mag: 2200600, sign: false }); + data.append(FP8x23 { mag: 1075454, sign: false }); + data.append(FP8x23 { mag: 3511549, sign: false }); + data.append(FP8x23 { mag: 3133710, sign: false }); + data.append(FP8x23 { mag: 3137437, sign: false }); + data.append(FP8x23 { mag: 3945678, sign: false }); + data.append(FP8x23 { mag: 4152968, sign: false }); + data.append(FP8x23 { mag: 2899120, sign: false }); + data.append(FP8x23 { mag: 3975549, sign: false }); + data.append(FP8x23 { mag: 3605293, sign: false }); + data.append(FP8x23 { mag: 1407558, sign: false }); + data.append(FP8x23 { mag: 2913046, sign: false }); + data.append(FP8x23 { mag: 2953995, sign: false }); + data.append(FP8x23 { mag: 2378199, sign: false }); + data.append(FP8x23 { mag: 5519061, sign: true }); + data.append(FP8x23 { mag: 9505985, sign: true }); + data.append(FP8x23 { mag: 5953065, sign: true }); + data.append(FP8x23 { mag: 10671552, sign: true }); + data.append(FP8x23 { mag: 9253238, sign: true }); + data.append(FP8x23 { mag: 8456070, sign: true }); + data.append(FP8x23 { mag: 8765994, sign: true }); + data.append(FP8x23 { mag: 10321987, sign: true }); + data.append(FP8x23 { mag: 4956334, sign: true }); + data.append(FP8x23 { mag: 9397565, sign: true }); + data.append(FP8x23 { mag: 5804390, sign: true }); + data.append(FP8x23 { mag: 7068711, sign: true }); + data.append(FP8x23 { mag: 8357470, sign: true }); + data.append(FP8x23 { mag: 2730661, sign: true }); + data.append(FP8x23 { mag: 11288302, sign: true }); + data.append(FP8x23 { mag: 6471215, sign: true }); + data.append(FP8x23 { mag: 5031987, sign: true }); + data.append(FP8x23 { mag: 7556525, sign: true }); + data.append(FP8x23 { mag: 12216328, sign: true }); + data.append(FP8x23 { mag: 9989912, sign: true }); + data.append(FP8x23 { mag: 8329009, sign: true }); + data.append(FP8x23 { mag: 6933996, sign: true }); + data.append(FP8x23 { mag: 7041329, sign: true }); + data.append(FP8x23 { mag: 10131720, sign: true }); + data.append(FP8x23 { mag: 9902094, sign: true }); + data.append(FP8x23 { mag: 7323838, sign: true }); + data.append(FP8x23 { mag: 8999526, sign: true }); + data.append(FP8x23 { mag: 10113658, sign: true }); + data.append(FP8x23 { mag: 9701154, sign: true }); + data.append(FP8x23 { mag: 10920619, sign: true }); + data.append(FP8x23 { mag: 7782087, sign: true }); + data.append(FP8x23 { mag: 8720786, sign: true }); + data.append(FP8x23 { mag: 8158800, sign: true }); + data.append(FP8x23 { mag: 10696608, sign: true }); + data.append(FP8x23 { mag: 10970576, sign: true }); + data.append(FP8x23 { mag: 6519342, sign: true }); + data.append(FP8x23 { mag: 2315982, sign: false }); + data.append(FP8x23 { mag: 2062538, sign: false }); + data.append(FP8x23 { mag: 1334015, sign: false }); + data.append(FP8x23 { mag: 3438188, sign: false }); + data.append(FP8x23 { mag: 3644397, sign: false }); + data.append(FP8x23 { mag: 2650537, sign: false }); + data.append(FP8x23 { mag: 2214009, sign: false }); + data.append(FP8x23 { mag: 3899397, sign: false }); + data.append(FP8x23 { mag: 1945128, sign: false }); + data.append(FP8x23 { mag: 4453021, sign: false }); + data.append(FP8x23 { mag: 4830447, sign: false }); + data.append(FP8x23 { mag: 2805907, sign: false }); + data.append(FP8x23 { mag: 2882212, sign: false }); + data.append(FP8x23 { mag: 4011197, sign: false }); + data.append(FP8x23 { mag: 2306130, sign: false }); + data.append(FP8x23 { mag: 2711281, sign: false }); + data.append(FP8x23 { mag: 2275369, sign: false }); + data.append(FP8x23 { mag: 2292394, sign: false }); + data.append(FP8x23 { mag: 5688841, sign: true }); + data.append(FP8x23 { mag: 6226057, sign: true }); + data.append(FP8x23 { mag: 9935715, sign: true }); + data.append(FP8x23 { mag: 6510777, sign: true }); + data.append(FP8x23 { mag: 9710788, sign: true }); + data.append(FP8x23 { mag: 3990077, sign: true }); + data.append(FP8x23 { mag: 9142271, sign: true }); + data.append(FP8x23 { mag: 7467268, sign: true }); + data.append(FP8x23 { mag: 4003245, sign: true }); + data.append(FP8x23 { mag: 4189441, sign: true }); + data.append(FP8x23 { mag: 9289647, sign: true }); + data.append(FP8x23 { mag: 9725400, sign: true }); + data.append(FP8x23 { mag: 6983333, sign: true }); + data.append(FP8x23 { mag: 6396089, sign: true }); + data.append(FP8x23 { mag: 10189960, sign: true }); + data.append(FP8x23 { mag: 11965866, sign: true }); + data.append(FP8x23 { mag: 8074573, sign: true }); + data.append(FP8x23 { mag: 7620764, sign: true }); + data.append(FP8x23 { mag: 7066176, sign: true }); + data.append(FP8x23 { mag: 9871921, sign: true }); + data.append(FP8x23 { mag: 8998642, sign: true }); + data.append(FP8x23 { mag: 8064301, sign: true }); + data.append(FP8x23 { mag: 9662329, sign: true }); + data.append(FP8x23 { mag: 8719657, sign: true }); + data.append(FP8x23 { mag: 9660693, sign: true }); + data.append(FP8x23 { mag: 7852658, sign: true }); + data.append(FP8x23 { mag: 10090598, sign: true }); + data.append(FP8x23 { mag: 7304836, sign: true }); + data.append(FP8x23 { mag: 8777550, sign: true }); + data.append(FP8x23 { mag: 10112702, sign: true }); + data.append(FP8x23 { mag: 11230464, sign: true }); + data.append(FP8x23 { mag: 12526101, sign: true }); + data.append(FP8x23 { mag: 8275460, sign: true }); + data.append(FP8x23 { mag: 7588845, sign: true }); + data.append(FP8x23 { mag: 6848514, sign: true }); + data.append(FP8x23 { mag: 11799936, sign: true }); + data.append(FP8x23 { mag: 4786406, sign: false }); + data.append(FP8x23 { mag: 4109428, sign: false }); + data.append(FP8x23 { mag: 3152226, sign: false }); + data.append(FP8x23 { mag: 3894764, sign: false }); + data.append(FP8x23 { mag: 3365903, sign: false }); + data.append(FP8x23 { mag: 3155598, sign: false }); + data.append(FP8x23 { mag: 1902133, sign: false }); + data.append(FP8x23 { mag: 2803955, sign: false }); + data.append(FP8x23 { mag: 2588914, sign: false }); + data.append(FP8x23 { mag: 2537436, sign: false }); + data.append(FP8x23 { mag: 1447406, sign: false }); + data.append(FP8x23 { mag: 2963705, sign: false }); + data.append(FP8x23 { mag: 691852, sign: false }); + data.append(FP8x23 { mag: 2984726, sign: false }); + data.append(FP8x23 { mag: 2218462, sign: false }); + data.append(FP8x23 { mag: 3035885, sign: false }); + data.append(FP8x23 { mag: 3072877, sign: false }); + data.append(FP8x23 { mag: 3360473, sign: false }); + data.append(FP8x23 { mag: 6557647, sign: true }); + data.append(FP8x23 { mag: 6518783, sign: true }); + data.append(FP8x23 { mag: 5280759, sign: true }); + data.append(FP8x23 { mag: 5558536, sign: true }); + data.append(FP8x23 { mag: 13107378, sign: true }); + data.append(FP8x23 { mag: 7050932, sign: true }); + data.append(FP8x23 { mag: 7708794, sign: true }); + data.append(FP8x23 { mag: 10351762, sign: true }); + data.append(FP8x23 { mag: 9174525, sign: true }); + data.append(FP8x23 { mag: 5737296, sign: true }); + data.append(FP8x23 { mag: 6926945, sign: true }); + data.append(FP8x23 { mag: 9546526, sign: true }); + data.append(FP8x23 { mag: 8811050, sign: true }); + data.append(FP8x23 { mag: 9765957, sign: true }); + data.append(FP8x23 { mag: 6063170, sign: true }); + data.append(FP8x23 { mag: 2877473, sign: true }); + data.append(FP8x23 { mag: 7580372, sign: true }); + data.append(FP8x23 { mag: 8492204, sign: true }); + data.append(FP8x23 { mag: 9567611, sign: true }); + data.append(FP8x23 { mag: 7875794, sign: true }); + data.append(FP8x23 { mag: 12879976, sign: true }); + data.append(FP8x23 { mag: 7845970, sign: true }); + data.append(FP8x23 { mag: 9686562, sign: true }); + data.append(FP8x23 { mag: 7960492, sign: true }); + data.append(FP8x23 { mag: 8870670, sign: true }); + data.append(FP8x23 { mag: 7885041, sign: true }); + data.append(FP8x23 { mag: 8348069, sign: true }); + data.append(FP8x23 { mag: 11074183, sign: true }); + data.append(FP8x23 { mag: 8661765, sign: true }); + data.append(FP8x23 { mag: 5989371, sign: true }); + data.append(FP8x23 { mag: 10726182, sign: true }); + data.append(FP8x23 { mag: 9259715, sign: true }); + data.append(FP8x23 { mag: 10336896, sign: true }); + data.append(FP8x23 { mag: 8057363, sign: true }); + data.append(FP8x23 { mag: 11120104, sign: true }); + data.append(FP8x23 { mag: 8305618, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels.cairo new file mode 100644 index 000000000..61101cfbc --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_highdim_batch_eq_channels() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_0.cairo new file mode 100644 index 000000000..b92f6b133 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_0.cairo @@ -0,0 +1,42 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(3); + shape.append(2); + shape.append(1); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 7649074, sign: true }); + data.append(FP8x23 { mag: 15131138, sign: true }); + data.append(FP8x23 { mag: 6851097, sign: false }); + data.append(FP8x23 { mag: 3652233, sign: true }); + data.append(FP8x23 { mag: 6761260, sign: false }); + data.append(FP8x23 { mag: 11060859, sign: true }); + data.append(FP8x23 { mag: 4130910, sign: false }); + data.append(FP8x23 { mag: 5583802, sign: true }); + data.append(FP8x23 { mag: 7717068, sign: true }); + data.append(FP8x23 { mag: 10798484, sign: true }); + data.append(FP8x23 { mag: 14302407, sign: false }); + data.append(FP8x23 { mag: 8104245, sign: true }); + data.append(FP8x23 { mag: 10993385, sign: false }); + data.append(FP8x23 { mag: 9869012, sign: true }); + data.append(FP8x23 { mag: 7247863, sign: true }); + data.append(FP8x23 { mag: 2273946, sign: false }); + data.append(FP8x23 { mag: 7044627, sign: true }); + data.append(FP8x23 { mag: 15165248, sign: false }); + data.append(FP8x23 { mag: 5982575, sign: false }); + data.append(FP8x23 { mag: 7138613, sign: true }); + data.append(FP8x23 { mag: 11200383, sign: false }); + data.append(FP8x23 { mag: 25522932, sign: false }); + data.append(FP8x23 { mag: 3612890, sign: false }); + data.append(FP8x23 { mag: 11607214, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_1.cairo new file mode 100644 index 000000000..f1654cfa0 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 261996, sign: false }); + data.append(FP8x23 { mag: 15609205, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_2.cairo new file mode 100644 index 000000000..38c94356e --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 5696205, sign: true }); + data.append(FP8x23 { mag: 13191362, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/output_0.cairo new file mode 100644 index 000000000..a77d0fc34 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_batch_eq_channels/output_0.cairo @@ -0,0 +1,42 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + shape.append(3); + shape.append(2); + shape.append(1); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 5810993, sign: true }); + data.append(FP8x23 { mag: 6045082, sign: true }); + data.append(FP8x23 { mag: 5357330, sign: true }); + data.append(FP8x23 { mag: 5685945, sign: true }); + data.append(FP8x23 { mag: 5360141, sign: true }); + data.append(FP8x23 { mag: 5917737, sign: true }); + data.append(FP8x23 { mag: 24609204, sign: false }); + data.append(FP8x23 { mag: 7347798, sign: false }); + data.append(FP8x23 { mag: 3557345, sign: false }); + data.append(FP8x23 { mag: 1917810, sign: true }); + data.append(FP8x23 { mag: 42682240, sign: false }); + data.append(FP8x23 { mag: 2869398, sign: false }); + data.append(FP8x23 { mag: 5415499, sign: true }); + data.append(FP8x23 { mag: 5985082, sign: true }); + data.append(FP8x23 { mag: 5913520, sign: true }); + data.append(FP8x23 { mag: 5653556, sign: true }); + data.append(FP8x23 { mag: 5907971, sign: true }); + data.append(FP8x23 { mag: 5301599, sign: true }); + data.append(FP8x23 { mag: 14974408, sign: false }); + data.append(FP8x23 { mag: 1892416, sign: true }); + data.append(FP8x23 { mag: 21681716, sign: false }); + data.append(FP8x23 { mag: 40092848, sign: false }); + data.append(FP8x23 { mag: 11928262, sign: false }); + data.append(FP8x23 { mag: 7636644, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_epsilon.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon.cairo new file mode 100644 index 000000000..7b4fb6bf1 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon.cairo @@ -0,0 +1,25 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FP8x23,FixedTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_highdim_epsilon() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::Some( FixedTrait::new(838860, false)) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_0.cairo new file mode 100644 index 000000000..7eaec3c6d --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(1); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 3059312, sign: false }); + data.append(FP8x23 { mag: 2240108, sign: true }); + data.append(FP8x23 { mag: 12671668, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_1.cairo new file mode 100644 index 000000000..e9d14120d --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_1.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 355102, sign: false }); + data.append(FP8x23 { mag: 3334275, sign: false }); + data.append(FP8x23 { mag: 2443930, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_2.cairo new file mode 100644 index 000000000..9cde4b5b8 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/input_2.cairo @@ -0,0 +1,15 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2876100, sign: true }); + data.append(FP8x23 { mag: 4082459, sign: true }); + data.append(FP8x23 { mag: 13939210, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/output_0.cairo new file mode 100644 index 000000000..9af88a44c --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_epsilon/output_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + shape.append(1); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2876100, sign: true }); + data.append(FP8x23 { mag: 4082459, sign: true }); + data.append(FP8x23 { mag: 13939210, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_single_batch.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch.cairo new file mode 100644 index 000000000..eb82c5080 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; + +#[test] +#[available_gas(2000000000)] +fn test_instance_normalization_fp8x23_highdim_single_batch() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.instance_normalization( @input_1 , @input_2 , Option::None(()) ); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_0.cairo new file mode 100644 index 000000000..e89b85d02 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(1); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 5761375, sign: true }); + data.append(FP8x23 { mag: 8171383, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_1.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_1.cairo new file mode 100644 index 000000000..18ddbd0a2 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_1.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 4681424, sign: true }); + data.append(FP8x23 { mag: 5202518, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_2.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_2.cairo new file mode 100644 index 000000000..9ec8c51af --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/input_2.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2648351, sign: false }); + data.append(FP8x23 { mag: 6107938, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/output_0.cairo b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/output_0.cairo new file mode 100644 index 000000000..366a5e786 --- /dev/null +++ b/tests/nodes/instance_normalization_fp8x23_highdim_single_batch/output_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::numbers::{FixedTrait, FP8x23}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(2); + shape.append(1); + shape.append(1); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 2648351, sign: false }); + data.append(FP8x23 { mag: 6107938, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} From 1ff001fc89cfebe31ff23b6e236561e8d35b47de Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 1 Apr 2024 20:08:38 +0100 Subject: [PATCH 6/9] adding instance norm demo guide --- .../tensor/tensor.instance_normalization.md | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 docs/framework/operators/tensor/tensor.instance_normalization.md diff --git a/docs/framework/operators/tensor/tensor.instance_normalization.md b/docs/framework/operators/tensor/tensor.instance_normalization.md new file mode 100644 index 000000000..d67efce02 --- /dev/null +++ b/docs/framework/operators/tensor/tensor.instance_normalization.md @@ -0,0 +1,107 @@ +# tensor.instance_normalization + +```rust + fn instance_normalization( + self: @Tensor, + scale: @Tensor, + bias: @Tensor, + epsilon: Option, +) -> Tensor; +``` + +Computes instance normalization on the input tensor. + +The overall computation has two stages: +1. The first stage normalizes the elements to have zero mean and unit variance for each instance. +2. The second stage scales and shifts the results of the first stage using the provided scale and bias tensors. + +## Args + +* `self` (`@Tensor`) - The input tensor with dimensions `(N x C x D1 x D2 ... Dn)`, where `N` is the batch size, + `C` is the number of channels, and `D1`, `D2`, ..., `Dn` are the remaining dimensions. +* `scale` (`@Tensor`) - Scale tensor of shape `(C)`. +* `bias` (`Option<@Tensor>`) - Bias tensor of shape `(C)`. If `None`, no bias is applied. +* `epsilon` (`Option`) (default is 1e-5) - The epsilon value to use to avoid division by zero. + +## Panics + +* Panics if the scale tensor's shape is not `(C)`. +* Panics if the bias tensor is provided and its shape is not `(C)`. + +## Returns + +A new tensor `Tensor` with the same shape as the input tensor, after applying instance normalization. + +## Example + +```rust +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::{FixedTrait, FP16x16}; + +fn instance_normalization_example() -> Tensor { + + let epsilon = Option::Some( FixedTrait::new(6554, false)); + + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + shape.append(2); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 24149, sign: false }); + data.append(FP16x16 { mag: 35894, sign: false }); + data.append(FP16x16 { mag: 38633, sign: true }); + data.append(FP16x16 { mag: 37793, sign: true }); + data.append(FP16x16 { mag: 23838, sign: false }); + data.append(FP16x16 { mag: 5937, sign: false }); + data.append(FP16x16 { mag: 13047, sign: true }); + data.append(FP16x16 { mag: 55527, sign: false }); + data.append(FP16x16 { mag: 97165, sign: true }); + data.append(FP16x16 { mag: 77657, sign: false }); + data.append(FP16x16 { mag: 7142, sign: false }); + data.append(FP16x16 { mag: 96338, sign: false }); + data.append(FP16x16 { mag: 24716, sign: true }); + let X = TensorTrait::new(shape.span(), data.span()); + + let mut shape = ArrayTrait::::new(); + shape.append(3); + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 41865, sign: true }); + data.append(FP16x16 { mag: 81535, sign: false }); + data.append(FP16x16 { mag: 81322, sign: true }); + let scale = TensorTrait::new(shape.span(), data.span()); + + let mut shape = ArrayTrait::::new(); + shape.append(3); + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 11243, sign: true }); + data.append(FP16x16 { mag: 122125, sign: false }); + data.append(FP16x16 { mag: 97543, sign: false }); + let bias = TensorTrait::new(shape.span(), data.span()); + + + return X.instance_normalization(@scale,@bias, epsilon); +} +>>> + [[[[-0.72982788], + [ 0.38671875]], + + [[ 0.83106995], + [ 2.89585876]], + + [[ 0.97167969], + [ 2.00509644]]], + + [[[-0.78804016], + [ 0.44493103]], + + [[ 2.93608093], + [ 0.79092407]], + + [[ 0.31443787], + [ 2.66233826]]]] +``` From ad362e1171dcc1ebdc376694fd52fe5042fba3cf Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 1 Apr 2024 20:12:45 +0100 Subject: [PATCH 7/9] adding instance norm to summary.md file --- docs/SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 477601b37..743d7c9f3 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -147,6 +147,7 @@ * [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.instance_normalization](framework/operators/tensor/tensor.instance_normalization.md) * [tensor.layer_normalization](framework/operators/tensor/tensor.layer_normalization.md) * [tensor.scatter\_nd](framework/operators/tensor/tensor.scatter\_nd.md) * [tensor.dynamic_quantize_linear](framework/operators/tensor/tensor.dequantize_linear.md) From a00710e680320a8bf4474dd5f77ed4b760fe3612 Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 1 Apr 2024 20:18:17 +0100 Subject: [PATCH 8/9] typo fixes --- nodegen/node/instance_normalization.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nodegen/node/instance_normalization.py b/nodegen/node/instance_normalization.py index ecb3568ea..1a1a757fd 100644 --- a/nodegen/node/instance_normalization.py +++ b/nodegen/node/instance_normalization.py @@ -4,14 +4,14 @@ def _instancenorm_test_mode(x, s, bias, epsilon=1e-5): # type: ignore - dims_x = len(x.shape) - axis = tuple(range(2, dims_x)) - mean = np.mean(x, axis=axis, keepdims=True) - var = np.var(x, axis=axis, keepdims=True) - dim_ones = (1,) * (dims_x - 2) - s = s.reshape(-1, *dim_ones) - bias = bias.reshape(-1, *dim_ones) - return s * (x - mean) / np.sqrt(var + epsilon) + bias + dims_x = len(x.shape) + axis = tuple(range(2, dims_x)) + mean = np.mean(x, axis=axis, keepdims=True) + var = np.var(x, axis=axis, keepdims=True) + dim_ones = (1,) * (dims_x - 2) + s = s.reshape(-1, *dim_ones) + bias = bias.reshape(-1, *dim_ones) + return s * (x - mean) / np.sqrt(var + epsilon) + bias class Instance_normalization(RunAll): @staticmethod From 6419bf1e885a9225524c91d08a8e39bb4723b537 Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 1 Apr 2024 20:27:44 +0100 Subject: [PATCH 9/9] fixing documentation typo --- .../operators/tensor/tensor.instance_normalization.md | 5 ++--- src/operators/tensor/core.cairo | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/framework/operators/tensor/tensor.instance_normalization.md b/docs/framework/operators/tensor/tensor.instance_normalization.md index d67efce02..da37e4877 100644 --- a/docs/framework/operators/tensor/tensor.instance_normalization.md +++ b/docs/framework/operators/tensor/tensor.instance_normalization.md @@ -9,7 +9,7 @@ ) -> Tensor; ``` -Computes instance normalization on the input tensor. +Computes instance normalization on a given input tensor. The overall computation has two stages: 1. The first stage normalizes the elements to have zero mean and unit variance for each instance. @@ -21,7 +21,7 @@ The overall computation has two stages: `C` is the number of channels, and `D1`, `D2`, ..., `Dn` are the remaining dimensions. * `scale` (`@Tensor`) - Scale tensor of shape `(C)`. * `bias` (`Option<@Tensor>`) - Bias tensor of shape `(C)`. If `None`, no bias is applied. -* `epsilon` (`Option`) (default is 1e-5) - The epsilon value to use to avoid division by zero. +* `epsilon` (`Option`) (default is zero) - The epsilon value to use to avoid division by zero. ## Panics @@ -83,7 +83,6 @@ fn instance_normalization_example() -> Tensor { data.append(FP16x16 { mag: 97543, sign: false }); let bias = TensorTrait::new(shape.span(), data.span()); - return X.instance_normalization(@scale,@bias, epsilon); } >>> diff --git a/src/operators/tensor/core.cairo b/src/operators/tensor/core.cairo index ad32c2d41..e47707e30 100644 --- a/src/operators/tensor/core.cairo +++ b/src/operators/tensor/core.cairo @@ -5107,7 +5107,7 @@ trait TensorTrait { /// ) -> Tensor; /// ``` /// - /// Computes instance normalization on the input tensor. + /// Computes instance normalization on a given input tensor. /// /// The overall computation has two stages: /// 1. The first stage normalizes the elements to have zero mean and unit variance for each instance. @@ -5119,7 +5119,7 @@ trait TensorTrait { /// `C` is the number of channels, and `D1`, `D2`, ..., `Dn` are the remaining dimensions. /// * `scale` (`@Tensor`) - Scale tensor of shape `(C)`. /// * `bias` (`Option<@Tensor>`) - Bias tensor of shape `(C)`. If `None`, no bias is applied. - /// * `epsilon` (`Option`) (default is 1e-5) - The epsilon value to use to avoid division by zero. + /// * `epsilon` (`Option`) (default is zero) - The epsilon value to use to avoid division by zero. /// /// ## Panics /// @@ -5181,7 +5181,6 @@ trait TensorTrait { /// data.append(FP16x16 { mag: 97543, sign: false }); /// let bias = TensorTrait::new(shape.span(), data.span()); /// - /// /// return X.instance_normalization(@scale,@bias, epsilon); /// } /// >>>