Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Commit 215cc80

Browse files
authored
Merge pull request #611 from gizatechxyz/refactor-
Refactor Conditional operators
2 parents 11d7723 + 976563f commit 215cc80

File tree

324 files changed

+2430
-2327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+2430
-2327
lines changed

docs/framework/operators/tensor/tensor.and.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.and
22

33
```rust
4-
fn and(self: @Tensor<bool>, other: @Tensor<bool>) -> Tensor<usize>;
4+
fn and(self: @Tensor<bool>, other: @Tensor<bool>) -> Tensor<i32>;
55
```
66

77
Computes the logical AND of two tensors element-wise.
@@ -20,7 +20,7 @@ The input tensors must have either:
2020

2121
## Returns
2222

23-
A new `Tensor<bool>` with the same shape as the broadcasted inputs.
23+
A new `Tensor<i32>` with the same shape as the broadcasted inputs.
2424

2525
## Examples
2626

@@ -29,7 +29,7 @@ use core::array::{ArrayTrait, SpanTrait};
2929

3030
use orion::operators::tensor::{TensorTrait, Tensor, BoolTensor};
3131

32-
fn and_example() -> Tensor<usize> {
32+
fn and_example() -> Tensor<i32> {
3333
let tensor_1 = TensorTrait::<bool>::new(
3434
shape: array![3, 3].span(), data: array![false, true, false, false, false, true, true, false, true, false, false, true].span(),
3535
);

docs/framework/operators/tensor/tensor.equal.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.equal
22

33
```rust
4-
fn equal(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<usize>;
4+
fn equal(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<i32>;
55
```
66

77
Check if two tensors are equal element-wise.
@@ -20,7 +20,7 @@ The input tensors must have either:
2020

2121
## Returns
2222

23-
A new `Tensor<bool>` of booleans (1 if equal, 0 otherwise) with the same shape as the broadcasted inputs.
23+
A new `Tensor<i32>` (1 if equal, 0 otherwise) with the same shape as the broadcasted inputs.
2424

2525
## Examples
2626

@@ -31,7 +31,7 @@ use core::array::{ArrayTrait, SpanTrait};
3131

3232
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
3333

34-
fn eq_example() -> Tensor<usize> {
34+
fn eq_example() -> Tensor<i32> {
3535
let tensor_1 = TensorTrait::<u32>::new(
3636
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
3737
);
@@ -53,7 +53,7 @@ use core::array::{ArrayTrait, SpanTrait};
5353

5454
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
5555

56-
fn eq_example() -> Tensor<usize> {
56+
fn eq_example() -> Tensor<i32> {
5757
let tensor_1 = TensorTrait::<u32>::new(
5858
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
5959
);

docs/framework/operators/tensor/tensor.greater.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.greater
22

33
```rust
4-
fn greater(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<usize>;
4+
fn greater(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<i32>;
55
```
66

77
Check if each element of the first tensor is greater than the corresponding element of the second tensor.
@@ -20,7 +20,7 @@ The input tensors must have either:
2020

2121
## Returns
2222

23-
A new `Tensor<usize>` of booleans (0 or 1) with the same shape as the broadcasted inputs.
23+
A new `Tensor<i32>` of booleans (0 or 1) with the same shape as the broadcasted inputs.
2424

2525
## Examples
2626

@@ -31,7 +31,7 @@ use core::array::{ArrayTrait, SpanTrait};
3131

3232
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
3333

34-
fn greater_example() -> Tensor<usize> {
34+
fn greater_example() -> Tensor<i32> {
3535
let tensor_1 = TensorTrait::<u32>::new(
3636
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
3737
);
@@ -53,7 +53,7 @@ use core::array::{ArrayTrait, SpanTrait};
5353

5454
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
5555

56-
fn greater_example() -> Tensor<usize> {
56+
fn greater_example() -> Tensor<i32> {
5757
let tensor_1 = TensorTrait::<u32>::new(
5858
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
5959
);

docs/framework/operators/tensor/tensor.greater_equal.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.greater_equal
22

33
```rust
4-
fn greater_equal(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<usize>;
4+
fn greater_equal(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<i32>;
55
```
66

77
Check if each element of the first tensor is greater than or equal to the corresponding element of the second tensor.
@@ -31,7 +31,7 @@ use core::array::{ArrayTrait, SpanTrait};
3131

3232
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
3333

34-
fn greater_equal_example() -> Tensor<usize> {
34+
fn greater_equal_example() -> Tensor<i32> {
3535
let tensor_1 = TensorTrait::<u32>::new(
3636
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
3737
);
@@ -53,7 +53,7 @@ use core::array::{ArrayTrait, SpanTrait};
5353

5454
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
5555

56-
fn greater_equal_example() -> Tensor<usize> {
56+
fn greater_equal_example() -> Tensor<i32> {
5757
let tensor_1 = TensorTrait::<u32>::new(
5858
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
5959
);

docs/framework/operators/tensor/tensor.less.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.less
22

33
```rust
4-
fn less(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<usize>;
4+
fn less(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<i32>;
55
```
66

77
Check if each element of the first tensor is less than the corresponding element of the second tensor.
@@ -31,7 +31,7 @@ use core::array::{ArrayTrait, SpanTrait};
3131

3232
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
3333

34-
fn less_example() -> Tensor<usize> {
34+
fn less_example() -> Tensor<i32> {
3535
let tensor_1 = TensorTrait::<u32>::new(
3636
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
3737
);
@@ -53,7 +53,7 @@ use core::array::{ArrayTrait, SpanTrait};
5353

5454
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
5555

56-
fn less_example() -> Tensor<usize> {
56+
fn less_example() -> Tensor<i32> {
5757
let tensor_1 = TensorTrait::<u32>::new(
5858
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
5959
);

docs/framework/operators/tensor/tensor.less_equal.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.less_equal
22

33
```rust
4-
fn less_equal(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<usize>;
4+
fn less_equal(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<i32>;
55
```
66

77
Check if each element of the first tensor is less than or equal to the corresponding element of the second tensor.
@@ -31,7 +31,7 @@ use core::array::{ArrayTrait, SpanTrait};
3131

3232
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
3333

34-
fn less_equal_example() -> Tensor<usize> {
34+
fn less_equal_example() -> Tensor<i32> {
3535
let tensor_1 = TensorTrait::<u32>::new(
3636
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
3737
);
@@ -53,7 +53,7 @@ use core::array::{ArrayTrait, SpanTrait};
5353

5454
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
5555

56-
fn less_equal_example() -> Tensor<usize> {
56+
fn less_equal_example() -> Tensor<i32> {
5757
let tensor_1 = TensorTrait::<u32>::new(
5858
shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
5959
);

docs/framework/operators/tensor/tensor.not.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.not
22

33
```rust
4-
fn not(self: @Tensor<bool>) -> Tensor<bool;
4+
fn not(self: @Tensor<bool>) -> Tensor<bool>;
55
```
66

77
Computes the negation of the elements in the bool type input tensor.
@@ -23,7 +23,7 @@ use core::array::{ArrayTrait, SpanTrait};
2323

2424
use orion::operators::tensor::{TensorTrait, Tensor, BoolTensor};
2525

26-
fn not_example() -> Tensor<usize> {
26+
fn not_example() -> Tensor<bool> {
2727
let tensor = TensorTrait::new(
2828
shape: array![3].span(),
2929
data: array![

docs/framework/operators/tensor/tensor.or.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.or
22

33
```rust
4-
fn or(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<usize>;
4+
fn or(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<i32>;
55
```
66

77
Computes the logical OR of two tensors element-wise.
@@ -20,7 +20,7 @@ The input tensors must have either:
2020

2121
## Returns
2222

23-
A new `Tensor<usize>` of booleans (0 or 1) with the same shape as the broadcasted inputs.
23+
A new `Tensor<i32>` (0 or 1) with the same shape as the broadcasted inputs.
2424

2525
## Examples
2626

@@ -31,7 +31,7 @@ use core::array::{ArrayTrait, SpanTrait};
3131

3232
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
3333

34-
fn or_example() -> Tensor<usize> {
34+
fn or_example() -> Tensor<i32> {
3535
let tensor_1 = TensorTrait::<u32>::new(
3636
shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
3737
);
@@ -52,7 +52,7 @@ use core::array::{ArrayTrait, SpanTrait};
5252

5353
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
5454

55-
fn or_example() -> Tensor<usize> {
55+
fn or_example() -> Tensor<i32> {
5656
let tensor_1 = TensorTrait::<u32>::new(
5757
shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
5858
);

docs/framework/operators/tensor/tensor.xor.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#tensor.xor
22

33
```rust
4-
fn xor(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<usize>;
4+
fn xor(self: @Tensor<T>, other: @Tensor<T>) -> Tensor<i32>;
55
```
66

77
Computes the logical XOR of two tensors element-wise.
@@ -20,7 +20,7 @@ The input tensors must have either:
2020

2121
## Returns
2222

23-
A new `Tensor<usize>` of booleans (0 or 1) with the same shape as the broadcasted inputs.
23+
A new `Tensor<i32>` (0 or 1) with the same shape as the broadcasted inputs.
2424

2525
## Examples
2626

@@ -31,7 +31,7 @@ use core::array::{ArrayTrait, SpanTrait};
3131

3232
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
3333

34-
fn xor_example() -> Tensor<usize> {
34+
fn xor_example() -> Tensor<i32> {
3535
let tensor_1 = TensorTrait::<u32>::new(
3636
shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
3737
);
@@ -52,7 +52,7 @@ use core::array::{ArrayTrait, SpanTrait};
5252

5353
use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor};
5454

55-
fn xor_example() -> Tensor<usize> {
55+
fn xor_example() -> Tensor<i32> {
5656
let tensor_1 = TensorTrait::<u32>::new(
5757
shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(),
5858
);

nodegen/node/and.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def default():
1313

1414
x = Tensor(Dtype.BOOL, x.shape, x.flatten())
1515
y = Tensor(Dtype.BOOL, y.shape, y.flatten())
16-
z = Tensor(Dtype.U32, z.shape, z.flatten())
16+
z = Tensor(Dtype.I32, z.shape, z.flatten())
1717

1818
name = "and_bool"
1919
make_test([x, y], z, "BoolTensor::and(@input_0, @input_1)", name)
@@ -25,7 +25,7 @@ def broadcast():
2525

2626
x = Tensor(Dtype.BOOL, x.shape, x.flatten())
2727
y = Tensor(Dtype.BOOL, y.shape, y.flatten())
28-
z = Tensor(Dtype.U32, z.shape, z.flatten())
28+
z = Tensor(Dtype.I32, z.shape, z.flatten())
2929

3030
name = "and_bool_broadcast"
3131
make_test([x, y], z, "BoolTensor::and(@input_0, @input_1)", name)

nodegen/node/equal.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def default():
1313

1414
x = Tensor(Dtype.U32, x.shape, x.flatten())
1515
y = Tensor(Dtype.U32, y.shape, y.flatten())
16-
z = Tensor(Dtype.U32, z.shape, z.flatten())
16+
z = Tensor(Dtype.I32, z.shape, z.flatten())
1717

1818
name = "equal_u32"
1919
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -25,7 +25,7 @@ def broadcast():
2525

2626
x = Tensor(Dtype.U32, x.shape, x.flatten())
2727
y = Tensor(Dtype.U32, y.shape, y.flatten())
28-
z = Tensor(Dtype.U32, z.shape, z.flatten())
28+
z = Tensor(Dtype.I32, z.shape, z.flatten())
2929

3030
name = "equal_u32_broadcast"
3131
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -42,7 +42,7 @@ def default():
4242

4343
x = Tensor(Dtype.I32, x.shape, x.flatten())
4444
y = Tensor(Dtype.I32, y.shape, y.flatten())
45-
z = Tensor(Dtype.U32, z.shape, z.flatten())
45+
z = Tensor(Dtype.I32, z.shape, z.flatten())
4646

4747
name = "equal_i32"
4848
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -54,7 +54,7 @@ def broadcast():
5454

5555
x = Tensor(Dtype.I32, x.shape, x.flatten())
5656
y = Tensor(Dtype.I32, y.shape, y.flatten())
57-
z = Tensor(Dtype.U32, z.shape, z.flatten())
57+
z = Tensor(Dtype.I32, z.shape, z.flatten())
5858

5959
name = "equal_i32_broadcast"
6060
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -71,7 +71,7 @@ def default():
7171

7272
x = Tensor(Dtype.I8, x.shape, x.flatten())
7373
y = Tensor(Dtype.I8, y.shape, y.flatten())
74-
z = Tensor(Dtype.U32, z.shape, z.flatten())
74+
z = Tensor(Dtype.I32, z.shape, z.flatten())
7575

7676
name = "equal_i8"
7777
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -83,7 +83,7 @@ def broadcast():
8383

8484
x = Tensor(Dtype.I8, x.shape, x.flatten())
8585
y = Tensor(Dtype.I8, y.shape, y.flatten())
86-
z = Tensor(Dtype.U32, z.shape, z.flatten())
86+
z = Tensor(Dtype.I32, z.shape, z.flatten())
8787

8888
name = "equal_i8_broadcast"
8989
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -102,7 +102,7 @@ def default():
102102
x.flatten(), FixedImpl.FP8x23))
103103
y = Tensor(Dtype.FP8x23, y.shape, to_fp(
104104
y.flatten(), FixedImpl.FP8x23))
105-
z = Tensor(Dtype.U32, z.shape, z.flatten())
105+
z = Tensor(Dtype.I32, z.shape, z.flatten())
106106

107107
name = "equal_fp8x23"
108108
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -116,7 +116,7 @@ def broadcast():
116116
x.flatten(), FixedImpl.FP8x23))
117117
y = Tensor(Dtype.FP8x23, y.shape, to_fp(
118118
y.flatten(), FixedImpl.FP8x23))
119-
z = Tensor(Dtype.U32, z.shape, z.flatten())
119+
z = Tensor(Dtype.I32, z.shape, z.flatten())
120120

121121
name = "equal_fp8x23_broadcast"
122122
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -135,7 +135,7 @@ def default():
135135
x.flatten(), FixedImpl.FP16x16))
136136
y = Tensor(Dtype.FP16x16, y.shape, to_fp(
137137
y.flatten(), FixedImpl.FP16x16))
138-
z = Tensor(Dtype.U32, z.shape, z.flatten())
138+
z = Tensor(Dtype.I32, z.shape, z.flatten())
139139

140140
name = "equal_fp16x16"
141141
make_test([x, y], z, "input_0.equal(@input_1)", name)
@@ -149,7 +149,7 @@ def broadcast():
149149
x.flatten(), FixedImpl.FP16x16))
150150
y = Tensor(Dtype.FP16x16, y.shape, to_fp(
151151
y.flatten(), FixedImpl.FP16x16))
152-
z = Tensor(Dtype.U32, z.shape, z.flatten())
152+
z = Tensor(Dtype.I32, z.shape, z.flatten())
153153

154154
name = "equal_fp16x16_broadcast"
155155
make_test([x, y], z, "input_0.equal(@input_1)", name)

0 commit comments

Comments
 (0)