From 8adc0dd095a4adc4dcff1ff6b7502048c0f37ef2 Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 30 Dec 2024 04:50:32 +0000 Subject: [PATCH 1/5] adding matmul of 3d tensors --- src/operators/tensor/linalg/matmul.cairo | 138 +++++++++++++++++++++-- 1 file changed, 129 insertions(+), 9 deletions(-) diff --git a/src/operators/tensor/linalg/matmul.cairo b/src/operators/tensor/linalg/matmul.cairo index fd604fe42..c27e20a51 100644 --- a/src/operators/tensor/linalg/matmul.cairo +++ b/src/operators/tensor/linalg/matmul.cairo @@ -1,5 +1,6 @@ use orion::numbers::NumberTrait; use orion::operators::tensor::core::{Tensor, TensorTrait}; +use core::debug::PrintTrait; /// Cf: TensorTrait::matmul docstring fn matmul< @@ -19,7 +20,7 @@ fn matmul< let self_ndim = (self_shape).len(); let other_ndim = (other_shape).len(); - assert(self_ndim <= 2 || other_ndim <= 2, 'supports only 1D and 2D matmul'); + assert(self_ndim <= 3 || other_ndim <= 3, 'supports only 1D and 2D matmul'); //! Case: Both tensors are 1-dimensional if self_ndim == 1 && other_ndim == 1 { @@ -27,20 +28,33 @@ fn matmul< let mut result_shape = ArrayTrait::new(); let mut result_data = ArrayTrait::new(); result_shape.append(1); - result_data.append(dot); + result_data.append(dot); return TensorTrait::new(result_shape.span(), result_data.span()); - } + }; - let self_shape = prepare_shape_for_matmul(self_shape, true); - let other_shape = prepare_shape_for_matmul(other_shape, false); + //! Case: if one tensors is 2-dimensional + if (self_ndim == 2 && other_ndim <= 2) || (self_ndim <= 2 && other_ndim == 2) { + let self_shape = prepare_shape_for_matmul(self_shape, true); + let other_shape = prepare_shape_for_matmul(other_shape, false); - let result = matrix_multiply(*self.data, self_shape, *other.data, other_shape); + let result = matrix_multiply(*self.data, self_shape, *other.data, other_shape); - let result_shape = adjust_output_shape_after_matmul(result.shape, self_ndim, other_ndim); + let result_shape = adjust_output_shape_after_matmul(result.shape, self_ndim, other_ndim); + + return TensorTrait::new(result_shape, result.data); + }; + + //! Case: Both tensors are 3-dimensional + let self_shape = prepare_shape_for_matmul_3d(self_shape); + let other_shape = prepare_shape_for_matmul_3d(other_shape); + + let result = matrix_multiply_3d(*self.data, self_shape, *other.data, other_shape); + + return result; + + } - TensorTrait::new(result_shape, result.data) -} /// Computes the dot product of two 1-dimensional i32 tensors. /// @@ -140,6 +154,69 @@ fn matrix_multiply< TensorTrait::new(result_shape.span(), result_data.span()) } +/// Computes the matrix multiplication of two 3-dimensional tensors. +/// +/// # Arguments +/// * `mat1` - A Span containing the data elements of the first 3D tensor. +/// * `mat1_shape` - A Span containing the shape of the first 3D tensor as usize elements. +/// * `mat2` - A Span containing the data elements of the second 3D tensor. +/// * `mat2_shape` - A Span containing the shape of the second 3D tensor as usize elements. +/// +/// # Panics +/// * Panics if the inner dimensions of the tensors do not match. +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * Returns the resulting tensor after 3D matrix multiplication. +fn matrix_multiply_3d< + T, + MAG, + impl TTensor: TensorTrait, + impl TNumber: NumberTrait, + impl TMul: Mul, + impl TAddEq: AddEq, + impl TCopy: Copy, + impl TDrop: Drop +>( + mat1: Span, mat1_shape: Span, mat2: Span, mat2_shape: Span +) -> Tensor { + + let l = *mat1_shape[0]; + let m = *mat1_shape[1]; + let n = *mat1_shape[2]; + let p = *mat2_shape[1]; + let q = *mat2_shape[2]; + + assert(n == p , 'shape incompatible'); + + let mut result_data: Array = array![]; + let mut result_shape: Array = array![l, m, q]; + + let mut l_idx = 0_usize; + while l_idx != l { + let mut i = 0_usize; + while i != m { + let mut j = 0_usize; + while j != q { + let mut sum: T = NumberTrait::zero(); + let mut k = 0_usize; + while k != n { + let mat1_index = l_idx * m * n + i * n + k; + let mat2_index = k * p + j; + sum += *mat1[mat1_index] * *mat2[mat2_index]; + k += 1; + }; + result_data.append(sum); + j += 1; + }; + i += 1; + }; + l_idx += 1; + }; + + TensorTrait::new(result_shape.span(), result_data.span()) +} + /// Prepares the shape of a tensor for matrix multiplication. /// /// # Arguments @@ -192,6 +269,49 @@ fn prepare_shape_for_matmul(mut shape: Span, is_first_tensor: bool) -> Sp shape } +/// Prepares the shape of a tensor for 3D matrix multiplication. +/// +/// # Arguments +/// * `shape` - A mutable span representing the shape of the tensor. +/// +/// # Behavior +/// This function adjusts the shapes of the tensors based on their dimensionality: +/// * If the tensor is 1-dimensional or 2-dimensional, it prepends 1s to the shape to make it 3-dimensional. +/// * If the tensor is already 3-dimensional, it returns the shape unchanged. +/// +/// # Panics +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * A span representing the adjusted shape of the tensor, ensuring it is 3-dimensional. +fn prepare_shape_for_matmul_3d(mut shape: Span) -> Span { + let ndim = shape.len(); + let diff = 3 - ndim; + + let mut shape_adjusted = ArrayTrait::new(); + + if ndim == 2 || ndim==1 { + // Prepend 1 to shape if it's 1-dimensional + let mut i = 0; + while i != diff { + shape_adjusted.append( 1); + i+=1 + }; + + loop { + match shape.pop_front() { + Option::Some(item) => { shape_adjusted.append(*item); }, + Option::None => { break; } + }; + }; + + return shape_adjusted.span(); +}; + +shape + +} + /// Adjusts the output shape of the matrix multiplication result based on the /// original dimensionality of the input tensors. /// From d363d353dc8f2c95baea9caa2e0bd1d411b8259f Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 30 Dec 2024 04:54:41 +0000 Subject: [PATCH 2/5] adding updated 3d matmul to core --- src/operators/tensor/core.cairo | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/operators/tensor/core.cairo b/src/operators/tensor/core.cairo index 02f9cc6e4..e76d444b6 100644 --- a/src/operators/tensor/core.cairo +++ b/src/operators/tensor/core.cairo @@ -938,7 +938,28 @@ trait TensorTrait { /// } /// >>> [5,14,23] /// ``` - /// + /// ``` + /// + /// Case 4: Matrix multiplication (3D \* 2D) + /// + /// ```rust + /// use core::array::{ArrayTrait, SpanTrait}; + /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; + /// + /// fn matrix_mul_example() -> Tensor { + /// let tensor_1 = TensorTrait::::new( + /// shape: array![3, 2].span(), data: array![243, 185, 207, 31, 183, 250].span() + /// ); + /// + /// let tensor_2 = TensorTrait::::new( + /// shape: array![2, 3].span(), data: array![143, 215, 214, 80, 174, 21 ].span() + /// ); + /// + /// // We can call `matmul` function as follows. + /// return tensor_1.matmul(@tensor_2); + /// } + /// >>> [[49549, 84435, 55887],[32081, 49899, 44949], [46169, 82845, 44412]] fn matmul(self: @Tensor, other: @Tensor) -> Tensor; /// # tensor.exp /// From 460cac1e25634d60088a036e88a76a3d11b9cb3f Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 30 Dec 2024 04:56:46 +0000 Subject: [PATCH 3/5] adding the updated 3d matmul testcases --- nodegen/node/matmul.py | 387 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) diff --git a/nodegen/node/matmul.py b/nodegen/node/matmul.py index 575c36933..be9636888 100644 --- a/nodegen/node/matmul.py +++ b/nodegen/node/matmul.py @@ -58,11 +58,82 @@ def matmul_1x2(): name = "matmul_u32_1x2" make_test( [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x3(): + a = np.random.randint(0, 255, (3, 3)).astype(np.uint32) + b = np.random.randint(0, 255, (3, 3)).astype(np.uint32) + y = np.matmul(a, b) + + a = Tensor(Dtype.U32, a.shape, a.flatten()) + b = Tensor(Dtype.U32, b.shape, b.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "matmul_u32_3x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + + def matmul_3x1(): + a = np.random.randint(0, 255, (3, 1)).astype(np.uint32) + b = np.random.randint(0, 255, (1, 3)).astype(np.uint32) + y = np.matmul(a, b) + + a = Tensor(Dtype.U32, a.shape, a.flatten()) + b = Tensor(Dtype.U32, b.shape, b.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "matmul_u32_3x1" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_1x3(): + a = np.random.randint(0, 255, (1, 3)).astype(np.uint32) + b = np.random.randint(0, 255, (3, 1)).astype(np.uint32) + y = np.matmul(a, b) + + a = Tensor(Dtype.U32, a.shape, a.flatten()) + b = Tensor(Dtype.U32, b.shape, b.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "matmul_u32_1x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_2x3(): + a = np.random.randint(0, 255, (2, 3)).astype(np.uint32) + b = np.random.randint(0, 255, (3, 2)).astype(np.uint32) + y = np.matmul(a, b) + + a = Tensor(Dtype.U32, a.shape, a.flatten()) + b = Tensor(Dtype.U32, b.shape, b.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "matmul_u32_2x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x2(): + a = np.random.randint(0, 255, (3, 2)).astype(np.uint32) + b = np.random.randint(0, 255, (2, 3)).astype(np.uint32) + y = np.matmul(a, b) + + a = Tensor(Dtype.U32, a.shape, a.flatten()) + b = Tensor(Dtype.U32, b.shape, b.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "matmul_u32_3x2" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) matmul_1D() matmul_2x2() matmul_2x1() matmul_1x2() + matmul_3x3() + matmul_3x1() + matmul_1x3() + matmul_2x3() + matmul_3x2() @staticmethod def matmul_i32(): @@ -117,11 +188,82 @@ def matmul_1x2(): name = "matmul_i32_1x2" make_test( [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_1x3(): + a = np.random.randint(-127, 127, (1, 3)).astype(np.int32) + b = np.random.randint(-127, 127, (3, 1)).astype(np.int32) + y = np.matmul(a, b) + + a = Tensor(Dtype.I32, a.shape, a.flatten()) + b = Tensor(Dtype.I32, b.shape, b.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "matmul_i32_1x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x1(): + a = np.random.randint(-127, 127, (3, 1)).astype(np.int32) + b = np.random.randint(-127, 127, (1, 3)).astype(np.int32) + y = np.matmul(a, b) + + a = Tensor(Dtype.I32, a.shape, a.flatten()) + b = Tensor(Dtype.I32, b.shape, b.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "matmul_i32_3x1" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_2x3(): + a = np.random.randint(-127, 127, (2, 3)).astype(np.int32) + b = np.random.randint(-127, 127, (3, 2)).astype(np.int32) + y = np.matmul(a, b) + + a = Tensor(Dtype.I32, a.shape, a.flatten()) + b = Tensor(Dtype.I32, b.shape, b.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "matmul_i32_2x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x2(): + a = np.random.randint(-127, 127, (3, 2)).astype(np.int32) + b = np.random.randint(-127, 127, (2, 3)).astype(np.int32) + y = np.matmul(a, b) + + a = Tensor(Dtype.I32, a.shape, a.flatten()) + b = Tensor(Dtype.I32, b.shape, b.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "matmul_i32_3x2" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x3(): + a = np.random.randint(-127, 127, (3, 3)).astype(np.int32) + b = np.random.randint(-127, 127, (3, 3)).astype(np.int32) + y = np.matmul(a, b) + + a = Tensor(Dtype.I32, a.shape, a.flatten()) + b = Tensor(Dtype.I32, b.shape, b.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "matmul_i32_3x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) matmul_1D() matmul_2x2() matmul_2x1() matmul_1x2() + matmul_3x3() + matmul_3x1() + matmul_1x3() + matmul_2x3() + matmul_3x2() + @staticmethod def matmul_i8(): @@ -176,11 +318,82 @@ def matmul_1x2(): name = "matmul_i8_1x2" make_test( [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_1x3(): + a = np.random.randint(-4, 5, (1, 3)).astype(np.int8) + b = np.random.randint(-4, 5, (3, 1)).astype(np.int8) + y = np.matmul(a, b) + + a = Tensor(Dtype.I8, a.shape, a.flatten()) + b = Tensor(Dtype.I8, b.shape, b.flatten()) + y = Tensor(Dtype.I8, y.shape, y.flatten()) + + name = "matmul_i8_1x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x1(): + a = np.random.randint(-4, 5, (3, 1)).astype(np.int8) + b = np.random.randint(-4, 5, (1, 3)).astype(np.int8) + y = np.matmul(a, b) + + a = Tensor(Dtype.I8, a.shape, a.flatten()) + b = Tensor(Dtype.I8, b.shape, b.flatten()) + y = Tensor(Dtype.I8, y.shape, y.flatten()) + + name = "matmul_i8_3x1" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x2(): + a = np.random.randint(-4, 5, (3, 2)).astype(np.int8) + b = np.random.randint(-4, 5, (2, 3)).astype(np.int8) + y = np.matmul(a, b) + + a = Tensor(Dtype.I8, a.shape, a.flatten()) + b = Tensor(Dtype.I8, b.shape, b.flatten()) + y = Tensor(Dtype.I8, y.shape, y.flatten()) + + name = "matmul_i8_3x2" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_2x3(): + a = np.random.randint(-4, 5, (2, 3)).astype(np.int8) + b = np.random.randint(-4, 5, (3, 2)).astype(np.int8) + y = np.matmul(a, b) + + a = Tensor(Dtype.I8, a.shape, a.flatten()) + b = Tensor(Dtype.I8, b.shape, b.flatten()) + y = Tensor(Dtype.I8, y.shape, y.flatten()) + + name = "matmul_i8_2x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x3(): + a = np.random.randint(-4, 5, (3, 3)).astype(np.int8) + b = np.random.randint(-4, 5, (3, 3)).astype(np.int8) + y = np.matmul(a, b) + + a = Tensor(Dtype.I8, a.shape, a.flatten()) + b = Tensor(Dtype.I8, b.shape, b.flatten()) + y = Tensor(Dtype.I8, y.shape, y.flatten()) + + name = "matmul_i8_3x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + matmul_1D() matmul_2x2() matmul_2x1() matmul_1x2() + matmul_3x3() + matmul_3x1() + matmul_1x3() + matmul_2x3() + matmul_3x2() @staticmethod def matmul_fp8x23(): @@ -247,11 +460,97 @@ def matmul_1x2(): name = "matmul_fp8x23_1x2" make_test( [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_1x3(): + a = np.random.randint(-3, 4, (1, 3)).astype(np.int64) + b = np.random.randint(-3, 4, (3, 1)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP8x23, a.shape, to_fp( + a.flatten(), FixedImpl.FP8x23)) + b = Tensor(Dtype.FP8x23, b.shape, to_fp( + b.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "matmul_fp8x23_1x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x1(): + a = np.random.randint(-3, 4, (3, 1)).astype(np.int64) + b = np.random.randint(-3, 4, (1, 3)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP8x23, a.shape, to_fp( + a.flatten(), FixedImpl.FP8x23)) + b = Tensor(Dtype.FP8x23, b.shape, to_fp( + b.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "matmul_fp8x23_3x1" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x2(): + a = np.random.randint(-3, 4, (3, 2)).astype(np.int64) + b = np.random.randint(-3, 4, (2, 3)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP8x23, a.shape, to_fp( + a.flatten(), FixedImpl.FP8x23)) + b = Tensor(Dtype.FP8x23, b.shape, to_fp( + b.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "matmul_fp8x23_3x2" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + + def matmul_2x3(): + a = np.random.randint(-3, 4, (2, 3)).astype(np.int64) + b = np.random.randint(-3, 4, (3, 2)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP8x23, a.shape, to_fp( + a.flatten(), FixedImpl.FP8x23)) + b = Tensor(Dtype.FP8x23, b.shape, to_fp( + b.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "matmul_fp8x23_2x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x3(): + a = np.random.randint(-3, 4, (3, 3)).astype(np.int64) + b = np.random.randint(-3, 4, (3, 3)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP8x23, a.shape, to_fp( + a.flatten(), FixedImpl.FP8x23)) + b = Tensor(Dtype.FP8x23, b.shape, to_fp( + b.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "matmul_fp8x23_3x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) matmul_1D() matmul_2x2() matmul_2x1() matmul_1x2() + matmul_3x3() + matmul_3x1() + matmul_1x3() + matmul_2x3() + matmul_3x2() @staticmethod def matmul_fp16x16(): @@ -318,8 +617,96 @@ def matmul_1x2(): name = "matmul_fp16x16_1x2" make_test( [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_1x3(): + a = np.random.randint(-3, 4, (1, 3)).astype(np.int64) + b = np.random.randint(-3, 4, (3, 1)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP16x16, a.shape, to_fp( + a.flatten(), FixedImpl.FP16x16)) + b = Tensor(Dtype.FP16x16, b.shape, to_fp( + b.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "matmul_fp16x16_1x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + + def matmul_3x1(): + a = np.random.randint(-3, 4, (3, 1)).astype(np.int64) + b = np.random.randint(-3, 4, (1, 3)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP16x16, a.shape, to_fp( + a.flatten(), FixedImpl.FP16x16)) + b = Tensor(Dtype.FP16x16, b.shape, to_fp( + b.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "matmul_fp16x16_3x1" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + + def matmul_3x2(): + a = np.random.randint(-3, 4, (3, 2)).astype(np.int64) + b = np.random.randint(-3, 4, (2, 3)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP16x16, a.shape, to_fp( + a.flatten(), FixedImpl.FP16x16)) + b = Tensor(Dtype.FP16x16, b.shape, to_fp( + b.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "matmul_fp16x16_3x2" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_2x3(): + a = np.random.randint(-3, 4, (2, 3)).astype(np.int64) + b = np.random.randint(-3, 4, (3, 2)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP16x16, a.shape, to_fp( + a.flatten(), FixedImpl.FP16x16)) + b = Tensor(Dtype.FP16x16, b.shape, to_fp( + b.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "matmul_fp16x16_2x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) + + def matmul_3x3(): + a = np.random.randint(-3, 4, (3, 3)).astype(np.int64) + b = np.random.randint(-3, 4, (3, 3)).astype(np.int64) + y = np.matmul(a, b) + + a = Tensor(Dtype.FP16x16, a.shape, to_fp( + a.flatten(), FixedImpl.FP16x16)) + b = Tensor(Dtype.FP16x16, b.shape, to_fp( + b.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "matmul_fp16x16_3x3" + make_test( + [a, b], y, "input_0.matmul(@input_1)", name) matmul_1D() matmul_2x2() matmul_2x1() matmul_1x2() + matmul_3x3() + matmul_3x1() + matmul_1x3() + matmul_2x3() + matmul_3x2() + From 80b4269e2954af04947e93463e93d5d1c2ade757 Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 30 Dec 2024 20:07:19 +0000 Subject: [PATCH 4/5] adding the 3d matmul generated testcases --- tests/nodes.cairo | 25 +++++++++++++++++++ tests/nodes/matmul_fp16x16_1d.cairo | 12 ++++----- tests/nodes/matmul_fp16x16_1d/input_0.cairo | 8 +++--- tests/nodes/matmul_fp16x16_1d/input_1.cairo | 6 ++--- tests/nodes/matmul_fp16x16_1d/output_0.cairo | 4 +-- tests/nodes/matmul_fp16x16_1x2.cairo | 12 ++++----- tests/nodes/matmul_fp16x16_1x2/input_0.cairo | 4 +-- tests/nodes/matmul_fp16x16_1x2/input_1.cairo | 6 ++--- tests/nodes/matmul_fp16x16_1x2/output_0.cairo | 4 +-- tests/nodes/matmul_fp16x16_1x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_1x3/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_fp16x16_1x3/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_fp16x16_1x3/output_0.cairo | 14 +++++++++++ tests/nodes/matmul_fp16x16_2x1.cairo | 12 ++++----- tests/nodes/matmul_fp16x16_2x1/input_0.cairo | 6 ++--- tests/nodes/matmul_fp16x16_2x1/input_1.cairo | 6 ++--- tests/nodes/matmul_fp16x16_2x1/output_0.cairo | 6 ++--- tests/nodes/matmul_fp16x16_2x2.cairo | 12 ++++----- tests/nodes/matmul_fp16x16_2x2/input_0.cairo | 6 ++--- tests/nodes/matmul_fp16x16_2x2/input_1.cairo | 8 +++--- tests/nodes/matmul_fp16x16_2x2/output_0.cairo | 10 ++++---- tests/nodes/matmul_fp16x16_2x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_2x3/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp16x16_2x3/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp16x16_2x3/output_0.cairo | 17 +++++++++++++ tests/nodes/matmul_fp16x16_3x1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_3x1/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_fp16x16_3x1/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_fp16x16_3x1/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_3x2.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_3x2/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp16x16_3x2/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp16x16_3x2/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_3x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_3x3/input_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_3x3/input_1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp16x16_3x3/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_1d.cairo | 10 ++++---- tests/nodes/matmul_fp8x23_1d/input_0.cairo | 6 ++--- tests/nodes/matmul_fp8x23_1d/input_1.cairo | 8 +++--- tests/nodes/matmul_fp8x23_1d/output_0.cairo | 4 +-- tests/nodes/matmul_fp8x23_1x2.cairo | 10 ++++---- tests/nodes/matmul_fp8x23_1x2/input_0.cairo | 6 ++--- tests/nodes/matmul_fp8x23_1x2/input_1.cairo | 4 +-- tests/nodes/matmul_fp8x23_1x2/output_0.cairo | 4 +-- tests/nodes/matmul_fp8x23_1x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_1x3/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_fp8x23_1x3/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_fp8x23_1x3/output_0.cairo | 14 +++++++++++ tests/nodes/matmul_fp8x23_2x1.cairo | 10 ++++---- tests/nodes/matmul_fp8x23_2x1/input_0.cairo | 6 ++--- tests/nodes/matmul_fp8x23_2x1/input_1.cairo | 6 ++--- tests/nodes/matmul_fp8x23_2x1/output_0.cairo | 8 +++--- tests/nodes/matmul_fp8x23_2x2.cairo | 10 ++++---- tests/nodes/matmul_fp8x23_2x2/input_0.cairo | 8 +++--- tests/nodes/matmul_fp8x23_2x2/input_1.cairo | 6 ++--- tests/nodes/matmul_fp8x23_2x2/output_0.cairo | 10 ++++---- tests/nodes/matmul_fp8x23_2x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_2x3/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp8x23_2x3/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp8x23_2x3/output_0.cairo | 17 +++++++++++++ tests/nodes/matmul_fp8x23_3x1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_3x1/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_fp8x23_3x1/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_fp8x23_3x1/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_3x2.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_3x2/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp8x23_3x2/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_fp8x23_3x2/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_3x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_3x3/input_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_3x3/input_1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_fp8x23_3x3/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_1d.cairo | 10 ++++---- tests/nodes/matmul_i32_1d/input_0.cairo | 9 ++++--- tests/nodes/matmul_i32_1d/input_1.cairo | 9 ++++--- tests/nodes/matmul_i32_1d/output_0.cairo | 5 ++-- tests/nodes/matmul_i32_1x2.cairo | 10 ++++---- tests/nodes/matmul_i32_1x2/input_0.cairo | 7 +++--- tests/nodes/matmul_i32_1x2/input_1.cairo | 7 +++--- tests/nodes/matmul_i32_1x2/output_0.cairo | 5 ++-- tests/nodes/matmul_i32_1x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_1x3/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_i32_1x3/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_i32_1x3/output_0.cairo | 14 +++++++++++ tests/nodes/matmul_i32_2x1.cairo | 10 ++++---- tests/nodes/matmul_i32_2x1/input_0.cairo | 7 +++--- tests/nodes/matmul_i32_2x1/input_1.cairo | 7 +++--- tests/nodes/matmul_i32_2x1/output_0.cairo | 11 ++++---- tests/nodes/matmul_i32_2x2.cairo | 10 ++++---- tests/nodes/matmul_i32_2x2/input_0.cairo | 11 ++++---- tests/nodes/matmul_i32_2x2/input_1.cairo | 11 ++++---- tests/nodes/matmul_i32_2x2/output_0.cairo | 11 ++++---- tests/nodes/matmul_i32_2x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_2x3/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_i32_2x3/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_i32_2x3/output_0.cairo | 17 +++++++++++++ tests/nodes/matmul_i32_3x1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_3x1/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_i32_3x1/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_i32_3x1/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_3x2.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_3x2/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_i32_3x2/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_i32_3x2/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_3x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_3x3/input_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_3x3/input_1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i32_3x3/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_1d.cairo | 12 ++++----- tests/nodes/matmul_i8_1d/input_0.cairo | 7 +++--- tests/nodes/matmul_i8_1d/input_1.cairo | 9 ++++--- tests/nodes/matmul_i8_1d/output_0.cairo | 5 ++-- tests/nodes/matmul_i8_1x2.cairo | 12 ++++----- tests/nodes/matmul_i8_1x2/input_0.cairo | 5 ++-- tests/nodes/matmul_i8_1x2/input_1.cairo | 7 +++--- tests/nodes/matmul_i8_1x2/output_0.cairo | 5 ++-- tests/nodes/matmul_i8_1x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_1x3/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_i8_1x3/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_i8_1x3/output_0.cairo | 14 +++++++++++ tests/nodes/matmul_i8_2x1.cairo | 12 ++++----- tests/nodes/matmul_i8_2x1/input_0.cairo | 5 ++-- tests/nodes/matmul_i8_2x1/input_1.cairo | 7 +++--- tests/nodes/matmul_i8_2x1/output_0.cairo | 5 ++-- tests/nodes/matmul_i8_2x2.cairo | 12 ++++----- tests/nodes/matmul_i8_2x2/input_0.cairo | 9 ++++--- tests/nodes/matmul_i8_2x2/input_1.cairo | 11 ++++---- tests/nodes/matmul_i8_2x2/output_0.cairo | 9 ++++--- tests/nodes/matmul_i8_2x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_2x3/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_i8_2x3/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_i8_2x3/output_0.cairo | 17 +++++++++++++ tests/nodes/matmul_i8_3x1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_3x1/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_i8_3x1/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_i8_3x1/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_3x2.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_3x2/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_i8_3x2/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_i8_3x2/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_3x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_3x3/input_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_3x3/input_1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_i8_3x3/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_1d.cairo | 10 ++++---- tests/nodes/matmul_u32_1d/input_0.cairo | 9 ++++--- tests/nodes/matmul_u32_1d/input_1.cairo | 9 ++++--- tests/nodes/matmul_u32_1d/output_0.cairo | 5 ++-- tests/nodes/matmul_u32_1x2.cairo | 10 ++++---- tests/nodes/matmul_u32_1x2/input_0.cairo | 7 +++--- tests/nodes/matmul_u32_1x2/input_1.cairo | 7 +++--- tests/nodes/matmul_u32_1x2/output_0.cairo | 5 ++-- tests/nodes/matmul_u32_1x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_1x3/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_u32_1x3/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_u32_1x3/output_0.cairo | 14 +++++++++++ tests/nodes/matmul_u32_2x1.cairo | 10 ++++---- tests/nodes/matmul_u32_2x1/input_0.cairo | 7 +++--- tests/nodes/matmul_u32_2x1/input_1.cairo | 7 +++--- tests/nodes/matmul_u32_2x1/output_0.cairo | 11 ++++---- tests/nodes/matmul_u32_2x2.cairo | 10 ++++---- tests/nodes/matmul_u32_2x2/input_0.cairo | 11 ++++---- tests/nodes/matmul_u32_2x2/input_1.cairo | 11 ++++---- tests/nodes/matmul_u32_2x2/output_0.cairo | 11 ++++---- tests/nodes/matmul_u32_2x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_2x3/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_u32_2x3/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_u32_2x3/output_0.cairo | 17 +++++++++++++ tests/nodes/matmul_u32_3x1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_3x1/input_0.cairo | 16 ++++++++++++ tests/nodes/matmul_u32_3x1/input_1.cairo | 16 ++++++++++++ tests/nodes/matmul_u32_3x1/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_3x2.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_3x2/input_0.cairo | 19 ++++++++++++++ tests/nodes/matmul_u32_3x2/input_1.cairo | 19 ++++++++++++++ tests/nodes/matmul_u32_3x2/output_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_3x3.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_3x3/input_0.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_3x3/input_1.cairo | 22 ++++++++++++++++ tests/nodes/matmul_u32_3x3/output_0.cairo | 22 ++++++++++++++++ 181 files changed, 2323 insertions(+), 307 deletions(-) create mode 100644 tests/nodes/matmul_fp16x16_1x3.cairo create mode 100644 tests/nodes/matmul_fp16x16_1x3/input_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_1x3/input_1.cairo create mode 100644 tests/nodes/matmul_fp16x16_1x3/output_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_2x3.cairo create mode 100644 tests/nodes/matmul_fp16x16_2x3/input_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_2x3/input_1.cairo create mode 100644 tests/nodes/matmul_fp16x16_2x3/output_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x1.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x1/input_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x1/input_1.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x1/output_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x2.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x2/input_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x2/input_1.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x2/output_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x3.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x3/input_0.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x3/input_1.cairo create mode 100644 tests/nodes/matmul_fp16x16_3x3/output_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_1x3.cairo create mode 100644 tests/nodes/matmul_fp8x23_1x3/input_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_1x3/input_1.cairo create mode 100644 tests/nodes/matmul_fp8x23_1x3/output_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_2x3.cairo create mode 100644 tests/nodes/matmul_fp8x23_2x3/input_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_2x3/input_1.cairo create mode 100644 tests/nodes/matmul_fp8x23_2x3/output_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x1.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x1/input_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x1/input_1.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x1/output_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x2.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x2/input_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x2/input_1.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x2/output_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x3.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x3/input_0.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x3/input_1.cairo create mode 100644 tests/nodes/matmul_fp8x23_3x3/output_0.cairo create mode 100644 tests/nodes/matmul_i32_1x3.cairo create mode 100644 tests/nodes/matmul_i32_1x3/input_0.cairo create mode 100644 tests/nodes/matmul_i32_1x3/input_1.cairo create mode 100644 tests/nodes/matmul_i32_1x3/output_0.cairo create mode 100644 tests/nodes/matmul_i32_2x3.cairo create mode 100644 tests/nodes/matmul_i32_2x3/input_0.cairo create mode 100644 tests/nodes/matmul_i32_2x3/input_1.cairo create mode 100644 tests/nodes/matmul_i32_2x3/output_0.cairo create mode 100644 tests/nodes/matmul_i32_3x1.cairo create mode 100644 tests/nodes/matmul_i32_3x1/input_0.cairo create mode 100644 tests/nodes/matmul_i32_3x1/input_1.cairo create mode 100644 tests/nodes/matmul_i32_3x1/output_0.cairo create mode 100644 tests/nodes/matmul_i32_3x2.cairo create mode 100644 tests/nodes/matmul_i32_3x2/input_0.cairo create mode 100644 tests/nodes/matmul_i32_3x2/input_1.cairo create mode 100644 tests/nodes/matmul_i32_3x2/output_0.cairo create mode 100644 tests/nodes/matmul_i32_3x3.cairo create mode 100644 tests/nodes/matmul_i32_3x3/input_0.cairo create mode 100644 tests/nodes/matmul_i32_3x3/input_1.cairo create mode 100644 tests/nodes/matmul_i32_3x3/output_0.cairo create mode 100644 tests/nodes/matmul_i8_1x3.cairo create mode 100644 tests/nodes/matmul_i8_1x3/input_0.cairo create mode 100644 tests/nodes/matmul_i8_1x3/input_1.cairo create mode 100644 tests/nodes/matmul_i8_1x3/output_0.cairo create mode 100644 tests/nodes/matmul_i8_2x3.cairo create mode 100644 tests/nodes/matmul_i8_2x3/input_0.cairo create mode 100644 tests/nodes/matmul_i8_2x3/input_1.cairo create mode 100644 tests/nodes/matmul_i8_2x3/output_0.cairo create mode 100644 tests/nodes/matmul_i8_3x1.cairo create mode 100644 tests/nodes/matmul_i8_3x1/input_0.cairo create mode 100644 tests/nodes/matmul_i8_3x1/input_1.cairo create mode 100644 tests/nodes/matmul_i8_3x1/output_0.cairo create mode 100644 tests/nodes/matmul_i8_3x2.cairo create mode 100644 tests/nodes/matmul_i8_3x2/input_0.cairo create mode 100644 tests/nodes/matmul_i8_3x2/input_1.cairo create mode 100644 tests/nodes/matmul_i8_3x2/output_0.cairo create mode 100644 tests/nodes/matmul_i8_3x3.cairo create mode 100644 tests/nodes/matmul_i8_3x3/input_0.cairo create mode 100644 tests/nodes/matmul_i8_3x3/input_1.cairo create mode 100644 tests/nodes/matmul_i8_3x3/output_0.cairo create mode 100644 tests/nodes/matmul_u32_1x3.cairo create mode 100644 tests/nodes/matmul_u32_1x3/input_0.cairo create mode 100644 tests/nodes/matmul_u32_1x3/input_1.cairo create mode 100644 tests/nodes/matmul_u32_1x3/output_0.cairo create mode 100644 tests/nodes/matmul_u32_2x3.cairo create mode 100644 tests/nodes/matmul_u32_2x3/input_0.cairo create mode 100644 tests/nodes/matmul_u32_2x3/input_1.cairo create mode 100644 tests/nodes/matmul_u32_2x3/output_0.cairo create mode 100644 tests/nodes/matmul_u32_3x1.cairo create mode 100644 tests/nodes/matmul_u32_3x1/input_0.cairo create mode 100644 tests/nodes/matmul_u32_3x1/input_1.cairo create mode 100644 tests/nodes/matmul_u32_3x1/output_0.cairo create mode 100644 tests/nodes/matmul_u32_3x2.cairo create mode 100644 tests/nodes/matmul_u32_3x2/input_0.cairo create mode 100644 tests/nodes/matmul_u32_3x2/input_1.cairo create mode 100644 tests/nodes/matmul_u32_3x2/output_0.cairo create mode 100644 tests/nodes/matmul_u32_3x3.cairo create mode 100644 tests/nodes/matmul_u32_3x3/input_0.cairo create mode 100644 tests/nodes/matmul_u32_3x3/input_1.cairo create mode 100644 tests/nodes/matmul_u32_3x3/output_0.cairo diff --git a/tests/nodes.cairo b/tests/nodes.cairo index 244d8b0c9..5ba3b239c 100644 --- a/tests/nodes.cairo +++ b/tests/nodes.cairo @@ -213,6 +213,31 @@ mod matmul_u32_1d; mod matmul_u32_2x2; mod matmul_u32_2x1; mod matmul_u32_1x2; +mod matmul_fp16x16_3x3; +mod matmul_fp16x16_3x1; +mod matmul_fp16x16_1x3; +mod matmul_fp16x16_2x3; +mod matmul_fp16x16_3x2; +mod matmul_fp8x23_3x3; +mod matmul_fp8x23_3x1; +mod matmul_fp8x23_1x3; +mod matmul_fp8x23_2x3; +mod matmul_fp8x23_3x2; +mod matmul_i32_3x3; +mod matmul_i32_3x1; +mod matmul_i32_1x3; +mod matmul_i32_2x3; +mod matmul_i32_3x2; +mod matmul_i8_3x3; +mod matmul_i8_3x1; +mod matmul_i8_1x3; +mod matmul_i8_2x3; +mod matmul_i8_3x2; +mod matmul_u32_3x3; +mod matmul_u32_3x1; +mod matmul_u32_1x3; +mod matmul_u32_2x3; +mod matmul_u32_3x2; mod mul_fp16x16; mod mul_fp16x16_broadcast; mod mul_fp8x23; diff --git a/tests/nodes/matmul_fp16x16_1d.cairo b/tests/nodes/matmul_fp16x16_1d.cairo index 0ae4502cf..553c7550d 100644 --- a/tests/nodes/matmul_fp16x16_1d.cairo +++ b/tests/nodes/matmul_fp16x16_1d.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; #[test] #[available_gas(2000000000)] fn test_matmul_fp16x16_1d() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp16x16_1d/input_0.cairo b/tests/nodes/matmul_fp16x16_1d/input_0.cairo index 2d1804d7b..86578929b 100644 --- a/tests/nodes/matmul_fp16x16_1d/input_0.cairo +++ b/tests/nodes/matmul_fp16x16_1d/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_0() -> Tensor { @@ -8,8 +8,8 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 65536, sign: true }); - data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_1d/input_1.cairo b/tests/nodes/matmul_fp16x16_1d/input_1.cairo index e42f7e810..4ad1f5f04 100644 --- a/tests/nodes/matmul_fp16x16_1d/input_1.cairo +++ b/tests/nodes/matmul_fp16x16_1d/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_1() -> Tensor { @@ -8,8 +8,8 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 65536, sign: false }); - data.append(FP16x16 { mag: 65536, sign: false }); data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_1d/output_0.cairo b/tests/nodes/matmul_fp16x16_1d/output_0.cairo index 747f05de2..d5310208e 100644 --- a/tests/nodes/matmul_fp16x16_1d/output_0.cairo +++ b/tests/nodes/matmul_fp16x16_1d/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn output_0() -> Tensor { @@ -8,6 +8,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 262144, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_1x2.cairo b/tests/nodes/matmul_fp16x16_1x2.cairo index 05fb96808..9253080e7 100644 --- a/tests/nodes/matmul_fp16x16_1x2.cairo +++ b/tests/nodes/matmul_fp16x16_1x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; #[test] #[available_gas(2000000000)] fn test_matmul_fp16x16_1x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp16x16_1x2/input_0.cairo b/tests/nodes/matmul_fp16x16_1x2/input_0.cairo index 9a8de084c..588cd3e16 100644 --- a/tests/nodes/matmul_fp16x16_1x2/input_0.cairo +++ b/tests/nodes/matmul_fp16x16_1x2/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_0() -> Tensor { @@ -10,6 +10,6 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(FP16x16 { mag: 196608, sign: false }); - data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_1x2/input_1.cairo b/tests/nodes/matmul_fp16x16_1x2/input_1.cairo index 577654bcd..8abbd22f8 100644 --- a/tests/nodes/matmul_fp16x16_1x2/input_1.cairo +++ b/tests/nodes/matmul_fp16x16_1x2/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_1() -> Tensor { @@ -9,7 +9,7 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 65536, sign: false }); - data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_1x2/output_0.cairo b/tests/nodes/matmul_fp16x16_1x2/output_0.cairo index def1e9307..868466229 100644 --- a/tests/nodes/matmul_fp16x16_1x2/output_0.cairo +++ b/tests/nodes/matmul_fp16x16_1x2/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn output_0() -> Tensor { @@ -9,6 +9,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 655360, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_1x3.cairo b/tests/nodes/matmul_fp16x16_1x3.cairo new file mode 100644 index 000000000..bb657dca5 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_1x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp16x16_1x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp16x16_1x3/input_0.cairo b/tests/nodes/matmul_fp16x16_1x3/input_0.cairo new file mode 100644 index 000000000..8fdbea204 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_1x3/input_0.cairo @@ -0,0 +1,16 @@ +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); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_1x3/input_1.cairo b/tests/nodes/matmul_fp16x16_1x3/input_1.cairo new file mode 100644 index 000000000..64c57d0a7 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_1x3/input_1.cairo @@ -0,0 +1,16 @@ +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); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_1x3/output_0.cairo b/tests/nodes/matmul_fp16x16_1x3/output_0.cairo new file mode 100644 index 000000000..51e4ce36a --- /dev/null +++ b/tests/nodes/matmul_fp16x16_1x3/output_0.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 output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 851968, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_2x1.cairo b/tests/nodes/matmul_fp16x16_2x1.cairo index eb424617e..1bd0d8475 100644 --- a/tests/nodes/matmul_fp16x16_2x1.cairo +++ b/tests/nodes/matmul_fp16x16_2x1.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; #[test] #[available_gas(2000000000)] fn test_matmul_fp16x16_2x1() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp16x16_2x1/input_0.cairo b/tests/nodes/matmul_fp16x16_2x1/input_0.cairo index 6ca4ce6f2..6a393f02a 100644 --- a/tests/nodes/matmul_fp16x16_2x1/input_0.cairo +++ b/tests/nodes/matmul_fp16x16_2x1/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_0() -> Tensor { @@ -9,7 +9,7 @@ fn input_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_2x1/input_1.cairo b/tests/nodes/matmul_fp16x16_2x1/input_1.cairo index c8ddc358f..4d759fb01 100644 --- a/tests/nodes/matmul_fp16x16_2x1/input_1.cairo +++ b/tests/nodes/matmul_fp16x16_2x1/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_1() -> Tensor { @@ -9,7 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_2x1/output_0.cairo b/tests/nodes/matmul_fp16x16_2x1/output_0.cairo index c37292865..b5bd146af 100644 --- a/tests/nodes/matmul_fp16x16_2x1/output_0.cairo +++ b/tests/nodes/matmul_fp16x16_2x1/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn output_0() -> Tensor { @@ -9,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 393216, sign: true }); data.append(FP16x16 { mag: 0, sign: false }); - data.append(FP16x16 { mag: 262144, sign: true }); data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 589824, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_2x2.cairo b/tests/nodes/matmul_fp16x16_2x2.cairo index 8821a6d08..3bfe8c2d1 100644 --- a/tests/nodes/matmul_fp16x16_2x2.cairo +++ b/tests/nodes/matmul_fp16x16_2x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; #[test] #[available_gas(2000000000)] fn test_matmul_fp16x16_2x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp16x16_2x2/input_0.cairo b/tests/nodes/matmul_fp16x16_2x2/input_0.cairo index 7d09668a2..033a7e5d1 100644 --- a/tests/nodes/matmul_fp16x16_2x2/input_0.cairo +++ b/tests/nodes/matmul_fp16x16_2x2/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_0() -> Tensor { @@ -9,9 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 196608, sign: true }); data.append(FP16x16 { mag: 65536, sign: false }); - data.append(FP16x16 { mag: 196608, sign: false }); data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_2x2/input_1.cairo b/tests/nodes/matmul_fp16x16_2x2/input_1.cairo index 10ef8f5a9..cbd87c12f 100644 --- a/tests/nodes/matmul_fp16x16_2x2/input_1.cairo +++ b/tests/nodes/matmul_fp16x16_2x2/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn input_1() -> Tensor { @@ -9,9 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); data.append(FP16x16 { mag: 196608, sign: false }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_2x2/output_0.cairo b/tests/nodes/matmul_fp16x16_2x2/output_0.cairo index 5f9ab986e..6e48df41e 100644 --- a/tests/nodes/matmul_fp16x16_2x2/output_0.cairo +++ b/tests/nodes/matmul_fp16x16_2x2/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; use orion::numbers::{FixedTrait, FP16x16}; fn output_0() -> Tensor { @@ -9,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 720896, sign: true }); - data.append(FP16x16 { mag: 262144, sign: false }); - data.append(FP16x16 { mag: 851968, sign: false }); - data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 393216, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp16x16_2x3.cairo b/tests/nodes/matmul_fp16x16_2x3.cairo new file mode 100644 index 000000000..9595d1406 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_2x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp16x16_2x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp16x16_2x3/input_0.cairo b/tests/nodes/matmul_fp16x16_2x3/input_0.cairo new file mode 100644 index 000000000..9a4a83d94 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_2x3/input_0.cairo @@ -0,0 +1,19 @@ +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); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_2x3/input_1.cairo b/tests/nodes/matmul_fp16x16_2x3/input_1.cairo new file mode 100644 index 000000000..d3c9f5f04 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_2x3/input_1.cairo @@ -0,0 +1,19 @@ +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); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_2x3/output_0.cairo b/tests/nodes/matmul_fp16x16_2x3/output_0.cairo new file mode 100644 index 000000000..25f29f5a1 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_2x3/output_0.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 output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x1.cairo b/tests/nodes/matmul_fp16x16_3x1.cairo new file mode 100644 index 000000000..27ef48a3b --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp16x16_3x1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp16x16_3x1/input_0.cairo b/tests/nodes/matmul_fp16x16_3x1/input_0.cairo new file mode 100644 index 000000000..a1fd1eb98 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x1/input_0.cairo @@ -0,0 +1,16 @@ +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(1); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x1/input_1.cairo b/tests/nodes/matmul_fp16x16_3x1/input_1.cairo new file mode 100644 index 000000000..2114e8f0c --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x1/input_1.cairo @@ -0,0 +1,16 @@ +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(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x1/output_0.cairo b/tests/nodes/matmul_fp16x16_3x1/output_0.cairo new file mode 100644 index 000000000..f0f2d3aa9 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x1/output_0.cairo @@ -0,0 +1,22 @@ +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(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x2.cairo b/tests/nodes/matmul_fp16x16_3x2.cairo new file mode 100644 index 000000000..9189ee328 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp16x16_3x2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp16x16_3x2/input_0.cairo b/tests/nodes/matmul_fp16x16_3x2/input_0.cairo new file mode 100644 index 000000000..80dd09b37 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x2/input_0.cairo @@ -0,0 +1,19 @@ +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(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x2/input_1.cairo b/tests/nodes/matmul_fp16x16_3x2/input_1.cairo new file mode 100644 index 000000000..eff0e3ae2 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x2/input_1.cairo @@ -0,0 +1,19 @@ +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); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x2/output_0.cairo b/tests/nodes/matmul_fp16x16_3x2/output_0.cairo new file mode 100644 index 000000000..43de9df65 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x2/output_0.cairo @@ -0,0 +1,22 @@ +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(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 327680, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x3.cairo b/tests/nodes/matmul_fp16x16_3x3.cairo new file mode 100644 index 000000000..b4b5b46d0 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::FP16x16TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp16x16_3x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp16x16_3x3/input_0.cairo b/tests/nodes/matmul_fp16x16_3x3/input_0.cairo new file mode 100644 index 000000000..605229c45 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x3/input_0.cairo @@ -0,0 +1,22 @@ +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(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x3/input_1.cairo b/tests/nodes/matmul_fp16x16_3x3/input_1.cairo new file mode 100644 index 000000000..92ffbe234 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x3/input_1.cairo @@ -0,0 +1,22 @@ +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); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp16x16_3x3/output_0.cairo b/tests/nodes/matmul_fp16x16_3x3/output_0.cairo new file mode 100644 index 000000000..d617a1ad7 --- /dev/null +++ b/tests/nodes/matmul_fp16x16_3x3/output_0.cairo @@ -0,0 +1,22 @@ +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(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_1d.cairo b/tests/nodes/matmul_fp8x23_1d.cairo index 4061730d6..e9ba3d297 100644 --- a/tests/nodes/matmul_fp8x23_1d.cairo +++ b/tests/nodes/matmul_fp8x23_1d.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_fp8x23_1d() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp8x23_1d/input_0.cairo b/tests/nodes/matmul_fp8x23_1d/input_0.cairo index 9c321435e..010ce68e6 100644 --- a/tests/nodes/matmul_fp8x23_1d/input_0.cairo +++ b/tests/nodes/matmul_fp8x23_1d/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_0() -> Tensor { @@ -8,8 +8,8 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 25165824, sign: false }); - data.append(FP8x23 { mag: 0, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_1d/input_1.cairo b/tests/nodes/matmul_fp8x23_1d/input_1.cairo index 8fd0df22b..a062ac386 100644 --- a/tests/nodes/matmul_fp8x23_1d/input_1.cairo +++ b/tests/nodes/matmul_fp8x23_1d/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_1() -> Tensor { @@ -8,8 +8,8 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 16777216, sign: true }); - data.append(FP8x23 { mag: 25165824, sign: true }); - data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_1d/output_0.cairo b/tests/nodes/matmul_fp8x23_1d/output_0.cairo index 48b2b150d..7a41f6073 100644 --- a/tests/nodes/matmul_fp8x23_1d/output_0.cairo +++ b/tests/nodes/matmul_fp8x23_1d/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn output_0() -> Tensor { @@ -8,6 +8,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_1x2.cairo b/tests/nodes/matmul_fp8x23_1x2.cairo index 133fa03c9..a2a7580fb 100644 --- a/tests/nodes/matmul_fp8x23_1x2.cairo +++ b/tests/nodes/matmul_fp8x23_1x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_fp8x23_1x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp8x23_1x2/input_0.cairo b/tests/nodes/matmul_fp8x23_1x2/input_0.cairo index 4869f6c4d..126f01935 100644 --- a/tests/nodes/matmul_fp8x23_1x2/input_0.cairo +++ b/tests/nodes/matmul_fp8x23_1x2/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_0() -> Tensor { @@ -9,7 +9,7 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_1x2/input_1.cairo b/tests/nodes/matmul_fp8x23_1x2/input_1.cairo index 383e0adcb..dd989278b 100644 --- a/tests/nodes/matmul_fp8x23_1x2/input_1.cairo +++ b/tests/nodes/matmul_fp8x23_1x2/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_1() -> Tensor { @@ -9,7 +9,7 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 0, sign: false }); data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_1x2/output_0.cairo b/tests/nodes/matmul_fp8x23_1x2/output_0.cairo index 26b2893e4..590927c8e 100644 --- a/tests/nodes/matmul_fp8x23_1x2/output_0.cairo +++ b/tests/nodes/matmul_fp8x23_1x2/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn output_0() -> Tensor { @@ -9,6 +9,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_1x3.cairo b/tests/nodes/matmul_fp8x23_1x3.cairo new file mode 100644 index 000000000..95630f95c --- /dev/null +++ b/tests/nodes/matmul_fp8x23_1x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp8x23_1x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp8x23_1x3/input_0.cairo b/tests/nodes/matmul_fp8x23_1x3/input_0.cairo new file mode 100644 index 000000000..0e8a93486 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_1x3/input_0.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_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_1x3/input_1.cairo b/tests/nodes/matmul_fp8x23_1x3/input_1.cairo new file mode 100644 index 000000000..bdd5f4a04 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_1x3/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(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_1x3/output_0.cairo b/tests/nodes/matmul_fp8x23_1x3/output_0.cairo new file mode 100644 index 000000000..2f77a01b5 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_1x3/output_0.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 output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_2x1.cairo b/tests/nodes/matmul_fp8x23_2x1.cairo index 80fd9dfc8..e3f3db9b1 100644 --- a/tests/nodes/matmul_fp8x23_2x1.cairo +++ b/tests/nodes/matmul_fp8x23_2x1.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_fp8x23_2x1() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp8x23_2x1/input_0.cairo b/tests/nodes/matmul_fp8x23_2x1/input_0.cairo index e9932e3f5..a67930de6 100644 --- a/tests/nodes/matmul_fp8x23_2x1/input_0.cairo +++ b/tests/nodes/matmul_fp8x23_2x1/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_0() -> Tensor { @@ -9,7 +9,7 @@ fn input_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 8388608, sign: false }); - data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_2x1/input_1.cairo b/tests/nodes/matmul_fp8x23_2x1/input_1.cairo index cdd3805b8..b84abb8c7 100644 --- a/tests/nodes/matmul_fp8x23_2x1/input_1.cairo +++ b/tests/nodes/matmul_fp8x23_2x1/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_1() -> Tensor { @@ -9,7 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_2x1/output_0.cairo b/tests/nodes/matmul_fp8x23_2x1/output_0.cairo index bcad056be..14252df84 100644 --- a/tests/nodes/matmul_fp8x23_2x1/output_0.cairo +++ b/tests/nodes/matmul_fp8x23_2x1/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn output_0() -> Tensor { @@ -9,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 75497472, sign: true }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_2x2.cairo b/tests/nodes/matmul_fp8x23_2x2.cairo index 4d8f7cd5a..178f8c1f4 100644 --- a/tests/nodes/matmul_fp8x23_2x2.cairo +++ b/tests/nodes/matmul_fp8x23_2x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_fp8x23_2x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_fp8x23_2x2/input_0.cairo b/tests/nodes/matmul_fp8x23_2x2/input_0.cairo index 9ac78c0b1..3b3649464 100644 --- a/tests/nodes/matmul_fp8x23_2x2/input_0.cairo +++ b/tests/nodes/matmul_fp8x23_2x2/input_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_0() -> Tensor { @@ -9,9 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 25165824, sign: false }); data.append(FP8x23 { mag: 8388608, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_2x2/input_1.cairo b/tests/nodes/matmul_fp8x23_2x2/input_1.cairo index 91f9b61f9..eef84ccc7 100644 --- a/tests/nodes/matmul_fp8x23_2x2/input_1.cairo +++ b/tests/nodes/matmul_fp8x23_2x2/input_1.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn input_1() -> Tensor { @@ -9,9 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 25165824, sign: false }); data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_2x2/output_0.cairo b/tests/nodes/matmul_fp8x23_2x2/output_0.cairo index 4bb02e98f..cbb7df8e0 100644 --- a/tests/nodes/matmul_fp8x23_2x2/output_0.cairo +++ b/tests/nodes/matmul_fp8x23_2x2/output_0.cairo @@ -1,6 +1,6 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; use orion::numbers::{FixedTrait, FP8x23}; fn output_0() -> Tensor { @@ -9,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 83886080, sign: false }); - data.append(FP8x23 { mag: 50331648, sign: false }); - data.append(FP8x23 { mag: 67108864, sign: false }); - data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_fp8x23_2x3.cairo b/tests/nodes/matmul_fp8x23_2x3.cairo new file mode 100644 index 000000000..fd6cbb86f --- /dev/null +++ b/tests/nodes/matmul_fp8x23_2x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp8x23_2x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp8x23_2x3/input_0.cairo b/tests/nodes/matmul_fp8x23_2x3/input_0.cairo new file mode 100644 index 000000000..e1eaec118 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_2x3/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(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_2x3/input_1.cairo b/tests/nodes/matmul_fp8x23_2x3/input_1.cairo new file mode 100644 index 000000000..66d149bf7 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_2x3/input_1.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_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_2x3/output_0.cairo b/tests/nodes/matmul_fp8x23_2x3/output_0.cairo new file mode 100644 index 000000000..af5096380 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_2x3/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: 16777216, sign: true }); + data.append(FP8x23 { mag: 83886080, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x1.cairo b/tests/nodes/matmul_fp8x23_3x1.cairo new file mode 100644 index 000000000..582cafbe4 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp8x23_3x1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp8x23_3x1/input_0.cairo b/tests/nodes/matmul_fp8x23_3x1/input_0.cairo new file mode 100644 index 000000000..ed584a6a9 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x1/input_0.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_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x1/input_1.cairo b/tests/nodes/matmul_fp8x23_3x1/input_1.cairo new file mode 100644 index 000000000..9309854db --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x1/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(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x1/output_0.cairo b/tests/nodes/matmul_fp8x23_3x1/output_0.cairo new file mode 100644 index 000000000..22df10331 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x1/output_0.cairo @@ -0,0 +1,22 @@ +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(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x2.cairo b/tests/nodes/matmul_fp8x23_3x2.cairo new file mode 100644 index 000000000..81155f84e --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp8x23_3x2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp8x23_3x2/input_0.cairo b/tests/nodes/matmul_fp8x23_3x2/input_0.cairo new file mode 100644 index 000000000..8b70501d8 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x2/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(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x2/input_1.cairo b/tests/nodes/matmul_fp8x23_3x2/input_1.cairo new file mode 100644 index 000000000..bc22e1f89 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x2/input_1.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_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x2/output_0.cairo b/tests/nodes/matmul_fp8x23_3x2/output_0.cairo new file mode 100644 index 000000000..ff7c9e454 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x2/output_0.cairo @@ -0,0 +1,22 @@ +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(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: true }); + data.append(FP8x23 { mag: 92274688, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x3.cairo b/tests/nodes/matmul_fp8x23_3x3.cairo new file mode 100644 index 000000000..a155c2290 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_fp8x23_3x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_fp8x23_3x3/input_0.cairo b/tests/nodes/matmul_fp8x23_3x3/input_0.cairo new file mode 100644 index 000000000..07503412d --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x3/input_0.cairo @@ -0,0 +1,22 @@ +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(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x3/input_1.cairo b/tests/nodes/matmul_fp8x23_3x3/input_1.cairo new file mode 100644 index 000000000..3383122b7 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x3/input_1.cairo @@ -0,0 +1,22 @@ +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); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_fp8x23_3x3/output_0.cairo b/tests/nodes/matmul_fp8x23_3x3/output_0.cairo new file mode 100644 index 000000000..3a70152c2 --- /dev/null +++ b/tests/nodes/matmul_fp8x23_3x3/output_0.cairo @@ -0,0 +1,22 @@ +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(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 67108864, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: true }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_1d.cairo b/tests/nodes/matmul_i32_1d.cairo index d1f347847..e85657865 100644 --- a/tests/nodes/matmul_i32_1d.cairo +++ b/tests/nodes/matmul_i32_1d.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::I32TensorPartialEq; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; -use orion::operators::tensor::{TensorTrait, Tensor}; #[test] #[available_gas(2000000000)] fn test_matmul_i32_1d() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i32_1d/input_0.cairo b/tests/nodes/matmul_i32_1d/input_0.cairo index 659790348..bdf2c91af 100644 --- a/tests/nodes/matmul_i32_1d/input_0.cairo +++ b/tests/nodes/matmul_i32_1d/input_0.cairo @@ -1,14 +1,15 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(-96); - data.append(50); - data.append(16); + data.append(-107); + data.append(-106); + data.append(101); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_1d/input_1.cairo b/tests/nodes/matmul_i32_1d/input_1.cairo index 7d21fd141..56f6e0987 100644 --- a/tests/nodes/matmul_i32_1d/input_1.cairo +++ b/tests/nodes/matmul_i32_1d/input_1.cairo @@ -1,14 +1,15 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(23); - data.append(89); - data.append(6); + data.append(15); + data.append(-43); + data.append(70); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_1d/output_0.cairo b/tests/nodes/matmul_i32_1d/output_0.cairo index 189514154..14f98e8ee 100644 --- a/tests/nodes/matmul_i32_1d/output_0.cairo +++ b/tests/nodes/matmul_i32_1d/output_0.cairo @@ -1,12 +1,13 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(2338); + data.append(10023); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_1x2.cairo b/tests/nodes/matmul_i32_1x2.cairo index 9ad27ca8a..5a5e63aad 100644 --- a/tests/nodes/matmul_i32_1x2.cairo +++ b/tests/nodes/matmul_i32_1x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::I32TensorPartialEq; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; -use orion::operators::tensor::{TensorTrait, Tensor}; #[test] #[available_gas(2000000000)] fn test_matmul_i32_1x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i32_1x2/input_0.cairo b/tests/nodes/matmul_i32_1x2/input_0.cairo index 227d616f6..4fbb7f4f0 100644 --- a/tests/nodes/matmul_i32_1x2/input_0.cairo +++ b/tests/nodes/matmul_i32_1x2/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(-86); - data.append(43); + data.append(120); + data.append(11); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_1x2/input_1.cairo b/tests/nodes/matmul_i32_1x2/input_1.cairo index 0c7111f33..278a16833 100644 --- a/tests/nodes/matmul_i32_1x2/input_1.cairo +++ b/tests/nodes/matmul_i32_1x2/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(125); - data.append(-59); + data.append(-62); + data.append(67); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_1x2/output_0.cairo b/tests/nodes/matmul_i32_1x2/output_0.cairo index 5ee7cb4f5..c9ffb2024 100644 --- a/tests/nodes/matmul_i32_1x2/output_0.cairo +++ b/tests/nodes/matmul_i32_1x2/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,6 +9,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(-13287); + data.append(-6703); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_1x3.cairo b/tests/nodes/matmul_i32_1x3.cairo new file mode 100644 index 000000000..c73191865 --- /dev/null +++ b/tests/nodes/matmul_i32_1x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::I32TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i32_1x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i32_1x3/input_0.cairo b/tests/nodes/matmul_i32_1x3/input_0.cairo new file mode 100644 index 000000000..0b56973a0 --- /dev/null +++ b/tests/nodes/matmul_i32_1x3/input_0.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-2); + data.append(-108); + data.append(32); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_1x3/input_1.cairo b/tests/nodes/matmul_i32_1x3/input_1.cairo new file mode 100644 index 000000000..221905891 --- /dev/null +++ b/tests/nodes/matmul_i32_1x3/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(-46); + data.append(-122); + data.append(112); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_1x3/output_0.cairo b/tests/nodes/matmul_i32_1x3/output_0.cairo new file mode 100644 index 000000000..ff834062a --- /dev/null +++ b/tests/nodes/matmul_i32_1x3/output_0.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(16852); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_2x1.cairo b/tests/nodes/matmul_i32_2x1.cairo index 00f56078c..975dc8dcc 100644 --- a/tests/nodes/matmul_i32_2x1.cairo +++ b/tests/nodes/matmul_i32_2x1.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::I32TensorPartialEq; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; -use orion::operators::tensor::{TensorTrait, Tensor}; #[test] #[available_gas(2000000000)] fn test_matmul_i32_2x1() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i32_2x1/input_0.cairo b/tests/nodes/matmul_i32_2x1/input_0.cairo index 261ca9e8e..4778f9778 100644 --- a/tests/nodes/matmul_i32_2x1/input_0.cairo +++ b/tests/nodes/matmul_i32_2x1/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(115); - data.append(-24); + data.append(69); + data.append(22); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_2x1/input_1.cairo b/tests/nodes/matmul_i32_2x1/input_1.cairo index d20e2a5a3..c544d6d27 100644 --- a/tests/nodes/matmul_i32_2x1/input_1.cairo +++ b/tests/nodes/matmul_i32_2x1/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(-103); - data.append(-90); + data.append(87); + data.append(58); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_2x1/output_0.cairo b/tests/nodes/matmul_i32_2x1/output_0.cairo index bd0612780..af7ef907a 100644 --- a/tests/nodes/matmul_i32_2x1/output_0.cairo +++ b/tests/nodes/matmul_i32_2x1/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(-11845); - data.append(-10350); - data.append(2472); - data.append(2160); + data.append(6003); + data.append(4002); + data.append(1914); + data.append(1276); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_2x2.cairo b/tests/nodes/matmul_i32_2x2.cairo index 6fe8fc3fd..877363b80 100644 --- a/tests/nodes/matmul_i32_2x2.cairo +++ b/tests/nodes/matmul_i32_2x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::I32TensorPartialEq; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; -use orion::operators::tensor::{TensorTrait, Tensor}; #[test] #[available_gas(2000000000)] fn test_matmul_i32_2x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i32_2x2/input_0.cairo b/tests/nodes/matmul_i32_2x2/input_0.cairo index bd377e2c6..7aa628432 100644 --- a/tests/nodes/matmul_i32_2x2/input_0.cairo +++ b/tests/nodes/matmul_i32_2x2/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(74); - data.append(-16); - data.append(61); - data.append(-21); + data.append(54); + data.append(58); + data.append(40); + data.append(52); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_2x2/input_1.cairo b/tests/nodes/matmul_i32_2x2/input_1.cairo index 3c7f91deb..ae2373e1e 100644 --- a/tests/nodes/matmul_i32_2x2/input_1.cairo +++ b/tests/nodes/matmul_i32_2x2/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(33); - data.append(119); - data.append(15); - data.append(113); + data.append(47); + data.append(-15); + data.append(29); + data.append(-99); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_2x2/output_0.cairo b/tests/nodes/matmul_i32_2x2/output_0.cairo index a6cd5d3f5..bc3565d7a 100644 --- a/tests/nodes/matmul_i32_2x2/output_0.cairo +++ b/tests/nodes/matmul_i32_2x2/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(2202); - data.append(6998); - data.append(1698); - data.append(4886); + data.append(4220); + data.append(-6552); + data.append(3388); + data.append(-5748); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i32_2x3.cairo b/tests/nodes/matmul_i32_2x3.cairo new file mode 100644 index 000000000..f56e72eca --- /dev/null +++ b/tests/nodes/matmul_i32_2x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::I32TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i32_2x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i32_2x3/input_0.cairo b/tests/nodes/matmul_i32_2x3/input_0.cairo new file mode 100644 index 000000000..55b73d0f3 --- /dev/null +++ b/tests/nodes/matmul_i32_2x3/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-37); + data.append(35); + data.append(-63); + data.append(73); + data.append(-74); + data.append(39); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_2x3/input_1.cairo b/tests/nodes/matmul_i32_2x3/input_1.cairo new file mode 100644 index 000000000..9121b41cf --- /dev/null +++ b/tests/nodes/matmul_i32_2x3/input_1.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(-68); + data.append(-16); + data.append(72); + data.append(-65); + data.append(17); + data.append(-57); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_2x3/output_0.cairo b/tests/nodes/matmul_i32_2x3/output_0.cairo new file mode 100644 index 000000000..dbb494db1 --- /dev/null +++ b/tests/nodes/matmul_i32_2x3/output_0.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(3965); + data.append(1908); + data.append(-9629); + data.append(1419); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x1.cairo b/tests/nodes/matmul_i32_3x1.cairo new file mode 100644 index 000000000..40e7595a1 --- /dev/null +++ b/tests/nodes/matmul_i32_3x1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::I32TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i32_3x1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i32_3x1/input_0.cairo b/tests/nodes/matmul_i32_3x1/input_0.cairo new file mode 100644 index 000000000..85518057f --- /dev/null +++ b/tests/nodes/matmul_i32_3x1/input_0.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(17); + data.append(-36); + data.append(-51); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x1/input_1.cairo b/tests/nodes/matmul_i32_3x1/input_1.cairo new file mode 100644 index 000000000..fc6b940ab --- /dev/null +++ b/tests/nodes/matmul_i32_3x1/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(10); + data.append(92); + data.append(15); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x1/output_0.cairo b/tests/nodes/matmul_i32_3x1/output_0.cairo new file mode 100644 index 000000000..c0a4d5314 --- /dev/null +++ b/tests/nodes/matmul_i32_3x1/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(170); + data.append(1564); + data.append(255); + data.append(-360); + data.append(-3312); + data.append(-540); + data.append(-510); + data.append(-4692); + data.append(-765); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x2.cairo b/tests/nodes/matmul_i32_3x2.cairo new file mode 100644 index 000000000..8fdee8f57 --- /dev/null +++ b/tests/nodes/matmul_i32_3x2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::I32TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i32_3x2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i32_3x2/input_0.cairo b/tests/nodes/matmul_i32_3x2/input_0.cairo new file mode 100644 index 000000000..0f19dd9c3 --- /dev/null +++ b/tests/nodes/matmul_i32_3x2/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(-58); + data.append(115); + data.append(57); + data.append(-104); + data.append(28); + data.append(117); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x2/input_1.cairo b/tests/nodes/matmul_i32_3x2/input_1.cairo new file mode 100644 index 000000000..68b59bc45 --- /dev/null +++ b/tests/nodes/matmul_i32_3x2/input_1.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-106); + data.append(-28); + data.append(8); + data.append(2); + data.append(-79); + data.append(41); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x2/output_0.cairo b/tests/nodes/matmul_i32_3x2/output_0.cairo new file mode 100644 index 000000000..d18258413 --- /dev/null +++ b/tests/nodes/matmul_i32_3x2/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(6378); + data.append(-7461); + data.append(4251); + data.append(-6250); + data.append(6620); + data.append(-3808); + data.append(-2734); + data.append(-10027); + data.append(5021); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x3.cairo b/tests/nodes/matmul_i32_3x3.cairo new file mode 100644 index 000000000..80fe57cc7 --- /dev/null +++ b/tests/nodes/matmul_i32_3x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::I32TensorPartialEq; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i32_3x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i32_3x3/input_0.cairo b/tests/nodes/matmul_i32_3x3/input_0.cairo new file mode 100644 index 000000000..7caa8f0dd --- /dev/null +++ b/tests/nodes/matmul_i32_3x3/input_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(115); + data.append(103); + data.append(-72); + data.append(18); + data.append(59); + data.append(115); + data.append(19); + data.append(-71); + data.append(-92); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x3/input_1.cairo b/tests/nodes/matmul_i32_3x3/input_1.cairo new file mode 100644 index 000000000..ae90fc097 --- /dev/null +++ b/tests/nodes/matmul_i32_3x3/input_1.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(31); + data.append(90); + data.append(114); + data.append(33); + data.append(91); + data.append(56); + data.append(-73); + data.append(-58); + data.append(110); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i32_3x3/output_0.cairo b/tests/nodes/matmul_i32_3x3/output_0.cairo new file mode 100644 index 000000000..60b45e97a --- /dev/null +++ b/tests/nodes/matmul_i32_3x3/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(12220); + data.append(23899); + data.append(10958); + data.append(-5890); + data.append(319); + data.append(18006); + data.append(4962); + data.append(585); + data.append(-11930); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_1d.cairo b/tests/nodes/matmul_i8_1d.cairo index 5230f9209..bfee4f903 100644 --- a/tests/nodes/matmul_i8_1d.cairo +++ b/tests/nodes/matmul_i8_1d.cairo @@ -4,19 +4,19 @@ mod output_0; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; -use orion::operators::tensor::I8TensorPartialEq; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_i8_1d() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i8_1d/input_0.cairo b/tests/nodes/matmul_i8_1d/input_0.cairo index 7a573dc03..eb725e11c 100644 --- a/tests/nodes/matmul_i8_1d/input_0.cairo +++ b/tests/nodes/matmul_i8_1d/input_0.cairo @@ -1,14 +1,15 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(-2); - data.append(-2); + data.append(2); + data.append(4); data.append(-2); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_1d/input_1.cairo b/tests/nodes/matmul_i8_1d/input_1.cairo index 26aebc810..d95db53fe 100644 --- a/tests/nodes/matmul_i8_1d/input_1.cairo +++ b/tests/nodes/matmul_i8_1d/input_1.cairo @@ -1,14 +1,15 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(-2); - data.append(-1); - data.append(-2); + data.append(0); + data.append(3); + data.append(4); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_1d/output_0.cairo b/tests/nodes/matmul_i8_1d/output_0.cairo index 616732847..c09cb6be9 100644 --- a/tests/nodes/matmul_i8_1d/output_0.cairo +++ b/tests/nodes/matmul_i8_1d/output_0.cairo @@ -1,12 +1,13 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(10); + data.append(4); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_1x2.cairo b/tests/nodes/matmul_i8_1x2.cairo index 1fc145c95..361551d2d 100644 --- a/tests/nodes/matmul_i8_1x2.cairo +++ b/tests/nodes/matmul_i8_1x2.cairo @@ -4,19 +4,19 @@ mod output_0; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; -use orion::operators::tensor::I8TensorPartialEq; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_i8_1x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i8_1x2/input_0.cairo b/tests/nodes/matmul_i8_1x2/input_0.cairo index 83b2e0d65..6048ee1e0 100644 --- a/tests/nodes/matmul_i8_1x2/input_0.cairo +++ b/tests/nodes/matmul_i8_1x2/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(-3); + data.append(-1); data.append(-2); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_1x2/input_1.cairo b/tests/nodes/matmul_i8_1x2/input_1.cairo index f3d60871b..d19e1ca6b 100644 --- a/tests/nodes/matmul_i8_1x2/input_1.cairo +++ b/tests/nodes/matmul_i8_1x2/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(3); - data.append(4); + data.append(-3); + data.append(1); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_1x2/output_0.cairo b/tests/nodes/matmul_i8_1x2/output_0.cairo index 51981a943..5b0f89f3a 100644 --- a/tests/nodes/matmul_i8_1x2/output_0.cairo +++ b/tests/nodes/matmul_i8_1x2/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,6 +9,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(-17); + data.append(1); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_1x3.cairo b/tests/nodes/matmul_i8_1x3.cairo new file mode 100644 index 000000000..24701d2f1 --- /dev/null +++ b/tests/nodes/matmul_i8_1x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i8_1x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i8_1x3/input_0.cairo b/tests/nodes/matmul_i8_1x3/input_0.cairo new file mode 100644 index 000000000..86c7263e5 --- /dev/null +++ b/tests/nodes/matmul_i8_1x3/input_0.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-1); + data.append(3); + data.append(-2); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_1x3/input_1.cairo b/tests/nodes/matmul_i8_1x3/input_1.cairo new file mode 100644 index 000000000..4a51bf5b4 --- /dev/null +++ b/tests/nodes/matmul_i8_1x3/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(2); + data.append(-3); + data.append(4); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_1x3/output_0.cairo b/tests/nodes/matmul_i8_1x3/output_0.cairo new file mode 100644 index 000000000..9a596acde --- /dev/null +++ b/tests/nodes/matmul_i8_1x3/output_0.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(-19); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_2x1.cairo b/tests/nodes/matmul_i8_2x1.cairo index 50a367412..081b0c190 100644 --- a/tests/nodes/matmul_i8_2x1.cairo +++ b/tests/nodes/matmul_i8_2x1.cairo @@ -4,19 +4,19 @@ mod output_0; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; -use orion::operators::tensor::I8TensorPartialEq; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_i8_2x1() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i8_2x1/input_0.cairo b/tests/nodes/matmul_i8_2x1/input_0.cairo index 1ba418176..1e0ba5ffe 100644 --- a/tests/nodes/matmul_i8_2x1/input_0.cairo +++ b/tests/nodes/matmul_i8_2x1/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,6 +10,6 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(3); + data.append(-3); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_2x1/input_1.cairo b/tests/nodes/matmul_i8_2x1/input_1.cairo index 3da364e60..070bc0e8f 100644 --- a/tests/nodes/matmul_i8_2x1/input_1.cairo +++ b/tests/nodes/matmul_i8_2x1/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(-3); + data.append(3); + data.append(4); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_2x1/output_0.cairo b/tests/nodes/matmul_i8_2x1/output_0.cairo index e3c8a8f9f..b50355c67 100644 --- a/tests/nodes/matmul_i8_2x1/output_0.cairo +++ b/tests/nodes/matmul_i8_2x1/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +11,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - data.append(0); data.append(-9); + data.append(-12); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_2x2.cairo b/tests/nodes/matmul_i8_2x2.cairo index a88880d58..f4edca9fd 100644 --- a/tests/nodes/matmul_i8_2x2.cairo +++ b/tests/nodes/matmul_i8_2x2.cairo @@ -4,19 +4,19 @@ mod output_0; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; -use orion::operators::tensor::I8TensorPartialEq; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_i8_2x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_i8_2x2/input_0.cairo b/tests/nodes/matmul_i8_2x2/input_0.cairo index cf2051a8e..474fa07bd 100644 --- a/tests/nodes/matmul_i8_2x2/input_0.cairo +++ b/tests/nodes/matmul_i8_2x2/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(2); - data.append(3); + data.append(-2); + data.append(-2); data.append(-3); - data.append(4); + data.append(-2); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_2x2/input_1.cairo b/tests/nodes/matmul_i8_2x2/input_1.cairo index 00f7bda36..504344dbb 100644 --- a/tests/nodes/matmul_i8_2x2/input_1.cairo +++ b/tests/nodes/matmul_i8_2x2/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(-1); - data.append(-1); - data.append(2); - data.append(-4); + data.append(-3); + data.append(3); + data.append(4); + data.append(4); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_2x2/output_0.cairo b/tests/nodes/matmul_i8_2x2/output_0.cairo index 532c41224..b8970df9b 100644 --- a/tests/nodes/matmul_i8_2x2/output_0.cairo +++ b/tests/nodes/matmul_i8_2x2/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(4); + data.append(-2); data.append(-14); - data.append(11); - data.append(-13); + data.append(1); + data.append(-17); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_i8_2x3.cairo b/tests/nodes/matmul_i8_2x3.cairo new file mode 100644 index 000000000..8c78f5f34 --- /dev/null +++ b/tests/nodes/matmul_i8_2x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i8_2x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i8_2x3/input_0.cairo b/tests/nodes/matmul_i8_2x3/input_0.cairo new file mode 100644 index 000000000..d7ef8671a --- /dev/null +++ b/tests/nodes/matmul_i8_2x3/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(4); + data.append(-2); + data.append(-2); + data.append(2); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_2x3/input_1.cairo b/tests/nodes/matmul_i8_2x3/input_1.cairo new file mode 100644 index 000000000..b72d08cbc --- /dev/null +++ b/tests/nodes/matmul_i8_2x3/input_1.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(3); + data.append(4); + data.append(0); + data.append(0); + data.append(0); + data.append(4); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_2x3/output_0.cairo b/tests/nodes/matmul_i8_2x3/output_0.cairo new file mode 100644 index 000000000..d52826b8e --- /dev/null +++ b/tests/nodes/matmul_i8_2x3/output_0.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(16); + data.append(-6); + data.append(0); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x1.cairo b/tests/nodes/matmul_i8_3x1.cairo new file mode 100644 index 000000000..5595de58a --- /dev/null +++ b/tests/nodes/matmul_i8_3x1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i8_3x1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i8_3x1/input_0.cairo b/tests/nodes/matmul_i8_3x1/input_0.cairo new file mode 100644 index 000000000..ddd0646e6 --- /dev/null +++ b/tests/nodes/matmul_i8_3x1/input_0.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(3); + data.append(0); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x1/input_1.cairo b/tests/nodes/matmul_i8_3x1/input_1.cairo new file mode 100644 index 000000000..699b93a96 --- /dev/null +++ b/tests/nodes/matmul_i8_3x1/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-2); + data.append(1); + data.append(0); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x1/output_0.cairo b/tests/nodes/matmul_i8_3x1/output_0.cairo new file mode 100644 index 000000000..87187bf09 --- /dev/null +++ b/tests/nodes/matmul_i8_3x1/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(0); + data.append(0); + data.append(-6); + data.append(3); + data.append(0); + data.append(0); + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x2.cairo b/tests/nodes/matmul_i8_3x2.cairo new file mode 100644 index 000000000..171a89250 --- /dev/null +++ b/tests/nodes/matmul_i8_3x2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i8_3x2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i8_3x2/input_0.cairo b/tests/nodes/matmul_i8_3x2/input_0.cairo new file mode 100644 index 000000000..bd2e04ea3 --- /dev/null +++ b/tests/nodes/matmul_i8_3x2/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(-3); + data.append(0); + data.append(1); + data.append(3); + data.append(-4); + data.append(0); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x2/input_1.cairo b/tests/nodes/matmul_i8_3x2/input_1.cairo new file mode 100644 index 000000000..b805ecc1b --- /dev/null +++ b/tests/nodes/matmul_i8_3x2/input_1.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-4); + data.append(-3); + data.append(2); + data.append(-2); + data.append(4); + data.append(3); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x2/output_0.cairo b/tests/nodes/matmul_i8_3x2/output_0.cairo new file mode 100644 index 000000000..595d54664 --- /dev/null +++ b/tests/nodes/matmul_i8_3x2/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(12); + data.append(9); + data.append(-6); + data.append(-10); + data.append(9); + data.append(11); + data.append(16); + data.append(12); + data.append(-8); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x3.cairo b/tests/nodes/matmul_i8_3x3.cairo new file mode 100644 index 000000000..d19201bc5 --- /dev/null +++ b/tests/nodes/matmul_i8_3x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_i8_3x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_i8_3x3/input_0.cairo b/tests/nodes/matmul_i8_3x3/input_0.cairo new file mode 100644 index 000000000..c75e3249f --- /dev/null +++ b/tests/nodes/matmul_i8_3x3/input_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(0); + data.append(-2); + data.append(0); + data.append(0); + data.append(2); + data.append(4); + data.append(-1); + data.append(2); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x3/input_1.cairo b/tests/nodes/matmul_i8_3x3/input_1.cairo new file mode 100644 index 000000000..c89d430ea --- /dev/null +++ b/tests/nodes/matmul_i8_3x3/input_1.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-2); + data.append(2); + data.append(-2); + data.append(-3); + data.append(3); + data.append(3); + data.append(3); + data.append(-3); + data.append(0); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_i8_3x3/output_0.cairo b/tests/nodes/matmul_i8_3x3/output_0.cairo new file mode 100644 index 000000000..76c95abad --- /dev/null +++ b/tests/nodes/matmul_i8_3x3/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(-6); + data.append(6); + data.append(0); + data.append(6); + data.append(-6); + data.append(0); + data.append(1); + data.append(-1); + data.append(-11); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_1d.cairo b/tests/nodes/matmul_u32_1d.cairo index ae57d6e50..b84cc8812 100644 --- a/tests/nodes/matmul_u32_1d.cairo +++ b/tests/nodes/matmul_u32_1d.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_u32_1d() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_u32_1d/input_0.cairo b/tests/nodes/matmul_u32_1d/input_0.cairo index 64ee3bf05..229bc7883 100644 --- a/tests/nodes/matmul_u32_1d/input_0.cairo +++ b/tests/nodes/matmul_u32_1d/input_0.cairo @@ -1,14 +1,15 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(184); - data.append(244); - data.append(49); + data.append(16); + data.append(127); + data.append(231); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_1d/input_1.cairo b/tests/nodes/matmul_u32_1d/input_1.cairo index df7267f29..26ae0aaf7 100644 --- a/tests/nodes/matmul_u32_1d/input_1.cairo +++ b/tests/nodes/matmul_u32_1d/input_1.cairo @@ -1,14 +1,15 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(45); - data.append(178); - data.append(105); + data.append(163); + data.append(195); + data.append(185); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_1d/output_0.cairo b/tests/nodes/matmul_u32_1d/output_0.cairo index 60b599a48..35a22d564 100644 --- a/tests/nodes/matmul_u32_1d/output_0.cairo +++ b/tests/nodes/matmul_u32_1d/output_0.cairo @@ -1,12 +1,13 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(56857); + data.append(70108); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_1x2.cairo b/tests/nodes/matmul_u32_1x2.cairo index cb582aa3c..0856bb729 100644 --- a/tests/nodes/matmul_u32_1x2.cairo +++ b/tests/nodes/matmul_u32_1x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_u32_1x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_u32_1x2/input_0.cairo b/tests/nodes/matmul_u32_1x2/input_0.cairo index a96df492a..9f68aa39d 100644 --- a/tests/nodes/matmul_u32_1x2/input_0.cairo +++ b/tests/nodes/matmul_u32_1x2/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(204); - data.append(167); + data.append(122); + data.append(199); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_1x2/input_1.cairo b/tests/nodes/matmul_u32_1x2/input_1.cairo index e429fc357..42c2d9897 100644 --- a/tests/nodes/matmul_u32_1x2/input_1.cairo +++ b/tests/nodes/matmul_u32_1x2/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(179); - data.append(76); + data.append(8); + data.append(160); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_1x2/output_0.cairo b/tests/nodes/matmul_u32_1x2/output_0.cairo index e3b6627c5..43abf5702 100644 --- a/tests/nodes/matmul_u32_1x2/output_0.cairo +++ b/tests/nodes/matmul_u32_1x2/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,6 +9,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(49208); + data.append(32816); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_1x3.cairo b/tests/nodes/matmul_u32_1x3.cairo new file mode 100644 index 000000000..fd272e643 --- /dev/null +++ b/tests/nodes/matmul_u32_1x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_u32_1x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_u32_1x3/input_0.cairo b/tests/nodes/matmul_u32_1x3/input_0.cairo new file mode 100644 index 000000000..6ada533dd --- /dev/null +++ b/tests/nodes/matmul_u32_1x3/input_0.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(135); + data.append(89); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_1x3/input_1.cairo b/tests/nodes/matmul_u32_1x3/input_1.cairo new file mode 100644 index 000000000..a3c8e0327 --- /dev/null +++ b/tests/nodes/matmul_u32_1x3/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(59); + data.append(214); + data.append(194); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_1x3/output_0.cairo b/tests/nodes/matmul_u32_1x3/output_0.cairo new file mode 100644 index 000000000..c00365a84 --- /dev/null +++ b/tests/nodes/matmul_u32_1x3/output_0.cairo @@ -0,0 +1,14 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(37293); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_2x1.cairo b/tests/nodes/matmul_u32_2x1.cairo index b7d44036c..e9d140c76 100644 --- a/tests/nodes/matmul_u32_2x1.cairo +++ b/tests/nodes/matmul_u32_2x1.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_u32_2x1() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_u32_2x1/input_0.cairo b/tests/nodes/matmul_u32_2x1/input_0.cairo index 3d176b2d4..2a15839de 100644 --- a/tests/nodes/matmul_u32_2x1/input_0.cairo +++ b/tests/nodes/matmul_u32_2x1/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(104); - data.append(169); + data.append(236); + data.append(5); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_2x1/input_1.cairo b/tests/nodes/matmul_u32_2x1/input_1.cairo index 98f62f818..27dbf2558 100644 --- a/tests/nodes/matmul_u32_2x1/input_1.cairo +++ b/tests/nodes/matmul_u32_2x1/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,7 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(118); - data.append(37); + data.append(176); + data.append(137); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_2x1/output_0.cairo b/tests/nodes/matmul_u32_2x1/output_0.cairo index 9b9591e02..7c12d9ce1 100644 --- a/tests/nodes/matmul_u32_2x1/output_0.cairo +++ b/tests/nodes/matmul_u32_2x1/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(12272); - data.append(3848); - data.append(19942); - data.append(6253); + data.append(41536); + data.append(32332); + data.append(880); + data.append(685); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_2x2.cairo b/tests/nodes/matmul_u32_2x2.cairo index c77f429ca..f8c34e5e7 100644 --- a/tests/nodes/matmul_u32_2x2.cairo +++ b/tests/nodes/matmul_u32_2x2.cairo @@ -3,20 +3,20 @@ mod input_1; mod output_0; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; use orion::utils::{assert_eq, assert_seq_eq}; -use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; #[test] #[available_gas(2000000000)] fn test_matmul_u32_2x2() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); - let z = output_0::output_0(); + let z_0 = output_0::output_0(); - let y = input_0.matmul(@input_1); + let y_0 = input_0.matmul(@input_1); - assert_eq(y, z); + assert_eq(y_0, z_0); } diff --git a/tests/nodes/matmul_u32_2x2/input_0.cairo b/tests/nodes/matmul_u32_2x2/input_0.cairo index 5929a9588..c9a8fd345 100644 --- a/tests/nodes/matmul_u32_2x2/input_0.cairo +++ b/tests/nodes/matmul_u32_2x2/input_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(162); - data.append(101); - data.append(130); - data.append(82); + data.append(84); + data.append(89); + data.append(77); + data.append(17); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_2x2/input_1.cairo b/tests/nodes/matmul_u32_2x2/input_1.cairo index 7c2581c10..73f07708f 100644 --- a/tests/nodes/matmul_u32_2x2/input_1.cairo +++ b/tests/nodes/matmul_u32_2x2/input_1.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(149); - data.append(196); - data.append(137); - data.append(132); + data.append(96); + data.append(220); + data.append(222); + data.append(248); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_2x2/output_0.cairo b/tests/nodes/matmul_u32_2x2/output_0.cairo index 9183714e6..f7c298cf7 100644 --- a/tests/nodes/matmul_u32_2x2/output_0.cairo +++ b/tests/nodes/matmul_u32_2x2/output_0.cairo @@ -1,6 +1,7 @@ use core::array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -8,9 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(37975); - data.append(45084); - data.append(30604); - data.append(36304); + data.append(27822); + data.append(40552); + data.append(11166); + data.append(21156); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/matmul_u32_2x3.cairo b/tests/nodes/matmul_u32_2x3.cairo new file mode 100644 index 000000000..ded636f5a --- /dev/null +++ b/tests/nodes/matmul_u32_2x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_u32_2x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_u32_2x3/input_0.cairo b/tests/nodes/matmul_u32_2x3/input_0.cairo new file mode 100644 index 000000000..c277cb556 --- /dev/null +++ b/tests/nodes/matmul_u32_2x3/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(24); + data.append(212); + data.append(46); + data.append(231); + data.append(207); + data.append(195); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_2x3/input_1.cairo b/tests/nodes/matmul_u32_2x3/input_1.cairo new file mode 100644 index 000000000..383e46070 --- /dev/null +++ b/tests/nodes/matmul_u32_2x3/input_1.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(79); + data.append(66); + data.append(200); + data.append(119); + data.append(96); + data.append(86); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_2x3/output_0.cairo b/tests/nodes/matmul_u32_2x3/output_0.cairo new file mode 100644 index 000000000..0ccf8dcaf --- /dev/null +++ b/tests/nodes/matmul_u32_2x3/output_0.cairo @@ -0,0 +1,17 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(48712); + data.append(30768); + data.append(78369); + data.append(56649); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x1.cairo b/tests/nodes/matmul_u32_3x1.cairo new file mode 100644 index 000000000..16f7b9aa9 --- /dev/null +++ b/tests/nodes/matmul_u32_3x1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_u32_3x1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_u32_3x1/input_0.cairo b/tests/nodes/matmul_u32_3x1/input_0.cairo new file mode 100644 index 000000000..3aeb1248b --- /dev/null +++ b/tests/nodes/matmul_u32_3x1/input_0.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(1); + + let mut data = ArrayTrait::new(); + data.append(24); + data.append(178); + data.append(187); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x1/input_1.cairo b/tests/nodes/matmul_u32_3x1/input_1.cairo new file mode 100644 index 000000000..d9b10c9bb --- /dev/null +++ b/tests/nodes/matmul_u32_3x1/input_1.cairo @@ -0,0 +1,16 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(1); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(113); + data.append(105); + data.append(69); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x1/output_0.cairo b/tests/nodes/matmul_u32_3x1/output_0.cairo new file mode 100644 index 000000000..ceb98bbea --- /dev/null +++ b/tests/nodes/matmul_u32_3x1/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(2712); + data.append(2520); + data.append(1656); + data.append(20114); + data.append(18690); + data.append(12282); + data.append(21131); + data.append(19635); + data.append(12903); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x2.cairo b/tests/nodes/matmul_u32_3x2.cairo new file mode 100644 index 000000000..ddf6b5443 --- /dev/null +++ b/tests/nodes/matmul_u32_3x2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_u32_3x2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_u32_3x2/input_0.cairo b/tests/nodes/matmul_u32_3x2/input_0.cairo new file mode 100644 index 000000000..b148debcc --- /dev/null +++ b/tests/nodes/matmul_u32_3x2/input_0.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(168); + data.append(145); + data.append(105); + data.append(239); + data.append(134); + data.append(46); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x2/input_1.cairo b/tests/nodes/matmul_u32_3x2/input_1.cairo new file mode 100644 index 000000000..b569e7b7f --- /dev/null +++ b/tests/nodes/matmul_u32_3x2/input_1.cairo @@ -0,0 +1,19 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(180); + data.append(127); + data.append(187); + data.append(90); + data.append(122); + data.append(127); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x2/output_0.cairo b/tests/nodes/matmul_u32_3x2/output_0.cairo new file mode 100644 index 000000000..2643aaae7 --- /dev/null +++ b/tests/nodes/matmul_u32_3x2/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(43290); + data.append(39026); + data.append(49831); + data.append(40410); + data.append(42493); + data.append(49988); + data.append(28260); + data.append(22630); + data.append(30900); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x3.cairo b/tests/nodes/matmul_u32_3x3.cairo new file mode 100644 index 000000000..fa26425fa --- /dev/null +++ b/tests/nodes/matmul_u32_3x3.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::operators::tensor::U32TensorPartialEq; +use core::array::{ArrayTrait, SpanTrait}; + +#[test] +#[available_gas(2000000000)] +fn test_matmul_u32_3x3() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z_0 = output_0::output_0(); + + let y_0 = input_0.matmul(@input_1); + + assert_eq(y_0, z_0); +} diff --git a/tests/nodes/matmul_u32_3x3/input_0.cairo b/tests/nodes/matmul_u32_3x3/input_0.cairo new file mode 100644 index 000000000..28da8a13b --- /dev/null +++ b/tests/nodes/matmul_u32_3x3/input_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(55); + data.append(83); + data.append(66); + data.append(57); + data.append(209); + data.append(111); + data.append(241); + data.append(47); + data.append(93); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x3/input_1.cairo b/tests/nodes/matmul_u32_3x3/input_1.cairo new file mode 100644 index 000000000..7b3138ad8 --- /dev/null +++ b/tests/nodes/matmul_u32_3x3/input_1.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(69); + data.append(239); + data.append(34); + data.append(181); + data.append(78); + data.append(99); + data.append(160); + data.append(74); + data.append(236); + TensorTrait::new(shape.span(), data.span()) +} diff --git a/tests/nodes/matmul_u32_3x3/output_0.cairo b/tests/nodes/matmul_u32_3x3/output_0.cairo new file mode 100644 index 000000000..7ecb476f3 --- /dev/null +++ b/tests/nodes/matmul_u32_3x3/output_0.cairo @@ -0,0 +1,22 @@ +use core::array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::numbers::NumberTrait; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(29378); + data.append(24503); + data.append(25663); + data.append(59522); + data.append(38139); + data.append(48825); + data.append(40016); + data.append(68147); + data.append(34795); + TensorTrait::new(shape.span(), data.span()) +} From 2ef8757a311c46663a6da3c584f78e26ea26d61c Mon Sep 17 00:00:00 2001 From: bemtg Date: Mon, 30 Dec 2024 20:11:35 +0000 Subject: [PATCH 5/5] updating the matmul doc guide --- .../operators/tensor/tensor.matmul.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/framework/operators/tensor/tensor.matmul.md b/docs/framework/operators/tensor/tensor.matmul.md index dce511f10..e68d5ba99 100644 --- a/docs/framework/operators/tensor/tensor.matmul.md +++ b/docs/framework/operators/tensor/tensor.matmul.md @@ -85,3 +85,25 @@ fn matrix_vec_mul_example() -> Tensor { } >>> [5,14,23] ``` +``` + +Case 4: Matrix multiplication (3D \* 2D) + +```rust +use core::array::{ArrayTrait, SpanTrait}; + +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; + +fn matrix_mul_example() -> Tensor { + let tensor_1 = TensorTrait::::new( + shape: array![3, 2].span(), data: array![243, 185, 207, 31, 183, 250].span() + ); + + let tensor_2 = TensorTrait::::new( + shape: array![2, 3].span(), data: array![143, 215, 214, 80, 174, 21 ].span() + ); + + // We can call `matmul` function as follows. + return tensor_1.matmul(@tensor_2); +} +>>> [[49549, 84435, 55887],[32081, 49899, 44949], [46169, 82845, 44412]] \ No newline at end of file