diff --git a/docs/framework/operators/tensor/tensor.and.md b/docs/framework/operators/tensor/tensor.and.md index 94556ce0f..2c2b74f16 100644 --- a/docs/framework/operators/tensor/tensor.and.md +++ b/docs/framework/operators/tensor/tensor.and.md @@ -1,7 +1,7 @@ #tensor.and ```rust - fn and(self: @Tensor, other: @Tensor) -> Tensor; + fn and(self: @Tensor, other: @Tensor) -> Tensor; ``` Computes the logical AND of two tensors element-wise. @@ -11,8 +11,8 @@ The input tensors must have either: ## Args -* `self`(`@Tensor`) - The first tensor to be compared -* `other`(`@Tensor`) - The second tensor to be compared +* `self`(`@Tensor`) - The first tensor to be compared +* `other`(`@Tensor`) - The second tensor to be compared ## Panics @@ -20,48 +20,25 @@ The input tensors must have either: ## Returns -A new `Tensor` of booleans (0 or 1) with the same shape as the broadcasted inputs. +A new `Tensor` with the same shape as the broadcasted inputs. ## Examples -Case 1: Compare tensors with same shape - -```rust -use array::{ArrayTrait, SpanTrait}; - -use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; - -fn and_example() -> Tensor { - let tensor_1 = TensorTrait::::new( - shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - ); - - let tensor_2 = TensorTrait::::new( - shape: array![3, 3].span(), data: array![0, 1, 2, 0, 1, 2, 0, 1, 2].span(), - ); - - return tensor_1.and(@tensor_2); -} ->>> [0,1,1,0,1,1,0,1,1] -``` - -Case 2: Compare tensors with different shapes - ```rust use array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; -fn and_example() -> Tensor { - let tensor_1 = TensorTrait::::new( - shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), +fn and_example() -> Tensor { + let tensor_1 = TensorTrait::::new( + shape: array![3, 3].span(), data: array![false, true, false, false, false, true, true, false, true, false, false, true].span(), ); - let tensor_2 = TensorTrait::::new( - shape: array![1, 3].span(), data: array![0, 1, 2].span(), + let tensor_2 = TensorTrait::::new( + shape: array![3, 3].span(), data: array![false, false, true, true, false, true, false, true, false, true, false, true].span(), ); return tensor_1.and(@tensor_2); } ->>> [0,1,1,0,1,1,0,1,1] +>>> [false, false, false, false, false, true, false, false, false, false, false, true] ``` diff --git a/nodegen/node/and.py b/nodegen/node/and.py index 6ef5ea17f..dfd28caf0 100644 --- a/nodegen/node/and.py +++ b/nodegen/node/and.py @@ -5,153 +5,29 @@ class And(RunAll): @staticmethod - def and_u32(): + def and_bool(): def default(): - x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32) - y = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32) + x = (np.random.randn(3, 4) > 0).astype(bool) + y = (np.random.randn(3, 4) > 0).astype(bool) z = np.logical_and(x, y) - x = Tensor(Dtype.U32, x.shape, x.flatten()) - y = Tensor(Dtype.U32, y.shape, y.flatten()) + x = Tensor(Dtype.BOOL, x.shape, x.flatten()) + y = Tensor(Dtype.BOOL, y.shape, y.flatten()) z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - name = "and_u32" + name = "and_bool" make_test([x, y], z, "input_0.and(@input_1)", name) def broadcast(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.random.randint(0, 6, (1, 2)).astype(np.uint32) + x = (np.random.randn(3, 4, 5) > 0).astype(bool) + y = (np.random.randn(4, 5) > 0).astype(bool) z = np.logical_and(x, y) - x = Tensor(Dtype.U32, x.shape, x.flatten()) - y = Tensor(Dtype.U32, y.shape, y.flatten()) + x = Tensor(Dtype.BOOL, x.shape, x.flatten()) + y = Tensor(Dtype.BOOL, y.shape, y.flatten()) z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - name = "and_u32_broadcast" - make_test([x, y], z, "input_0.and(@input_1)", name) - - default() - broadcast() - - @staticmethod - def and_i32(): - def default(): - x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int32) - y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int32) - z = np.logical_and(x, y) - - x = Tensor(Dtype.I32, x.shape, x.flatten()) - y = Tensor(Dtype.I32, y.shape, y.flatten()) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_i32" - make_test([x, y], z, "input_0.and(@input_1)", name) - - def broadcast(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.random.randint(-3, 3, (1, 2)).astype(np.int32) - z = np.logical_and(x, y) - - x = Tensor(Dtype.I32, x.shape, x.flatten()) - y = Tensor(Dtype.I32, y.shape, y.flatten()) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_i32_broadcast" - make_test([x, y], z, "input_0.and(@input_1)", name) - - default() - broadcast() - - @staticmethod - def and_i8(): - def default(): - x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int8) - y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int8) - z = np.logical_and(x, y) - - x = Tensor(Dtype.I8, x.shape, x.flatten()) - y = Tensor(Dtype.I8, y.shape, y.flatten()) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_i8" - make_test([x, y], z, "input_0.and(@input_1)", name) - - def broadcast(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = np.random.randint(-3, 3, (1, 2)).astype(np.int8) - z = np.logical_and(x, y) - - x = Tensor(Dtype.I8, x.shape, x.flatten()) - y = Tensor(Dtype.I8, y.shape, y.flatten()) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_i8_broadcast" - make_test([x, y], z, "input_0.and(@input_1)", name) - - default() - broadcast() - - @staticmethod - def and_fp8x23(): - def default(): - x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) - y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) - z = np.logical_and(x, y) - - x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23)) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23)) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_fp8x23" - make_test([x, y], z, "input_0.and(@input_1)", name) - - def broadcast(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.float64) - y = np.random.randint(-3, 3, (1, 2)).astype(np.float64) - z = np.logical_and(x, y) - - x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23)) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23)) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_fp8x23_broadcast" - make_test([x, y], z, "input_0.and(@input_1)", name) - - default() - broadcast() - - @staticmethod - def and_fp16x16(): - def default(): - x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) - y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) - z = np.logical_and(x, y) - - x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16)) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16)) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_fp16x16" - make_test([x, y], z, "input_0.and(@input_1)", name) - - def broadcast(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.float64) - y = np.random.randint(-3, 3, (1, 2)).astype(np.float64) - z = np.logical_and(x, y) - - x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16)) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16)) - z = Tensor(Dtype.BOOL, z.shape, z.flatten()) - - name = "and_fp16x16_broadcast" + name = "and_bool_broadcast" make_test([x, y], z, "input_0.and(@input_1)", name) default() diff --git a/src/operators/tensor/core.cairo b/src/operators/tensor/core.cairo index d2ffdb12a..75f90224f 100644 --- a/src/operators/tensor/core.cairo +++ b/src/operators/tensor/core.cairo @@ -3452,7 +3452,7 @@ trait TensorTrait { /// #tensor.and /// /// ```rust - /// fn and(self: @Tensor, other: @Tensor) -> Tensor; + /// fn and(self: @Tensor, other: @Tensor) -> Tensor; /// ``` /// /// Computes the logical AND of two tensors element-wise. @@ -3462,8 +3462,8 @@ trait TensorTrait { /// /// ## Args /// - /// * `self`(`@Tensor`) - The first tensor to be compared - /// * `other`(`@Tensor`) - The second tensor to be compared + /// * `self`(`@Tensor`) - The first tensor to be compared + /// * `other`(`@Tensor`) - The second tensor to be compared /// /// ## Panics /// @@ -3475,49 +3475,26 @@ trait TensorTrait { /// /// ## Examples /// - /// Case 1: Compare tensors with same shape - /// - /// ```rust - /// use array::{ArrayTrait, SpanTrait}; - /// - /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; - /// - /// fn and_example() -> Tensor { - /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - /// ); - /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![3, 3].span(), data: array![0, 1, 2, 0, 1, 2, 0, 1, 2].span(), - /// ); - /// - /// return tensor_1.and(@tensor_2); - /// } - /// >>> [false, true, true, false, true, true, false, true, true] - /// ``` - /// - /// Case 2: Compare tensors with different shapes - /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn and_example() -> Tensor { - /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), + /// let tensor_1 = TensorTrait::::new( + /// shape: array![3, 3].span(), data: array![false, true, false, false, false, true, true, false, true, false, false, true].span(), /// ); /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![1, 3].span(), data: array![0, 1, 2].span(), + /// let tensor_2 = TensorTrait::::new( + /// shape: array![3, 3].span(), data: array![false, false, true, true, false, true, false, true, false, true, false, true].span(), /// ); /// /// return tensor_1.and(@tensor_2); /// } - /// >>> [false, true, true, false, true, true, false, true, true] + /// >>> [false, false, false, false, false, true, false, false, false, false, false, true] /// ``` /// - fn and(self: @Tensor, other: @Tensor) -> Tensor; + fn and(self: @Tensor, other: @Tensor) -> Tensor; /// #tensor.where /// /// ```rust diff --git a/src/operators/tensor/implementations/tensor_bool.cairo b/src/operators/tensor/implementations/tensor_bool.cairo index cfd6639db..c0a8d1ceb 100644 --- a/src/operators/tensor/implementations/tensor_bool.cairo +++ b/src/operators/tensor/implementations/tensor_bool.cairo @@ -257,7 +257,7 @@ impl BoolTensor of TensorTrait { } fn and(self: @Tensor, other: @Tensor) -> Tensor { - panic(array!['not supported!']) + math::and::and(self, other) } fn identity(self: @Tensor) -> Tensor { diff --git a/src/operators/tensor/implementations/tensor_fp16x16.cairo b/src/operators/tensor/implementations/tensor_fp16x16.cairo index 33829c816..dee654729 100644 --- a/src/operators/tensor/implementations/tensor_fp16x16.cairo +++ b/src/operators/tensor/implementations/tensor_fp16x16.cairo @@ -372,7 +372,7 @@ impl FP16x16Tensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_fp16x16wide.cairo b/src/operators/tensor/implementations/tensor_fp16x16wide.cairo index c892b9c0f..2f89df88b 100644 --- a/src/operators/tensor/implementations/tensor_fp16x16wide.cairo +++ b/src/operators/tensor/implementations/tensor_fp16x16wide.cairo @@ -334,7 +334,7 @@ impl FP16x16WTensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_fp32x32.cairo b/src/operators/tensor/implementations/tensor_fp32x32.cairo index 2f804c750..7517ef7cd 100644 --- a/src/operators/tensor/implementations/tensor_fp32x32.cairo +++ b/src/operators/tensor/implementations/tensor_fp32x32.cairo @@ -373,7 +373,7 @@ impl FP32x32Tensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_fp64x64.cairo b/src/operators/tensor/implementations/tensor_fp64x64.cairo index 6e8ec0dc0..d4c7e0a2b 100644 --- a/src/operators/tensor/implementations/tensor_fp64x64.cairo +++ b/src/operators/tensor/implementations/tensor_fp64x64.cairo @@ -373,7 +373,7 @@ impl FP64x64Tensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_fp8x23.cairo b/src/operators/tensor/implementations/tensor_fp8x23.cairo index 7ef733cfc..1f10a73a5 100644 --- a/src/operators/tensor/implementations/tensor_fp8x23.cairo +++ b/src/operators/tensor/implementations/tensor_fp8x23.cairo @@ -373,7 +373,7 @@ impl FP8x23Tensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_fp8x23wide.cairo b/src/operators/tensor/implementations/tensor_fp8x23wide.cairo index a81f87d20..fc820222d 100644 --- a/src/operators/tensor/implementations/tensor_fp8x23wide.cairo +++ b/src/operators/tensor/implementations/tensor_fp8x23wide.cairo @@ -323,7 +323,7 @@ impl FP8x23WTensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_i32.cairo b/src/operators/tensor/implementations/tensor_i32.cairo index e54dc6a35..106daa208 100644 --- a/src/operators/tensor/implementations/tensor_i32.cairo +++ b/src/operators/tensor/implementations/tensor_i32.cairo @@ -371,7 +371,7 @@ impl I32Tensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_i8.cairo b/src/operators/tensor/implementations/tensor_i8.cairo index 56386bdd1..d9bb40cb1 100644 --- a/src/operators/tensor/implementations/tensor_i8.cairo +++ b/src/operators/tensor/implementations/tensor_i8.cairo @@ -371,7 +371,7 @@ impl I8Tensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } diff --git a/src/operators/tensor/implementations/tensor_u32.cairo b/src/operators/tensor/implementations/tensor_u32.cairo index 003ed3380..288c834e9 100644 --- a/src/operators/tensor/implementations/tensor_u32.cairo +++ b/src/operators/tensor/implementations/tensor_u32.cairo @@ -315,7 +315,7 @@ impl U32Tensor of TensorTrait { core::clip(self, min, max) } - fn and(self: @Tensor, other: @Tensor) -> Tensor { + fn and(self: @Tensor, other: @Tensor) -> Tensor { math::and::and(self, other) } @@ -334,7 +334,7 @@ impl U32Tensor of TensorTrait { fn bitwise_xor(self: @Tensor, other: @Tensor) -> Tensor { math::bitwise_xor::bitwise_xor(self, other) } - + fn bitwise_or(self: @Tensor, other: @Tensor) -> Tensor { math::bitwise_or::bitwise_or(self, other) } @@ -376,12 +376,14 @@ impl U32Tensor of TensorTrait { fn reduce_l2(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { panic(array!['not supported!']) } - + fn not(self: @Tensor) -> Tensor { panic(array!['not supported!']) } - fn gather_elements(self: @Tensor, indices: Tensor, axis: Option) -> Tensor { + fn gather_elements( + self: @Tensor, indices: Tensor, axis: Option + ) -> Tensor { math::gather_elements::gather_elements(self, indices, axis) } @@ -439,15 +441,19 @@ impl U32Tensor of TensorTrait { math::sequence_insert::sequence_insert(self, tensor, position) } - fn is_inf(self: @Tensor, detect_negative: Option, detect_positive: Option) -> Tensor { - math::is_inf::is_inf(self, detect_negative, detect_positive) + fn is_inf( + self: @Tensor, detect_negative: Option, detect_positive: Option + ) -> Tensor { + math::is_inf::is_inf(self, detect_negative, detect_positive) } fn is_nan(self: @Tensor) -> Tensor { panic(array!['not supported!']) } - fn concat_from_sequence(sequence: Array>, axis: i32, new_axis: Option) -> Tensor { + fn concat_from_sequence( + sequence: Array>, axis: i32, new_axis: Option + ) -> Tensor { math::concat_from_sequence::concat_from_sequence(sequence, axis, new_axis) } } diff --git a/src/operators/tensor/math/and.cairo b/src/operators/tensor/math/and.cairo index 1f31dc8de..123ae335a 100644 --- a/src/operators/tensor/math/and.cairo +++ b/src/operators/tensor/math/and.cairo @@ -3,22 +3,13 @@ use option::OptionTrait; use array::SpanTrait; use orion::numbers::NumberTrait; -use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::{core::{Tensor, TensorTrait, unravel_index}, BoolTensor}; use orion::operators::tensor::helpers::{ broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility }; /// Cf: TensorTrait::and docstring -fn and< - T, - MAG, - impl TNumber: NumberTrait, - impl UsizeFTensor: TensorTrait, - impl TCopy: Copy, - impl TDrop: Drop ->( - y: @Tensor, z: @Tensor -) -> Tensor { +fn and(y: @Tensor, z: @Tensor) -> Tensor { let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); let mut result: Array = ArrayTrait::new(); @@ -31,11 +22,7 @@ fn and< let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); - if NumberTrait::and(*(*y.data)[indices_self], *(*z.data)[indices_other]) { - result.append(true); - } else { - result.append(false); - } + result.append(*(*y.data)[indices_self] && *(*z.data)[indices_other]); n += 1; if n == num_elements { diff --git a/tests/nodes.cairo b/tests/nodes.cairo index f7986bb13..12bc31c9b 100644 --- a/tests/nodes.cairo +++ b/tests/nodes.cairo @@ -433,16 +433,6 @@ mod clip_i8_2d; mod clip_i8_3d; mod clip_u32_2d; mod clip_u32_3d; -mod and_fp16x16; -mod and_fp16x16_broadcast; -mod and_fp8x23; -mod and_fp8x23_broadcast; -mod and_i32; -mod and_i32_broadcast; -mod and_i8; -mod and_i8_broadcast; -mod and_u32; -mod and_u32_broadcast; mod identity_fP16x16; mod identity_fP8x23; mod identity_i32; @@ -829,3 +819,4 @@ mod is_pos_inf_i32; mod is_neg_inf_i32; mod is_pos_inf_i8; mod is_neg_inf_i8; +mod and_bool; diff --git a/tests/nodes/and_i8.cairo b/tests/nodes/and_bool.cairo similarity index 75% rename from tests/nodes/and_i8.cairo rename to tests/nodes/and_bool.cairo index e662e0869..d858d66bc 100644 --- a/tests/nodes/and_i8.cairo +++ b/tests/nodes/and_bool.cairo @@ -3,22 +3,20 @@ mod input_1; mod output_0; -use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::BoolTensor; +use orion::operators::tensor::BoolTensorPartialEq; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I8Tensor; -use orion::operators::tensor::I8TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; #[test] #[available_gas(2000000000)] -fn test_and_i8() { +fn test_and_bool() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); let z = output_0::output_0(); - let y = input_0.and(@input_1); + let y = BoolTensor::and(@input_0, @input_1); assert_eq(y, z); } diff --git a/tests/nodes/and_fp8x23_broadcast/output_0.cairo b/tests/nodes/and_bool/input_0.cairo similarity index 57% rename from tests/nodes/and_fp8x23_broadcast/output_0.cairo rename to tests/nodes/and_bool/input_0.cairo index c58f10275..4c8339cbc 100644 --- a/tests/nodes/and_fp8x23_broadcast/output_0.cairo +++ b/tests/nodes/and_bool/input_0.cairo @@ -2,15 +2,23 @@ use array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; use orion::operators::tensor::BoolTensor; -fn output_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); + shape.append(3); + shape.append(4); let mut data = ArrayTrait::new(); + data.append(false); + data.append(true); + data.append(false); + data.append(false); + data.append(false); + data.append(true); data.append(true); + data.append(false); data.append(true); data.append(false); + data.append(false); data.append(true); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/and_i32_broadcast/output_0.cairo b/tests/nodes/and_bool/input_1.cairo similarity index 58% rename from tests/nodes/and_i32_broadcast/output_0.cairo rename to tests/nodes/and_bool/input_1.cairo index b77d9ccb8..1a0058463 100644 --- a/tests/nodes/and_i32_broadcast/output_0.cairo +++ b/tests/nodes/and_bool/input_1.cairo @@ -2,13 +2,21 @@ use array::{ArrayTrait, SpanTrait}; use orion::operators::tensor::{TensorTrait, Tensor}; use orion::operators::tensor::BoolTensor; -fn output_0() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); + shape.append(3); + shape.append(4); let mut data = ArrayTrait::new(); data.append(false); + data.append(false); + data.append(true); + data.append(true); + data.append(false); + data.append(true); + data.append(false); + data.append(true); + data.append(false); data.append(true); data.append(false); data.append(true); diff --git a/tests/nodes/and_fp16x16_broadcast/output_0.cairo b/tests/nodes/and_bool/output_0.cairo similarity index 62% rename from tests/nodes/and_fp16x16_broadcast/output_0.cairo rename to tests/nodes/and_bool/output_0.cairo index 9123acad8..b094436db 100644 --- a/tests/nodes/and_fp16x16_broadcast/output_0.cairo +++ b/tests/nodes/and_bool/output_0.cairo @@ -4,13 +4,21 @@ use orion::operators::tensor::BoolTensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); + shape.append(3); + shape.append(4); let mut data = ArrayTrait::new(); data.append(false); data.append(false); data.append(false); + data.append(false); + data.append(false); + data.append(true); + data.append(false); + data.append(false); + data.append(false); + data.append(false); + data.append(false); data.append(true); TensorTrait::new(shape.span(), data.span()) } diff --git a/tests/nodes/and_i32.cairo b/tests/nodes/and_bool_broadcast.cairo similarity index 75% rename from tests/nodes/and_i32.cairo rename to tests/nodes/and_bool_broadcast.cairo index cce348f4f..fba23fd79 100644 --- a/tests/nodes/and_i32.cairo +++ b/tests/nodes/and_bool_broadcast.cairo @@ -3,22 +3,20 @@ mod input_1; mod output_0; -use orion::utils::{assert_eq, assert_seq_eq}; +use orion::operators::tensor::BoolTensor; +use orion::operators::tensor::BoolTensorPartialEq; use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::{assert_eq, assert_seq_eq}; use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::I32Tensor; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; #[test] #[available_gas(2000000000)] -fn test_and_i32() { +fn test_and_bool_broadcast() { let input_0 = input_0::input_0(); let input_1 = input_1::input_1(); let z = output_0::output_0(); - let y = input_0.and(@input_1); + let y = BoolTensor::and(@input_0, @input_1); assert_eq(y, z); } diff --git a/tests/nodes/and_fp16x16.cairo b/tests/nodes/and_fp16x16.cairo deleted file mode 100644 index 9eeff2023..000000000 --- a/tests/nodes/and_fp16x16.cairo +++ /dev/null @@ -1,24 +0,0 @@ -mod input_0; -mod input_1; -mod output_0; - - -use orion::utils::{assert_eq, assert_seq_eq}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; -use orion::operators::tensor::FP16x16TensorPartialEq; -use orion::operators::tensor::FP16x16Tensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_fp16x16() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_fp16x16/input_0.cairo b/tests/nodes/and_fp16x16/input_0.cairo deleted file mode 100644 index 7c02fb8d9..000000000 --- a/tests/nodes/and_fp16x16/input_0.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP16x16Tensor; -use orion::numbers::{FixedTrait, FP16x16}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - 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: 131072, sign: true }); - data.append(FP16x16 { mag: 0, sign: false }); - data.append(FP16x16 { mag: 65536, sign: true }); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 65536, sign: true }); - data.append(FP16x16 { mag: 65536, sign: false }); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 0, sign: false }); - data.append(FP16x16 { mag: 65536, sign: false }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 65536, sign: false }); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 0, sign: false }); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 65536, sign: false }); - 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/and_fp16x16/input_1.cairo b/tests/nodes/and_fp16x16/input_1.cairo deleted file mode 100644 index d072cc603..000000000 --- a/tests/nodes/and_fp16x16/input_1.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP16x16Tensor; -use orion::numbers::{FixedTrait, FP16x16}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - 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: 131072, sign: false }); - data.append(FP16x16 { mag: 131072, sign: false }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 65536, sign: false }); - data.append(FP16x16 { mag: 65536, sign: true }); - data.append(FP16x16 { mag: 65536, sign: true }); - data.append(FP16x16 { mag: 65536, sign: true }); - data.append(FP16x16 { mag: 0, sign: false }); - data.append(FP16x16 { mag: 131072, sign: true }); - 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: 196608, sign: true }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 0, sign: false }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 196608, sign: true }); - data.append(FP16x16 { mag: 65536, sign: true }); - data.append(FP16x16 { mag: 131072, sign: true }); - data.append(FP16x16 { mag: 65536, 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/and_fp16x16/output_0.cairo b/tests/nodes/and_fp16x16/output_0.cairo deleted file mode 100644 index 0417518fa..000000000 --- a/tests/nodes/and_fp16x16/output_0.cairo +++ /dev/null @@ -1,40 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::BoolTensor; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_fp16x16_broadcast.cairo b/tests/nodes/and_fp16x16_broadcast.cairo deleted file mode 100644 index 735da46d7..000000000 --- a/tests/nodes/and_fp16x16_broadcast.cairo +++ /dev/null @@ -1,24 +0,0 @@ -mod input_0; -mod input_1; -mod output_0; - - -use orion::utils::{assert_eq, assert_seq_eq}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; -use orion::operators::tensor::FP16x16TensorPartialEq; -use orion::operators::tensor::FP16x16Tensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_fp16x16_broadcast() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_fp16x16_broadcast/input_0.cairo b/tests/nodes/and_fp16x16_broadcast/input_0.cairo deleted file mode 100644 index e88a21894..000000000 --- a/tests/nodes/and_fp16x16_broadcast/input_0.cairo +++ /dev/null @@ -1,17 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP16x16Tensor; -use orion::numbers::{FixedTrait, FP16x16}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 65536, 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/and_fp16x16_broadcast/input_1.cairo b/tests/nodes/and_fp16x16_broadcast/input_1.cairo deleted file mode 100644 index a92003169..000000000 --- a/tests/nodes/and_fp16x16_broadcast/input_1.cairo +++ /dev/null @@ -1,15 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP16x16Tensor; -use orion::numbers::{FixedTrait, FP16x16}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(1); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FP16x16 { mag: 0, sign: false }); - data.append(FP16x16 { mag: 196608, sign: true }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_fp8x23.cairo b/tests/nodes/and_fp8x23.cairo deleted file mode 100644 index 4ed68acc3..000000000 --- a/tests/nodes/and_fp8x23.cairo +++ /dev/null @@ -1,24 +0,0 @@ -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::FP8x23TensorPartialEq; -use orion::operators::tensor::FP8x23Tensor; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_fp8x23() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_fp8x23/input_0.cairo b/tests/nodes/and_fp8x23/input_0.cairo deleted file mode 100644 index 09c47c6ad..000000000 --- a/tests/nodes/and_fp8x23/input_0.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP8x23Tensor; -use orion::numbers::{FixedTrait, FP8x23}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 25165824, sign: true }); - data.append(FP8x23 { mag: 16777216, sign: true }); - data.append(FP8x23 { mag: 25165824, sign: true }); - data.append(FP8x23 { mag: 16777216, sign: false }); - 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: 8388608, sign: true }); - data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: false }); - 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: 25165824, sign: true }); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 25165824, sign: true }); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: true }); - data.append(FP8x23 { mag: 25165824, sign: true }); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_fp8x23/input_1.cairo b/tests/nodes/and_fp8x23/input_1.cairo deleted file mode 100644 index 5286e4abe..000000000 --- a/tests/nodes/and_fp8x23/input_1.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP8x23Tensor; -use orion::numbers::{FixedTrait, FP8x23}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - 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: 8388608, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 25165824, sign: true }); - 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: 16777216, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: false }); - 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: 16777216, sign: true }); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 0, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 8388608, sign: true }); - data.append(FP8x23 { mag: 8388608, sign: false }); - data.append(FP8x23 { mag: 16777216, sign: true }); - data.append(FP8x23 { mag: 8388608, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_fp8x23/output_0.cairo b/tests/nodes/and_fp8x23/output_0.cairo deleted file mode 100644 index 30a68fb27..000000000 --- a/tests/nodes/and_fp8x23/output_0.cairo +++ /dev/null @@ -1,40 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::BoolTensor; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(false); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_fp8x23_broadcast.cairo b/tests/nodes/and_fp8x23_broadcast.cairo deleted file mode 100644 index c5e5aecc2..000000000 --- a/tests/nodes/and_fp8x23_broadcast.cairo +++ /dev/null @@ -1,24 +0,0 @@ -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::FP8x23TensorPartialEq; -use orion::operators::tensor::FP8x23Tensor; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_fp8x23_broadcast() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_fp8x23_broadcast/input_0.cairo b/tests/nodes/and_fp8x23_broadcast/input_0.cairo deleted file mode 100644 index 4d4602452..000000000 --- a/tests/nodes/and_fp8x23_broadcast/input_0.cairo +++ /dev/null @@ -1,17 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP8x23Tensor; -use orion::numbers::{FixedTrait, FP8x23}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 8388608, sign: false }); - 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/and_fp8x23_broadcast/input_1.cairo b/tests/nodes/and_fp8x23_broadcast/input_1.cairo deleted file mode 100644 index f357c23e3..000000000 --- a/tests/nodes/and_fp8x23_broadcast/input_1.cairo +++ /dev/null @@ -1,15 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::FP8x23Tensor; -use orion::numbers::{FixedTrait, FP8x23}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(1); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FP8x23 { mag: 16777216, sign: false }); - data.append(FP8x23 { mag: 8388608, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i32/input_0.cairo b/tests/nodes/and_i32/input_0.cairo deleted file mode 100644 index e7c8cedff..000000000 --- a/tests/nodes/and_i32/input_0.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I32Tensor; -use orion::numbers::{IntegerTrait, i32}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i32/input_1.cairo b/tests/nodes/and_i32/input_1.cairo deleted file mode 100644 index f1bb1ecdd..000000000 --- a/tests/nodes/and_i32/input_1.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I32Tensor; -use orion::numbers::{IntegerTrait, i32}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: true }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i32/output_0.cairo b/tests/nodes/and_i32/output_0.cairo deleted file mode 100644 index 279220947..000000000 --- a/tests/nodes/and_i32/output_0.cairo +++ /dev/null @@ -1,40 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::BoolTensor; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(false); - data.append(false); - data.append(false); - data.append(true); - data.append(true); - data.append(false); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i32_broadcast.cairo b/tests/nodes/and_i32_broadcast.cairo deleted file mode 100644 index 0a2c327ae..000000000 --- a/tests/nodes/and_i32_broadcast.cairo +++ /dev/null @@ -1,24 +0,0 @@ -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::I32TensorPartialEq; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::I32Tensor; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_i32_broadcast() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_i32_broadcast/input_0.cairo b/tests/nodes/and_i32_broadcast/input_0.cairo deleted file mode 100644 index 8bf3fb2fc..000000000 --- a/tests/nodes/and_i32_broadcast/input_0.cairo +++ /dev/null @@ -1,17 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I32Tensor; -use orion::numbers::{IntegerTrait, i32}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i32_broadcast/input_1.cairo b/tests/nodes/and_i32_broadcast/input_1.cairo deleted file mode 100644 index e0e0ce800..000000000 --- a/tests/nodes/and_i32_broadcast/input_1.cairo +++ /dev/null @@ -1,15 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I32Tensor; -use orion::numbers::{IntegerTrait, i32}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(1); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i8/input_0.cairo b/tests/nodes/and_i8/input_0.cairo deleted file mode 100644 index 831184af2..000000000 --- a/tests/nodes/and_i8/input_0.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I8Tensor; -use orion::numbers::{IntegerTrait, i8}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i8/input_1.cairo b/tests/nodes/and_i8/input_1.cairo deleted file mode 100644 index 441a56a0c..000000000 --- a/tests/nodes/and_i8/input_1.cairo +++ /dev/null @@ -1,41 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I8Tensor; -use orion::numbers::{IntegerTrait, i8}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i8/output_0.cairo b/tests/nodes/and_i8/output_0.cairo deleted file mode 100644 index cb879d158..000000000 --- a/tests/nodes/and_i8/output_0.cairo +++ /dev/null @@ -1,40 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::BoolTensor; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(false); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i8_broadcast.cairo b/tests/nodes/and_i8_broadcast.cairo deleted file mode 100644 index fb730f5c8..000000000 --- a/tests/nodes/and_i8_broadcast.cairo +++ /dev/null @@ -1,24 +0,0 @@ -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; -use orion::operators::tensor::I8TensorPartialEq; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_i8_broadcast() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_i8_broadcast/input_0.cairo b/tests/nodes/and_i8_broadcast/input_0.cairo deleted file mode 100644 index 9b56de844..000000000 --- a/tests/nodes/and_i8_broadcast/input_0.cairo +++ /dev/null @@ -1,17 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I8Tensor; -use orion::numbers::{IntegerTrait, i8}; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i8_broadcast/input_1.cairo b/tests/nodes/and_i8_broadcast/input_1.cairo deleted file mode 100644 index 9a3d0511b..000000000 --- a/tests/nodes/and_i8_broadcast/input_1.cairo +++ /dev/null @@ -1,15 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::I8Tensor; -use orion::numbers::{IntegerTrait, i8}; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(1); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_i8_broadcast/output_0.cairo b/tests/nodes/and_i8_broadcast/output_0.cairo deleted file mode 100644 index cfa512f61..000000000 --- a/tests/nodes/and_i8_broadcast/output_0.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::BoolTensor; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_u32.cairo b/tests/nodes/and_u32.cairo deleted file mode 100644 index cd0223fe3..000000000 --- a/tests/nodes/and_u32.cairo +++ /dev/null @@ -1,24 +0,0 @@ -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::U32TensorPartialEq; -use orion::operators::tensor::U32Tensor; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_u32() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_u32/input_0.cairo b/tests/nodes/and_u32/input_0.cairo deleted file mode 100644 index 223353b25..000000000 --- a/tests/nodes/and_u32/input_0.cairo +++ /dev/null @@ -1,40 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::U32Tensor; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(5); - data.append(1); - data.append(4); - data.append(1); - data.append(1); - data.append(2); - data.append(1); - data.append(2); - data.append(5); - data.append(4); - data.append(4); - data.append(0); - data.append(4); - data.append(0); - data.append(3); - data.append(0); - data.append(1); - data.append(4); - data.append(0); - data.append(0); - data.append(5); - data.append(2); - data.append(1); - data.append(3); - data.append(3); - data.append(0); - data.append(3); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_u32/input_1.cairo b/tests/nodes/and_u32/input_1.cairo deleted file mode 100644 index 0f7af1f59..000000000 --- a/tests/nodes/and_u32/input_1.cairo +++ /dev/null @@ -1,40 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::U32Tensor; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(2); - data.append(3); - data.append(1); - data.append(3); - data.append(1); - data.append(2); - data.append(0); - data.append(0); - data.append(5); - data.append(1); - data.append(5); - data.append(4); - data.append(4); - data.append(0); - data.append(1); - data.append(2); - data.append(5); - data.append(0); - data.append(2); - data.append(0); - data.append(2); - data.append(1); - data.append(5); - data.append(5); - data.append(1); - data.append(3); - data.append(3); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_u32/output_0.cairo b/tests/nodes/and_u32/output_0.cairo deleted file mode 100644 index 86e333ba7..000000000 --- a/tests/nodes/and_u32/output_0.cairo +++ /dev/null @@ -1,40 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::BoolTensor; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(3); - shape.append(3); - shape.append(3); - - let mut data = ArrayTrait::new(); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - data.append(false); - data.append(true); - data.append(false); - data.append(true); - data.append(false); - data.append(false); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(true); - data.append(false); - data.append(true); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_u32_broadcast.cairo b/tests/nodes/and_u32_broadcast.cairo deleted file mode 100644 index 242b3af94..000000000 --- a/tests/nodes/and_u32_broadcast.cairo +++ /dev/null @@ -1,24 +0,0 @@ -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::U32TensorPartialEq; -use orion::operators::tensor::U32Tensor; -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::BoolTensorPartialEq; -use orion::operators::tensor::BoolTensor; - -#[test] -#[available_gas(2000000000)] -fn test_and_u32_broadcast() { - let input_0 = input_0::input_0(); - let input_1 = input_1::input_1(); - let z = output_0::output_0(); - - let y = input_0.and(@input_1); - - assert_eq(y, z); -} diff --git a/tests/nodes/and_u32_broadcast/input_0.cairo b/tests/nodes/and_u32_broadcast/input_0.cairo deleted file mode 100644 index ecd2ce1a3..000000000 --- a/tests/nodes/and_u32_broadcast/input_0.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::U32Tensor; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(0); - data.append(2); - data.append(1); - data.append(2); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_u32_broadcast/input_1.cairo b/tests/nodes/and_u32_broadcast/input_1.cairo deleted file mode 100644 index 01550d690..000000000 --- a/tests/nodes/and_u32_broadcast/input_1.cairo +++ /dev/null @@ -1,14 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::U32Tensor; - -fn input_1() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(1); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(2); - data.append(1); - TensorTrait::new(shape.span(), data.span()) -} diff --git a/tests/nodes/and_u32_broadcast/output_0.cairo b/tests/nodes/and_u32_broadcast/output_0.cairo deleted file mode 100644 index 83cb01c24..000000000 --- a/tests/nodes/and_u32_broadcast/output_0.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::{TensorTrait, Tensor}; -use orion::operators::tensor::BoolTensor; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(false); - data.append(true); - data.append(true); - data.append(true); - TensorTrait::new(shape.span(), data.span()) -}