diff --git a/.all-contributorsrc b/.all-contributorsrc index 7ae3aa0a2..fc389d5f5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -87,8 +87,8 @@ "profile": "https://github.com/BemTG", "contributions": [ "code", - "doc", - ] + "doc" + ] }, { "login": "danilowhk", @@ -98,7 +98,7 @@ "contributions": [ "code" ] - }, + }, { "login": "Falco90", "name": "Falco R", @@ -108,6 +108,15 @@ "code" ] }, + { + "login": "dincerguner", + "name": "dincerguner", + "avatar_url": "https://avatars.githubusercontent.com/u/32523713?v=4", + "profile": "https://github.com/dincerguner", + "contributions": [ + "code" + ] + }, { "login": "richwarner", "name": "Rich Warner", @@ -115,13 +124,18 @@ "profile": "https://github.com/richwarner", "contributions": [ "code" - ] + ] }, { "login": "dbejarano820", "name": "Daniel Bejarano", "avatar_url": "https://avatars.githubusercontent.com/u/58019353?v=4", "profile": "https://github.com/dbejarano820", + "contributions": [ + "doc" + ] + }, + { "login": "vikkydataseo", "name": "vikkydataseo", "avatar_url": "https://avatars.githubusercontent.com/u/65757691?v=4", @@ -138,4 +152,4 @@ "projectName": "orion", "projectOwner": "gizatechxyz", "commitType": "docs" -} +} \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3c3cdbcda..239d65b0a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,5 +9,5 @@ jobs: - uses: actions/checkout@v3 - uses: software-mansion/setup-scarb@v1 with: - scarb-version: "0.6.2" + scarb-version: "0.7.0" - run: scarb test \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..3999f337f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "starkware.cairo1" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index d44564954..6791dea9e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@
- +
+
@@ -22,7 +23,7 @@ # Orion: An Open-source Framework for Validity and ZK ML ✨ -[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-) Orion is an open-source, community-driven framework dedicated to Provable Machine Learning. It provides essential components and a new ONNX runtime for building verifiable Machine Learning models using [STARKs](https://starkware.co/stark/). diff --git a/Scarb.toml b/Scarb.toml index 3aa1fcb3c..a70ca0d59 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -7,8 +7,9 @@ homepage = "https://github.com/gizatechxyz/orion" [dependencies] alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git" } +cubit = { git = "https://github.com/influenceth/cubit.git" } [scripts] sierra = "cairo-compile . -r" docgen = "cd docgen && cargo run" -nodegen = "python3 nodegen/node/__init__.py" \ No newline at end of file +nodegen = "python3 nodegen/node/__init__.py" diff --git a/docgen/src/main.rs b/docgen/src/main.rs index 330332432..493511d4c 100644 --- a/docgen/src/main.rs +++ b/docgen/src/main.rs @@ -34,14 +34,6 @@ fn main() { let trait_name: &str = "IntegerTrait"; doc_trait(trait_path, doc_path, label); doc_functions(trait_path, doc_path, trait_name, label); - - // PERFORMANCE DOC - let trait_path = "src/performance/core.cairo"; - let doc_path = "docs/framework/performance"; - let label = "performance"; - let trait_name = "PerfomanceTrait"; - doc_trait(trait_path, doc_path, label); - doc_functions(trait_path, doc_path, trait_name, label); } fn doc_trait(trait_path: &str, doc_path: &str, label: &str) { diff --git a/docs/.gitbook/assets/gitbook_banner.png b/docs/.gitbook/assets/gitbook_banner.png new file mode 100644 index 000000000..0222c542d Binary files /dev/null and b/docs/.gitbook/assets/gitbook_banner.png differ diff --git a/docs/.gitbook/assets/orion_gitbook_banner (1).png b/docs/.gitbook/assets/orion_gitbook_banner (1).png new file mode 100644 index 000000000..89f0fc5f1 Binary files /dev/null and b/docs/.gitbook/assets/orion_gitbook_banner (1).png differ diff --git a/docs/.gitbook/assets/orion_gitbook_banner.png b/docs/.gitbook/assets/orion_gitbook_banner.png new file mode 100644 index 000000000..89f0fc5f1 Binary files /dev/null and b/docs/.gitbook/assets/orion_gitbook_banner.png differ diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ad67051cf..114efa076 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] - 2023-09-03 + +## Changed +- Add FP64x64 and FP32x32 fixed points (from cubit library). +- Implement Tensor FP64x64 and FP3x32. +- Implement NN FP64x64 and FP3x32. + +## [Unreleased] - 2023-09-01 + +## Changed +Refactored Orion to support generic types. + ## [Unreleased] - 2023-08-24 ## Changed @@ -16,6 +28,19 @@ Use only LUTs for trigonometric functions. ## [Unreleased] - 2023-08-15 +### Added + +- Concat for tensors with tests +- Added i8 tensor helper for tests. + +## [Unreleased] - 2023-08-09 + +### Added + +- Onehot encoding for tensors with tests + +## [Unreleased] - 2023-08-15 + ### Added Add FixedType implementation of NNTrait. diff --git a/docs/README.md b/docs/README.md index 7ac3b4b22..ba5dbc390 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,7 +6,7 @@ description: An Open-source ecosystem for Validity and ZK ML. Orion is an open-source, community-driven framework dedicated to Provable Machine Learning. It provides essential components and a new ONNX runtime for building verifiable Machine Learning models using [STARKs](https://starkware.co/stark/). -
+
### 🤔 What is ONNX Runtime? diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 61f4576a3..a31015203 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -21,7 +21,6 @@ * [fp.new](framework/numbers/fixed-point/fp.new.md) * [fp.new\_unscaled](framework/numbers/fixed-point/fp.new\_unscaled.md) * [fp.from\_felt](framework/numbers/fixed-point/fp.from\_felt.md) - * [fp.from\_unscaled\_felt](framework/numbers/fixed-point/fp.from\_unscaled\_felt.md) * [fp.abs](framework/numbers/fixed-point/fp.abs.md) * [fp.ceil](framework/numbers/fixed-point/fp.ceil.md) * [fp.floor](framework/numbers/fixed-point/fp.floor.md) @@ -75,6 +74,10 @@ * [tensor.or](framework/operators/tensor/tensor.or.md) * [tensor.xor](framework/operators/tensor/tensor.xor.md) * [tensor.onehot](framework/operators/tensor/tensor.onehot.md) + * [tensor.slice](framework/operators/tensor/tensor.slice.md) + * [tensor.concat](framework/operators/tensor/tensor.concat.md) + * [tensor.quantize\_linear](framework/operators/tensor/tensor.quantize\_linear.md) + * [tensor.dequantize\_linear](framework/operators/tensor/tensor.dequantize\_linear.md) * [Neural Network](framework/operators/neural-network/README.md) * [nn.relu](framework/operators/neural-network/nn.relu.md) * [nn.leaky\_relu](framework/operators/neural-network/nn.leaky\_relu.md) @@ -84,9 +87,6 @@ * [nn.softsign](framework/operators/neural-network/nn.softsign.md) * [nn.softplus](framework/operators/neural-network/nn.softplus.md) * [nn.linear](framework/operators/neural-network/nn.linear.md) -* [Performance](framework/performance/README.md) - * [performance.quantize\_linear](framework/performance/performance.quantize\_linear.md) - * [performance.dequantize\_linear](framework/performance/performance.dequantize\_linear.md) ## 🏛 Hub diff --git a/docs/academy/tutorials/implement-new-operators-in-orion.md b/docs/academy/tutorials/implement-new-operators-in-orion.md index fee2ee978..9fa351cb1 100644 --- a/docs/academy/tutorials/implement-new-operators-in-orion.md +++ b/docs/academy/tutorials/implement-new-operators-in-orion.md @@ -12,7 +12,7 @@ Throughout this tutorial, any concept that is directly explained in the official Orion repo uses Scarb, a Cairo package manager. You can find all information about Scarb and Cairo installation [here](../../framework/get-started.md#installations). -The repository is structured as follows: +The repository is structured as follows: ``` . @@ -30,19 +30,16 @@ The repository is structured as follows: │ ├── numbers.cairo │ ├── operators │ ├── operators.cairo -│ ├── performance -│ ├── performance.cairo │ ├── tests │ ├── tests.cairo │ └── utils.cairo └── target ``` -In the `src` directory, you'll find four distinct folders: +In the `src` directory, you'll find four distinct folders: -* [`numbers`](../../framework/numbers/): This folder contains a complete implementation of Signed Integer and Fixed Point. -* [`operators`](../../framework/operators/): This directory includes a set of functions and operations used in calculating neural network models. -* [`performance`](../../framework/performance/): Here, you'll find a set of functions designed to enhance the performance of models. +* [`numbers`](../../framework/numbers/): This folder contains a complete implementation of Signed Integer and Fixed Point. +* [`operators`](../../framework/operators/): This directory includes a set of functions and operations used in calculating neural network models. * `tests`: This is the location where we'll test our code. In this tutorial we will focus on `operators` directory, as we will implement a new operator from scratch. @@ -55,9 +52,9 @@ Orion operators represent specific computations or operations performed by machi Ensuring compatibility with ONNX operators facilitates integration into the ONNX ecosystem. This enables researchers and developers to pre-train models using their preferred framework, before executing verifiable inferences with Orion. -We implemented two different types of operators, each having their own trait: +We implemented two different types of operators, each having their own trait: -* [`tensor (TensorTrait)`](../../framework/operators/tensor/): This represents a full implementation of multi-dimensional arrays. +* [`tensor (TensorTrait)`](../../framework/operators/tensor/): This represents a full implementation of multi-dimensional arrays. * [`nn (NNTrait)`](../../framework/operators/neural-network/) - These are operators designed for building neural networks. {% hint style="info" %} @@ -110,43 +107,9 @@ trait NNTrait { #### Step 2: Add the business logic -In the `src/operators/nn/functional` directory, create a new file named `softmax.cairo` and include the following code: +In the `src/operators/nn/functional` directory, create a new file named `softmax.cairo`. -```rust -//In softmax.cairo -mod softmax_u32; -mod softmax_i32; -``` - -Subsequently, create a `softmax` directory containing the following files: `softmax_u32.cairo` and `softmax_i32.cairo`. - -The resulting directory structure should look as follows: - -``` -nn -├── core.cairo -├── functional -│ ├── softmax -│ │ ├── softmax_i32.cairo -│ │ └── softmax_u32.cairo -│ ├── softmax.cairo -│ [...] -├── functional.cairo -├── implementations -│ ├── impl_nn_i32.cairo -│ └── impl_nn_u32.cairo -└── implementations.cairo -``` - -The `functional` folder is where all the business logic resides. The two lines in `softmax.cairo` instruct the compiler to include `softmax_u32.cairo` and `softmax_i32.cairo`. - -As you can see, Orion currently supports two implementations for `NNTrait`: `i32` and `u32`. Therefore, we need to develop logic for both implementations. - -{% hint style="warning" %} -`TensorTrait` supports more types, you will therefore need to add the necessary logic to all supported types if you decide to implement a new tensor operator. -{% endhint %} - -Now that the files are set up, let's proceed to code the business logic. +The `functional` folder is where all the business logic resides. All functions should be implemented with generic type. A softmax function can be implemented as follows: @@ -154,41 +117,22 @@ A softmax function can be implemented as follows: So we can leverage the [`exp`](../../framework/operators/tensor/tensor.exp.md) and [`reduce_sum`](../../framework/operators/tensor/tensor.reduce\_sum.md) operators from `TensorTrait` to implement softmax. -Here's the implementation in `softmax_i32.cairo`: +Here's the implementation in `softmax.cairo`: ```rust -//In softmax_i32.cairo - -use orion::numbers::signed_integer::i32::i32; -use orion::numbers::fixed_point::core::FixedType; use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_i32::Tensor_i32, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; /// Cf: NNTrait::softmax docstring -fn softmax_i32(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - - return softmax; -} -``` - -Similarly, implement the logic in `softmax_u32.cairo`: - -```rust -//In softmax_u32.cairo - -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_u32::Tensor_u32, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; - -/// Cf: NNTrait::softmax docstring -fn softmax_u32(z: @Tensor, axis: usize) -> Tensor { +fn softmax< + T, + impl TTensor: TensorTrait, + impl TTensor: TensorTrait, + impl TTensorDiv: Div>, + impl TCopy: Copy, + impl TDrop: Drop, +>( + z: @Tensor, axis: usize +) -> Tensor { let exp_tensor = z.exp(); let sum = exp_tensor.reduce_sum(axis, true); let softmax = exp_tensor / sum; @@ -199,39 +143,28 @@ fn softmax_u32(z: @Tensor, axis: usize) -> Tensor { #### Step 3: Add softmax to the implementations -Now, we need to add the softmax function into the different representations. In `nn/implementations/impl_nn_i32.cairo`, import the business logic and add the softmax implementation. +Now, we need to add the softmax function into the different representations. In `nn/implementations/nn_fp8x23.cairo`, import the business logic and add the softmax implementation. ```rust -// In impl_nn_i32.cairo -use core::option::OptionTrait; -use orion::operators::tensor::core::Tensor; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::nn::functional::softmax::softmax_i32::softmax_i32; - -impl NN_i32 of NNTrait { +// In nn_fp8x23.cairo + +impl FP8x23NN of NNTrait { // [...] - fn softmax(tensor: @Tensor, axis: usize) -> Tensor { - softmax_i32(tensor, axis) + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::softmax::softmax(tensor, axis) } } ``` -Do the same for `u32` implementation. +Do the same for all other fixed point implementations (`FP16x16NN`, `FP32x32NN`, `FP64x64NN`). As softmax only support fixed point tensors, it should panic for other implementations. Below an example with `U32NN`. ```rust -// In impl_nn_u32.cairo -use core::option::OptionTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::tensor::core::Tensor; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::functional::softmax::softmax_u32::softmax_u32; - -impl NN_u32 of NNTrait { +// In nn_u32.cairo + +impl U32NN of NNTrait { // [...] - fn softmax(tensor: @Tensor, axis: usize) -> Tensor { - softmax_u32(tensor, axis) + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + panic(array!['not supported!']) } } ``` @@ -250,7 +183,7 @@ trait NNTrait { /// # NNTrait::softmax /// /// ```rust - /// fn softmax(tensor: @Tensor, axis: usize) -> Tensor; + /// fn softmax(tensor: @Tensor, axis: usize) -> Tensor; /// ``` /// /// Applies the Softmax function to an n-dimensional input Tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range \[0,1] and sum to 1. @@ -268,18 +201,31 @@ trait NNTrait { /// /// A Tensor of fixed point numbers with the same shape than the input Tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Examples /// /// ```rust - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_u32::NN_u32; + /// use array::{ArrayTrait, SpanTrait}; + /// + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; + /// use orion::operators::nn::{NNTrait, FP8x23NN}; + /// use orion::numbers::{FP8x23, FixedTrait}; + /// + /// fn softmax_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2, 2].span(), + /// data: array![ + /// NNTrait::new(0, false), + /// NNTrait::new(1, false), + /// NNTrait::new(2, false), + /// NNTrait::new(3, false), + /// ] + /// .span(), + /// ); /// - /// fn softmax_example() -> Tensor { - /// // We instantiate a 2D Tensor here. - /// // [[0,1],[2,3]] - /// let tensor = u32_tensor_2x2_helper(); - /// - /// // We can call `softmax` function as follows. /// return NNTrait::softmax(@tensor, 1); /// } /// >>> [[2255697,6132911],[2255697,6132911]] @@ -287,15 +233,15 @@ trait NNTrait { /// // [[0.2689, 0.7311],[0.2689, 0.7311]] /// ``` /// - fn softmax(tensor: @Tensor, axis: usize) -> Tensor; + fn softmax(tensor: @Tensor, axis: usize) -> Tensor; } ```` Voilà! We have successfully implemented the softmax function in `NNTrait`! -### How to test the Orion Operator? +### How to test the Orion Operator? -Now, let's proceed to testing the softmax operator we've just implemented. When testing an operator in Orion, you should ensure to test across all types of implementation. +Now, let's proceed to testing the softmax operator we've just implemented. When testing an operator in Orion, you should ensure to test across all types of implementation. Since softmax employs fixed points for intermediate calculations and returns a tensor of `FixedType`, it is essential to test it across all fixed point implementations. As of now, Orion supports two fixed point implementations: [`FP16x16`](../../framework/numbers/fixed-point/#data-types) and [`FP8x23`](../../framework/numbers/fixed-point/#data-types). @@ -317,7 +263,7 @@ def softmax(x: np.ndarray, axis: int = -1) -> np.ndarray: return tmp / s ``` -Finally, we create a Softmax class, containing tests for each dtypes. +Finally, we create a Softmax class, containing tests for each dtypes. ```python import numpy as np @@ -331,136 +277,68 @@ def softmax(x: np.ndarray, axis: int = -1) -> np.ndarray: return tmp / s class Softmax(RunAll): - - # Define tests for i32 dtype + @staticmethod - def softmax_i32(): - # Softmax returns a FixedType. - # So we test here with fp8x23 implementation. - def fp8x23(): - # Create a random numpy array: - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - # Ddefine the expected result: - y = softmax(x, 0) - - # Convert the input and output to Tensor class, similar to Orion's Tensor struct: - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - # Convert the floats values in `y` to fixed points with `to_fp` method: - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - # Define the name of the generated folder. - name = "softmax_i32_fp8x23" - # Invoke `make_node` method to generate Cairo representation of `x` and `y`: - make_node([x], [y], name) - # Invoke `make_test` method to generate corresponding Cairo tests: - make_test( - [x], # List of input tensors. - y, # The expected output result. - "NNTrait::softmax(@input_0, 0)", # The code signature. - name, # The name of the generated folder. - Trait.NN # The trait, if the function is present in either the TensorTrait or NNTrait. - ) + # We test here with fp8x23 implementation. + def fp8x23(): + # Create a random numpy array: + x = np.random.randint(-3, 3, (2, 2)).astype(np.float64) + # Ddefine the expected result: + y = softmax(x, 0) - # Test here with fp16x16 implementation. - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = softmax(x, 1) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softmax_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 1)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def softmax_i8(): - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = softmax(x, 1) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softmax_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 1)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = softmax(x, 0) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softmax_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 0)", - name, Trait.NN) - - fp8x23() - fp16x16() - + # Convert the input and output to Tensor class, similar to Orion's Tensor struct: + x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + # Convert the floats values in `y` to fixed points with `to_fp` method: + y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) + + # Define the name of the generated folder. + name = "softmax_fp8x23" + # Invoke `make_node` method to generate Cairo representation of `x` and `y`: + make_node([x], [y], name) + # Invoke `make_test` method to generate corresponding Cairo tests: + make_test( + [x], # List of input tensors. + y, # The expected output result. + "NNTrait::softmax(@input_0, 0)", # The code signature. + name, # The name of the generated folder. + Trait.NN # The trait, if the function is present in either the TensorTrait or NNTrait. + ) + + # We test here with fp16x16 implementation. @staticmethod - def softmax_u32(): - def fp8x23(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = softmax(x, 1) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softmax_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 1)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = softmax(x, 0) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softmax_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 0)", - name, Trait.NN) - - fp8x23() - fp16x16() + def fp16x16(): + x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) + y = softmax(x, 1) + + x = Tensor(Dtype.FP16x16, x.shape, to_fp( + x.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "softmax_fp16x16" + make_node([x], [y], name) + make_test([x], y, "NNTrait::softmax(@input_0, 1)", + name, Trait.NN) ``` Once set up, you can generate tests and data by executing `scarb run nodegen softmax`. -The above code will generate 6 test files located in `src/tests/nodes`. As an example, here's the content of the `softmax_i32_fp8x23.cairo` generated file: +The above code will generate 6 test files located in `src/tests/nodes`. As an example, here's the content of the `softmax_fp8x23.cairo` generated file: ```rust -// softmax_i32_fp8x23.cairo +// softmax_fp8x23.cairo mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] #[available_gas(2000000000)] -fn test_softmax_i32_fp8x23() { +fn test_softmax_fp8x23() { let input_0 = input_0::input_0(); let z = output_0::output_0(); @@ -472,8 +350,6 @@ fn test_softmax_i32_fp8x23() { If you'd like to expand the tests with additional cases, feel free to edit the generated Cairo file. - - You're now ready to prepare your Pull Request. Please ensure you thoroughly read the [Contribution Guidelines](../../framework/contribute.md) before making your first PR. Your contribution is greatly appreciated, and we sincerely value your interest 🫶. Orion leverages Cairo to guarantee the reliability of inference, providing developers with a user-friendly framework to build complex and verifiable machine learning models. We invite the community to join us in shaping a future where trustworthy AI becomes a reliable resource for all. diff --git a/docs/academy/tutorials/mnist-classification-with-orion.md b/docs/academy/tutorials/mnist-classification-with-orion.md index 143051e97..bb85956d5 100644 --- a/docs/academy/tutorials/mnist-classification-with-orion.md +++ b/docs/academy/tutorials/mnist-classification-with-orion.md @@ -2,7 +2,7 @@
-Orion is a dedicated Cairo-based library designed specifically to build machine learning models for ValidityML. Its purpose is to facilitate verifiable inference. Orion exclusively operates with 8-bit quantized models, an approach intended to optimize performance. In this tutorial, you will be guided on how to train your model using Quantized Aware Training using MNIST dataset, how to convert your pre-trained model to Cairo 1, and how to perform inference with Orion. +Orion is a dedicated Cairo-based library designed specifically to build machine learning models for ValidityML. Its purpose is to facilitate verifiable inference. For better performance we will operate with an 8-bit quantized model. In this tutorial, you will be guided on how to train your model using Quantized Aware Training using MNIST dataset, how to convert your pre-trained model to Cairo 1, and how to perform inference with Orion. {% hint style="info" %} You can find all the code and the notebook in the dedicated [repository.](https://github.com/gizatechxyz/orion\_tutorials) @@ -385,30 +385,28 @@ tensors = { Now let's generate Cairo files for each tensor in the object. -
# Create the directory if it doesn't exist
+```python
+# Create the directory if it doesn't exist
 os.makedirs('src/generated', exist_ok=True)
 
 for tensor_name, tensor in tensors.items():
     with open(os.path.join('src', 'generated', f"{tensor_name}.cairo"), "w") as f:
         f.write(
-            "use array::ArrayTrait;\n" +
-            "use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams};\n" +
-            "use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32;\n" +
-            "use orion::numbers::fixed_point::core::FixedImpl;\n" +
-            "use orion::numbers::signed_integer::i32::i32;\n\n" +
-            "fn {0}() -> Tensor<i32> ".format(tensor_name) + "{\n" +
-            "    let mut shape = ArrayTrait::<usize>::new();\n"
+            "use array::ArrayTrait;\n" +
+            "use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor};\n" +
+            "use orion::numbers::i32;\n\n" +
+            "\nfn {0}() -> Tensor ".format(tensor_name) + "{\n" +
+            "    let mut shape = ArrayTrait::::new();\n"
         )
         for dim in tensor.shape:
             f.write("    shape.append({0});\n".format(dim))
         f.write(
-            "    let mut data = ArrayTrait::<i32>::new();\n"
+            "    let mut data = ArrayTrait::::new();\n"
         )
         for val in np.nditer(tensor.flatten()):
-            f.write("    data.append(i32 {{ mag: {0}, sign: {1} }});\n".format(abs(int(val)), str(val < 0).lower()))
+            f.write("    data.append(i32 {{ mag: {0}, sign: {1} }});\n".format(abs(int(val)), str(val < 0).lower()))
         f.write(
-            "let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; \n" +
-            "    TensorTrait::new(shape.span(), data.span(), Option::Some(extra))\n" +
+            "    TensorTrait::new(shape.span(), data.span())\n" +
             "}\n"
         )
       
@@ -416,7 +414,7 @@ with open(os.path.join('src', 'generated.cairo'), 'w') as f:
     for param_name in tensors.keys():
         f.write(f"mod {param_name};\n")
 
-
+``` Your Cairo files are generated in `src/generated` directory. @@ -434,27 +432,25 @@ Here is a file we generated: `fc1_bias.cairo` ```rust use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::numbers::signed_integer::i32::i32; +use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; +use orion::numbers::i32; + fn fc1_bias() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(10); let mut data = ArrayTrait::::new(); - data.append(i32 { mag: 1300, sign: true }); - data.append(i32 { mag: 7644, sign: false }); - data.append(i32 { mag: 472, sign: true }); - data.append(i32 { mag: 3601, sign: false }); - data.append(i32 { mag: 5538, sign: false }); - data.append(i32 { mag: 5476, sign: false }); - data.append(i32 { mag: 3879, sign: false }); - data.append(i32 { mag: 3268, sign: true }); - data.append(i32 { mag: 1979, sign: false }); - data.append(i32 { mag: 1435, sign: false }); -let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1287, sign: false }); + data.append(i32 { mag: 3667, sign: true }); + data.append(i32 { mag: 2954, sign: false }); + data.append(i32 { mag: 7938, sign: false }); + data.append(i32 { mag: 3959, sign: false }); + data.append(i32 { mag: 5862, sign: true }); + data.append(i32 { mag: 4886, sign: false }); + data.append(i32 { mag: 4992, sign: false }); + data.append(i32 { mag: 10126, sign: false }); + data.append(i32 { mag: 2237, sign: true }); + TensorTrait::new(shape.span(), data.span()) } ``` @@ -482,15 +478,6 @@ The second concept Orion introduced is the [Tensor](../../framework/operators/te struct Tensor { shape: Span, data: Span - extra: Option -} -``` - -`ExtraParams` is a struct containing additional parameters for the tensor. The `fixed_point` parameter specifies the fixed-point implementation to be used when a tensor operation uses fixed points. - -```rust -struct ExtraParams { - fixed_point: Option } ``` @@ -527,7 +514,8 @@ It should return a `Tensor`. ```rust use orion::operators::tensor::core::Tensor; -use orion::numbers::signed_integer::i32::i32; +use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use orion::operators::nn::{NNTrait, I32NN}; fn fc1(i: Tensor, w: Tensor, b: Tensor) -> Tensor { // ... @@ -539,35 +527,30 @@ To build the first layer, we need a [Linear](../../framework/operators/neural-ne ```rust use orion::operators::tensor::core::Tensor; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; +use orion::operators::nn::{NNTrait, I32NN}; fn fc1(i: Tensor, w: Tensor, b: Tensor) -> Tensor { - let x = NNTrait::linear(i, w, b, true); // `true` because we want to quantize the result - NNTrait::relu(@x, IntegerTrait::new(0, false)) + let x = NNTrait::linear(i, w, b); + NNTrait::relu(@x) } ``` #### Dense Layer 2 -In a similar way, we can build the second layer `fc2`, which contains a [Linear](../../framework/operators/neural-network/nn.linear.md) function and a [Softmax](../../framework/operators/neural-network/nn.softmax.md) from [NNTrait](../../framework/operators/neural-network/). Because after a softmax the output tensor lies in the interval \[0,1], floating points are represented by [fixed points](../../framework/numbers/fixed-point/). This is why `fc2` returns `Tensor`. +In a similar way, we can build the second layer `fc2`, which contains a [Linear](../../framework/operators/neural-network/nn.linear.md) function and a [Softmax](../../framework/operators/neural-network/nn.softmax.md) from [NNTrait](../../framework/operators/neural-network/). We could convert the tensor to fixed point in order to perform softmax, but for this simple tutorial it's not necessary. ```rust use orion::operators::tensor::core::Tensor; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; +use orion::operators::nn::{NNTrait, I32NN}; fn fc1(i: Tensor, w: Tensor, b: Tensor) -> Tensor { - let x = NNTrait::linear(i, w, b, true); - NNTrait::relu(@x, IntegerTrait::new(0, false)) + let x = NNTrait::linear(i, w, b); + NNTrait::relu(@x) } -fn fc2(i: Tensor, w: Tensor, b: Tensor) -> Tensor { - let x = NNTrait::linear(i, w, b, true); - NNTrait::softmax(@x, 0) +fn fc2(i: Tensor, w: Tensor, b: Tensor) -> Tensor { + NNTrait::linear(i, w, b) } ``` @@ -638,7 +621,7 @@ fn mnist_nn_test() { } ``` -Finally, let's make a prediction. The input data represents the digit 7. The probability at index 7 must therefore be close to 1. +Finally, let's make a prediction. The input data represents the digit 7. So the index 7 should have the highest probability. ```rust use core::array::SpanTrait; @@ -651,7 +634,7 @@ use mnist_nn::generated::fc1_weights::fc1_weights; use mnist_nn::generated::fc2_bias::fc2_bias; use mnist_nn::generated::fc2_weights::fc2_weights; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use orion::operators::tensor::I32Tensor; #[test] #[available_gas(99999999999999999)] @@ -665,21 +648,13 @@ fn mnist_nn_test() { let x = fc1(input, fc1_weights, fc1_bias); let x = fc2(x, fc2_weights, fc2_bias); - assert(*x.data.at(0).mag == 0, 'proba x is 0 -> 0'); - assert(*x.data.at(1).mag == 0, 'proba x is 1 -> 0'); - assert(*x.data.at(2).mag == 0, 'proba x is 2 -> 0'); - assert(*x.data.at(3).mag == 0, 'proba x is 3 -> 0'); - assert(*x.data.at(4).mag == 0, 'proba x is 4 -> 0'); - assert(*x.data.at(5).mag == 0, 'proba x is 5 -> 0'); - assert(*x.data.at(6).mag == 0, 'proba x is 6 -> 0'); - assert(*x.data.at(7).mag > 62259, 'proba x is 7 -> 1'); // 62259 represents ONE in fp16x16. - assert(*x.data.at(8).mag == 0, 'proba x is 8 -> 0'); - assert(*x.data.at(9).mag == 0, 'proba x is 9 -> 0'); -} + let x = *x.argmax(0, Option::None(()), Option::None(())).data.at(0); + assert(x == 7, 'should predict 7'); +} ``` -Test your model by running `scarb cairo-test -f mnist_nn_test`. +Test your model by running `scarb test`. ```sh testing mnist_nn ... @@ -693,5 +668,3 @@ Bravo 👏 You can be proud of yourself! You just built your first Neural Networ Orion leverages Cairo to guarantee the reliability of inference, providing developers with a user-friendly framework to build complex and verifiable machine learning models. We invite the community to join us in shaping a future where trustworthy AI becomes a reliable resource for all.
Join Discord Communityhttps://discord.gg/yqWB57XNYg
Get Started Orionhttps://orion.gizatech.xyz/apis/get-started
- -[^1]: Maybe for this to make it a bit cleaner we could use triple quotes so we don't have to add "\n" on each line diff --git a/docs/academy/tutorials/verifiable-linear-regression-model-in-orion.md b/docs/academy/tutorials/verifiable-linear-regression-model-in-orion.md index e2c475a76..65e610f14 100644 --- a/docs/academy/tutorials/verifiable-linear-regression-model-in-orion.md +++ b/docs/academy/tutorials/verifiable-linear-regression-model-in-orion.md @@ -145,7 +145,7 @@ name = "verifiable_linear_regression" version = "0.1.0" [dependencies] -orion = { git = "https://github.com/gizatechxyz/orion.git", branch = "einsum-impl" } +orion = { git = "https://github.com/gizatechxyz/orion.git"} [scripts] test = "scarb cairo-test -f linear_regression_test" @@ -165,11 +165,9 @@ def generate_cairo_files(data, name): with open(os.path.join('src', 'generated', f"{name}.cairo"), "w") as f: f.write( "use array::ArrayTrait;\n" + - "use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams};\n" + - "use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp;\n" + - "use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl};\n" - "use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16PartialEq };\n"+ - "fn {0}() -> Tensor ".format(name) + "{\n" + + "use orion::operators::tensor::{FP16x16Tensor, TensorTrait, Tensor};\n" + + "use orion::numbers::{FixedTrait, FP16x16, FP16x16Impl};\n" + "\nfn {0}() -> Tensor ".format(name) + "{\n" + " let mut shape = ArrayTrait::new();\n" ) for dim in data.shape: @@ -180,19 +178,13 @@ def generate_cairo_files(data, name): for val in np.nditer(data.flatten()): f.write(" data.append(FixedTrait::new({0}, {1} ));\n".format(abs(int(val * 2**16)), str(val < 0).lower())) f.write( - "let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; \n" + - "let tensor = TensorTrait::::new(shape.span(), data.span(), Option::Some(extra)); \n \n" + + "let tensor = TensorTrait::::new(shape.span(), data.span()); \n \n" + "return tensor;\n\n"+ "}\n" ) with open(os.path.join('src', 'generated.cairo'), 'w') as f: for param_name in tensor_name: f.write(f"mod {param_name};\n") - - -generate_cairo_files(X, 'X_values') -generate_cairo_files(y, 'Y_values') - ``` The X\_values and y\_values tensor values will now be generated under `src/generated` directory. @@ -209,52 +201,41 @@ This will tell our compiler to include the separate modules listed above during ```rust use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::i32::i32; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16Into, FP16x16PartialEq }; +use orion::operators::tensor::{FP16x16Tensor, TensorTrait, Tensor}; +use orion::numbers::{FixedTrait, FP16x16, FP16x16Impl}; -fn X_values() -> Tensor { +fn X_values() -> Tensor { let mut shape = ArrayTrait::new(); - shape.append(150); + shape.append(150); let mut data = ArrayTrait::new(); - data.append(FixedTrait::new_unscaled(10, true )); - data.append(FixedTrait::new_unscaled(9, true )); - -// data has been truncated (only showing the first and last 2 values out of the 150 values) - - data.append(FixedTrait::new_unscaled(24, false )); - data.append(FixedTrait::new_unscaled(25, false )); -let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; -let tensor = TensorTrait::::new(shape.span(), data.span(), Option::Some(extra)); - -return tensor; - + data.append(FixedTrait::new(32768, true)); + data.append(FixedTrait::new(32328, true)); + // data has been truncated (only showing the first and last 2 values out of the 150 values) + data.append(FixedTrait::new(32328, false)); + data.append(FixedTrait::new(32768, false)); + let tensor = TensorTrait::::new(shape.span(), data.span()); + + return tensor; } - ``` Since Cairo does not come with built-in signed integers we have to explicitly define it for our X and y values. Luckily, this is already implemented in Orion for us as a struct as shown below: ```rust -// Example of a FixedType. -struct FixedType { - mag: u128, +// Example of a FP16x16. +struct FP16x16 { + mag: u32, sign: bool } ``` -For this tutorial, we will use FixedType numbers where the magnitude represents the absolute value and the boolean indicates whether the number is negative or positive. To replicate the OLS functions, we will conduct our operations using FixedType Tensors which are also represented as a structs in Orion. +For this tutorial, we will use FP16x16 numbers where the magnitude represents the absolute value and the boolean indicates whether the number is negative or positive. To replicate the OLS functions, we will conduct our operations using FP16x16 Tensors which are also represented as a structs in Orion. ```rust struct Tensor { shape: Span, data: Span - extra: Option } struct ExtraParams { @@ -263,40 +244,34 @@ struct ExtraParams { ``` -A `Tensor` in Orion takes a shape, a span array of the data and an extra parameter. For our tutorial, the ExtraParams specifies that the Tensor is associated with using fp16x16 format. In a 16x16 fixed-point format, there are 16 bits dedicated to the integer part of the number and 16 bits for the fractional part of the number. This format allows us to work with a wide range of values and a high degree of precision for conducting the OLS Tensor operations. - -```rust= -let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - -``` +A `Tensor` in Orion takes a shape and a span array of the data and an extra parameter. In a 16x16 fixed-point format, there are 16 bits dedicated to the integer part of the number and 16 bits for the fractional part of the number. This format allows us to work with a wide range of values and a high degree of precision for conducting the OLS Tensor operations. ### Implementing OLS functions using Orion -At this stage, we will be reproducing the OLS functions now that we have generated our X and Y Fixedpoint Tensors. We will begin by creating a separate file for our linear regression functions file named `lin_reg_func.cairo` to host all of our linear regression functions. +At this stage, we will be reproducing the OLS functions now that we have generated our X and Y fixed point Tensors. We will begin by creating a separate file for our linear regression functions file named `lin_reg_func.cairo` to host all of our linear regression functions. #### Computing the mean ```rust -fn calculate_mean(tensor_data: Tensor) -> FixedType { - - let tensor_size = FP16x16Impl::new_unscaled(tensor_data.data.len(), false); +/// Calculates the mean of a given 1D tensor. +fn calculate_mean(tensor_data: Tensor) -> FP16x16 { + let tensor_size = FixedTrait::::new_unscaled(tensor_data.data.len(), false); let cumulated_sum = tensor_data.cumsum(0, Option::None(()), Option::None(())); - let sum_result = cumulated_sum.data[tensor_data.data.len() - 1]; - let mean = FP16x16Div::div(*sum_result, tensor_size); + let sum_result = cumulated_sum.data[tensor_data.data.len() - 1]; + let mean = *sum_result / tensor_size; return mean; } - ``` -The above function takes in a FixedType Tensor and computes its corresponding mean value. We break the steps down by first calculating the cumulative sum of the tensor values using the `cumsum` built-in orion operator. We then divide the result by the length of the tensor size and return the output as a Fixedtype number. +The above function takes in an FP16x16 Tensor and computes its corresponding mean value. We break the steps down by first calculating the cumulative sum of the tensor values using the `cumsum` built-in orion operator. We then divide the result by the length of the tensor size and return the output as a fixed point number. #### Computing the deviation from the mean ```rust -fn deviation_from_mean(tensor_data: Tensor ) -> Tensor { - +/// Calculates the deviation of each element from the mean of the provided 1D tensor. +fn deviation_from_mean(tensor_data: Tensor) -> Tensor { let mean_value = calculate_mean(tensor_data); let mut tensor_shape = array::ArrayTrait::new(); @@ -304,21 +279,22 @@ fn deviation_from_mean(tensor_data: Tensor ) -> Tensor { let mut deviation_values = array::ArrayTrait::new(); - let mut i:u32 = 0; + let mut i: u32 = 0; loop { - if i >= tensor_data.data.len() { - break(); + if i >= tensor_data.data.len() { + break (); } let distance_from_mean = *tensor_data.data.at(i) - mean_value; deviation_values.append(distance_from_mean); i += 1; - }; - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let distance_from_mean_tensor = TensorTrait::::new(tensor_shape.span(), deviation_values.span(), Option::Some(extra)); + }; + + let distance_from_mean_tensor = TensorTrait::::new( + tensor_shape.span(), deviation_values.span() + ); return distance_from_mean_tensor; } - ``` The following deviation\_from\_mean function calculates the deviation from the mean for each element of a given tensor. We initially calculate the tensor's mean value and store it under the variable mean\_value. We then create a for loop to iterate over each element in the tensor values and calculate the deviation from the mean which we will append the result to `deviation_values` array. Finally, we create a new tensor named distance\_from\_mean\_tensor by passing the deviation\_values array and the tensor shape. @@ -332,20 +308,18 @@ $$ $$ ```rust - -fn compute_beta(x_values: Tensor, y_values: Tensor ) -> FixedType { - +/// Calculates the beta value for linear regression. +fn compute_beta(x_values: Tensor, y_values: Tensor) -> FP16x16 { let x_deviation = deviation_from_mean(x_values); let y_deviation = deviation_from_mean(y_values); let x_y_covariance = x_deviation.matmul(@y_deviation); let x_variance = x_deviation.matmul(@x_deviation); - let beta_value = FP16x16Div::div(*x_y_covariance.data.at(0), *x_variance.data.at(0)); + let beta_value = *x_y_covariance.data.at(0) / *x_variance.data.at(0); return beta_value; } - ``` We can now compute the beta value for our linear regression utilising the previous deviation\_from\_mean function. We first calculate both the deviation of x values and y values from the mean and store them in separate variables as tensors. To calculate the covariance, we use the built-in Orion `matmul` operator to multiply x\_deviation by y\_deviation tensors. Similarly, we compute the X variance by multiplying x\_deviation tensor by itself. Finally, we divide the `x_y_covariance` by the `x_variance` to get an approximate gradient value for our regression model. @@ -354,17 +328,17 @@ We can now compute the beta value for our linear regression utilising the previo ```rust /// Calculates the intercept for linear regression. -fn compute_intercept(beta_value:FixedType, x_values: Tensor, y_values: Tensor) -> FixedType { - +fn compute_intercept( + beta_value: FP16x16, x_values: Tensor, y_values: Tensor +) -> FP16x16 { let x_mean = calculate_mean(x_values); let y_mean = calculate_mean(y_values); - let mx= FP16x16Mul::mul(beta_value, x_mean); + let mx = beta_value * x_mean; let intercept = y_mean - mx; return intercept; } - ``` Calculating the y-intercept is fairly simple, we just need to substitute the calculated beta, y\_mean and x\_mean values and rearrange for the intercept value as previously shown in the Python implementation section. @@ -374,56 +348,46 @@ Calculating the y-intercept is fairly simple, we just need to substitute the cal Now that we have implemented all the necessary functions for the OLS method, we can finally test our linear regression model. We begin by creating a new separate test file named `test.cairo` and import all the necessary Orion libraries including our `X_values` and `y_values` found in the generated folder. We also import all the OLS functions from `lin_reg_func.cairo` file as we will be relying upon them to construct the regression model. ```rust -use core::array::SpanTrait; -use traits::Into; use debug::PrintTrait; -use array::ArrayTrait; + use verifiable_linear_regression::generated::X_values::X_values; use verifiable_linear_regression::generated::Y_values::Y_values; -use verifiable_linear_regression::lin_reg_func::{calculate_mean, deviation_from_mean, compute_beta, compute_intercept, predict_y_values, compute_mse, calculate_r_score}; - -use orion::operators::tensor::math::cumsum::cumsum_i32::cumsum; -use orion::operators::tensor::implementations::{impl_tensor_u32::Tensor_u32, impl_tensor_fp::Tensor_fp}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::math::arithmetic::arithmetic_fp::core::{add, sub, mul, div}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Print, FP16x16PartialEq, FP16x16Sub, - FP16x16SubEq, FP16x16Mul, FP16x16MulEq, FP16x16Div, FP16x16DivEq, FP16x16PartialOrd, FP16x16Neg +use verifiable_linear_regression::lin_reg_func::{ + calculate_mean, deviation_from_mean, compute_beta, compute_intercept, predict_y_values, + compute_mse, calculate_r_score }; -use orion::operators::tensor::linalg::matmul::matmul_fp::core::matmul; #[test] #[available_gas(99999999999999999)] fn linear_regression_test() { - //Data Retrieval + // Fetching the x and y values let y_values = Y_values(); let x_values = X_values(); - //Beta Calculation - let beta_value = compute_beta(x_values,y_values ); + // (*x_values.data.at(18)).print(); + + let beta_value = compute_beta(x_values, y_values); // beta_value.print(); // calculated gradient value - //Intercept Calculation - let intercept_value = compute_intercept(beta_value, x_values, y_values ); + let intercept_value = compute_intercept(beta_value, x_values, y_values); // intercept_value.print(); // calculated intercept value - //Prediction Phase - let y_pred = predict_y_values(beta_value, x_values, y_values ); + let y_pred = predict_y_values(beta_value, x_values, y_values); - //Evaluation let mse = compute_mse(y_values, y_pred); // mse.print(); // mean squared error ouput + let r_score = calculate_r_score(y_values, y_pred); - // r_score.print(); // accuracy of model 0.97494506835 + r_score.print(); // accuracy of model around 0.97494506835 assert(beta_value.mag > 0, 'x & y not positively correlated'); assert(r_score.mag > 0, 'R-Squared needs to be above 0'); - assert(r_score.mag < 65536, 'R-Squared has to be below 65536'); // 65536 represents ONE in fp16x16. + assert( + r_score.mag < 65536, 'R-Squared has to be below 65536' + ); // 65536 represents ONE in fp16x16. assert(r_score.mag > 32768, 'Accuracy below 50% '); } - ``` Our model will get tested under the `linear_regression_test()` function which will follow the following steps: diff --git a/docs/framework/compatibility.md b/docs/framework/compatibility.md index a5b693849..054c4e009 100644 --- a/docs/framework/compatibility.md +++ b/docs/framework/compatibility.md @@ -47,14 +47,10 @@ You can see below the list of current supported ONNX Operators: | [Acos](operators/tensor/tensor.acos.md) | :white\_check\_mark: | | [Sqrt](operators/tensor/tensor.sqrt.md) | :white\_check\_mark: | | [Onehot](operators/tensor/tensor.onehot.md) | :white\_check\_mark: | -| [QuantizeLinear](performance/performance.quantize\_linear.md) | :white\_check\_mark: | -| [DequantizeLinear](performance/performance.quantize\_linear.md) | :white\_check\_mark: | +| [Slice](operators/tensor/tensor.slice.md) | :white\_check\_mark: | +| [Concat](operators/tensor/tensor.concat.md) | :white\_check\_mark: | +| [QuantizeLinear](operators/tensor/tensor.quantize\_linear.md) | :white\_check\_mark: | +| [DequantizeLinear](operators/tensor/tensor.quantize\_linear.md) | :white\_check\_mark: | -Performance optimizations: - -| Optimization | Implemented | -| :----------------: | :------------------: | -| 8-bit quantization | :white\_check\_mark: | - -Current Operators support: **42/156 (27%)** \ No newline at end of file +Current Operators support: **44/156 (28%)** diff --git a/docs/framework/get-started.md b/docs/framework/get-started.md index 5d24463f5..833df5885 100644 --- a/docs/framework/get-started.md +++ b/docs/framework/get-started.md @@ -3,7 +3,7 @@ In this section, we will guide you to start using Orion successfully. We will help you install Cairo 1.0 and add Orion dependency in your project. {% hint style="info" %} -Orion supports **Cairo v2.1.1** and **Scarb 0.6.2** +Orion supports **Cairo v2.2.0** and **Scarb 0.7.0** {% endhint %} ## 📦 Installations @@ -58,10 +58,8 @@ You can now use the `orion` in your files: ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; +use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; +use orion::operators::nn::{NNTrait, I32NN}; use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; fn relu_example() -> Tensor { @@ -72,8 +70,8 @@ fn relu_example() -> Tensor { IntegerTrait::new(2, false), IntegerTrait::new(1, true), IntegerTrait::new(2, true), - ].span(), - extra: Option::None(()) + ] + .span(), ); return NNTrait::relu(@tensor); @@ -82,4 +80,4 @@ fn relu_example() -> Tensor { ## 🔭 Discover the Orion APIs -
⚙️ OperatorsA set of standardized math functions that are used in the computation of neural network models.operators
🔢 NumbersA full implementation of Signed Integer and Fixed Point in Cairo.numbers
🚀 PerformanceA set of functions to increase the performance of your model.performance
+
⚙️ OperatorsA set of standardized math functions that are used in the computation of neural network models.operators
🔢 NumbersA full implementation of Signed Integer and Fixed Point in Cairo.numbers
diff --git a/docs/framework/numbers/fixed-point/README.md b/docs/framework/numbers/fixed-point/README.md index 54960e168..9f5f18551 100644 --- a/docs/framework/numbers/fixed-point/README.md +++ b/docs/framework/numbers/fixed-point/README.md @@ -1,15 +1,15 @@ # Fixed Point {% hint style="info" %} -This library has been modified from [cubit](https://github.com/influenceth/cubit) library by [influenceth](https://github.com/influenceth) and adjusted to match with Q8.23 and Q16.16 fixed points. +This library has been modified from [cubit](https://github.com/influenceth/cubit) library by [influenceth](https://github.com/influenceth) and adjusted to match with other fixed point implementations. {% endhint %} -This API provides basic some operations for signed fixed point Q8.23 and Q16.16 numbers. Fixed point numbers are represented as a struct `FixedType` with a magnitude and a sign. +This API provides basic some operations for signed fixed point numbers. Fixed point numbers are represented as a struct with a magnitude and a sign. The magnitude represents the absolute value of the number, and the sign indicates whether the number is positive or negative. ```rust -struct FixedType { +struct FP8x23 { mag: u32, sign: bool } @@ -17,12 +17,14 @@ struct FixedType { ### Data types -Orion supports currently one fixed point type. +Orion supports currently these fixed point types: -| Data type | dtype | -| --------- | ----------- | -| Q8.23 | `FixedType` | -| Q16.16 | `FixedType` | +| Data type | dtype | +| --------- | --------- | +| Q8.23 | `FP8x23` | +| Q16.16 | `FP16x16` | +| Q32.32 | `FP32x32` | +| Q64.64 | `FP64x64` | ### **`Fixed` Trait** @@ -32,40 +34,40 @@ use orion::numbers::fixed_point::core::FixedTrait; `Fixed` trait defines the operations that can be performed on a fixed point. -| function | description | -| --- | --- | -| [`fp.new`](fp.new.md) | Constructs a new fixed point instance. | -| [`fp.new_unscaled`](fp.new\_unscaled.md) | Creates a new fixed point instance with the specified unscaled magnitude and sign. | -| [`fp.from_felt`](fp.from\_felt.md) | Creates a new fixed point instance from a felt252 value. | -| [`fp.abs`](fp.abs.md) | Returns the absolute value of the fixed point number. | -| [`fp.ceil`](fp.ceil.md) | Returns the smallest integer greater than or equal to the fixed point number. | -| [`fp.exp`](fp.exp.md) | Returns the value of e raised to the power of the fixed point number. | -| [`fp.exp2`](fp.exp2.md) | Returns the value of 2 raised to the power of the fixed point number. | -| [`fp.floor`](fp.floor.md) | Returns the largest integer less than or equal to the fixed point number. | -| [`fp.ln`](fp.ln.md) | Returns the natural logarithm of the fixed point number. | -| [`fp.log2`](fp.log2.md) | Returns the base-2 logarithm of the fixed point number. | -| [`fp.log10`](fp.log10.md) | Returns the base-10 logarithm of the fixed point number. | -| [`fp.pow`](fp.pow.md) | Returns the result of raising the fixed point number to the power of another fixed point number. | -| [`fp.round`](fp.round.md) | Rounds the fixed point number to the nearest whole number. | -| [`fp.sqrt`](fp.sqrt.md) | Returns the square root of the fixed point number. | -| [`fp.acos`](fp.acos.md) | Returns the arccosine (inverse of cosine) of the fixed point number. | -| [`fp.acos_fast`](fp.acos\_fast.md) | Returns the arccosine (inverse of cosine) of the fixed point number faster with LUT. | -| [`fp.asin`](fp.asin.md) | Returns the arcsine (inverse of sine) of the fixed point number. | -| [`fp.asin_fast`](fp.asin\_fast.md) | Returns the arcsine (inverse of sine) of the fixed point number faster with LUT. | -| [`fp.atan`](fp.atan.md) | Returns the arctangent (inverse of tangent) of the input fixed point number. | -| [`fp.atan_fast`](fp.atan\_fast.md) | Returns the arctangent (inverse of tangent) of the input fixed point number faster with LUT. | -| [`fp.cos`](fp.cos.md) | Returns the cosine of the fixed point number. | -| [`fp.cos_fast`](fp.cos\_fast.md) | Returns the cosine of the fixed point number fast with LUT. | -| [`fp.sin`](fp.sin.md) | Returns the sine of the fixed point number. | -| [`fp.sin_fast`](fp.sin\_fast.md) | Returns the sine of the fixed point number faster with LUT. | -| [`fp.tan`](fp.tan.md) | Returns the tangent of the fixed point number. | -| [`fp.tan_fast`](fp.tan\_fast.md) | Returns the tangent of the fixed point number faster with LUT. | -| [`fp.acosh`](fp.acosh.md) | Returns the value of the inverse hyperbolic cosine of the fixed point number. | -| [`fp.asinh`](fp.asinh.md) | Returns the value of the inverse hyperbolic sine of the fixed point number. | -| [`fp.atanh`](fp.atanh.md) | Returns the value of the inverse hyperbolic tangent of the fixed point number. | -| [`fp.cosh`](fp.cosh.md) | Returns the value of the hyperbolic cosine of the fixed point number. | -| [`fp.sinh`](fp.sinh.md) | Returns the value of the hyperbolic sine of the fixed point number. | -| [`fp.tanh`](fp.tanh.md) | Returns the value of the hyperbolic tangent of the fixed point number. | +| function | description | +| ---------------------------------------- | ------------------------------------------------------------------------------------------------ | +| [`fp.new`](fp.new.md) | Constructs a new fixed point instance. | +| [`fp.new_unscaled`](fp.new\_unscaled.md) | Creates a new fixed point instance with the specified unscaled magnitude and sign. | +| [`fp.from_felt`](fp.from\_felt.md) | Creates a new fixed point instance from a felt252 value. | +| [`fp.abs`](fp.abs.md) | Returns the absolute value of the fixed point number. | +| [`fp.ceil`](fp.ceil.md) | Returns the smallest integer greater than or equal to the fixed point number. | +| [`fp.exp`](fp.exp.md) | Returns the value of e raised to the power of the fixed point number. | +| [`fp.exp2`](fp.exp2.md) | Returns the value of 2 raised to the power of the fixed point number. | +| [`fp.floor`](fp.floor.md) | Returns the largest integer less than or equal to the fixed point number. | +| [`fp.ln`](fp.ln.md) | Returns the natural logarithm of the fixed point number. | +| [`fp.log2`](fp.log2.md) | Returns the base-2 logarithm of the fixed point number. | +| [`fp.log10`](fp.log10.md) | Returns the base-10 logarithm of the fixed point number. | +| [`fp.pow`](fp.pow.md) | Returns the result of raising the fixed point number to the power of another fixed point number. | +| [`fp.round`](fp.round.md) | Rounds the fixed point number to the nearest whole number. | +| [`fp.sqrt`](fp.sqrt.md) | Returns the square root of the fixed point number. | +| [`fp.acos`](fp.acos.md) | Returns the arccosine (inverse of cosine) of the fixed point number. | +| [`fp.acos_fast`](fp.acos\_fast.md) | Returns the arccosine (inverse of cosine) of the fixed point number faster with LUT. | +| [`fp.asin`](fp.asin.md) | Returns the arcsine (inverse of sine) of the fixed point number. | +| [`fp.asin_fast`](fp.asin\_fast.md) | Returns the arcsine (inverse of sine) of the fixed point number faster with LUT. | +| [`fp.atan`](fp.atan.md) | Returns the arctangent (inverse of tangent) of the input fixed point number. | +| [`fp.atan_fast`](fp.atan\_fast.md) | Returns the arctangent (inverse of tangent) of the input fixed point number faster with LUT. | +| [`fp.cos`](fp.cos.md) | Returns the cosine of the fixed point number. | +| [`fp.cos_fast`](fp.cos\_fast.md) | Returns the cosine of the fixed point number fast with LUT. | +| [`fp.sin`](fp.sin.md) | Returns the sine of the fixed point number. | +| [`fp.sin_fast`](fp.sin\_fast.md) | Returns the sine of the fixed point number faster with LUT. | +| [`fp.tan`](fp.tan.md) | Returns the tangent of the fixed point number. | +| [`fp.tan_fast`](fp.tan\_fast.md) | Returns the tangent of the fixed point number faster with LUT. | +| [`fp.acosh`](fp.acosh.md) | Returns the value of the inverse hyperbolic cosine of the fixed point number. | +| [`fp.asinh`](fp.asinh.md) | Returns the value of the inverse hyperbolic sine of the fixed point number. | +| [`fp.atanh`](fp.atanh.md) | Returns the value of the inverse hyperbolic tangent of the fixed point number. | +| [`fp.cosh`](fp.cosh.md) | Returns the value of the hyperbolic cosine of the fixed point number. | +| [`fp.sinh`](fp.sinh.md) | Returns the value of the hyperbolic sine of the fixed point number. | +| [`fp.tanh`](fp.tanh.md) | Returns the value of the hyperbolic tangent of the fixed point number. | ### Arithmetic & Comparison operators @@ -75,26 +77,26 @@ use orion::numbers::fixed_point::core::FixedTrait; ```rust fn add_fp_example() { - // We instantiate two fixed point from felt here. + // We instantiate two fixed point from here. // a = 1 // b = 2 - let a = Fixed::from_unscaled_felt(1); - let b = Fixed::from_unscaled_felt(2); + let a = Fixed::new_unscaled(1, false); + let b = Fixed::new_unscaled(2, false); // We can add two fixed point as follows. let result = a + b; - assert(result == Fixed::from_unscaled_felt(3), 'invalid result'); + assert(result == Fixed::new_unscaled(3), 'invalid result'); } ``` ```rust fn compare_fp_example() -> bool { - // We instantiate two fixed point from felt here. + // We instantiate two fixed point from here. // a = 42 // b = -10 - let a = Fixed::from_unscaled_felt(42); - let b = Fixed::from_unscaled_felt(-10); + let a = Fixed::new_unscaled(42, false); + let b = Fixed::new_unscaled(10, true); // We can compare two fixed point as follows. return a > b; diff --git a/docs/framework/numbers/fixed-point/fp.abs.md b/docs/framework/numbers/fixed-point/fp.abs.md index 13e01d26a..a7dd2db49 100644 --- a/docs/framework/numbers/fixed-point/fp.abs.md +++ b/docs/framework/numbers/fixed-point/fp.abs.md @@ -1,14 +1,14 @@ # fp.abs ```rust -fn abs(self: FixedType) -> FixedType; +fn abs(self: T) -> T; ``` Returns the absolute value of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,10 @@ The absolute value of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn abs_fp_example() -> FixedType { + +fn abs_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(1, true); diff --git a/docs/framework/numbers/fixed-point/fp.acos.md b/docs/framework/numbers/fixed-point/fp.acos.md index 5998cf793..7b2d82ca5 100644 --- a/docs/framework/numbers/fixed-point/fp.acos.md +++ b/docs/framework/numbers/fixed-point/fp.acos.md @@ -1,14 +1,14 @@ # fp.acos ```rust -fn acos(self: FixedType) -> FixedType; +fn acos(self: T) -> T; ``` Returns the arccosine (inverse of cosine) of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the acos of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn acos_fp_example() -> FixedType { +fn acos_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(1, true); diff --git a/docs/framework/numbers/fixed-point/fp.acos_fast.md b/docs/framework/numbers/fixed-point/fp.acos_fast.md index e8e982994..bd9aaa1d9 100644 --- a/docs/framework/numbers/fixed-point/fp.acos_fast.md +++ b/docs/framework/numbers/fixed-point/fp.acos_fast.md @@ -1,14 +1,14 @@ # fp.acos_fast ```rust -fn acos_fast(self: FixedType) -> FixedType; +fn acos_fast(self: T) -> T; ``` Returns the arccosine (inverse of cosine) of the fixed point number faster with LUT. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the acos of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn acos_fast_fp_example() -> FixedType { +fn acos_fast_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(1, true); diff --git a/docs/framework/numbers/fixed-point/fp.acosh.md b/docs/framework/numbers/fixed-point/fp.acosh.md index 4a394bc91..685adddab 100644 --- a/docs/framework/numbers/fixed-point/fp.acosh.md +++ b/docs/framework/numbers/fixed-point/fp.acosh.md @@ -1,14 +1,14 @@ # fp.acosh ```rust -fn acosh(self: FixedType) -> FixedType; +fn acosh(self: T) -> T; ``` Returns the value of the inverse hyperbolic cosine of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The inverse hyperbolic cosine of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn acosh_fp_example() -> FixedType { +fn acosh_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.asin.md b/docs/framework/numbers/fixed-point/fp.asin.md index 9c0838bc7..e012f6295 100644 --- a/docs/framework/numbers/fixed-point/fp.asin.md +++ b/docs/framework/numbers/fixed-point/fp.asin.md @@ -1,14 +1,14 @@ # fp.asin ```rust -fn asin(self: FixedType) -> FixedType; +fn asin(self: T) -> T; ``` Returns the arcsine (inverse of sine) of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the asin of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn asin_fp_example() -> FixedType { +fn asin_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(1, false); diff --git a/docs/framework/numbers/fixed-point/fp.asin_fast.md b/docs/framework/numbers/fixed-point/fp.asin_fast.md index 4c090d308..e4a032d87 100644 --- a/docs/framework/numbers/fixed-point/fp.asin_fast.md +++ b/docs/framework/numbers/fixed-point/fp.asin_fast.md @@ -1,14 +1,14 @@ # fp.asin_fast ```rust -fn asin_fast(self: FixedType) -> FixedType; +fn asin_fast(self: T) -> T; ``` Returns the arcsine (inverse of sine) of the fixed point number faster with LUT. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the asin of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn asin_fast_fp_example() -> FixedType { +fn asin_fast_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(1, false); diff --git a/docs/framework/numbers/fixed-point/fp.asinh.md b/docs/framework/numbers/fixed-point/fp.asinh.md index edfe579b0..43a7128e1 100644 --- a/docs/framework/numbers/fixed-point/fp.asinh.md +++ b/docs/framework/numbers/fixed-point/fp.asinh.md @@ -1,14 +1,14 @@ # fp.asinh ```rust -fn asinh(self: FixedType) -> FixedType; +fn asinh(self: T) -> T; ``` Returns the value of the inverse hyperbolic sine of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The inverse hyperbolic sine of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn asinh_fp_example() -> FixedType { +fn asinh_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.atan.md b/docs/framework/numbers/fixed-point/fp.atan.md index febb7a7ab..87f04eb43 100644 --- a/docs/framework/numbers/fixed-point/fp.atan.md +++ b/docs/framework/numbers/fixed-point/fp.atan.md @@ -1,14 +1,14 @@ # fp.atan ```rust -fn atan(self: FixedType) -> FixedType; +fn atan(self: T) -> T; ``` Returns the arctangent (inverse of tangent) of the input fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the arctangent (inverse of tangent) of the inp ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn atan_fp_example() -> FixedType { +fn atan_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.atan_fast.md b/docs/framework/numbers/fixed-point/fp.atan_fast.md index f60d7100d..9cd91edc7 100644 --- a/docs/framework/numbers/fixed-point/fp.atan_fast.md +++ b/docs/framework/numbers/fixed-point/fp.atan_fast.md @@ -1,14 +1,14 @@ # fp.atan_fast ```rust -fn atan_fast(self: FixedType) -> FixedType; +fn atan_fast(self: T) -> T; ``` Returns the arctangent (inverse of tangent) of the input fixed point number faster with LUT. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the arctangent (inverse of tangent) of the inp ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn atan_fast_fp_example() -> FixedType { +fn atan_fast_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.atanh.md b/docs/framework/numbers/fixed-point/fp.atanh.md index 6c37618d6..21b0bf3be 100644 --- a/docs/framework/numbers/fixed-point/fp.atanh.md +++ b/docs/framework/numbers/fixed-point/fp.atanh.md @@ -1,14 +1,14 @@ # fp.atanh ```rust -fn atanh(self: FixedType) -> FixedType; +fn atanh(self: T) -> T; ``` Returns the value of the inverse hyperbolic tangent of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The inverse hyperbolic tangent of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn atanh_fp_example() -> FixedType { +fn atanh_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::from_felt(32768); // 0.5 diff --git a/docs/framework/numbers/fixed-point/fp.ceil.md b/docs/framework/numbers/fixed-point/fp.ceil.md index 9f778c095..a3b93e0d3 100644 --- a/docs/framework/numbers/fixed-point/fp.ceil.md +++ b/docs/framework/numbers/fixed-point/fp.ceil.md @@ -1,14 +1,14 @@ # fp.ceil ```rust -fn ceil(self: FixedType) -> FixedType; +fn ceil(self: T) -> T; ``` Returns the smallest integer greater than or equal to the fixed point number. ## Args -*`self`(`FixedType`) - The input fixed point +*`self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The smallest integer greater than or equal to the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn ceil_fp_example() -> FixedType { +fn ceil_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::from_felt(190054); // 2.9 diff --git a/docs/framework/numbers/fixed-point/fp.cos.md b/docs/framework/numbers/fixed-point/fp.cos.md index e352fdced..c09c46c25 100644 --- a/docs/framework/numbers/fixed-point/fp.cos.md +++ b/docs/framework/numbers/fixed-point/fp.cos.md @@ -1,14 +1,14 @@ # fp.cos ```rust -fn cos(self: FixedType) -> FixedType; +fn cos(self: T) -> T; ``` Returns the cosine of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the cosine of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn cos_fp_example() -> FixedType { +fn cos_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.cos_fast.md b/docs/framework/numbers/fixed-point/fp.cos_fast.md index 810ddbbe5..605e36100 100644 --- a/docs/framework/numbers/fixed-point/fp.cos_fast.md +++ b/docs/framework/numbers/fixed-point/fp.cos_fast.md @@ -1,14 +1,14 @@ # fp.cos_fast ```rust -fn cos_fast(self: FixedType) -> FixedType; +fn cos_fast(self: T) -> T; ``` Returns the cosine of the fixed point number fast with LUT. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the cosine of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn cos_fast_fp_example() -> FixedType { +fn cos_fast_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.cosh.md b/docs/framework/numbers/fixed-point/fp.cosh.md index 6163bd35e..231e9ec2b 100644 --- a/docs/framework/numbers/fixed-point/fp.cosh.md +++ b/docs/framework/numbers/fixed-point/fp.cosh.md @@ -1,14 +1,14 @@ # fp.cosh ```rust -fn cosh(self: FixedType) -> FixedType; +fn cosh(self: T) -> T; ``` Returns the value of the hyperbolic cosine of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The hyperbolic cosine of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn cosh_fp_example() -> FixedType { +fn cosh_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.exp.md b/docs/framework/numbers/fixed-point/fp.exp.md index dfffa4bd1..a1ae7e4ac 100644 --- a/docs/framework/numbers/fixed-point/fp.exp.md +++ b/docs/framework/numbers/fixed-point/fp.exp.md @@ -1,14 +1,14 @@ # fp.exp ```rust -fn exp(self: FixedType) -> FixedType; +fn exp(self: T) -> T; ``` Returns the value of e raised to the power of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The natural exponent of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn exp_fp_example() -> FixedType { +fn exp_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.exp2.md b/docs/framework/numbers/fixed-point/fp.exp2.md index 2c42fbbc7..27cccb262 100644 --- a/docs/framework/numbers/fixed-point/fp.exp2.md +++ b/docs/framework/numbers/fixed-point/fp.exp2.md @@ -1,14 +1,14 @@ # fp.exp2 ```rust -fn exp2(self: FixedType) -> FixedType; +fn exp2(self: T) -> T; ``` Returns the value of 2 raised to the power of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The binary exponent of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn exp2_fp_example() -> FixedType { +fn exp2_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.floor.md b/docs/framework/numbers/fixed-point/fp.floor.md index 6dde41760..4b6939368 100644 --- a/docs/framework/numbers/fixed-point/fp.floor.md +++ b/docs/framework/numbers/fixed-point/fp.floor.md @@ -1,14 +1,14 @@ # fp.floor ```rust -fn floor(self: FixedType) -> FixedType; +fn floor(self: T) -> T; ``` Returns the largest integer less than or equal to the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ Returns the largest integer less than or equal to the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn floor_fp_example() -> FixedType { +fn floor_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::from_felt(190054); // 2.9 diff --git a/docs/framework/numbers/fixed-point/fp.from_felt.md b/docs/framework/numbers/fixed-point/fp.from_felt.md index 227b0b612..783dd023e 100644 --- a/docs/framework/numbers/fixed-point/fp.from_felt.md +++ b/docs/framework/numbers/fixed-point/fp.from_felt.md @@ -2,14 +2,14 @@ ```rust -fn from_felt(val: felt252) -> FixedType; +fn from_felt(val: felt252) -> T; ``` Creates a new fixed point instance from a felt252 value. ## Args -* `val`(`felt252`) - `felt252` value to convert in FixedType +* `val`(`felt252`) - `felt252` value to convert in fixed point. ## Returns @@ -18,9 +18,11 @@ A new fixed point instance. ## Examples ```rust -fn from_felt_example() -> FixedType { +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; + +fn from_felt_example() -> FP16x16 { // We can call `from_felt` function as follows . - FixedTrait::from_felt(190054); + FixedTrait::from_felt(190054) } >>> {mag: 190054, sign: false} // = 2.9 ``` diff --git a/docs/framework/numbers/fixed-point/fp.from_unscaled_felt.md b/docs/framework/numbers/fixed-point/fp.from_unscaled_felt.md deleted file mode 100644 index bac4023fd..000000000 --- a/docs/framework/numbers/fixed-point/fp.from_unscaled_felt.md +++ /dev/null @@ -1,2 +0,0 @@ -# fp.from\_unscaled\_felt - diff --git a/docs/framework/numbers/fixed-point/fp.ln.md b/docs/framework/numbers/fixed-point/fp.ln.md index 51b3bef8e..8959d6161 100644 --- a/docs/framework/numbers/fixed-point/fp.ln.md +++ b/docs/framework/numbers/fixed-point/fp.ln.md @@ -2,14 +2,14 @@ ```rust -fn ln(self: FixedType) -> FixedType; +fn ln(self: T) -> T; ``` Returns the natural logarithm of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -18,10 +18,9 @@ A fixed point representing the natural logarithm of the input number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn ln_fp_example() -> FixedType { +fn ln_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(1, false); diff --git a/docs/framework/numbers/fixed-point/fp.log10.md b/docs/framework/numbers/fixed-point/fp.log10.md index 850e05f5a..3f570d851 100644 --- a/docs/framework/numbers/fixed-point/fp.log10.md +++ b/docs/framework/numbers/fixed-point/fp.log10.md @@ -1,14 +1,14 @@ # fp.log10 ```rust -fn log10(self: FixedType) -> FixedType; +fn log10(self: T) -> T; ``` Returns the base-10 logarithm of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point representing the base 10 logarithm of the input number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn log10_fp_example() -> FixedType { +fn log10_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(3, false); diff --git a/docs/framework/numbers/fixed-point/fp.log2.md b/docs/framework/numbers/fixed-point/fp.log2.md index c39272c46..b6facc2fe 100644 --- a/docs/framework/numbers/fixed-point/fp.log2.md +++ b/docs/framework/numbers/fixed-point/fp.log2.md @@ -1,14 +1,14 @@ # fp.log2 ```rust -fn log2(self: FixedType) -> FixedType; +fn log2(self: T) -> T; ``` Returns the base-2 logarithm of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Panics @@ -21,10 +21,9 @@ A fixed point representing the binary logarithm of the input number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn log2_fp_example() -> FixedType { +fn log2_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(3, false); diff --git a/docs/framework/numbers/fixed-point/fp.new.md b/docs/framework/numbers/fixed-point/fp.new.md index e46e9277a..0f041a850 100644 --- a/docs/framework/numbers/fixed-point/fp.new.md +++ b/docs/framework/numbers/fixed-point/fp.new.md @@ -1,14 +1,14 @@ # FixedTrait::new ```rust -fn new(mag: u32, sign: bool) -> FixedType; +fn new(mag: MAG, sign: bool) -> T; ``` Constructs a new fixed point instance. ## Args -* `mag`(`u32`) - The magnitude of the fixed point. +* `mag`(`MAG`) - The magnitude of the fixed point. * `sign`(`bool`) - The sign of the fixed point, where `true` represents a negative number. ## Returns @@ -18,10 +18,9 @@ A new fixed point instance. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn new_fp_example() -> FixedType { +fn new_fp_example() -> FP16x16 { // We can call `new` function as follows. FixedTrait::new(65536, false) } diff --git a/docs/framework/numbers/fixed-point/fp.new_unscaled.md b/docs/framework/numbers/fixed-point/fp.new_unscaled.md index b897f93a5..dda9e8192 100644 --- a/docs/framework/numbers/fixed-point/fp.new_unscaled.md +++ b/docs/framework/numbers/fixed-point/fp.new_unscaled.md @@ -1,14 +1,14 @@ # FixedTrait::new\_unscaled ```rust - fn new_unscaled(mag: u32, sign: bool) -> FixedType; + fn new_unscaled(mag: MAG, sign: bool) -> T; ``` Creates a new fixed point instance with the specified unscaled magnitude and sign. ## Args -`mag`(`u32`) - The unscaled magnitude of the fixed point. +`mag`(`MAG`) - The unscaled magnitude of the fixed point. `sign`(`bool`) - The sign of the fixed point, where `true` represents a negative number. ## Returns @@ -18,10 +18,9 @@ A new fixed point instance. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn new_unscaled_example() -> FixedType { +fn new_unscaled_example() -> FP16x16 { // We can call `new_unscaled` function as follows. FixedTrait::new_unscaled(1, false) } diff --git a/docs/framework/numbers/fixed-point/fp.pow.md b/docs/framework/numbers/fixed-point/fp.pow.md index 956e59576..6bff5b5af 100644 --- a/docs/framework/numbers/fixed-point/fp.pow.md +++ b/docs/framework/numbers/fixed-point/fp.pow.md @@ -1,15 +1,15 @@ # fp.pow ```rust -fn pow(self: FixedType, b: FixedType) -> FixedType; +fn pow(self: T, b: T) -> T; ``` Returns the result of raising the fixed point number to the power of another fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point. -* `b`(`FixedType`) - The exponent fixed point number. +* `self`(`T`) - The input fixed point. +* `b`(`T`) - The exponent fixed point number. ## Returns @@ -18,10 +18,9 @@ A fixed point number representing the result of x^y. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn pow_fp_example() -> FixedType { +fn pow_fp_example() -> FP16x16 { // We instantiate FixedTrait points here. let a = FixedTrait::new_unscaled(3, false); let b = FixedTrait::new_unscaled(4, false); diff --git a/docs/framework/numbers/fixed-point/fp.round.md b/docs/framework/numbers/fixed-point/fp.round.md index 7711b3c2b..e7721808a 100644 --- a/docs/framework/numbers/fixed-point/fp.round.md +++ b/docs/framework/numbers/fixed-point/fp.round.md @@ -1,14 +1,14 @@ # fp.round ```rust -fn round(self: FixedType) -> FixedType; +fn round(self: T) -> T; ``` Rounds the fixed point number to the nearest whole number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -18,10 +18,9 @@ A fixed point number representing the rounded value. ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn round_fp_example() -> FixedType { +fn round_fp_example() -> FP16x16 { // We instantiate FixedTrait points here. let a = FixedTrait::from_felt(190054); // 2.9 diff --git a/docs/framework/numbers/fixed-point/fp.sin.md b/docs/framework/numbers/fixed-point/fp.sin.md index 079806547..43aa5e84f 100644 --- a/docs/framework/numbers/fixed-point/fp.sin.md +++ b/docs/framework/numbers/fixed-point/fp.sin.md @@ -1,14 +1,14 @@ # fp.sin ```rust -fn sin(self: FixedType) -> FixedType; +fn sin(self: T) -> T; ``` Returns the sine of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the sin of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn sin_fp_example() -> FixedType { +fn sin_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.sin_fast.md b/docs/framework/numbers/fixed-point/fp.sin_fast.md index a8f159bf1..999dd5fd6 100644 --- a/docs/framework/numbers/fixed-point/fp.sin_fast.md +++ b/docs/framework/numbers/fixed-point/fp.sin_fast.md @@ -1,14 +1,14 @@ # fp.sin_fast ```rust -fn sin_fast(self: FixedType) -> FixedType; +fn sin_fast(self: T) -> T; ``` Returns the sine of the fixed point number faster with LUT. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the sin of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn sin_fast_fp_example() -> FixedType { +fn sin_fast_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.sinh.md b/docs/framework/numbers/fixed-point/fp.sinh.md index e87b83ae8..6dff4da04 100644 --- a/docs/framework/numbers/fixed-point/fp.sinh.md +++ b/docs/framework/numbers/fixed-point/fp.sinh.md @@ -1,14 +1,14 @@ # fp.sinh ```rust -fn sinh(self: FixedType) -> FixedType; +fn sinh(self: T) -> T; ``` Returns the value of the hyperbolic sine of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The hyperbolic sine of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn sinh_fp_example() -> FixedType { +fn sinh_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.sqrt.md b/docs/framework/numbers/fixed-point/fp.sqrt.md index 04393bfdf..7ac877d2f 100644 --- a/docs/framework/numbers/fixed-point/fp.sqrt.md +++ b/docs/framework/numbers/fixed-point/fp.sqrt.md @@ -1,14 +1,14 @@ # fp.sqrt ```rust -fn sqrt(self: FixedType) -> FixedType; +fn sqrt(self: T) -> T; ``` Returns the square root of the fixed point number. ## Args -`self`(`FixedType`) - The input fixed point +`self`(`T`) - The input fixed point ## Panics @@ -21,10 +21,9 @@ A fixed point number representing the square root of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn sqrt_fp_example() -> FixedType { +fn sqrt_fp_example() -> FP16x16 { // We instantiate FixedTrait points here. let a = FixedTrait::new_unscaled(9, false); diff --git a/docs/framework/numbers/fixed-point/fp.tan.md b/docs/framework/numbers/fixed-point/fp.tan.md index 1ae168c76..2bb686dbb 100644 --- a/docs/framework/numbers/fixed-point/fp.tan.md +++ b/docs/framework/numbers/fixed-point/fp.tan.md @@ -1,14 +1,14 @@ # fp.tan ```rust -fn tan(self: FixedType) -> FixedType; +fn tan(self: T) -> T; ``` Returns the tangent of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the tan of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn tan_fp_example() -> FixedType { +fn tan_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.tan_fast.md b/docs/framework/numbers/fixed-point/fp.tan_fast.md index 8e520ac93..3e71b5bd6 100644 --- a/docs/framework/numbers/fixed-point/fp.tan_fast.md +++ b/docs/framework/numbers/fixed-point/fp.tan_fast.md @@ -1,14 +1,14 @@ # fp.tan_fast ```rust -fn tan_fast(self: FixedType) -> FixedType; +fn tan_fast(self: T) -> T; ``` Returns the tangent of the fixed point number faster with LUT. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ A fixed point number representing the tan of the input value. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn tan_fast_fp_example() -> FixedType { +fn tan_fast_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/fixed-point/fp.tanh.md b/docs/framework/numbers/fixed-point/fp.tanh.md index 5301ac022..3bda5aed2 100644 --- a/docs/framework/numbers/fixed-point/fp.tanh.md +++ b/docs/framework/numbers/fixed-point/fp.tanh.md @@ -1,14 +1,14 @@ # fp.tanh ```rust -fn tanh(self: FixedType) -> FixedType; +fn tanh(self: T) -> T; ``` Returns the value of the hyperbolic tangent of the fixed point number. ## Args -* `self`(`FixedType`) - The input fixed point +* `self`(`T`) - The input fixed point ## Returns @@ -17,10 +17,9 @@ The hyperbolic tangent of the input fixed point number. ## Examples ```rust -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; +use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; -fn tanh_fp_example() -> FixedType { +fn tanh_fp_example() -> FP16x16 { // We instantiate fixed point here. let fp = FixedTrait::new_unscaled(2, false); diff --git a/docs/framework/numbers/signed-integer/int.new.md b/docs/framework/numbers/signed-integer/int.new.md index f4425b0a9..24fc1dc6e 100644 --- a/docs/framework/numbers/signed-integer/int.new.md +++ b/docs/framework/numbers/signed-integer/int.new.md @@ -1,17 +1,17 @@ # IntegerTrait::new ```rust -fn new(mag: U, sign: bool) -> T; +fn new(mag: MAG, sign: bool) -> T; ``` Returns a new signed integer. ## Args -* `mag`(`U`) - The magnitude of the integer. +* `mag`(`MAG`) - The magnitude of the integer. * `sign`(`bool`) - The sign of the integer, where `true` represents a negative number. -> _`` generic type depends on the uint type (u8, u16, u32, u64, u128)._ +> _`` generic type depends on the uint type (u8, u16, u32, u64, u128)._ ## Panics diff --git a/docs/framework/operators/neural-network/README.md b/docs/framework/operators/neural-network/README.md index b673f3b8a..19dfbf5a3 100644 --- a/docs/framework/operators/neural-network/README.md +++ b/docs/framework/operators/neural-network/README.md @@ -10,12 +10,12 @@ use orion::operators::nn; Orion supports currently these `NN` types. -| Data type | dtype | -| ------------------------- | -------- | -| 32-bit integer (signed) | `nn_i32` | -| 8-bit integer (signed) | `nn_i8` | -| 32-bit integer (unsigned) | `nn_u32` | -| Fixed point (signed) | `nn_fp` | +| Data type | dtype | +| ------------------------- | ------------------------------------------------- | +| 32-bit integer (signed) | `Tensor` | +| 8-bit integer (signed) | `Tensor` | +| 32-bit integer (unsigned) | `Tensor` | +| Fixed point (signed) | `Tensor` | ### NN**Trait** @@ -31,4 +31,3 @@ Orion supports currently these `NN` types. | [`nn.softsign`](nn.softsign.md) | Applies the Softsign function element-wise. | | [`nn.softplus`](nn.softplus.md) | Applies the Softplus function element-wise. | | [`nn.linear`](nn.linear.md) | Performs a linear transformation of the input tensor using the provided weights and bias. | - diff --git a/docs/framework/operators/neural-network/nn.leaky_relu.md b/docs/framework/operators/neural-network/nn.leaky_relu.md index 6b8199a8f..04d671ec3 100644 --- a/docs/framework/operators/neural-network/nn.leaky_relu.md +++ b/docs/framework/operators/neural-network/nn.leaky_relu.md @@ -1,7 +1,7 @@ # NNTrait::leaky_relu ```rust - fn leaky_relu(inputs: @Tensor, alpha: @FixedType) -> Tensor + fn leaky_relu(inputs: @Tensor, alpha: @T) -> Tensor ``` Applies the leaky rectified linear unit (Leaky ReLU) activation function element-wise to a given tensor. @@ -10,38 +10,36 @@ The Leaky ReLU function is defined as f(x) = alpha * x if x < 0, f(x) = x otherw ## Args * `inputs`(`@Tensor`) - A snapshot of a tensor to which the Leaky ReLU function will be applied. -* `alpha`(`@FixedType`) - A snapshot of a FixedType scalar that defines the alpha value of the Leaky ReLU function. +* `alpha`(`@T`) - A snapshot of a fixed point scalar that defines the alpha value of the Leaky ReLU function. ## Returns -A new FixedType tensor with the same shape as the input tensor and the Leaky ReLU function applied element-wise. +A new fixed point tensor with the same shape as the input tensor and the Leaky ReLU function applied element-wise. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedImpl, FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - -fn leaky_relu_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; +use orion::operators::nn::{NNTrait, FP8x23NN}; +use orion::numbers::{FP8x23, FixedTrait}; + +fn leaky_relu_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2, 3].span(), data: array![ - IntegerTrait::new(1, false), - IntegerTrait::new(2, false), - IntegerTrait::new(1, true), - IntegerTrait::new(2, true), - IntegerTrait::new(0, false), - IntegerTrait::new(0, false), + FixedTrait::new(1, false), + FixedTrait::new(2, false), + FixedTrait::new(1, true), + FixedTrait::new(2, true), + FixedTrait::new(0, false), + FixedTrait::new(0, false), ] .span(), - extra: Option::Some(extra) ); let alpha = FixedTrait::from_felt(838861); // 0.1 diff --git a/docs/framework/operators/neural-network/nn.linear.md b/docs/framework/operators/neural-network/nn.linear.md index 26d158af0..0e37fd268 100644 --- a/docs/framework/operators/neural-network/nn.linear.md +++ b/docs/framework/operators/neural-network/nn.linear.md @@ -25,24 +25,18 @@ A `Tensor` representing the result of the linear transformation. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; +use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; +use orion::operators::nn::{NNTrait, I32NN}; +use orion::numbers::{i32, IntegerTrait}; fn linear_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - // We instantiate inputs here. let inputs = TensorTrait::::new( shape: array![3].span(), data: array![ - IntegerTrait::new(71, true), IntegerTrait::new(38, false), IntegerTrait::new(62, false), + IntegerTrait::new(71, true), IntegerTrait::new(38, false), IntegerTrait::new(62, false), ] .span(), - extra: Option::Some(extra) ); // We instantiate weights here. @@ -55,18 +49,14 @@ fn linear_example() -> Tensor { IntegerTrait::new(33, true), IntegerTrait::new(34, true), IntegerTrait::new(20, true), - ].span(), - extra: Option::Some(extra) + ] + .span(), ); // We instantiate bias here. let bias = TensorTrait::::new( shape: array![2].span(), - data: array![ - IntegerTrait::new(61, false), - IntegerTrait::new(61, true), - ].span(), - extra: Option::Some(extra) + data: array![IntegerTrait::new(61, false), IntegerTrait::new(61, true),].span(), ); return NNTrait::linear(inputs, weights, bias); diff --git a/docs/framework/operators/neural-network/nn.logsoftmax.md b/docs/framework/operators/neural-network/nn.logsoftmax.md index 781301a8e..1aba6b01b 100644 --- a/docs/framework/operators/neural-network/nn.logsoftmax.md +++ b/docs/framework/operators/neural-network/nn.logsoftmax.md @@ -1,7 +1,7 @@ # NNTrait::logsoftmax ```rust - fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor ``` Applies the natural log to Softmax function to an n-dimensional input Tensor consisting of values in the range \[0,1]. @@ -19,29 +19,29 @@ $$ A Tensor of fixed point numbers with the same shape than the input Tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; +use orion::operators::nn::{NNTrait, FP8x23NN}; +use orion::numbers::{FP8x23, FixedTrait}; -fn logsoftmax_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn logsoftmax_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2, 2].span(), data: array![ - IntegerTrait::new(0, false), - IntegerTrait::new(1, false), - IntegerTrait::new(2, false), - IntegerTrait::new(3, false), - ].span(), - extra: Option::Some(extra) + FixedTrait::new(0, false), + FixedTrait::new(1, false), + FixedTrait::new(2, false), + FixedTrait::new(3, false), + ] + .span(), ); return NNTrait::logsoftmax(@tensor, 1); diff --git a/docs/framework/operators/neural-network/nn.relu.md b/docs/framework/operators/neural-network/nn.relu.md index 0673e70d5..c4f622066 100644 --- a/docs/framework/operators/neural-network/nn.relu.md +++ b/docs/framework/operators/neural-network/nn.relu.md @@ -23,11 +23,9 @@ A `Tensor` with the same shape as the input tensor. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; +use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; +use orion::operators::nn::{NNTrait, I32NN}; +use orion::numbers::{i32, IntegerTrait}; fn relu_example() -> Tensor { let tensor = TensorTrait::::new( @@ -37,8 +35,8 @@ fn relu_example() -> Tensor { IntegerTrait::new(2, false), IntegerTrait::new(1, true), IntegerTrait::new(2, true), - ].span(), - extra: Option::None(()) + ] + .span(), ); return NNTrait::relu(@tensor); diff --git a/docs/framework/operators/neural-network/nn.sigmoid.md b/docs/framework/operators/neural-network/nn.sigmoid.md index 86ebf279b..28503f04a 100644 --- a/docs/framework/operators/neural-network/nn.sigmoid.md +++ b/docs/framework/operators/neural-network/nn.sigmoid.md @@ -1,7 +1,7 @@ # NNTrait::sigmoid ```rust - fn sigmoid(tensor: @Tensor) -> Tensor; + fn sigmoid(tensor: @Tensor) -> Tensor; ``` Applies the Sigmoid function to an n-dimensional input tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range \[0,1]. @@ -18,30 +18,29 @@ $$ A Tensor of fixed point numbers with the same shape than the input Tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; +use orion::operators::nn::{NNTrait, FP8x23NN}; +use orion::numbers::{FP8x23, FixedTrait}; -fn sigmoid_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn sigmoid_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2, 2].span(), data: array![ - IntegerTrait::new(0, false), - IntegerTrait::new(1, false), - IntegerTrait::new(2, false), - IntegerTrait::new(3, false), + FixedTrait::new(0, false), + FixedTrait::new(1, false), + FixedTrait::new(2, false), + FixedTrait::new(3, false), ] .span(), - extra: Option::Some(extra) ); return NNTrait::sigmoid(@tensor); diff --git a/docs/framework/operators/neural-network/nn.softmax.md b/docs/framework/operators/neural-network/nn.softmax.md index 0d2681721..13717bdb3 100644 --- a/docs/framework/operators/neural-network/nn.softmax.md +++ b/docs/framework/operators/neural-network/nn.softmax.md @@ -1,7 +1,7 @@ # NNTrait::softmax ```rust - fn softmax(tensor: @Tensor, axis: usize) -> Tensor; + fn softmax(tensor: @Tensor, axis: usize) -> Tensor; ``` Applies the Softmax function to an n-dimensional input Tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range \[0,1] and sum to 1. @@ -19,29 +19,29 @@ $$ A Tensor of fixed point numbers with the same shape than the input Tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; +use orion::operators::nn::{NNTrait, FP8x23NN}; +use orion::numbers::{FP8x23, FixedTrait}; -fn softmax_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn softmax_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2, 2].span(), data: array![ - IntegerTrait::new(0, false), - IntegerTrait::new(1, false), - IntegerTrait::new(2, false), - IntegerTrait::new(3, false), - ].span(), - extra: Option::Some(extra) + NNTrait::new(0, false), + NNTrait::new(1, false), + NNTrait::new(2, false), + NNTrait::new(3, false), + ] + .span(), ); return NNTrait::softmax(@tensor, 1); diff --git a/docs/framework/operators/neural-network/nn.softplus.md b/docs/framework/operators/neural-network/nn.softplus.md index be0077d11..32caeda7a 100644 --- a/docs/framework/operators/neural-network/nn.softplus.md +++ b/docs/framework/operators/neural-network/nn.softplus.md @@ -1,7 +1,7 @@ # NNTrait::softplus ```rust - fn softplus(tensor: @Tensor) -> Tensor; + fn softplus(tensor: @Tensor) -> Tensor; ``` Applies the Softplus function to an n-dimensional input Tensor such that the elements of the n-dimensional output Tensor lie in the range \[-1,1]. @@ -18,30 +18,29 @@ $$ A Tensor of fixed point numbers with the same shape than the input Tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; +use orion::operators::nn::{NNTrait, FP8x23NN}; +use orion::numbers::{FP8x23, FixedTrait}; -fn softplus_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn softplus_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2, 2].span(), data: array![ - IntegerTrait::new(0, false), - IntegerTrait::new(1, false), - IntegerTrait::new(2, false), - IntegerTrait::new(3, false), + FixedTrait::new(0, false), + FixedTrait::new(1, false), + FixedTrait::new(2, false), + FixedTrait::new(3, false), ] .span(), - extra: Option::Some(extra) ); return NNTrait::softplus(@tensor); diff --git a/docs/framework/operators/neural-network/nn.softsign.md b/docs/framework/operators/neural-network/nn.softsign.md index f79b28abe..d80b89d7c 100644 --- a/docs/framework/operators/neural-network/nn.softsign.md +++ b/docs/framework/operators/neural-network/nn.softsign.md @@ -1,7 +1,7 @@ # NNTrait::softsign ```rust - fn softsign(tensor: @Tensor) -> Tensor; + fn softsign(tensor: @Tensor) -> Tensor; ``` Applies the Softsign function to an n-dimensional input Tensor such that the elements of the n-dimensional output Tensor lie in the range \[-1,1]. @@ -18,30 +18,29 @@ $$ A Tensor of fixed point numbers with the same shape than the input Tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; +use orion::operators::nn::{NNTrait, FP8x23NN}; +use orion::numbers::{FP8x23, FixedTrait}; -fn softsign_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn softsign_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2, 2].span(), data: array![ - IntegerTrait::new(0, false), - IntegerTrait::new(1, false), - IntegerTrait::new(2, false), - IntegerTrait::new(3, false), + FixedTrait::new(0, false), + FixedTrait::new(1, false), + FixedTrait::new(2, false), + FixedTrait::new(3, false), ] .span(), - extra: Option::Some(extra) ); return NNTrait::softsign(@tensor); diff --git a/docs/framework/operators/tensor/README.md b/docs/framework/operators/tensor/README.md index b8ac7064e..5e614e62a 100644 --- a/docs/framework/operators/tensor/README.md +++ b/docs/framework/operators/tensor/README.md @@ -2,91 +2,79 @@ A Tensor represents a multi-dimensional array of elements. -A `Tensor` represents a multi-dimensional array of elements and is depicted as a struct containing both the tensor's shape, a flattened array of its data and extra parameters. The generic Tensor is defined as follows: +A `Tensor` represents a multi-dimensional array of elements and is depicted as a struct containing both the tensor's shape and a flattened array of its data. The generic Tensor is defined as follows: ```rust struct Tensor { shape: Span, data: Span - extra: Option } ``` -`ExtraParams` is a struct containing additional parameters for the tensor. - -`fixed_point` extra param indicates the implementation of the fixed point to be used with the tensor, if fixed points are required in certain operations (e.g. `tensor.exp()`). - -```rust -struct ExtraParams { - fixed_point: Option -} -``` - -**ExtraParams** - -
Paramsdtypedefaultdesciption
fixed_pointOption<FixedImpl>FP16x16()Specifies the type of Fixed Point a Tensor can supports.
- ### Data types Orion supports currently these tensor types. -| Data type | dtype | -| ------------------------- | ------------------- | -| 32-bit integer (signed) | `Tensor` | -| 8-bit integer (signed) | `Tensor` | -| 32-bit integer (unsigned) | `Tensor` | -| Fixed point (signed) | `Tensor` | +| Data type | dtype | +| ------------------------- | ------------------------------------------------- | +| 32-bit integer (signed) | `Tensor` | +| 8-bit integer (signed) | `Tensor` | +| 32-bit integer (unsigned) | `Tensor` | +| Fixed point (signed) | `Tensor` | *** ### Tensor**Trait** ```rust -use orion::operators::tensor::core::TensorTrait; +use orion::operators::tensor::TensorTrait; ``` `TensorTrait` defines the operations that can be performed on a Tensor. -| function | description | -| --- | --- | -| [`tensor.new`](tensor.new.md) | Returns a new tensor with the given shape and data. | -| [`tensor.reshape`](tensor.reshape.md) | Returns a new tensor with the specified target shape and the same data as the input tensor. | -| [`tensor.flatten`](tensor.flatten.md) | Flattens the input tensor into a 2D tensor. | -| [`tensor.transpose`](tensor.transpose.md) | Returns a new tensor with the axes rearranged according to the given permutation. | -| [`tensor.at`](tensor.at.md) | Retrieves the value at the specified indices of a Tensor. | -| [`tensor.ravel_index`](tensor.ravel\_index.md) | Converts a multi-dimensional index to a one-dimensional index. | -| [`tensor.unravel_index`](tensor.unravel\_index.md) | Converts a one-dimensional index to a multi-dimensional index. | -| [`tensor.equal`](tensor.equal.md) | Check if two tensors are equal element-wise. | -| [`tensor.greater`](tensor.greater.md) | Check if each element of the first tensor is greater than the corresponding element of the second tensor. | -| [`tensor.greater_equal`](tensor.greater\_equal.md) | Check if each element of the first tensor is greater than or equal to the corresponding element of the second tensor. | -| [`tensor.less`](tensor.less.md) | Check if each element of the first tensor is less than the corresponding element of the second tensor. | -| [`tensor.less_equal`](tensor.less\_equal.md) | Check if each element of the first tensor is less than or equal to the corresponding element of the second tensor. | -| [`tensor.or`](tensor.or.md) | Computes the logical OR of two tensors element-wise. | -| [`tensor.xor`](tensor.xor.md) | Computes the logical XOR of two tensors element-wise. | -| [`tensor.stride`](tensor.stride.md) | Computes the stride of each dimension in the tensor. | -| [`tensor.onehot`](tensor.onehot.md) | Produces one-hot tensor based on input. | -| [`tensor.min`](tensor.min.md) | Returns the minimum value in the tensor. | -| [`tensor.max`](tensor.max.md) | Returns the maximum value in the tensor. | -| [`tensor.reduce_sum`](tensor.reduce\_sum.md) | Reduces a tensor by summing its elements along a specified axis. | -| [`tensor.argmax`](tensor.argmax.md) | Returns the index of the maximum value along the specified axis. | -| [`tensor.argmin`](tensor.argmin.md) | Returns the index of the minimum value along the specified axis. | -| [`tensor.cumsum`](tensor.cumsum.md) | Performs cumulative sum of the input elements along the given axis. | -| [`tensor.matmul`](tensor.matmul.md) | Performs matrix product of two tensors. | -| [`tensor.exp`](tensor.exp.md) | Computes the exponential of all elements of the input tensor. | -| [`tensor.log`](tensor.log.md) | Computes the natural log of all elements of the input tensor. | -| [`tensor.abs`](tensor.abs.md) | Computes the absolute value of all elements in the input tensor. | -| [`tensor.ceil`](tensor.ceil.md) | Rounds up the value of each element in the input tensor. | -| [`tensor.sqrt`](tensor.sqrt.md) | Computes the square root of all elements of the input tensor. | -| [`tensor.sin`](tensor.sin.md) | Computes the sine of all elements of the input tensor. | -| [`tensor.cos`](tensor.cos.md) | Computes the cosine of all elements of the input tensor. | -| [`tensor.atan`](tensor.atan.md) | Computes the arctangent (inverse of tangent) of all elements of the input tensor. | -| [`tensor.asin`](tensor.asin.md) | Computes the arcsine (inverse of sine) of all elements of the input tensor. | -| [`tensor.acos`](tensor.acos.md) | Computes the arccosine (inverse of cosine) of all elements of the input tensor. | -| [`tensor.sinh`](tensor.sinh.md) | Computes the hyperbolic sine of all elements of the input tensor. | -| [`tensor.tanh`](tensor.tanh.md) | Computes the hyperbolic tangent of all elements of the input tensor. | -| [`tensor.cosh`](tensor.cosh.md) | Computes the hyperbolic cosine of all elements of the input tensor. | -| [`tensor.asinh`](tensor.asinh.md) | Computes the inverse hyperbolic sine of all elements of the input tensor. | -| [`tensor.acosh`](tensor.acosh.md) | Computes the inverse hyperbolic cosine of all elements of the input tensor. | +| function | description | +| ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | +| [`tensor.new`](tensor.new.md) | Returns a new tensor with the given shape and data. | +| [`tensor.reshape`](tensor.reshape.md) | Returns a new tensor with the specified target shape and the same data as the input tensor. | +| [`tensor.flatten`](tensor.flatten.md) | Flattens the input tensor into a 2D tensor. | +| [`tensor.transpose`](tensor.transpose.md) | Returns a new tensor with the axes rearranged according to the given permutation. | +| [`tensor.at`](tensor.at.md) | Retrieves the value at the specified indices of a Tensor. | +| [`tensor.ravel_index`](tensor.ravel\_index.md) | Converts a multi-dimensional index to a one-dimensional index. | +| [`tensor.unravel_index`](tensor.unravel\_index.md) | Converts a one-dimensional index to a multi-dimensional index. | +| [`tensor.equal`](tensor.equal.md) | Check if two tensors are equal element-wise. | +| [`tensor.greater`](tensor.greater.md) | Check if each element of the first tensor is greater than the corresponding element of the second tensor. | +| [`tensor.greater_equal`](tensor.greater\_equal.md) | Check if each element of the first tensor is greater than or equal to the corresponding element of the second tensor. | +| [`tensor.less`](tensor.less.md) | Check if each element of the first tensor is less than the corresponding element of the second tensor. | +| [`tensor.less_equal`](tensor.less\_equal.md) | Check if each element of the first tensor is less than or equal to the corresponding element of the second tensor. | +| [`tensor.or`](tensor.or.md) | Computes the logical OR of two tensors element-wise. | +| [`tensor.xor`](tensor.xor.md) | Computes the logical XOR of two tensors element-wise. | +| [`tensor.stride`](tensor.stride.md) | Computes the stride of each dimension in the tensor. | +| [`tensor.onehot`](tensor.onehot.md) | Produces one-hot tensor based on input. | +| [`tensor.min`](tensor.min.md) | Returns the minimum value in the tensor. | +| [`tensor.max`](tensor.max.md) | Returns the maximum value in the tensor. | +| [`tensor.reduce_sum`](tensor.reduce\_sum.md) | Reduces a tensor by summing its elements along a specified axis. | +| [`tensor.argmax`](tensor.argmax.md) | Returns the index of the maximum value along the specified axis. | +| [`tensor.argmin`](tensor.argmin.md) | Returns the index of the minimum value along the specified axis. | +| [`tensor.cumsum`](tensor.cumsum.md) | Performs cumulative sum of the input elements along the given axis. | +| [`tensor.matmul`](tensor.matmul.md) | Performs matrix product of two tensors. | +| [`tensor.exp`](tensor.exp.md) | Computes the exponential of all elements of the input tensor. | +| [`tensor.log`](tensor.log.md) | Computes the natural log of all elements of the input tensor. | +| [`tensor.abs`](tensor.abs.md) | Computes the absolute value of all elements in the input tensor. | +| [`tensor.ceil`](tensor.ceil.md) | Rounds up the value of each element in the input tensor. | +| [`tensor.sqrt`](tensor.sqrt.md) | Computes the square root of all elements of the input tensor. | +| [`tensor.sin`](tensor.sin.md) | Computes the sine of all elements of the input tensor. | +| [`tensor.cos`](tensor.cos.md) | Computes the cosine of all elements of the input tensor. | +| [`tensor.atan`](tensor.atan.md) | Computes the arctangent (inverse of tangent) of all elements of the input tensor. | +| [`tensor.asin`](tensor.asin.md) | Computes the arcsine (inverse of sine) of all elements of the input tensor. | +| [`tensor.acos`](tensor.acos.md) | Computes the arccosine (inverse of cosine) of all elements of the input tensor. | +| [`tensor.sinh`](tensor.sinh.md) | Computes the hyperbolic sine of all elements of the input tensor. | +| [`tensor.tanh`](tensor.tanh.md) | Computes the hyperbolic tangent of all elements of the input tensor. | +| [`tensor.cosh`](tensor.cosh.md) | Computes the hyperbolic cosine of all elements of the input tensor. | +| [`tensor.asinh`](tensor.asinh.md) | Computes the inverse hyperbolic sine of all elements of the input tensor. | +| [`tensor.acosh`](tensor.acosh.md) | Computes the inverse hyperbolic cosine of all elements of the input tensor. | +| [`tensor.concat`](tensor.concat.md) | Concatenate a list of tensors into a single tensor. | +| [`tensor.quantize_linear`](tensor.quantize\_linear.md) | Quantizes a Tensor to i8 using linear quantization. | +| [`tensor.dequantize_linear`](tensor.dequantize\_linear.md) | Dequantizes an i8 Tensor using linear dequantization. | ### Arithmetic Operations @@ -103,22 +91,15 @@ Element-wise add. ```rust use array::{ArrayTrait, SpanTrait}; - -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorAdd}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor, U32TensorAdd}; fn element_wise_add_example() -> Tensor { // We instantiate two 3D Tensors here. let tensor_1 = TensorTrait::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); let tensor_2 = TensorTrait::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can add two tensors as follows. @@ -131,22 +112,17 @@ Add two tensors of different shapes but compatible in broadcasting. ```rust use array::{ArrayTrait, SpanTrait}; - -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorAdd}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor, U32TensorAdd}; fn broadcasting_add_example() -> Tensor { // We instantiate two 3D Tensors here. let tensor_1 = TensorTrait::new( shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) ); let tensor_2 = TensorTrait::new( shape: array![1, 2, 1].span(), data: array![10, 100].span(), - extra: Option::None(()) ); // We can add two tensors as follows. diff --git a/docs/framework/operators/tensor/tensor.abs.md b/docs/framework/operators/tensor/tensor.abs.md index b141c5559..923c7cedc 100644 --- a/docs/framework/operators/tensor/tensor.abs.md +++ b/docs/framework/operators/tensor/tensor.abs.md @@ -21,19 +21,16 @@ the absolute value of all elements in the input tensor. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; +use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; +use orion::numbers::{i32, IntegerTrait}; fn abs_example() -> Tensor { - let tensor = TensorTrait::::new( + let tensor = TensorTrait::new( shape: array![3].span(), data: array![ - IntegerTrait::new(1, true), - IntegerTrait::new(2, true), - IntegerTrait::new(3, false) - ].span(), - extra: Option::None(()) + IntegerTrait::new(1, true), IntegerTrait::new(2, true), IntegerTrait::new(3, false) + ] + .span(), ); return tensor.abs(); diff --git a/docs/framework/operators/tensor/tensor.acos.md b/docs/framework/operators/tensor/tensor.acos.md index f05951f0a..724947e68 100644 --- a/docs/framework/operators/tensor/tensor.acos.md +++ b/docs/framework/operators/tensor/tensor.acos.md @@ -16,28 +16,26 @@ Computes the arccosine (inverse of cosine) of all elements of the input tensor. A new `Tensor` of the same shape as the input tensor with the arccosine value of all elements in the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FP8x23, FixedTrait}; -fn acos_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn acos_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2].span(), - data: array![ - FixedTrait::new_unscaled(0, false), - FixedTrait::new_unscaled(1, false), - ].span(), - extra: Option::Some(extra) + data: array![FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false),] + .span(), ); - return tensor.acos(); + return tensor.acos(); } >>> [13176794, 0] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.acosh.md b/docs/framework/operators/tensor/tensor.acosh.md index a5134db70..7dbf6ba09 100644 --- a/docs/framework/operators/tensor/tensor.acosh.md +++ b/docs/framework/operators/tensor/tensor.acosh.md @@ -1,7 +1,7 @@ # tensor.acosh ```rust - fn acosh(self: @Tensor) -> Tensor; + fn acosh(self: @Tensor) -> Tensor; ``` Computes the inverse hyperbolic cosine of all elements of the input tensor. @@ -15,32 +15,33 @@ $$ ## Returns -Returns a new tensor in `FixedType` with the hyperblic cosine of the elements of the input tensor. +Returns a new tensor in `T` with the hyperblic cosine of the elements of the input tensor. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn acosh_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( - shape: array![2,2].span(), +fn acosh_example() -> Tensor { + let tensor = TensorTrait::::new( + shape: array![2, 2].span(), data: array![ FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false), FixedTrait::new_unscaled(3, false), FixedTrait::new_unscaled(4, false) - ].span(), - extra: Option::Some(extra) + ] + .span(), ); - return tensor.acosh(); + return tensor.acosh(); } >>> [[0,11047444],[14786996,17309365]] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.argmax.md b/docs/framework/operators/tensor/tensor.argmax.md index d661a2c77..511b05c91 100644 --- a/docs/framework/operators/tensor/tensor.argmax.md +++ b/docs/framework/operators/tensor/tensor.argmax.md @@ -28,22 +28,15 @@ Case 1: argmax with default parameters ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn argmax_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), ); // We can call `argmax` function as follows. - return tensor.argmax( - axis: 2, - keepdims: Option::None(()), - select_last_index: Option::None(()) - ); + return tensor.argmax(axis: 2, keepdims: Option::None(()), select_last_index: Option::None(())); } >>> [[[1,1],[0,0]]] ``` @@ -52,22 +45,16 @@ Case 2: argmax with keepdims set to false ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn argmax_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), ); // We can call `argmax` function as follows. - return tensor.argmax( - axis: 2, - keepdims: Option::Some(false), - select_last_index: Option::None(()) - ); + return tensor + .argmax(axis: 2, keepdims: Option::Some(false), select_last_index: Option::None(())); } >>> [[1,1],[0,0]] ``` @@ -77,22 +64,16 @@ Case 3: argmax with select_last_index set to true ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn argmax_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), ); // We can call `argmax` function as follows. - return tensor.argmax( - axis: 2, - keepdims: Option::None(()), - select_last_index: Option::Some(true) - ); + return tensor + .argmax(axis: 2, keepdims: Option::None(()), select_last_index: Option::Some(true)); } >>> [[[1,1],[1,1]]] ``` diff --git a/docs/framework/operators/tensor/tensor.argmin.md b/docs/framework/operators/tensor/tensor.argmin.md index aedbc82d9..cfe15e89b 100644 --- a/docs/framework/operators/tensor/tensor.argmin.md +++ b/docs/framework/operators/tensor/tensor.argmin.md @@ -28,22 +28,15 @@ Case 1: argmin with default parameters ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn argmin_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), ); // We can call `argmin` function as follows. - return tensor.argmin( - axis: 2, - keepdims: Option::None(()), - select_last_index: Option::None(()) - ); + return tensor.argmin(axis: 2, keepdims: Option::None(()), select_last_index: Option::None(())); } >>> [[[0,0],[0,0]]] @@ -53,22 +46,16 @@ Case 2: argmin with keepdims set to false ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn argmin_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), ); // We can call `argmin` function as follows. - return tensor.argmin( - axis: 2, - keepdims: Option::Some(false), - select_last_index: Option::None(()) - ); + return tensor + .argmin(axis: 2, keepdims: Option::Some(false), select_last_index: Option::None(())); } >>> [[0,0],[0,0]] ``` @@ -78,22 +65,16 @@ Case 3: argmin with select_last_index set to true ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn argmin_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), ); // We can call `argmin` function as follows. - return tensor.argmin( - axis: 2, - keepdims: Option::None(()), - select_last_index: Option::None(true) - ); + return tensor + .argmin(axis: 2, keepdims: Option::None(()), select_last_index: Option::Some(true)); } >>> [[[0,0],[1,1]]] ``` diff --git a/docs/framework/operators/tensor/tensor.asin.md b/docs/framework/operators/tensor/tensor.asin.md index 054965aa3..0c29f8735 100644 --- a/docs/framework/operators/tensor/tensor.asin.md +++ b/docs/framework/operators/tensor/tensor.asin.md @@ -16,28 +16,26 @@ Computes the arcsine (inverse of sine) of all elements of the input tensor. A new `Tensor` of the same shape as the input tensor with the arcsine value of all elements in the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn asin_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn asin_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![2].span(), - data: array![ - FixedTrait::new_unscaled(0, false), - FixedTrait::new_unscaled(1, false), - ].span(), - extra: Option::Some(extra) + data: array![FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false),] + .span(), ); - return tensor.asin(); + return tensor.asin(); } >>> [0, 13176794] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.asinh.md b/docs/framework/operators/tensor/tensor.asinh.md index c1fe50bb9..c0193b8b8 100644 --- a/docs/framework/operators/tensor/tensor.asinh.md +++ b/docs/framework/operators/tensor/tensor.asinh.md @@ -1,7 +1,7 @@ # tensor.asinh ```rust - fn asinh(self: @Tensor) -> Tensor; + fn asinh(self: @Tensor) -> Tensor; ``` Computes the inverse hyperbolic sine of all elements of the input tensor. @@ -15,32 +15,33 @@ $$ ## Returns -Returns a new tensor in `FixedType` with the hyperblic sine of the elements of the input tensor. +Returns a new tensor in `T` with the hyperblic sine of the elements of the input tensor. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn asinh_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( - shape: array![2,2].span(), +fn asinh_example() -> Tensor { + let tensor = TensorTrait::::new( + shape: array![2, 2].span(), data: array![ FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false), FixedTrait::new_unscaled(3, false) - ].span(), - extra: Option::Some(extra) + ] + .span(), ); - return tensor.asinh(); + return tensor.asinh(); } >>> [[0,7393498],[12110093,15254235]] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.at.md b/docs/framework/operators/tensor/tensor.at.md index 68d6bf254..0cc9833d5 100644 --- a/docs/framework/operators/tensor/tensor.at.md +++ b/docs/framework/operators/tensor/tensor.at.md @@ -24,21 +24,16 @@ The `T` value at the specified indices. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn at_example() -> u32 { let tensor = TensorTrait::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `at` function as follows. - return tensor.at( - indices: array![0, 1, 1].span() - ); + return tensor.at(indices: array![0, 1, 1].span()); } >>> 3 ``` diff --git a/docs/framework/operators/tensor/tensor.atan.md b/docs/framework/operators/tensor/tensor.atan.md index e6a402ac7..f0b7e12ab 100644 --- a/docs/framework/operators/tensor/tensor.atan.md +++ b/docs/framework/operators/tensor/tensor.atan.md @@ -16,29 +16,30 @@ Computes the arctangent (inverse of tangent) of all elements of the input tensor A new `Tensor` of the same shape as the input tensor with the arctangent (inverse of tangent) value of all elements in the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn atan_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn atan_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![3].span(), data: array![ FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false), - ].span(), - extra: Option::Some(extra) + ] + .span(), ); - return tensor.atan(); + return tensor.atan(); } >>> [0,6588397,9287028] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.ceil.md b/docs/framework/operators/tensor/tensor.ceil.md index 90e8abb12..33a0bf932 100644 --- a/docs/framework/operators/tensor/tensor.ceil.md +++ b/docs/framework/operators/tensor/tensor.ceil.md @@ -16,26 +16,27 @@ Rounds up the value of each element in the input tensor. A new `Tensor` of the same shape as the input tensor with the rounded up value of all elements in the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FP8x23, FixedTrait}; -fn ceil_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn ceil_example() -> Tensor { + let tensor = TensorTrait::new( shape: array![3].span(), data: array![ FixedTrait::new(29998, false), // 0.003576 FixedTrait::new(100663252, false), // 11.9999947548 FixedTrait::new(100663252, true) // -11.9999947548 - ].span(), - extra: Option::Some(extra) + ] + .span(), ); return tensor.ceil(); diff --git a/docs/framework/operators/tensor/tensor.concat.md b/docs/framework/operators/tensor/tensor.concat.md new file mode 100644 index 000000000..0e134a288 --- /dev/null +++ b/docs/framework/operators/tensor/tensor.concat.md @@ -0,0 +1,52 @@ +# tensor.concat + +```rust + fn concat(tensors: Span>, axis: usize, ) -> Tensor; +``` + +Concatenate a list of tensors into a single tensor. + +## Args + +* `tensors`(` Span>,`) - Array of the input tensors. +* `axis`(`usize`) - Axis to concat on. + +## Panics + +* Panic if tensor length is not greater than 1. +* Panics if dimension is not greater than axis. + +## Returns + +A new `Tensor` concatenated tensor of the input tensors. + +## Example + +```rust +use array::{ArrayTrait, SpanTrait}; + +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; + +fn concat_example() -> Tensor { + let tensor1 = TensorTrait::new(shape: array![2, 2].span(), data: array![0, 1, 2, 3].span(),); + let tensor2 = TensorTrait::new(shape: array![2, 2].span(), data: array![0, 1, 2, 3].span(),); + let result = TensorTrait::concat(tensors: array![tensor1, tensor2].span(), axis: 0); + return result; +} +>>> [[0. 1.] + [2. 3.], + [0. 1.] + [2. 3.]] + + result.shape +>>> (4, 2) + + let result = TensorTrait::concat(tensors: array![tensor1, tensor2].span(), axis: 1); + return result; +} +>>> [[0. 1., 0., 1.] + [2. 3., 2., 3.]] + + result.shape +>>> (2, 4 ) +``` diff --git a/docs/framework/operators/tensor/tensor.cos.md b/docs/framework/operators/tensor/tensor.cos.md index 3e33fb38c..f9384ec6d 100644 --- a/docs/framework/operators/tensor/tensor.cos.md +++ b/docs/framework/operators/tensor/tensor.cos.md @@ -16,19 +16,20 @@ Computes the cosine of all elements of the input tensor. A new `Tensor` of the same shape as the input tensor with the cosine value of all elements in the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FP8x23, FixedTrait}; -fn cos_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn cos_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![3].span(), data: array![ FixedTrait::new_unscaled(0, false), @@ -36,7 +37,6 @@ fn cos_example() -> Tensor { FixedTrait::new_unscaled(2, false) ] .span(), - extra: Option::Some(extra) ); return tensor.cos(); diff --git a/docs/framework/operators/tensor/tensor.cosh.md b/docs/framework/operators/tensor/tensor.cosh.md index 3995b09d2..3668e8ca0 100644 --- a/docs/framework/operators/tensor/tensor.cosh.md +++ b/docs/framework/operators/tensor/tensor.cosh.md @@ -1,7 +1,7 @@ # tensor.cosh ```rust - fn cosh(self: @Tensor) -> Tensor; + fn cosh(self: @Tensor) -> Tensor; ``` Computes the hyperbolic cosine of all elements of the input tensor. @@ -15,32 +15,33 @@ $$ ## Returns -Returns a new tensor in `FixedType` with the hyperblic cosine of the elements of the input tensor. +Returns a new tensor in `T` with the hyperblic cosine of the elements of the input tensor. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn cosh_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( - shape: array![2,2].span(), +fn cosh_example() -> Tensor { + let tensor = TensorTrait::::new( + shape: array![2, 2].span(), data: array![ FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false), FixedTrait::new_unscaled(3, false) - ].span(), - extra: Option::Some(extra) + ] + .span(), ); - return tensor.cosh(); + return tensor.cosh(); } >>> [[8388608,12944299],[31559585,84453670]] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.cumsum.md b/docs/framework/operators/tensor/tensor.cumsum.md index 1e56431e8..c93fa4d94 100644 --- a/docs/framework/operators/tensor/tensor.cumsum.md +++ b/docs/framework/operators/tensor/tensor.cumsum.md @@ -28,22 +28,14 @@ Case 1: cumsum with default parameters ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn cumsum_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); - return tensor.cumsum( - axis: 2, - exclusive: Option::None(()), - reverse: Option::None(()) - ); + return tensor.cumsum(axis: 2, exclusive: Option::None(()), reverse: Option::None(())); } >>> [[[0,1],[2,5]],[[4,9],[6,13]]] ``` @@ -53,22 +45,14 @@ Case 2: cumsum with exclusive = true ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn cumsum_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); - return tensor.cumsum( - axis: 2, - exclusive: Option::Some(true), - reverse: Option::None(()) - ); + return tensor.cumsum(axis: 2, exclusive: Option::Some(true), reverse: Option::None(())); } >>> [[[0,0],[0,2]],[[0,4],[0,6]]] ``` @@ -78,22 +62,14 @@ Case 3: cumsum with exclusive = true and reverse = true ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn cumsum_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); - return tensor.cumsum( - axis: 2, - exclusive: Option::Some(true), - reverse: Option::Some(true) - ); + return tensor.cumsum(axis: 2, exclusive: Option::Some(true), reverse: Option::Some(true)); } >>> [[[1,0],[3,0]],[[5,0],[7,0]]] ``` diff --git a/docs/framework/operators/tensor/tensor.dequantize_linear.md b/docs/framework/operators/tensor/tensor.dequantize_linear.md new file mode 100644 index 000000000..c3476f9c2 --- /dev/null +++ b/docs/framework/operators/tensor/tensor.dequantize_linear.md @@ -0,0 +1,62 @@ +# tensor.dequantize_linear + +```rust +fn dequantize_linear(self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor) -> Tensor::; +``` + +Dequantizes a Tensor using linear dequantization. + +The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute +the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and +x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, +or a 1-D tensor for per-axis quantization. + +## Args + +* `self`(`@Tensor`) - The input tensor. +* `x_scale`(`@Tensor`) - Scale for input `x`. +* `x_zero_point`(`@Tensor`) - Zero point for input `x`. + +## Returns + +A new `Tensor` with the same shape as the input tensor, containing the dequantized values. + +## Type Constraints + +u32 tensor, not supported. + +## Examples + +```rust + use array::{ArrayTrait, SpanTrait}; + + use orion::operators::tensor::{TensorTrait, Tensor, I8Tensor, I32Tensor}; + use orion::numbers::{i8, i32, IntegerTrait}; + + fn dequantize_linear_example() -> Tensor { + // We instantiate a 1D Tensor here. + let x = TensorTrait::::new( + shape: array![4].span(), + data: array![ + IntegerTrait::new(0, false), + IntegerTrait::new(3, false), + IntegerTrait::new(125, false), + IntegerTrait::new(127, false), + ] + .span(), + ); + + // We instantiate the x_scale here. + let x_scale = TensorTrait::::new( + shape: array![1].span(), data: array![IntegerTrait::new(2, false)].span(), + ); + + // We instantiate the x_zero_point here. + let x_zero_point = TensorTrait::::new( + shape: array![1].span(), data: array![IntegerTrait::new(0, false)].span(), + ); + + return x.dequantize_linear(@x_scale, @x_zero_point); + } +>>> [0, 6, 250, 254] +``` diff --git a/docs/framework/operators/tensor/tensor.equal.md b/docs/framework/operators/tensor/tensor.equal.md index 990ce33b4..83bb52a5d 100644 --- a/docs/framework/operators/tensor/tensor.equal.md +++ b/docs/framework/operators/tensor/tensor.equal.md @@ -29,20 +29,15 @@ Case 1: Compare tensors with same shape ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn eq_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); let tensor_2 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), ); // We can call `equal` function as follows. @@ -56,21 +51,14 @@ Case 2: Compare tensors with different shapes ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn eq_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); - let tensor_2 = TensorTrait::::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); // We can call `equal` function as follows. return tensor_1.equal(@tensor_2); diff --git a/docs/framework/operators/tensor/tensor.exp.md b/docs/framework/operators/tensor/tensor.exp.md index 65d8e1ab0..187d9becd 100644 --- a/docs/framework/operators/tensor/tensor.exp.md +++ b/docs/framework/operators/tensor/tensor.exp.md @@ -1,7 +1,7 @@ # tensor.exp ```rust - fn exp(self: @Tensor) -> Tensor; + fn exp(self: @Tensor) -> Tensor; ``` Computes the exponential of all elements of the input tensor. @@ -15,23 +15,29 @@ $$ ## Returns -Returns a new tensor in `FixedType` with the exponential of the elements of the input tensor. +Returns a new tensor in `T` with the exponential of the elements of the input tensor. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FP8x23, FixedTrait}; -fn exp_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; +fn exp_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2].span(), - data: array![0, 1, 2, 3].span(), - extra: Option::Some(extra) + shape: array![2, 2].span(), + data: array![ + FixedTrait::new_unscaled(0, false), + FixedTrait::new_unscaled(1, false), + FixedTrait::new_unscaled(2, false), + FixedTrait::new_unscaled(3, false), + ] ); // We can call `exp` function as follows. diff --git a/docs/framework/operators/tensor/tensor.flatten.md b/docs/framework/operators/tensor/tensor.flatten.md index 78ee6240b..0740346b4 100644 --- a/docs/framework/operators/tensor/tensor.flatten.md +++ b/docs/framework/operators/tensor/tensor.flatten.md @@ -26,12 +26,6 @@ A new `Tensor` instance containing the flattened version of the input tensor. Case 1: flatten with axis 0 ```rust -use array::{ArrayTrait, SpanTrait}; - -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - fn flatten_example() -> Tensor { let tensor = TensorTrait::::new( shape: array![2, 2, 2].span(), @@ -49,15 +43,11 @@ Case 2: flatten with axis 1 ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn flatten_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); return tensor.flatten(1); // equivalent to tensor.reshape(2,4) @@ -70,15 +60,11 @@ Case 3: flatten with axis 2 ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn flatten_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); return tensor.flatten(2); // equivalent to tensor.reshape(4,2) diff --git a/docs/framework/operators/tensor/tensor.greater.md b/docs/framework/operators/tensor/tensor.greater.md index f1c17b02a..677bc1220 100644 --- a/docs/framework/operators/tensor/tensor.greater.md +++ b/docs/framework/operators/tensor/tensor.greater.md @@ -29,20 +29,15 @@ Case 1: Compare tensors with same shape ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn greater_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); let tensor_2 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), ); // We can call `greater` function as follows. @@ -56,21 +51,14 @@ Case 2: Compare tensors with different shapes ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn greater_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); - let tensor_2 = TensorTrait::::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); // We can call `greater` function as follows. return tensor_1.greater(@tensor_2); diff --git a/docs/framework/operators/tensor/tensor.greater_equal.md b/docs/framework/operators/tensor/tensor.greater_equal.md index 8eb47ab75..8a2d6637d 100644 --- a/docs/framework/operators/tensor/tensor.greater_equal.md +++ b/docs/framework/operators/tensor/tensor.greater_equal.md @@ -29,20 +29,15 @@ Case 1: Compare tensors with same shape ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn greater_equal_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); let tensor_2 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), ); // We can call `greater_equal` function as follows. @@ -56,21 +51,14 @@ Case 2: Compare tensors with different shapes ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn greater_equal_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); - let tensor_2 = TensorTrait::::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); // We can call `greater_equal` function as follows. return tensor_1.greater_equal(@tensor_2); diff --git a/docs/framework/operators/tensor/tensor.less.md b/docs/framework/operators/tensor/tensor.less.md index 805c4121a..0413fa7ea 100644 --- a/docs/framework/operators/tensor/tensor.less.md +++ b/docs/framework/operators/tensor/tensor.less.md @@ -29,20 +29,15 @@ Case 1: Compare tensors with same shape ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn less_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); let tensor_2 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), ); // We can call `less` function as follows. @@ -56,21 +51,14 @@ Case 2: Compare tensors with different shapes ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn less_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); - let tensor_2 = TensorTrait::::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); // We can call `less` function as follows. return tensor_1.less(@tensor_2); diff --git a/docs/framework/operators/tensor/tensor.less_equal.md b/docs/framework/operators/tensor/tensor.less_equal.md index 7dc8f20cc..23d3356fa 100644 --- a/docs/framework/operators/tensor/tensor.less_equal.md +++ b/docs/framework/operators/tensor/tensor.less_equal.md @@ -29,20 +29,15 @@ Case 1: Compare tensors with same shape ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn less_equal_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); let tensor_2 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), ); // We can call `less_equal` function as follows. @@ -56,21 +51,14 @@ Case 2: Compare tensors with different shapes ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn less_equal_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3, 3].span(), - data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); - let tensor_2 = TensorTrait::::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); // We can call `less_equal` function as follows. return tensor_1.less_equal(@tensor_2); diff --git a/docs/framework/operators/tensor/tensor.log.md b/docs/framework/operators/tensor/tensor.log.md index 546e0ccfd..d14245e47 100644 --- a/docs/framework/operators/tensor/tensor.log.md +++ b/docs/framework/operators/tensor/tensor.log.md @@ -1,7 +1,7 @@ # tensor.log ```rust - fn log(self: @Tensor) -> Tensor; + fn log(self: @Tensor) -> Tensor; ``` Computes the natural log of all elements of the input tensor. @@ -15,23 +15,29 @@ $$ ## Returns -Returns a new tensor in `FixedType` with the natural log of the elements of the input tensor. +Returns a new tensor in `T` with the natural log of the elements of the input tensor. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FP8x23, FixedTrait}; -fn log_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; +fn log_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2].span(), - data: array![1, 2, 3, 100].span(), - extra: Option::Some(extra) + shape: array![2, 2].span(), + data: array![ + FixedTrait::new_unscaled(0, false), + FixedTrait::new_unscaled(1, false), + FixedTrait::new_unscaled(2, false), + FixedTrait::new_unscaled(100, false), + ] ); // We can call `log` function as follows. diff --git a/docs/framework/operators/tensor/tensor.matmul.md b/docs/framework/operators/tensor/tensor.matmul.md index 684061e0e..21e828a76 100644 --- a/docs/framework/operators/tensor/tensor.matmul.md +++ b/docs/framework/operators/tensor/tensor.matmul.md @@ -31,21 +31,12 @@ Case 1: Dot product of two vectors (1D \* 1D) ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn dot_product_example() -> Tensor { - let tensor_1 = TensorTrait::::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_1 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); - let tensor_2 = TensorTrait::::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); // We can call `matmul` function as follows. return tensor_1.matmul(@tensor_2); @@ -58,20 +49,15 @@ Case 2: Matrix multiplication (2D \* 2D) ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn matrix_mul_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![2, 2].span(), - data: array![244, 99, 109, 162].span(), - extra: Option::None(()) + shape: array![2, 2].span(), data: array![244, 99, 109, 162].span() ); let tensor_2 = TensorTrait::::new( - shape: array![2, 2].span(), - data: array![151, 68, 121, 170].span(), - extra: Option::None(()) + shape: array![2, 2].span(), data: array![151, 68, 121, 170].span() ); // We can call `matmul` function as follows. @@ -85,21 +71,14 @@ Case 3: Matrix-Vector multiplication (2D x 1D) ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn matrix_vec_mul_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + 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].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); // We can call `matmul` function as follows. return tensor_1.matmul(@tensor_2); diff --git a/docs/framework/operators/tensor/tensor.max.md b/docs/framework/operators/tensor/tensor.max.md index 19061fdeb..e115cc559 100644 --- a/docs/framework/operators/tensor/tensor.max.md +++ b/docs/framework/operators/tensor/tensor.max.md @@ -19,15 +19,11 @@ Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn max_example() -> u32 { let tensor = TensorTrait::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `max` function as follows. diff --git a/docs/framework/operators/tensor/tensor.min.md b/docs/framework/operators/tensor/tensor.min.md index ff0af7ee0..037c4067f 100644 --- a/docs/framework/operators/tensor/tensor.min.md +++ b/docs/framework/operators/tensor/tensor.min.md @@ -19,15 +19,12 @@ The minimum `T` value in the tensor. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn min_example() -> u32 { let tensor = TensorTrait::new( shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) ); // We can call `min` function as follows. diff --git a/docs/framework/operators/tensor/tensor.new.md b/docs/framework/operators/tensor/tensor.new.md index 59e96a96a..3d29c9da3 100644 --- a/docs/framework/operators/tensor/tensor.new.md +++ b/docs/framework/operators/tensor/tensor.new.md @@ -1,7 +1,7 @@ # tensor.new ```rust - fn new(shape: Span, data: Span, extra: Option) -> Tensor; + fn new(shape: Span, data: Span) -> Tensor; ``` Returns a new tensor with the given shape and data. @@ -10,7 +10,6 @@ Returns a new tensor with the given shape and data. * `shape`(`Span`) - A span representing the shape of the tensor. * `data` (`Span`) - A span containing the array of elements. -* `extra` (`Option`) - A parameter for extra tensor options. ## Panics @@ -27,27 +26,22 @@ Let's create new u32 Tensors. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::operators::tensor::{ + TensorTrait, // we import the trait + Tensor, // we import the type + U32Tensor // we import the implementation. +}; // 1D TENSOR fn tensor_1D() -> Tensor { - let tensor = TensorTrait::new( - shape: array![3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) - ); + let tensor = TensorTrait::new(shape: array![3].span(), data: array![0, 1, 2].span()); return tensor; } // 2D TENSOR fn tensor_2D() -> Tensor { - let tensor = TensorTrait::new( - shape: array![2, 2].span(), - data: array![0, 1, 2, 3].span(), - extra: Option::None(()) - ); + let tensor = TensorTrait::new(shape: array![2, 2].span(), data: array![0, 1, 2, 3].span()); return tensor; } @@ -55,9 +49,7 @@ fn tensor_2D() -> Tensor { // 3D TENSOR fn tensor_3D() -> Tensor { let tensor = TensorTrait::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); return tensor; diff --git a/docs/framework/operators/tensor/tensor.onehot.md b/docs/framework/operators/tensor/tensor.onehot.md index d5e73edca..09e88f02d 100644 --- a/docs/framework/operators/tensor/tensor.onehot.md +++ b/docs/framework/operators/tensor/tensor.onehot.md @@ -21,28 +21,31 @@ Produces one-hot tensor based on input. A new `Tensor` one-hot encode of the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust -fn onehot_example() -> Tensor { use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - -fn onehot_example() -> Tensor { - let tensor = TensorTrait::::new( - shape: array![2, 2].span(), - data: array![0, 1, 2, 3].span(), - extra: Option::None(()) - ); - - return tensor.onehot( - depth: 3, - axis: Option::None(()), - values: array![0, 1].span() - ); +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FP8x23, FixedTrait}; + +fn onehot_example() -> Tensor { + let tensor = TensorTrait::::new( + shape: array![2,2].span(), + data: array![ + FixedTrait::new_unscaled(0, false), + FixedTrait::new_unscaled(1, false), + FixedTrait::new_unscaled(2, false), + FixedTrait::new_unscaled(3, false), + ] + .span(), + ); + + return tensor.onehot(depth: 3, axis: Option::None(()), values: array![0, 1].span()); } >>> [[1. 0. 0.] [0. 1. 0.] diff --git a/docs/framework/operators/tensor/tensor.or.md b/docs/framework/operators/tensor/tensor.or.md index 3143531a2..ec92f7bab 100644 --- a/docs/framework/operators/tensor/tensor.or.md +++ b/docs/framework/operators/tensor/tensor.or.md @@ -29,21 +29,15 @@ Case 1: Compare tensors with same shape ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn or_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + 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, 3, 4, 5, 9, 1, 5].span(), - extra: Option::None(()) + shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), ); return tensor_1.or(@tensor_2); @@ -56,21 +50,15 @@ Case 2: Compare tensors with different shapes ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn or_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); let tensor_2 = TensorTrait::::new( - shape: array![1, 3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) + shape: array![1, 3].span(), data: array![0, 1, 2].span(), ); return tensor_1.or(@tensor_2); diff --git a/docs/framework/operators/tensor/tensor.quantize_linear.md b/docs/framework/operators/tensor/tensor.quantize_linear.md new file mode 100644 index 000000000..312cb94cb --- /dev/null +++ b/docs/framework/operators/tensor/tensor.quantize_linear.md @@ -0,0 +1,65 @@ +# tensor.quantize_linear + +```rust +fn quantize_linear(self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor) -> Tensor::; +``` + +Quantizes a Tensor using linear quantization. + +The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point +to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, +and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. +The quantization formula is `y = saturate ((x / y_scale) + y_zero_point)`. For saturation, it saturates to `[-128, 127]`. +For (x / y_scale), it's rounding to the nearest even. + +## Args + +* `self`(`@Tensor`) - The input tensor. +* `y_scale`(`@Tensor`) - Scale for doing quantization to get `y`. +* `y_zero_point`(`@Tensor`) - Zero point for doing quantization to get `y`. + +## Returns + +A new `Tensor` with the same shape as the input tensor, containing the quantized values. + +## Type Constraints + +u32 tensor, not supported. + +## Examples + +```rust +use array::{ArrayTrait, SpanTrait}; + +use orion::operators::tensor::{TensorTrait, Tensor, I8Tensor, I32Tensor}; +use orion::numbers::{i8, i32, IntegerTrait}; + +fn quantize_linear_example() -> Tensor { + // We instantiate a 1D Tensor here. + let x = TensorTrait::::new( + shape: array![6].span(), + data: array![ + IntegerTrait::new(0, false), + IntegerTrait::new(2, false), + IntegerTrait::new(3, false), + IntegerTrait::new(1000, false), + IntegerTrait::new(254, true), + IntegerTrait::new(1000, true), + ] + .span(), + ); + + // We instantiate the y_scale here. + let y_scale = TensorTrait::::new( + shape: array![1].span(), data: array![IntegerTrait::new(2, false)].span(), + ); + + // We instantiate the y_zero_point here. + let y_zero_point = TensorTrait::::new( + shape: array![1].span(), data: array![IntegerTrait::new(1, false)].span(), + ); + + return x.quantize_linear(@y_scale, @y_zero_point); +} +>>> [1, 2, 2, 127, -126, -128] +``` diff --git a/docs/framework/operators/tensor/tensor.ravel_index.md b/docs/framework/operators/tensor/tensor.ravel_index.md index 40c0cf83d..6d6ff9725 100644 --- a/docs/framework/operators/tensor/tensor.ravel_index.md +++ b/docs/framework/operators/tensor/tensor.ravel_index.md @@ -24,21 +24,15 @@ The index corresponding to the given indices. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn ravel_index_example() -> usize { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `ravel_index` function as follows. - return tensor.ravel_index( - indices: array![1, 3, 0].span() - ); + return tensor.ravel_index(indices: array![1, 3, 0].span()); } >>> 10 // This means that the value of indices [1,3,0] diff --git a/docs/framework/operators/tensor/tensor.reduce_sum.md b/docs/framework/operators/tensor/tensor.reduce_sum.md index a1a4bd67f..e596ba311 100644 --- a/docs/framework/operators/tensor/tensor.reduce_sum.md +++ b/docs/framework/operators/tensor/tensor.reduce_sum.md @@ -25,22 +25,15 @@ A new `Tensor` instance with the specified axis reduced by summing its elemen ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn reduce_sum_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `reduce_sum` function as follows. - return tensor.reduce_sum( - axis: 0, - keepdims: false - ); + return tensor.reduce_sum(axis: 0, keepdims: false); } >>> [[4,6],[8,10]] ``` diff --git a/docs/framework/operators/tensor/tensor.reshape.md b/docs/framework/operators/tensor/tensor.reshape.md index 8781a8f5d..998c40c1a 100644 --- a/docs/framework/operators/tensor/tensor.reshape.md +++ b/docs/framework/operators/tensor/tensor.reshape.md @@ -24,21 +24,15 @@ A new `Tensor` with the specified target shape and the same data. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn reshape_tensor_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `reshape` function as follows. - return tensor.reshape( - target_shape: array![2,4].span() - ); + return tensor.reshape(target_shape: array![2, 4].span()); } >>> [[0,1,2,3], [4,5,6,7]] ``` diff --git a/docs/framework/operators/tensor/tensor.sin.md b/docs/framework/operators/tensor/tensor.sin.md index b6c12ad29..3c7e0da17 100644 --- a/docs/framework/operators/tensor/tensor.sin.md +++ b/docs/framework/operators/tensor/tensor.sin.md @@ -16,19 +16,20 @@ Computes the sine of all elements of the input tensor. A new `Tensor` of the same shape as the input tensor with the sine value of all elements in the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FP8x23, FixedTrait}; -fn sin_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn sin_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![3].span(), data: array![ FixedTrait::new_unscaled(0, false), @@ -36,7 +37,6 @@ fn sin_example() -> Tensor { FixedTrait::new_unscaled(2, false) ] .span(), - extra: Option::Some(extra) ); return tensor.sin(); diff --git a/docs/framework/operators/tensor/tensor.sinh.md b/docs/framework/operators/tensor/tensor.sinh.md index d02ae627b..c89f40ecb 100644 --- a/docs/framework/operators/tensor/tensor.sinh.md +++ b/docs/framework/operators/tensor/tensor.sinh.md @@ -1,7 +1,7 @@ # tensor.sinh ```rust - fn sinh(self: @Tensor) -> Tensor; + fn sinh(self: @Tensor) -> Tensor; ``` Computes the hyperbolic sine of all elements of the input tensor. @@ -15,32 +15,33 @@ $$ ## Returns -Returns a new tensor in `FixedType` with the hyperbolic sine of the elements of the input tensor. +Returns a new tensor in `T` with the hyperbolic sine of the elements of the input tensor. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn sinh_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( - shape: array![2,2].span(), +fn sinh_example() -> Tensor { + let tensor = TensorTrait::::new( + shape: array![2, 2].span(), data: array![ FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false), FixedTrait::new_unscaled(3, false) - ].span(), - extra: Option::Some(extra) + ] + .span(), ); - return tensor.sinh(); + return tensor.sinh(); } >>> [[0,9858303],[30424311,84036026]] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.slice.md b/docs/framework/operators/tensor/tensor.slice.md new file mode 100644 index 000000000..f2843b53d --- /dev/null +++ b/docs/framework/operators/tensor/tensor.slice.md @@ -0,0 +1,52 @@ +# tensor.slice + +```rust + fn slice(self: @Tensor, starts: Span, ends: Span, axes: Option>, steps: Option>) -> Tensor; +``` + +Produces a slice of the input tensor along multiple axes. + +## Args + +* `self`(`@Tensor`) - Tensor of data to extract slices from. +* `starts`(Span) - 1-D tensor of starting indices of corresponding axis in `axes` +* `ends`(Span) - 1-D tensor of ending indices (exclusive) of corresponding axis in `axes` +* `axes`(Option>) - 1-D tensor of axes that `starts` and `ends` apply to. +* `steps`(Option>) - 1-D tensor of slice step of corresponding axis in `axes`. + +## Panics + +* Panics if the length of starts is not equal to the length of ends. +* Panics if the length of starts is not equal to the length of axes. +* Panics if the length of starts is not equal to the length of steps. + +## Returns + +A new `Tensor` slice of the input tensor. + +## Example + +```rust +use array::{ArrayTrait, SpanTrait}; + +use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; +use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; +use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + +fn slice_example() -> Tensor { + let tensor = TensorTrait::::new( + shape: array![2, 4].span(), + data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), + extra: Option::None(()) + ); + + return tensor.slice( + starts: array![0, 2].span(), + ends: array![2, 4].span(), + axis: Option::None(()), + steps: Option::Some(array![1, 1].span()) + ); +} +>>> [[2 3] + [6 7]] +``` diff --git a/docs/framework/operators/tensor/tensor.sqrt.md b/docs/framework/operators/tensor/tensor.sqrt.md index 6392730f6..918913f0b 100644 --- a/docs/framework/operators/tensor/tensor.sqrt.md +++ b/docs/framework/operators/tensor/tensor.sqrt.md @@ -16,26 +16,27 @@ Computes the square root of all elements of the input tensor. A new `Tensor` of the same shape as the input tensor with the arctangent (inverse of tangent) value of all elements in the input tensor. +## Type Constraints + +Constrain input and output types to fixed point tensors. + ## Example ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn sqrt_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( +fn sqrt_example() -> Tensor { + let tensor = TensorTrait::::new( shape: array![3].span(), data: array![ FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false), - ].span(), - extra: Option::Some(extra) + ] + .span(), ); return tensor.sqrt(); diff --git a/docs/framework/operators/tensor/tensor.stride.md b/docs/framework/operators/tensor/tensor.stride.md index 64d7a70cf..75313770a 100644 --- a/docs/framework/operators/tensor/tensor.stride.md +++ b/docs/framework/operators/tensor/tensor.stride.md @@ -18,15 +18,11 @@ A span of usize representing the stride for each dimension of the tensor. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn stride_example() -> Span { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `stride` function as follows. diff --git a/docs/framework/operators/tensor/tensor.tanh.md b/docs/framework/operators/tensor/tensor.tanh.md index 96df26d85..9ffec7780 100644 --- a/docs/framework/operators/tensor/tensor.tanh.md +++ b/docs/framework/operators/tensor/tensor.tanh.md @@ -1,7 +1,7 @@ # tensor.tanh ```rust - fn tanh(self: @Tensor) -> Tensor; + fn tanh(self: @Tensor) -> Tensor; ``` Computes the hyperbolic tangent of all elements of the input tensor. @@ -15,32 +15,33 @@ $$ ## Returns -Returns a new tensor in `FixedType` with the hyperbolic tangent of the elements of the input tensor. +Returns a new tensor in `T` with the hyperbolic tangent of the elements of the input tensor. + +## Type Constraints + +Constrain input and output types to fixed point tensors. ## Examples ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; +use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; +use orion::numbers::{FixedTrait, FP8x23}; -fn tanh_example() -> Tensor { - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - let tensor = TensorTrait::::new( - shape: array![2,2].span(), +fn tanh_example() -> Tensor { + let tensor = TensorTrait::::new( + shape: array![2, 2].span(), data: array![ FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false), FixedTrait::new_unscaled(3, false) - ].span(), - extra: Option::Some(extra) + ] + .span(), ); - return tensor.tanh(); + return tensor.tanh(); } >>> [[0,6388715],[8086850,8347125]] // The fixed point representation of diff --git a/docs/framework/operators/tensor/tensor.transpose.md b/docs/framework/operators/tensor/tensor.transpose.md index 2908ebef1..0dee6e2fb 100644 --- a/docs/framework/operators/tensor/tensor.transpose.md +++ b/docs/framework/operators/tensor/tensor.transpose.md @@ -24,21 +24,15 @@ A `Tensor` instance with the axes reordered according to the given permutatio ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn transpose_tensor_example() -> Tensor { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `transpose` function as follows. - return tensor.transpose( - axes: array![1, 2, 0].span() - ); + return tensor.transpose(axes: array![1, 2, 0].span()); } >>> [[[0,4],[1,5]],[[2,6],[3,7]]] ``` diff --git a/docs/framework/operators/tensor/tensor.unravel_index.md b/docs/framework/operators/tensor/tensor.unravel_index.md index 4a9bf516c..6221a5bd7 100644 --- a/docs/framework/operators/tensor/tensor.unravel_index.md +++ b/docs/framework/operators/tensor/tensor.unravel_index.md @@ -24,15 +24,11 @@ The unraveled indices corresponding to the given index. ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn unravel_index_example() -> Span { let tensor = TensorTrait::::new( - shape: array![2, 2, 2].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - extra: Option::None(()) + shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), ); // We can call `unravel_index` function as follows. diff --git a/docs/framework/operators/tensor/tensor.xor.md b/docs/framework/operators/tensor/tensor.xor.md index cfc725714..53d89b24e 100644 --- a/docs/framework/operators/tensor/tensor.xor.md +++ b/docs/framework/operators/tensor/tensor.xor.md @@ -29,21 +29,15 @@ Case 1: Compare tensors with same shape ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn xor_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + 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, 3, 4, 5, 9, 1, 5].span(), - extra: Option::None(()) + shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), ); return tensor_1.xor(@tensor_2); @@ -56,21 +50,15 @@ Case 2: Compare tensors with different shapes ```rust use array::{ArrayTrait, SpanTrait}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; +use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; fn xor_example() -> Tensor { let tensor_1 = TensorTrait::::new( - shape: array![3, 3].span(), - data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - extra: Option::None(()) + shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), ); let tensor_2 = TensorTrait::::new( - shape: array![1, 3].span(), - data: array![0, 1, 2].span(), - extra: Option::None(()) + shape: array![1, 3].span(), data: array![0, 1, 2].span(), ); return tensor_1.xor(@tensor_2); diff --git a/docs/framework/performance/README.md b/docs/framework/performance/README.md deleted file mode 100644 index 222fd5fcf..000000000 --- a/docs/framework/performance/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Performance - -This trait contains a set of functions to increase the performance of your model. Performance trait takes two generic parameters: - -* `T`, the type of the unquantized tensor. -* `Q`, the type of the quantized tensor. - -```rust -use orion::performance::core::PerfomanceTrait; -``` - -### Data types - -Orion supports currently these `performance` types. - -
T Data typeQ Data typedtype
32-bit integer (signed),8-bit integer (signed)PerformanceTrait<i32, i8>
Fixed point (signed)8-bit integer (signed)PerformanceTrait<FixedType, i8>
- -| function | description | -| --- | --- | -| [`performance.quantize_linear`](performance.quantize\_linear.md) | Quantizes a Tensor using linear quantization. | -| [`performance.dequantize_linear`](performance.dequantize\_linear.md) | Dequantizes a Tensor using linear dequantization. | - diff --git a/docs/framework/performance/performance.dequantize_linear.md b/docs/framework/performance/performance.dequantize_linear.md deleted file mode 100644 index a99a3831d..000000000 --- a/docs/framework/performance/performance.dequantize_linear.md +++ /dev/null @@ -1,67 +0,0 @@ -# performance.dequantize_linear - -```rust -fn dequantize_linear(self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor) -> Tensor::; -``` - -Dequantizes a Tensor using linear dequantization. - -The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute -the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and -x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, -or a 1-D tensor for per-axis quantization. - -## Args - -* `self`(`@Tensor`) - The input tensor. -* `x_scale`(`@Tensor`) - Scale for input `x`. -* `x_zero_point`(`@Tensor`) - Zero point for input `x`. - -## Returns - -A new `Tensor` with the same shape as the input tensor, containing the dequantized values. - -## Examples - -```rust -use array::{ArrayTrait, SpanTrait}; - -use orion::operators::tensor::core::{TensorTrait, Tensor}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::i32::i32; -use orion::numbers::signed_integer::i8::{i8, IntegerTrait}; -use orion::performance::core::PerfomanceTrait; -use orion::performance::implementations::impl_performance_i32::Performance_i32_i8; - -fn dequantize_linear_example() -> Tensor { - // We instantiate a 1D Tensor here. - let x = TensorTrait::::new( - shape: array![4].span(), - data: array![ - IntegerTrait::new(0, false), - IntegerTrait::new(3, false), - IntegerTrait::new(125, false), - IntegerTrait::new(127, false), - ].span(), - extra: Option::None(()) - ); - - // We instantiate the x_scale here. - let x_scale = TensorTrait::::new( - shape: array![1].span(), - data: array![IntegerTrait::new(2, false)].span(), - extra: Option::None(()) - ); - - // We instantiate the x_zero_point here. - let x_zero_point = TensorTrait::::new( - shape: array![1].span(), - data: array![IntegerTrait::new(0, false)].span(), - extra: Option::None(()) - ); - - return x.dequantize_linear(@x_scale, @x_zero_point); -} ->>> [0, 6, 250, 254] -``` diff --git a/docs/framework/performance/performance.quantize_linear.md b/docs/framework/performance/performance.quantize_linear.md deleted file mode 100644 index 3e1909b51..000000000 --- a/docs/framework/performance/performance.quantize_linear.md +++ /dev/null @@ -1,70 +0,0 @@ -# performance.quantize_linear - -```rust -fn quantize_linear(self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor) -> Tensor::; -``` - -Quantizes a Tensor using linear quantization. - -The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point -to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, -and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. -The quantization formula is `y = saturate ((x / y_scale) + y_zero_point)`. For saturation, it saturates to `[-128, 127]`. -For (x / y_scale), it's rounding to the nearest even. - -## Args - -* `self`(`@Tensor`) - The input tensor. -* `y_scale`(`@Tensor`) - Scale for doing quantization to get `y`. -* `y_zero_point`(`@Tensor`) - Zero point for doing quantization to get `y`. - -## Returns - -A new `Tensor` with the same shape as the input tensor, containing the quantized values. - -## Examples - -```rust -use array::{ArrayTrait, SpanTrait}; - -use orion::operators::tensor::core::{TensorTrait, Tensor}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::performance::core::PerfomanceTrait; -use orion::performance::implementations::impl_performance_i32::Performance_i32_i8; - -fn quantize_linear_example() -> Tensor { - // We instantiate a 1D Tensor here. - let x = TensorTrait::::new( - shape: array![6].span(), - data: array![ - IntegerTrait::new(0, false), - IntegerTrait::new(2, false), - IntegerTrait::new(3, false), - IntegerTrait::new(1000, false), - IntegerTrait::new(254, true), - IntegerTrait::new(1000, true), - ] - .span(), - extra: Option::None(()) - ); - - // We instantiate the y_scale here. - let y_scale = TensorTrait::::new( - shape: array![1].span(), - data: array![IntegerTrait::new(2, false)].span(), - extra: Option::None(()) - ); - - // We instantiate the y_zero_point here. - let y_zero_point = TensorTrait::::new( - shape: array![1].span(), - data: array![IntegerTrait::new(1, false)].span(), - extra: Option::None(()) - ); - - return x.quantize_linear(@y_scale, @y_zero_point); -} ->>> [1, 2, 2, 127, -126, -128] -``` diff --git a/docs/images/orion-banner.jpeg b/docs/images/orion-banner.jpeg index 69d1bf22d..fd0f6f622 100644 Binary files a/docs/images/orion-banner.jpeg and b/docs/images/orion-banner.jpeg differ diff --git a/nodegen/helpers.py b/nodegen/helpers.py index f36b82f31..0a3099c1b 100644 --- a/nodegen/helpers.py +++ b/nodegen/helpers.py @@ -23,11 +23,10 @@ class FixedImpl(Enum): class Tensor: - def __init__(self, dtype: Dtype, shape: [], data: [], extra_fp=FixedImpl.FP16x16): + def __init__(self, dtype: Dtype, shape: [], data: []): self.dtype = dtype self.shape = shape self.data = data - self.extra_fp = extra_fp class Trait(Enum): @@ -60,76 +59,75 @@ def make_test(inputs: [Tensor], output: Tensor, func_sig: str, file_name: str, t match trait_type: case Trait.TENSOR: - code.append("\n\nuse array::ArrayTrait;\n") - code.append("use orion::operators::tensor::core::TensorTrait;\n") + code.append("\n\nuse array::{ArrayTrait, SpanTrait};\n") + code.append("use orion::operators::tensor::TensorTrait;\n") match type_of_first_input: case Dtype.U32: code.append( - "use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32;\n") + "use orion::operators::tensor::U32Tensor;\n") case Dtype.I32: code.append( - "use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32;\n") + "use orion::operators::tensor::I32Tensor;\n") case Dtype.I8: code.append( - "use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8;\n") - case Dtype.FP16x16 | Dtype.FP8x23: + "use orion::operators::tensor::I8Tensor;\n") + case Dtype.FP8x23: + code.append( + "use orion::operators::tensor::FP8x23Tensor;\n") + case Dtype.FP16x16: code.append( - "use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp;\n") + "use orion::operators::tensor::FP16x16Tensor;\n") match type_of_output: case Dtype.U32: code.append( - "use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq;\n") + "use orion::operators::tensor::U32TensorPartialEq;\n") case Dtype.I32: code.append( - "use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq;\n") + "use orion::operators::tensor::I32TensorPartialEq;\n") case Dtype.I8: code.append( - "use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq;\n") + "use orion::operators::tensor::I8TensorPartialEq;\n") case Dtype.FP16x16: code.append( - "use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq;\n") + "use orion::operators::tensor::FP16x16TensorPartialEq;\n") case Dtype.FP8x23: code.append( - "use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq;\n") + "use orion::operators::tensor::FP8x23TensorPartialEq;\n") case Trait.NN: - code.append("\n\nuse orion::operators::nn::core::NNTrait;\n") - code.append("use orion::numbers::fixed_point::core::FixedTrait;\n") + code.append("\n\nuse orion::operators::nn::NNTrait;\n") + code.append("use orion::numbers::FixedTrait;\n") match type_of_first_input: case Dtype.I32: code.append( - "use orion::operators::nn::implementations::impl_nn_i32::NN_i32;\n") + "use orion::operators::nn::I32NN;\n") case Dtype.I8: code.append( - "use orion::operators::nn::implementations::impl_nn_i8::NN_i8;\n") + "use orion::operators::nn::I8NN;\n") case Dtype.U32: code.append( - "use orion::operators::nn::implementations::impl_nn_u32::NN_u32;\n") - case Dtype.FP8x23 | Dtype.FP16x16: - code.append( - "use orion::operators::nn::implementations::impl_nn_fp::NN_fp;\n") - match inputs[0].extra_fp: - case FixedImpl.FP8x23: + "use orion::operators::nn::U32NN;\n") + case Dtype.FP8x23: code.append( - "use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl;\n") - case FixedImpl.FP16x16: + "use orion::operators::nn::FP8x23NN;\n") + case Dtype.FP16x16: code.append( - "use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl;\n") + "use orion::operators::nn::FP16x16NN;\n") match type_of_output: case Dtype.U32: code.append( - "use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq;\n") + "use orion::operators::tensor::U32TensorPartialEq;\n") case Dtype.I32: code.append( - "use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq;\n") + "use orion::operators::tensor::I32TensorPartialEq;\n") case Dtype.I8: code.append( - "use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq;\n") + "use orion::operators::tensor::I8TensorPartialEq;\n") case Dtype.FP16x16: code.append( - "use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq;\n") + "use orion::operators::tensor::FP16x16TensorPartialEq;\n") case Dtype.FP8x23: code.append( - "use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq;\n") + "use orion::operators::tensor::FP8x23TensorPartialEq;\n") code.append("use orion::utils::assert_eq;\n\n") code.append("#[test]\n") @@ -166,23 +164,38 @@ def to_fp(x: np.array, fp_impl: FixedImpl): def __build_tensor_code(tensor: Tensor, name: str, type_string: str, is_fixed: bool = False, is_signed_int: bool = False) -> []: result = [ - f"use array::ArrayTrait;\n", - f"use orion::operators::tensor::core::{{TensorTrait, Tensor, ExtraParams}};\n", + "use array::{ArrayTrait, SpanTrait};\n", + "use orion::operators::tensor::{TensorTrait, Tensor};\n", ] - if is_fixed: - result.append( - f"use orion::numbers::fixed_point::core::{{FixedTrait, FixedType, FixedImpl}};\n") - result.append( - f"use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp;\n") - else: - result.append( - f"use orion::numbers::fixed_point::core::FixedImpl;\n") - result.append( - f"use orion::operators::tensor::implementations::impl_tensor_{type_string.lower()}::Tensor_{type_string.lower()};\n") - if is_signed_int: + match tensor.dtype: + case Dtype.U32: + result.append( + "use orion::operators::tensor::U32Tensor;\n") + case Dtype.I32: + result.append( + "use orion::operators::tensor::I32Tensor;\n") result.append( - f"use orion::numbers::signed_integer::{{integer_trait::IntegerTrait, {type_string}::{type_string}}};\n") + "use orion::numbers::{IntegerTrait, i32};\n") + case Dtype.I8: + result.append( + "use orion::operators::tensor::I8Tensor;\n") + result.append( + "use orion::numbers::{IntegerTrait, i8};\n") + case Dtype.FP8x23: + result.append( + "use orion::operators::tensor::FP8x23Tensor;\n") + result.append( + "use orion::numbers::FixedTrait;\n") + result.append( + "use orion::numbers::FP8x23;\n") + case Dtype.FP16x16: + result.append( + "use orion::operators::tensor::FP16x16Tensor;\n") + result.append( + "use orion::numbers::FixedTrait;\n") + result.append( + "use orion::numbers::FP16x16;\n") result.append(f"\nfn {name}() -> Tensor<{type_string}> {{\n") result.append(" let mut shape = ArrayTrait::::new();\n") @@ -197,17 +210,15 @@ def __build_tensor_code(tensor: Tensor, name: str, type_string: str, is_fixed: b for val in tensor.data: result.append(f" data.append({abs(int(val))});\n") result.append( - f"\n let extra = ExtraParams {{ fixed_point: Option::Some(FixedImpl::{tensor.extra_fp.name}) }};\n") - result.append( - " TensorTrait::new(shape.span(), data.span(), Option::Some(extra))\n") + " TensorTrait::new(shape.span(), data.span())\n") result.append("}") return result def __convert_tensor_to_cairo(tensor: Tensor, name: str) -> []: dtype_mapping = { - Dtype.FP8x23: ('FixedType', True, False), - Dtype.FP16x16: ('FixedType', True, False), + Dtype.FP8x23: ('FP8x23', True, False), + Dtype.FP16x16: ('FP16x16', True, False), Dtype.I32: ('i32', False, True), Dtype.I8: ('i8', False, True), Dtype.U32: ('u32', False, False), diff --git a/nodegen/node/abs.py b/nodegen/node/abs.py index 75a3e668f..13467e4ea 100644 --- a/nodegen/node/abs.py +++ b/nodegen/node/abs.py @@ -14,7 +14,7 @@ def abs_i32(): name = "abs_i32" make_node([x], [y], name) - make_test([x], y, "x.abs()", name) + make_test([x], y, "input_0.abs()", name) @staticmethod def abs_i8(): @@ -26,7 +26,7 @@ def abs_i8(): name = "abs_i8" make_node([x], [y], name) - make_test([x], y, "x.abs()", name) + make_test([x], y, "input_0.abs()", name) @staticmethod def abs_fp8x23(): @@ -34,12 +34,12 @@ def abs_fp8x23(): ).astype(np.int64), FixedImpl.FP8x23) y = abs(x) - x = Tensor(Dtype.FP8x23, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, y.flatten(), FixedImpl.FP8x23) + x = Tensor(Dtype.FP8x23, x.shape, x.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) name = "abs_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.abs()", name) + make_test([x], y, "input_0.abs()", name) @staticmethod def abs_fp16x16(): @@ -47,9 +47,9 @@ def abs_fp16x16(): ).astype(np.int64), FixedImpl.FP16x16) y = abs(x) - x = Tensor(Dtype.FP16x16, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, y.flatten(), FixedImpl.FP16x16) + x = Tensor(Dtype.FP16x16, x.shape, x.flatten()) + y = Tensor(Dtype.FP16x16, y.shape, y.flatten()) name = "abs_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.abs()", name) + make_test([x], y, "input_0.abs()", name) diff --git a/nodegen/node/acos.py b/nodegen/node/acos.py index 224c5f53d..6b7015e6e 100644 --- a/nodegen/node/acos.py +++ b/nodegen/node/acos.py @@ -9,24 +9,24 @@ def acos_fp8x23(): x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64) y = np.arccos(x) - x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) name = "acos_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.acos()", name) + make_test([x], y, "input_0.acos()", name) @staticmethod def acos_fp16x16(): x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64) y = np.arccos(x) - x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) name = "acos_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.acos()", name) + make_test([x], y, "input_0.acos()", name) diff --git a/nodegen/node/acosh.py b/nodegen/node/acosh.py index d55bbb033..62f870206 100644 --- a/nodegen/node/acosh.py +++ b/nodegen/node/acosh.py @@ -4,110 +4,19 @@ class Acosh(RunAll): - - @staticmethod - def acosh_i32(): - - def fp8x23(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int32) - y = np.arccosh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "acosh_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) - - def fp16x16(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int32) - y = np.arccosh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "acosh_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def acosh_i8(): - - def fp8x23(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int8) - y = np.arccosh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "acosh_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) - - def fp16x16(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int32) - y = np.arccosh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "acosh_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def acosh_u32(): - - def fp8x23(): - x = np.random.randint(1, 5, (2, 2)).astype(np.uint32) - y = np.arccosh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "acosh_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) - - def fp16x16(): - x = np.random.randint(1, 5, (2, 2)).astype(np.uint32) - y = np.arccosh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "acosh_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) - - fp8x23() - fp16x16() - @staticmethod def acosh_fp8x23(): x = np.random.uniform(1, 5, (2, 2)).astype(np.float64) y = np.arccosh(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "acosh_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) + make_test([x], y, "input_0.acosh()", name) @staticmethod def acosh_fp16x16(): @@ -115,10 +24,10 @@ def acosh_fp16x16(): y = np.arccosh(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "acosh_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.acosh()", name) + make_test([x], y, "input_0.acosh()", name) diff --git a/nodegen/node/add.py b/nodegen/node/add.py index 2a77a88a3..1f274208c 100644 --- a/nodegen/node/add.py +++ b/nodegen/node/add.py @@ -17,7 +17,7 @@ def default(): name = "add_u32" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) def broadcast(): x = np.random.randint(0, 3, (3, 3, 3)).astype(np.uint32) @@ -30,7 +30,7 @@ def broadcast(): name = "add_u32_broadcast" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) default() broadcast() @@ -48,7 +48,7 @@ def default(): name = "add_i32" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) def broadcast(): x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int32) @@ -61,7 +61,7 @@ def broadcast(): name = "add_i32_broadcast" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) default() broadcast() @@ -79,7 +79,7 @@ def default(): name = "add_i8" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) def broadcast(): x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int8) @@ -92,7 +92,7 @@ def broadcast(): name = "add_i8_broadcast" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) default() broadcast() @@ -105,15 +105,15 @@ def default(): z = x + y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "add_fp8x23" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) def broadcast(): x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) @@ -121,15 +121,15 @@ def broadcast(): z = x + y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "add_fp8x23_broadcast" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) default() broadcast() @@ -142,15 +142,15 @@ def default(): z = x + y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "add_fp16x16" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) def broadcast(): x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) @@ -158,15 +158,15 @@ def broadcast(): z = x + y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "add_fp16x16_broadcast" make_node([x, y], [z], name) - make_test([x, y], z, "input_0.add(@input_1)", name) + make_test([x, y], z, "input_0 + input_1", name) default() broadcast() diff --git a/nodegen/node/argmax.py b/nodegen/node/argmax.py index 433be1064..bf5dfa432 100644 --- a/nodegen/node/argmax.py +++ b/nodegen/node/argmax.py @@ -36,7 +36,7 @@ def default_params(): name = "argmax_u32_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(0, 255, (3)).astype(np.uint32) @@ -49,7 +49,7 @@ def keepdims_false(): name = "argmax_u32_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (3)).astype(np.uint32) @@ -62,7 +62,7 @@ def last_index(): name = "argmax_u32_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -80,7 +80,7 @@ def default_params(): name = "argmax_u32_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(0, 255, (2, 2)).astype(np.uint32) @@ -93,7 +93,7 @@ def keepdims_false(): name = "argmax_u32_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (2, 2)).astype(np.uint32) @@ -106,7 +106,7 @@ def last_index(): name = "argmax_u32_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -124,7 +124,7 @@ def default_params(): name = "argmax_u32_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(0, 255, (2, 2, 2)).astype(np.uint32) @@ -137,7 +137,7 @@ def keepdims_false(): name = "argmax_u32_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (2, 2, 2)).astype(np.uint32) @@ -150,7 +150,7 @@ def last_index(): name = "argmax_u32_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -170,7 +170,7 @@ def default_params(): name = "argmax_i32_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (3)).astype(np.int32) @@ -183,7 +183,7 @@ def keepdims_false(): name = "argmax_i32_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (3)).astype(np.int32) @@ -196,7 +196,7 @@ def last_index(): name = "argmax_i32_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -214,7 +214,7 @@ def default_params(): name = "argmax_i32_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int32) @@ -227,7 +227,7 @@ def keepdims_false(): name = "argmax_i32_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int32) @@ -240,7 +240,7 @@ def last_index(): name = "argmax_i32_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -258,7 +258,7 @@ def default_params(): name = "argmax_i32_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int32) @@ -271,7 +271,7 @@ def keepdims_false(): name = "argmax_i32_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int32) @@ -284,7 +284,7 @@ def last_index(): name = "argmax_i32_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -304,7 +304,7 @@ def default_params(): name = "argmax_i8_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (3)).astype(np.int8) @@ -317,7 +317,7 @@ def keepdims_false(): name = "argmax_i8_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (3)).astype(np.int8) @@ -330,7 +330,7 @@ def last_index(): name = "argmax_i8_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -348,7 +348,7 @@ def default_params(): name = "argmax_i8_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int8) @@ -361,7 +361,7 @@ def keepdims_false(): name = "argmax_i8_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int8) @@ -374,7 +374,7 @@ def last_index(): name = "argmax_i8_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -392,7 +392,7 @@ def default_params(): name = "argmax_i8_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int8) @@ -405,7 +405,7 @@ def keepdims_false(): name = "argmax_i8_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int8) @@ -418,7 +418,7 @@ def last_index(): name = "argmax_i8_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -439,7 +439,7 @@ def default_params(): name = "argmax_fp16x16_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (3) @@ -453,7 +453,7 @@ def keepdims_false(): name = "argmax_fp16x16_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(0, 255, (3)).astype( @@ -467,7 +467,7 @@ def last_index(): name = "argmax_fp16x16_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -486,7 +486,7 @@ def default_params(): name = "argmax_fp16x16_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -500,7 +500,7 @@ def keepdims_false(): name = "argmax_fp16x16_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -514,7 +514,7 @@ def last_index(): name = "argmax_fp16x16_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -533,7 +533,7 @@ def default_params(): name = "argmax_fp16x16_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -547,7 +547,7 @@ def keepdims_false(): name = "argmax_fp16x16_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -561,7 +561,7 @@ def last_index(): name = "argmax_fp16x16_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -577,13 +577,13 @@ def default_params(): y = argmax_use_numpy(x, dtype=np.uint32).reshape((1)) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (3) @@ -592,13 +592,13 @@ def keepdims_false(): x, keepdims=0, dtype=np.uint32).reshape((1)) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(0, 255, (3)).astype( @@ -607,13 +607,13 @@ def last_index(): x, dtype=np.uint32).reshape((1)) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -632,7 +632,7 @@ def default_params(): name = "argmax_fp8x23_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -641,13 +641,13 @@ def keepdims_false(): x, keepdims=0, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -656,13 +656,13 @@ def last_index(): x, dtype=np.int8) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -676,13 +676,13 @@ def default_params(): y = argmax_use_numpy(x, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -691,13 +691,13 @@ def keepdims_false(): x, keepdims=0, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmax(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -706,13 +706,13 @@ def last_index(): x, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmax_fp8x23_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmax(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmax(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() diff --git a/nodegen/node/argmin.py b/nodegen/node/argmin.py index e81fb205d..fd3249a55 100644 --- a/nodegen/node/argmin.py +++ b/nodegen/node/argmin.py @@ -36,7 +36,7 @@ def default_params(): name = "argmin_u32_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(0, 255, (3)).astype(np.uint32) @@ -49,7 +49,7 @@ def keepdims_false(): name = "argmin_u32_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (3)).astype(np.uint32) @@ -62,7 +62,7 @@ def last_index(): name = "argmin_u32_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -80,7 +80,7 @@ def default_params(): name = "argmin_u32_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(0, 255, (2, 2)).astype(np.uint32) @@ -93,7 +93,7 @@ def keepdims_false(): name = "argmin_u32_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (2, 2)).astype(np.uint32) @@ -106,7 +106,7 @@ def last_index(): name = "argmin_u32_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -124,7 +124,7 @@ def default_params(): name = "argmin_u32_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(0, 255, (2, 2, 2)).astype(np.uint32) @@ -137,7 +137,7 @@ def keepdims_false(): name = "argmin_u32_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (2, 2, 2)).astype(np.uint32) @@ -150,7 +150,7 @@ def last_index(): name = "argmin_u32_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -170,7 +170,7 @@ def default_params(): name = "argmin_i32_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (3)).astype(np.int32) @@ -183,7 +183,7 @@ def keepdims_false(): name = "argmin_i32_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (3)).astype(np.int32) @@ -196,7 +196,7 @@ def last_index(): name = "argmin_i32_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -214,7 +214,7 @@ def default_params(): name = "argmin_i32_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int32) @@ -227,7 +227,7 @@ def keepdims_false(): name = "argmin_i32_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int32) @@ -240,7 +240,7 @@ def last_index(): name = "argmin_i32_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -258,7 +258,7 @@ def default_params(): name = "argmin_i32_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int32) @@ -271,7 +271,7 @@ def keepdims_false(): name = "argmin_i32_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int32) @@ -284,7 +284,7 @@ def last_index(): name = "argmin_i32_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -304,7 +304,7 @@ def default_params(): name = "argmin_i8_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (3)).astype(np.int8) @@ -317,7 +317,7 @@ def keepdims_false(): name = "argmin_i8_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(0, 255, (3)).astype(np.int8) @@ -330,7 +330,7 @@ def last_index(): name = "argmin_i8_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -348,7 +348,7 @@ def default_params(): name = "argmin_i8_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int8) @@ -361,7 +361,7 @@ def keepdims_false(): name = "argmin_i8_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int8) @@ -374,7 +374,7 @@ def last_index(): name = "argmin_i8_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -392,7 +392,7 @@ def default_params(): name = "argmin_i8_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int8) @@ -405,7 +405,7 @@ def keepdims_false(): name = "argmin_i8_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = np.random.randint(-127, 127, (2, 2, 2)).astype(np.int8) @@ -418,7 +418,7 @@ def last_index(): name = "argmin_i8_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -439,7 +439,7 @@ def default_params(): name = "argmin_fp16x16_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (3) @@ -453,7 +453,7 @@ def keepdims_false(): name = "argmin_fp16x16_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(0, 255, (3)).astype( @@ -467,7 +467,7 @@ def last_index(): name = "argmin_fp16x16_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -486,7 +486,7 @@ def default_params(): name = "argmin_fp16x16_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -500,7 +500,7 @@ def keepdims_false(): name = "argmin_fp16x16_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -514,7 +514,7 @@ def last_index(): name = "argmin_fp16x16_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -533,7 +533,7 @@ def default_params(): name = "argmin_fp16x16_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -547,7 +547,7 @@ def keepdims_false(): name = "argmin_fp16x16_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -561,7 +561,7 @@ def last_index(): name = "argmin_fp16x16_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -577,13 +577,13 @@ def default_params(): y = argmin_use_numpy(x, dtype=np.uint32).reshape((1)) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_1D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (3) @@ -592,13 +592,13 @@ def keepdims_false(): x, keepdims=0, dtype=np.uint32).reshape((1)) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_1D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(0, 255, (3)).astype( @@ -607,13 +607,13 @@ def last_index(): x, dtype=np.uint32).reshape((1)) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_1D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -632,7 +632,7 @@ def default_params(): name = "argmin_fp8x23_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -641,13 +641,13 @@ def keepdims_false(): x, keepdims=0, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_2D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2) @@ -656,13 +656,13 @@ def last_index(): x, dtype=np.int8) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_2D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() @@ -676,13 +676,13 @@ def default_params(): y = argmin_use_numpy(x, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_3D_default" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::None(()))", name) def keepdims_false(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -691,13 +691,13 @@ def keepdims_false(): x, keepdims=0, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_3D_keepdims_false" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::Some(false), Option::None(()))", name) + [x], y, "input_0.argmin(0, Option::Some(false), Option::None(()))", name) def last_index(): x = to_fp(np.random.randint(-127, 127, (2, 2, 2) @@ -706,13 +706,13 @@ def last_index(): x, dtype=np.uint32) x = Tensor(Dtype.FP8x23, x.shape, - x.flatten(), FixedImpl.FP8x23) + x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "argmin_fp8x23_3D_last_index" make_node([x], [y], name) make_test( - [x], y, "x.argmin(0, Option::None(()), Option::Some(true))", name) + [x], y, "input_0.argmin(0, Option::None(()), Option::Some(true))", name) default_params() keepdims_false() diff --git a/nodegen/node/asin.py b/nodegen/node/asin.py index a8874e133..7268666ed 100644 --- a/nodegen/node/asin.py +++ b/nodegen/node/asin.py @@ -9,24 +9,24 @@ def asin_fp8x23(): x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64) y = np.arcsin(x) - x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) name = "asin_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.asin()", name) + make_test([x], y, "input_0.asin()", name) @staticmethod def asin_fp16x16(): x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64) y = np.arcsin(x) - x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) name = "asin_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.asin()", name) + make_test([x], y, "input_0.asin()", name) diff --git a/nodegen/node/asinh.py b/nodegen/node/asinh.py index 036ad5155..995e93d4a 100644 --- a/nodegen/node/asinh.py +++ b/nodegen/node/asinh.py @@ -5,109 +5,19 @@ class Asinh(RunAll): - @staticmethod - def asinh_i32(): - - def fp8x23(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int32) - y = np.arcsinh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "asinh_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) - - def fp16x16(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int32) - y = np.arcsinh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "asinh_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def asinh_i8(): - - def fp8x23(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int8) - y = np.arcsinh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "asinh_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) - - def fp16x16(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int32) - y = np.arcsinh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "asinh_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def asinh_u32(): - - def fp8x23(): - x = np.random.randint(1, 5, (2, 2)).astype(np.uint32) - y = np.arcsinh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "asinh_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) - - def fp16x16(): - x = np.random.randint(1, 5, (2, 2)).astype(np.uint32) - y = np.arcsinh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "asinh_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) - - fp8x23() - fp16x16() - @staticmethod def asinh_fp8x23(): x = np.random.uniform(1, 5, (2, 2)).astype(np.float64) y = np.arcsinh(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "asinh_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) + make_test([x], y, "input_0.asinh()", name) @staticmethod def asinh_fp16x16(): @@ -115,10 +25,10 @@ def asinh_fp16x16(): y = np.arcsinh(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "asinh_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.asinh()", name) + make_test([x], y, "input_0.asinh()", name) diff --git a/nodegen/node/atan.py b/nodegen/node/atan.py index eee25e59f..8731a6838 100644 --- a/nodegen/node/atan.py +++ b/nodegen/node/atan.py @@ -4,110 +4,19 @@ class Atan(RunAll): - - @staticmethod - def atan_i32(): - - def fp8x23(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.int32) - y = np.arctan(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "atan_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.atan()", name) - - def fp16x16(): - x = np.random.randint(1, 127, (2, 2)).astype(np.int32) - y = np.arctan(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "atan_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.atan()", name) - - fp8x23() - fp16x16() - - @staticmethod - def atan_i8(): - - def fp8x23(): - x = np.random.randint(-10, 5, (2, 2)).astype(np.int8) - y = np.arctan(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "atan_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.atan()", name) - - def fp16x16(): - x = np.random.randint(1, 127, (2, 2)).astype(np.int32) - y = np.arctan(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "atan_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.atan()", name) - - fp8x23() - fp16x16() - - @staticmethod - def atan_u32(): - - def fp8x23(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.uint32) - y = np.arctan(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "atan_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.atan()", name) - - def fp16x16(): - x = np.random.randint(1, 127, (2, 2)).astype(np.uint32) - y = np.arctan(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "atan_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.atan()", name) - - fp8x23() - fp16x16() - @staticmethod def atan_fp8x23(): x = np.random.uniform(-10, 127, (2, 2)).astype(np.float64) y = np.arctan(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "atan_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.atan()", name) + make_test([x], y, "input_0.atan()", name) @staticmethod def atan_fp16x16(): @@ -115,10 +24,10 @@ def atan_fp16x16(): y = np.arctan(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "atan_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.atan()", name) + make_test([x], y, "input_0.atan()", name) diff --git a/nodegen/node/ceil.py b/nodegen/node/ceil.py index 1bf58a2ff..361cf74d4 100644 --- a/nodegen/node/ceil.py +++ b/nodegen/node/ceil.py @@ -9,24 +9,24 @@ def ceil_fp8x23(): x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64) y = np.ceil(x) - x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x = Tensor(Dtype.FP8x23, x.shape, to_fp(x.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedImpl.FP8x23)) name = "ceil_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.ceil()", name) + make_test([x], y, "input_0.ceil()", name) @staticmethod def ceil_fp16x16(): x = np.random.uniform(-1, 1, (2, 2)).astype(np.float64) y = np.ceil(x) - x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x = Tensor(Dtype.FP16x16, x.shape, to_fp(x.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp(y.flatten(), FixedImpl.FP16x16)) name = "ceil_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.ceil()", name) + make_test([x], y, "input_0.ceil()", name) diff --git a/nodegen/node/concat.py b/nodegen/node/concat.py new file mode 100644 index 000000000..794fedd8d --- /dev/null +++ b/nodegen/node/concat.py @@ -0,0 +1,686 @@ +import numpy as np +from nodegen.node import RunAll +from ..helpers import make_node, make_test, to_fp, Tensor, Dtype, FixedImpl, Trait +# 687 +class Concat(RunAll): + @staticmethod + def concat_u32(): + + def concat_1D(): + x1 = np.arange(0,3).astype(np.uint32) + x2 = np.arange(3,6).astype(np.uint32) + y = np.concatenate((x1, x2)) + + x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "concat_u32_1d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + + def concat_2D(): + x1 = np.arange(0,4).astype(np.uint32).reshape(2,2) + x2 = np.arange(4,8).astype(np.uint32).reshape(2,2) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "concat_u32_2d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def concat_3D(): + def default(): + x1 = np.arange(0,27).astype(np.uint32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.uint32).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "concat_u32_3d_default" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def axis_1(): + x1 = np.arange(0,27).astype(np.uint32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.uint32).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=1) + + x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "concat_u32_3d_axis_1" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def axis_2(): + x1 = np.arange(0,27).astype(np.uint32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.uint32).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=2) + + x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "concat_u32_3d_axis_2" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_1(): + x1 = np.arange(0,27).astype(np.uint32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.uint32).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.uint32).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=1) + + x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) + x3 = Tensor(Dtype.U32, x3.shape, x3.flatten()) + + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "concat_u32_3d_three_tensors_axis_1" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_2(): + x1 = np.arange(0,27).astype(np.uint32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.uint32).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.uint32).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=2) + + x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) + x3 = Tensor(Dtype.U32, x3.shape, x3.flatten()) + + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "concat_u32_3d_three_tensors_axis_2" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + default() + axis_1() + axis_2() + three_tensors_axis_1() + three_tensors_axis_2() + + concat_1D() + concat_2D() + concat_3D() + + @staticmethod + def concat_i32(): + def concat_1D(): + x1 = np.arange(0,3).astype(np.int32) + x2 = np.arange(3,6).astype(np.int32) + y = np.concatenate((x1, x2)) + + x1 = Tensor(Dtype.I32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.I32, x2.shape, x2.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "concat_i32_1d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR.TENSOR) + + + def concat_2D(): + x1 = np.arange(0,4).astype(np.int32).reshape(2,2) + x2 = np.arange(4,8).astype(np.int32).reshape(2,2) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.I32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.I32, x2.shape, x2.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "concat_i32_2d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def concat_3D(): + def default(): + x1 = np.arange(0,27).astype(np.int32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int32).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.I32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.I32, x2.shape, x2.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "concat_i32_3d_default" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def axis_1(): + x1 = np.arange(0,27).astype(np.int32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int32).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=1) + + x1 = Tensor(Dtype.I32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.I32, x2.shape, x2.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "concat_i32_3d_axis_1" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def axis_2(): + x1 = np.arange(0,27).astype(np.int32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int32).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=2) + + x1 = Tensor(Dtype.I32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.I32, x2.shape, x2.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "concat_i32_3d_axis_2" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_1(): + x1 = np.arange(0,27).astype(np.int32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int32).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int32).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=1) + + x1 = Tensor(Dtype.I32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.I32, x2.shape, x2.flatten()) + x3 = Tensor(Dtype.I32, x3.shape, x3.flatten()) + + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "concat_i32_3d_three_tensors_axis_1" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_2(): + x1 = np.arange(0,27).astype(np.int32).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int32).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int32).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=2) + + x1 = Tensor(Dtype.I32, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.I32, x2.shape, x2.flatten()) + x3 = Tensor(Dtype.I32, x3.shape, x3.flatten()) + + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "concat_i32_3d_three_tensors_axis_2" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + default() + axis_1() + axis_2() + three_tensors_axis_1() + three_tensors_axis_2() + + concat_1D() + concat_2D() + concat_3D() + + @staticmethod + def concat_i8(): + def concat_1D(): + x1 = np.arange(0,3).astype(np.int8) + x2 = np.arange(3,6).astype(np.int8) + y = np.concatenate((x1, x2)) + + x1 = Tensor(Dtype.FP8x23, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.FP8x23, x2.shape, x2.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "concat_i8_1d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR.TENSOR) + + + def concat_2D(): + x1 = np.arange(0,4).astype(np.int8).reshape(2,2) + x2 = np.arange(4,8).astype(np.int8).reshape(2,2) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.FP8x23, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.FP8x23, x2.shape, x2.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "concat_i8_2d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def concat_3D(): + def default(): + x1 = np.arange(0,27).astype(np.int8).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int8).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.FP8x23, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.FP8x23, x2.shape, x2.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "concat_i8_3d_default" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def axis_1(): + x1 = np.arange(0,27).astype(np.int8).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int8).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=1) + + x1 = Tensor(Dtype.FP8x23, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.FP8x23, x2.shape, x2.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "concat_i8_3d_axis_1" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def axis_2(): + x1 = np.arange(0,27).astype(np.int8).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int8).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=2) + + x1 = Tensor(Dtype.FP8x23, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.FP8x23, x2.shape, x2.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "concat_i8_3d_axis_2" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_1(): + x1 = np.arange(0,27).astype(np.int8).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int8).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int8).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=1) + + x1 = Tensor(Dtype.FP8x23, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.FP8x23, x2.shape, x2.flatten()) + x3 = Tensor(Dtype.FP8x23, x3.shape, x3.flatten()) + + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "concat_i8_3d_three_tensors_axis_1" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_2(): + x1 = np.arange(0,27).astype(np.int8).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int8).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int8).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=2) + + x1 = Tensor(Dtype.FP8x23, x1.shape, x1.flatten()) + x2 = Tensor(Dtype.FP8x23, x2.shape, x2.flatten()) + x3 = Tensor(Dtype.FP8x23, x3.shape, x3.flatten()) + + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "concat_i8_3d_three_tensors_axis_2" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + default() + axis_1() + axis_2() + three_tensors_axis_1() + three_tensors_axis_2() + + concat_1D() + concat_2D() + concat_3D() + + @staticmethod + def concat_fp8x23(): + def concat_1D(): + x1 = np.arange(0,3).astype(np.int64) + x2 = np.arange(3,6).astype(np.int64) + y = np.concatenate((x1, x2)) + + x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP8x23)) + x2 = Tensor(Dtype.FP8x23, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "concat_fp8x23_1d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR.TENSOR) + + + def concat_2D(): + x1 = np.arange(0,4).astype(np.int64).reshape(2,2) + x2 = np.arange(4,8).astype(np.int64).reshape(2,2) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP8x23)) + x2 = Tensor(Dtype.FP8x23, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "concat_fp8x23_2d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def concat_3D(): + def default(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP8x23)) + x2 = Tensor(Dtype.FP8x23, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape,to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "concat_fp8x23_3d_default" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def axis_1(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=1) + + x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP8x23)) + x2 = Tensor(Dtype.FP8x23, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "concat_fp8x23_3d_axis_1" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def axis_2(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=2) + + x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP8x23)) + x2 = Tensor(Dtype.FP8x23, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "concat_fp8x23_3d_axis_2" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_1(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int64).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=1) + + x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP8x23)) + x2 = Tensor(Dtype.FP8x23, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP8x23)) + x3 = Tensor(Dtype.FP8x23, x3.shape,to_fp( + x3.flatten(), FixedImpl.FP8x23)) + + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "concat_fp8x23_3d_three_tensors_axis_1" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_2(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int64).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=2) + + x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP8x23)) + x2 = Tensor(Dtype.FP8x23, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP8x23)) + x3 = Tensor(Dtype.FP8x23, x3.shape, to_fp( + x3.flatten(), FixedImpl.FP8x23)) + + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) + + name = "concat_fp8x23_3d_three_tensors_axis_2" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + default() + axis_1() + axis_2() + three_tensors_axis_1() + three_tensors_axis_2() + + concat_1D() + concat_2D() + concat_3D() + + staticmethod + def concat_fp16x16(): + def concat_1D(): + x1 = np.arange(0,3).astype(np.int64) + x2 = np.arange(3,6).astype(np.int64) + y = np.concatenate((x1, x2)) + + x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP16x16)) + x2 = Tensor(Dtype.FP16x16, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "concat_fp16x16_1d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR.TENSOR) + + + def concat_2D(): + x1 = np.arange(0,4).astype(np.int64).reshape(2,2) + x2 = np.arange(4,8).astype(np.int64).reshape(2,2) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP16x16)) + x2 = Tensor(Dtype.FP16x16, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "concat_fp16x16_2d" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def concat_3D(): + def default(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=0) + + x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP16x16)) + x2 = Tensor(Dtype.FP16x16, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "concat_fp16x16_3d_default" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 0);", + file_name= name, trait_type= Trait.TENSOR) + + def axis_1(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=1) + + x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP16x16)) + x2 = Tensor(Dtype.FP16x16, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape ,to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "concat_fp16x16_3d_axis_1" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def axis_2(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + y = np.concatenate((x1, x2), axis=2) + + x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP16x16)) + x2 = Tensor(Dtype.FP16x16, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "concat_fp16x16_3d_axis_2" + make_node([x1, x2], [y], name) + make_test( + inputs = [x1, x2], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_1(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int64).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=1) + + x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP16x16)) + x2 = Tensor(Dtype.FP16x16, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP16x16)) + x3 = Tensor(Dtype.FP16x16, x3.shape, to_fp( + x3.flatten(), FixedImpl.FP16x16)) + + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "concat_fp16x16_3d_three_tensors_axis_1" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 1)", + file_name= name, trait_type= Trait.TENSOR) + + def three_tensors_axis_2(): + x1 = np.arange(0,27).astype(np.int64).reshape(3,3,3) + x2 = np.arange(27,54).astype(np.int64).reshape(3,3,3) + x3 = np.arange(54,81).astype(np.int64).reshape(3,3,3) + + y = np.concatenate((x1, x2, x3), axis=2) + + x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp( + x1.flatten(), FixedImpl.FP16x16)) + x2 = Tensor(Dtype.FP16x16, x2.shape, to_fp( + x2.flatten(), FixedImpl.FP16x16)) + x3 = Tensor(Dtype.FP16x16, x3.shape, to_fp( + x3.flatten(), FixedImpl.FP16x16)) + + y = Tensor(Dtype.FP16x16, y.shape,to_fp( + y.flatten(), FixedImpl.FP16x16)) + + name = "concat_fp16x16_3d_three_tensors_axis_2" + make_node([x1, x2, x3], [y], name) + make_test( + inputs = [x1, x2, x3], output = y, func_sig = "TensorTrait::concat(array![input_0, input_1, input_2].span(), 2)", + file_name= name, trait_type= Trait.TENSOR) + + default() + axis_1() + axis_2() + three_tensors_axis_1() + three_tensors_axis_2() + + concat_1D() + concat_2D() + concat_3D() diff --git a/nodegen/node/cos.py b/nodegen/node/cos.py index 7e75cd393..c6f965432 100644 --- a/nodegen/node/cos.py +++ b/nodegen/node/cos.py @@ -5,109 +5,19 @@ class Cos(RunAll): - @staticmethod - def cos_i32(): - - def fp8x23(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.int32) - y = np.cos(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "cos_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.cos()", name) - - def fp16x16(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.int32) - y = np.cos(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "cos_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.cos()", name) - - fp8x23() - fp16x16() - - @staticmethod - def cos_i8(): - - def fp8x23(): - x = np.random.randint(-10, 5, (2, 2)).astype(np.int8) - y = np.cos(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "cos_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.cos()", name) - - def fp16x16(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.int32) - y = np.cos(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "cos_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.cos()", name) - - fp8x23() - fp16x16() - - @staticmethod - def cos_u32(): - - def fp8x23(): - x = np.random.randint(0, 127, (2, 2)).astype(np.uint32) - y = np.cos(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "cos_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.cos()", name) - - def fp16x16(): - x = np.random.randint(0, 127, (2, 2)).astype(np.uint32) - y = np.cos(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "cos_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.cos()", name) - - fp8x23() - fp16x16() - @staticmethod def cos_fp8x23(): x = np.random.uniform(-10, 127, (2, 2)).astype(np.float64) y = np.cos(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cos_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.cos()", name) + make_test([x], y, "input_0.cos()", name) @staticmethod def cos_fp16x16(): @@ -115,10 +25,10 @@ def cos_fp16x16(): y = np.cos(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cos_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.cos()", name) + make_test([x], y, "input_0.cos()", name) diff --git a/nodegen/node/cosh.py b/nodegen/node/cosh.py index 129ff87e2..fac5f3ef5 100644 --- a/nodegen/node/cosh.py +++ b/nodegen/node/cosh.py @@ -5,109 +5,19 @@ class Cosh(RunAll): - @staticmethod - def cosh_i32(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.cosh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "cosh_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.cosh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "cosh_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def cosh_i8(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = np.cosh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "cosh_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.cosh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "cosh_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def cosh_u32(): - - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.cosh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "cosh_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.cosh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "cosh_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) - - fp8x23() - fp16x16() - @staticmethod def cosh_fp8x23(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = np.cosh(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cosh_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) + make_test([x], y, "input_0.cosh()", name) @staticmethod def cosh_fp16x16(): @@ -115,10 +25,10 @@ def cosh_fp16x16(): y = np.cosh(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cosh_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.cosh()", name) + make_test([x], y, "input_0.cosh()", name) diff --git a/nodegen/node/cumsum.py b/nodegen/node/cumsum.py index 9ca74e07b..9ed5c6747 100644 --- a/nodegen/node/cumsum.py +++ b/nodegen/node/cumsum.py @@ -17,7 +17,7 @@ def default(): name = "cumsum_u32_1d_default" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.uint32) @@ -29,7 +29,7 @@ def exclusive(): name = "cumsum_u32_1d_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(false))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(false))", name) def reverse(): x = np.array([1, 2, 3, 4, 5]).astype(np.uint32) @@ -41,7 +41,7 @@ def reverse(): name = "cumsum_u32_1d_reverse" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(false), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(false), Option::Some(true))", name) def reverse_exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.uint32) @@ -53,7 +53,7 @@ def reverse_exclusive(): name = "cumsum_u32_1d_reverse_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(true))", name) default() exclusive() @@ -74,7 +74,7 @@ def axis_0(): name = "cumsum_u32_2d_axis_0" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def axis_1(): x = np.array([1, 2, 3, 4, 5, 6]).astype( @@ -88,7 +88,7 @@ def axis_1(): name = "cumsum_u32_2d_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(1, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(1, Option::None(()), Option::None(()))", name) axis_0() axis_1() @@ -107,7 +107,7 @@ def default(): name = "cumsum_i32_1d_default" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int32) @@ -119,7 +119,7 @@ def exclusive(): name = "cumsum_i32_1d_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(false))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(false))", name) def reverse(): x = np.array([1, 2, 3, 4, 5]).astype(np.int32) @@ -131,7 +131,7 @@ def reverse(): name = "cumsum_i32_1d_reverse" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(false), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(false), Option::Some(true))", name) def reverse_exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int32) @@ -143,7 +143,7 @@ def reverse_exclusive(): name = "cumsum_i32_1d_reverse_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(true))", name) default() exclusive() @@ -164,7 +164,7 @@ def axis_0(): name = "cumsum_i32_2d_axis_0" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def axis_1(): x = np.array([1, 2, 3, 4, 5, 6]).astype( @@ -178,7 +178,7 @@ def axis_1(): name = "cumsum_i32_2d_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(1, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(1, Option::None(()), Option::None(()))", name) axis_0() axis_1() @@ -197,7 +197,7 @@ def default(): name = "cumsum_i8_1d_default" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int8) @@ -209,7 +209,7 @@ def exclusive(): name = "cumsum_i8_1d_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(false))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(false))", name) def reverse(): x = np.array([1, 2, 3, 4, 5]).astype(np.int8) @@ -221,7 +221,7 @@ def reverse(): name = "cumsum_i8_1d_reverse" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(false), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(false), Option::Some(true))", name) def reverse_exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int8) @@ -233,7 +233,7 @@ def reverse_exclusive(): name = "cumsum_i8_1d_reverse_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(true))", name) default() exclusive() @@ -254,7 +254,7 @@ def axis_0(): name = "cumsum_i8_2d_axis_0" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def axis_1(): x = np.array([1, 2, 3, 4, 5, 6]).astype( @@ -268,7 +268,7 @@ def axis_1(): name = "cumsum_i8_2d_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(1, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(1, Option::None(()), Option::None(()))", name) axis_0() axis_1() @@ -282,56 +282,56 @@ def default(): y = np.array([1, 3, 6, 10, 15]).astype(np.int64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cumsum_fp8x23_1d_default" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int64) y = np.array([0, 1, 3, 6, 10]).astype(np.int64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cumsum_fp8x23_1d_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(false))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(false))", name) def reverse(): x = np.array([1, 2, 3, 4, 5]).astype(np.int64) y = np.array([15, 14, 12, 9, 5]).astype(np.int64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cumsum_fp8x23_1d_reverse" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(false), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(false), Option::Some(true))", name) def reverse_exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int64) y = np.array([14, 12, 9, 5, 0]).astype(np.int64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cumsum_fp8x23_1d_reverse_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(true))", name) default() exclusive() @@ -347,14 +347,14 @@ def axis_0(): np.int64).reshape((2, 3)) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cumsum_fp8x23_2d_axis_0" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def axis_1(): x = np.array([1, 2, 3, 4, 5, 6]).astype( @@ -363,14 +363,14 @@ def axis_1(): np.int64).reshape((2, 3)) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "cumsum_fp8x23_2d_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(1, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(1, Option::None(()), Option::None(()))", name) axis_0() axis_1() @@ -384,56 +384,56 @@ def default(): y = np.array([1, 3, 6, 10, 15]).astype(np.int64) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cumsum_fp16x16_1d_default" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int64) y = np.array([0, 1, 3, 6, 10]).astype(np.int64) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cumsum_fp16x16_1d_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(false))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(false))", name) def reverse(): x = np.array([1, 2, 3, 4, 5]).astype(np.int64) y = np.array([15, 14, 12, 9, 5]).astype(np.int64) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cumsum_fp16x16_1d_reverse" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(false), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(false), Option::Some(true))", name) def reverse_exclusive(): x = np.array([1, 2, 3, 4, 5]).astype(np.int64) y = np.array([14, 12, 9, 5, 0]).astype(np.int64) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cumsum_fp16x16_1d_reverse_exclusive" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::Some(true), Option::Some(true))", name) + [x], y, "input_0.cumsum(0, Option::Some(true), Option::Some(true))", name) default() exclusive() @@ -449,14 +449,14 @@ def axis_0(): np.int64).reshape((2, 3)) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cumsum_fp16x16_2d_axis_0" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(0, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(0, Option::None(()), Option::None(()))", name) def axis_1(): x = np.array([1, 2, 3, 4, 5, 6]).astype( @@ -465,14 +465,14 @@ def axis_1(): np.int64).reshape((2, 3)) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "cumsum_fp16x16_2d_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.cumsum(1, Option::None(()), Option::None(()))", name) + [x], y, "input_0.cumsum(1, Option::None(()), Option::None(()))", name) axis_0() axis_1() diff --git a/nodegen/node/div.py b/nodegen/node/div.py index b9ddbb69a..92fe6cc1a 100644 --- a/nodegen/node/div.py +++ b/nodegen/node/div.py @@ -105,11 +105,11 @@ def default(): z = x / y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "div_fp8x23" make_node([x, y], [z], name) @@ -121,11 +121,11 @@ def broadcast(): z = x / y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "div_fp8x23_broadcast" make_node([x, y], [z], name) @@ -142,11 +142,11 @@ def default(): z = x / y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "div_fp16x16" make_node([x, y], [z], name) @@ -158,11 +158,11 @@ def broadcast(): z = x / y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "div_fp16x16_broadcast" make_node([x, y], [z], name) diff --git a/nodegen/node/equal.py b/nodegen/node/equal.py index 0ce6c7327..a4b6c070a 100644 --- a/nodegen/node/equal.py +++ b/nodegen/node/equal.py @@ -105,9 +105,9 @@ def default(): z = np.equal(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "equal_fp8x23" @@ -120,9 +120,9 @@ def broadcast(): z = np.equal(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "equal_fp8x23_broadcast" @@ -140,9 +140,9 @@ def default(): z = np.equal(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "equal_fp16x16" @@ -155,9 +155,9 @@ def broadcast(): z = np.equal(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "equal_fp16x16_broadcast" diff --git a/nodegen/node/exp.py b/nodegen/node/exp.py index e13103c5b..3194c1081 100644 --- a/nodegen/node/exp.py +++ b/nodegen/node/exp.py @@ -5,109 +5,19 @@ class Exp(RunAll): - @staticmethod - def exp_i32(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.exp(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "exp_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.exp()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.exp(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "exp_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.exp()", name) - - fp8x23() - fp16x16() - - @staticmethod - def exp_i8(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = np.exp(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "exp_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.exp()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.exp(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "exp_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.exp()", name) - - fp8x23() - fp16x16() - - @staticmethod - def exp_u32(): - - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.exp(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "exp_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.exp()", name) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.exp(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "exp_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.exp()", name) - - fp8x23() - fp16x16() - @staticmethod def exp_fp8x23(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = np.exp(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "exp_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.exp()", name) + make_test([x], y, "input_0.exp()", name) @staticmethod def exp_fp16x16(): @@ -115,10 +25,10 @@ def exp_fp16x16(): y = np.exp(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "exp_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.exp()", name) + make_test([x], y, "input_0.exp()", name) diff --git a/nodegen/node/greater.py b/nodegen/node/greater.py index fb534db36..8abf66f47 100644 --- a/nodegen/node/greater.py +++ b/nodegen/node/greater.py @@ -105,9 +105,9 @@ def default(): z = np.greater(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_fp8x23" @@ -120,9 +120,9 @@ def broadcast(): z = np.greater(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_fp8x23_broadcast" @@ -140,9 +140,9 @@ def default(): z = np.greater(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_fp16x16" @@ -155,9 +155,9 @@ def broadcast(): z = np.greater(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_fp16x16_broadcast" diff --git a/nodegen/node/greater_equal.py b/nodegen/node/greater_equal.py index 3a6a08e75..1606150ff 100644 --- a/nodegen/node/greater_equal.py +++ b/nodegen/node/greater_equal.py @@ -105,9 +105,9 @@ def default(): z = np.greater_equal(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_equal_fp8x23" @@ -120,9 +120,9 @@ def broadcast(): z = np.greater_equal(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_equal_fp8x23_broadcast" @@ -140,9 +140,9 @@ def default(): z = np.greater_equal(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_equal_fp16x16" @@ -155,9 +155,9 @@ def broadcast(): z = np.greater_equal(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "greater_equal_fp16x16_broadcast" diff --git a/nodegen/node/leaky_relu.py b/nodegen/node/leaky_relu.py index 9119d192e..a20704f3c 100644 --- a/nodegen/node/leaky_relu.py +++ b/nodegen/node/leaky_relu.py @@ -6,72 +6,6 @@ class Leaky_relu(RunAll): - @staticmethod - def leaky_relu_i32(): - def fp8x23(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int32) - layer = tf.keras.layers.LeakyReLU(alpha=0.1) - y = layer(x).numpy() - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "leaky_relu_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::leaky_relu(@input_0, @FixedTrait::new(838861, false))", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int32) - layer = tf.keras.layers.LeakyReLU(alpha=0.1) - y = layer(x).numpy() - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "leaky_relu_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::leaky_relu(@input_0, @FixedTrait::new(6554, false))", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def leaky_relu_i8(): - def fp8x23(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int32) - layer = tf.keras.layers.LeakyReLU(alpha=0.1) - y = layer(x).numpy() - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "leaky_relu_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::leaky_relu(@input_0, @FixedTrait::new(838861, false))", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int32) - layer = tf.keras.layers.LeakyReLU(alpha=0.1) - y = layer(x).numpy() - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "leaky_relu_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::leaky_relu(@input_0, @FixedTrait::new(6554, false))", - name, Trait.NN) - - fp8x23() - fp16x16() - @staticmethod def leaky_relu_fp8x23(): @@ -80,9 +14,9 @@ def leaky_relu_fp8x23(): y = layer(x).numpy() x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "leaky_relu_fp8x23" make_node([x], [y], name) @@ -97,9 +31,9 @@ def leaky_relu_fp16x16(): y = layer(x).numpy() x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "leaky_relu_fp16x16" make_node([x], [y], name) diff --git a/nodegen/node/less.py b/nodegen/node/less.py index c6a2c8f35..8b694ef5d 100644 --- a/nodegen/node/less.py +++ b/nodegen/node/less.py @@ -105,9 +105,9 @@ def default(): z = np.less(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_fp8x23" @@ -120,9 +120,9 @@ def broadcast(): z = np.less(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_fp8x23_broadcast" @@ -140,9 +140,9 @@ def default(): z = np.less(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_fp16x16" @@ -155,9 +155,9 @@ def broadcast(): z = np.less(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_fp16x16_broadcast" diff --git a/nodegen/node/less_equal.py b/nodegen/node/less_equal.py index e041ab0ad..26cef6453 100644 --- a/nodegen/node/less_equal.py +++ b/nodegen/node/less_equal.py @@ -105,9 +105,9 @@ def default(): z = np.less_equal(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_equal_fp8x23" @@ -120,9 +120,9 @@ def broadcast(): z = np.less_equal(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_equal_fp8x23_broadcast" @@ -140,9 +140,9 @@ def default(): z = np.less_equal(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_equal_fp16x16" @@ -155,9 +155,9 @@ def broadcast(): z = np.less_equal(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "less_equal_fp16x16_broadcast" diff --git a/nodegen/node/linear.py b/nodegen/node/linear.py index 1b577fd32..b3a486398 100644 --- a/nodegen/node/linear.py +++ b/nodegen/node/linear.py @@ -74,13 +74,13 @@ def linear_fp8x23(): y = linear(i, w, b) i = Tensor(Dtype.FP8x23, i.shape, to_fp( - i.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + i.flatten(), FixedImpl.FP8x23)) w = Tensor(Dtype.FP8x23, w.shape, to_fp( - w.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + w.flatten(), FixedImpl.FP8x23)) b = Tensor(Dtype.FP8x23, b.shape, to_fp( - b.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + b.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "linear_fp8x23" make_node([i, w, b], [y], name) @@ -95,13 +95,13 @@ def linear_fp16x16(): y = linear(i, w, b) i = Tensor(Dtype.FP16x16, i.shape, to_fp( - i.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + i.flatten(), FixedImpl.FP16x16)) w = Tensor(Dtype.FP16x16, w.shape, to_fp( - w.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + w.flatten(), FixedImpl.FP16x16)) b = Tensor(Dtype.FP16x16, b.shape, to_fp( - b.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + b.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "linear_fp16x16" make_node([i, w, b], [y], name) diff --git a/nodegen/node/log.py b/nodegen/node/log.py index c25256154..0465dc95f 100644 --- a/nodegen/node/log.py +++ b/nodegen/node/log.py @@ -5,109 +5,19 @@ class Log(RunAll): - @staticmethod - def log_i32(): - - def fp8x23(): - x = np.random.randint(1, 127, (2, 2)).astype(np.int32) - y = np.log(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "log_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.log()", name) - - def fp16x16(): - x = np.random.randint(1, 127, (2, 2)).astype(np.int32) - y = np.log(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "log_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.log()", name) - - fp8x23() - fp16x16() - - @staticmethod - def log_i8(): - - def fp8x23(): - x = np.random.randint(1, 5, (2, 2)).astype(np.int8) - y = np.log(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "log_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.log()", name) - - def fp16x16(): - x = np.random.randint(1, 127, (2, 2)).astype(np.int32) - y = np.log(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "log_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.log()", name) - - fp8x23() - fp16x16() - - @staticmethod - def log_u32(): - - def fp8x23(): - x = np.random.randint(0, 127, (2, 2)).astype(np.uint32) - y = np.log(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "log_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.log()", name) - - def fp16x16(): - x = np.random.randint(0, 127, (2, 2)).astype(np.uint32) - y = np.log(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "log_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.log()", name) - - fp8x23() - fp16x16() - @staticmethod def log_fp8x23(): x = np.random.uniform(1, 127, (2, 2)).astype(np.float64) y = np.log(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "log_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.log()", name) + make_test([x], y, "input_0.log()", name) @staticmethod def log_fp16x16(): @@ -115,10 +25,10 @@ def log_fp16x16(): y = np.log(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "log_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.log()", name) + make_test([x], y, "input_0.log()", name) diff --git a/nodegen/node/logsoftmax.py b/nodegen/node/logsoftmax.py index 942dc52ed..af87e76ee 100644 --- a/nodegen/node/logsoftmax.py +++ b/nodegen/node/logsoftmax.py @@ -11,208 +11,35 @@ def logsoftmax(x: np.ndarray, axis: int = -1) -> np.ndarray: class Logsoftmax(RunAll): - def logsoftmax_i32(): - def fp8x23_axis_0(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 0) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "logsoftmax_i32_fp8x23_axis_0" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) - - def fp8x23_axis_1(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 1) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "logsoftmax_i32_fp8x23_axis_1" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) - - def fp16x16_axis_0(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 0) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "logsoftmax_i32_fp16x16_axis_0" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) - - def fp16x16_axis_1(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 1) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "logsoftmax_i32_fp16x16_axis_1" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) - - fp8x23_axis_0() - fp8x23_axis_1() - fp16x16_axis_0() - fp16x16_axis_1() - - def logsoftmax_i8(): - def fp8x23_axis_0(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 0) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "logsoftmax_i8_fp8x23_axis_0" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) - - def fp8x23_axis_1(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 1) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "logsoftmax_i8_fp8x23_axis_1" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) - - def fp16x16_axis_0(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 0) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - name = "logsoftmax_i8_fp16x16_axis_0" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) - - def fp16x16_axis_1(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 1) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "logsoftmax_i8_fp16x16_axis_1" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) - - fp8x23_axis_0() - fp8x23_axis_1() - fp16x16_axis_0() - fp16x16_axis_1() - - def logsoftmax_u32(): - def fp8x23_axis_0(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 0) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "logsoftmax_u32_fp8x23_axis_0" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) - - def fp8x23_axis_1(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 1) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "logsoftmax_u32_fp8x23_axis_1" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) - - def fp16x16_axis_0(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 0) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "logsoftmax_u32_fp16x16_axis_0" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) - - def fp16x16_axis_1(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = logsoftmax(x, 1) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "logsoftmax_u32_fp16x16_axis_1" - make_node([x], [y], name) - make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) - - fp8x23_axis_0() - fp8x23_axis_1() - fp16x16_axis_0() - fp16x16_axis_1() - def logsoftmax_fp8x23(): def axis_0(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = logsoftmax(x, 0) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "logsoftmax_fp8x23_axis_0" make_node([x], [y], name) make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) + name, Trait.NN) def axis_1(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = logsoftmax(x, 1) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "logsoftmax_fp8x23_axis_1" make_node([x], [y], name) make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) + name, Trait.NN) axis_0() axis_1() @@ -223,30 +50,28 @@ def axis_0(): y = logsoftmax(x, 0) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "logsoftmax_fp16x16_axis_0" make_node([x], [y], name) make_test([x], y, "NNTrait::logsoftmax(@input_0, 0)", - name, Trait.NN) + name, Trait.NN) def axis_1(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = logsoftmax(x, 1) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "logsoftmax_fp16x16_axis_1" make_node([x], [y], name) make_test([x], y, "NNTrait::logsoftmax(@input_0, 1)", - name, Trait.NN) + name, Trait.NN) axis_0() axis_1() - - diff --git a/nodegen/node/matmul.py b/nodegen/node/matmul.py index ae367f696..6965fcc41 100644 --- a/nodegen/node/matmul.py +++ b/nodegen/node/matmul.py @@ -202,11 +202,11 @@ def matmul_1D(): y = np.matmul(a, b).reshape((1)) a = Tensor(Dtype.FP8x23, a.shape, to_fp( - a.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + a.flatten(), FixedImpl.FP8x23)) b = Tensor(Dtype.FP8x23, b.shape, to_fp( - b.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + b.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "matmul_fp8x23_1d" make_node([a, b], [y], name) @@ -219,11 +219,11 @@ def matmul_2x2(): y = np.matmul(a, b) a = Tensor(Dtype.FP8x23, a.shape, to_fp( - a.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + a.flatten(), FixedImpl.FP8x23)) b = Tensor(Dtype.FP8x23, b.shape, to_fp( - b.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + b.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "matmul_fp8x23_2x2" make_node([a, b], [y], name) @@ -236,11 +236,11 @@ def matmul_2x1(): y = np.matmul(a, b) a = Tensor(Dtype.FP8x23, a.shape, to_fp( - a.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + a.flatten(), FixedImpl.FP8x23)) b = Tensor(Dtype.FP8x23, b.shape, to_fp( - b.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + b.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "matmul_fp8x23_2x1" make_node([a, b], [y], name) @@ -253,11 +253,11 @@ def matmul_1x2(): y = np.matmul(a, b) a = Tensor(Dtype.FP8x23, a.shape, to_fp( - a.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + a.flatten(), FixedImpl.FP8x23)) b = Tensor(Dtype.FP8x23, b.shape, to_fp( - b.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + b.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "matmul_fp8x23_1x2" make_node([a, b], [y], name) diff --git a/nodegen/node/mul.py b/nodegen/node/mul.py index bd070eeb0..2922c6bc1 100644 --- a/nodegen/node/mul.py +++ b/nodegen/node/mul.py @@ -105,11 +105,11 @@ def default(): z = x * y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "mul_fp8x23" make_node([x, y], [z], name) @@ -121,11 +121,11 @@ def broadcast(): z = x * y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "mul_fp8x23_broadcast" make_node([x, y], [z], name) @@ -142,11 +142,11 @@ def default(): z = x * y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "mul_fp16x16" make_node([x, y], [z], name) @@ -158,11 +158,11 @@ def broadcast(): z = x * y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "mul_fp16x16_broadcast" make_node([x, y], [z], name) diff --git a/nodegen/node/or.py b/nodegen/node/or.py index 7bacf76ac..f67778749 100644 --- a/nodegen/node/or.py +++ b/nodegen/node/or.py @@ -105,9 +105,9 @@ def default(): z = np.logical_or(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "or_fp8x23" @@ -120,9 +120,9 @@ def broadcast(): z = np.logical_or(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "or_fp8x23_broadcast" @@ -140,9 +140,9 @@ def default(): z = np.logical_or(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "or_fp16x16" @@ -155,9 +155,9 @@ def broadcast(): z = np.logical_or(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "or_fp16x16_broadcast" diff --git a/nodegen/node/reduce_sum.py b/nodegen/node/reduce_sum.py index 8647f3e5b..3a4449032 100644 --- a/nodegen/node/reduce_sum.py +++ b/nodegen/node/reduce_sum.py @@ -16,7 +16,7 @@ def reduce_sum_1D(): name = "reduce_sum_u32_1D" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def reduce_sum_2D(): def default(): @@ -29,7 +29,7 @@ def default(): name = "reduce_sum_u32_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def keepdims(): x = np.array([0, 1, 2, 3]).astype(np.uint32).reshape(2, 2) @@ -41,7 +41,7 @@ def keepdims(): name = "reduce_sum_u32_2D_keepdims" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, true)", name) + [x], y, "input_0.reduce_sum(0, true)", name) def axis_1(): x = np.array([0, 1, 2, 3]).astype(np.uint32).reshape(2, 2) @@ -53,7 +53,7 @@ def axis_1(): name = "reduce_sum_u32_2D_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(1, false)", name) + [x], y, "input_0.reduce_sum(1, false)", name) default() keepdims() @@ -73,7 +73,7 @@ def reduce_sum_1D(): name = "reduce_sum_i32_1D" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def reduce_sum_2D(): def default(): @@ -86,7 +86,7 @@ def default(): name = "reduce_sum_i32_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def keepdims(): x = np.array([0, 1, 2, 3]).astype(np.int32).reshape(2, 2) @@ -98,7 +98,7 @@ def keepdims(): name = "reduce_sum_i32_2D_keepdims" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, true)", name) + [x], y, "input_0.reduce_sum(0, true)", name) def axis_1(): x = np.array([0, 1, 2, 3]).astype(np.int32).reshape(2, 2) @@ -110,7 +110,7 @@ def axis_1(): name = "reduce_sum_i32_2D_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(1, false)", name) + [x], y, "input_0.reduce_sum(1, false)", name) default() keepdims() @@ -130,7 +130,7 @@ def reduce_sum_1D(): name = "reduce_sum_i8_1D" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def reduce_sum_2D(): def default(): @@ -143,7 +143,7 @@ def default(): name = "reduce_sum_i8_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def keepdims(): x = np.array([0, 1, 2, 3]).astype(np.int8).reshape(2, 2) @@ -155,7 +155,7 @@ def keepdims(): name = "reduce_sum_i8_2D_keepdims" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, true)", name) + [x], y, "input_0.reduce_sum(0, true)", name) def axis_1(): x = np.array([0, 1, 2, 3]).astype(np.int8).reshape(2, 2) @@ -167,7 +167,7 @@ def axis_1(): name = "reduce_sum_i8_2D_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(1, false)", name) + [x], y, "input_0.reduce_sum(1, false)", name) default() keepdims() @@ -182,14 +182,14 @@ def reduce_sum_1D(): y = np.array([3]).astype(np.int64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "reduce_sum_fp8x23_1D" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def reduce_sum_2D(): def default(): @@ -197,42 +197,42 @@ def default(): y = np.array([2, 4]).astype(np.int64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "reduce_sum_fp8x23_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def keepdims(): x = np.array([0, 1, 2, 3]).astype(np.int64).reshape(2, 2) y = np.array([2, 4]).astype(np.int64).reshape(1, 2) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "reduce_sum_fp8x23_2D_keepdims" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, true)", name) + [x], y, "input_0.reduce_sum(0, true)", name) def axis_1(): x = np.array([0, 1, 2, 3]).astype(np.int64).reshape(2, 2) y = np.array([1, 5]).astype(np.int64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "reduce_sum_fp8x23_2D_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(1, false)", name) + [x], y, "input_0.reduce_sum(1, false)", name) default() keepdims() @@ -248,14 +248,14 @@ def reduce_sum_1D(): y = np.array([3]).astype(np.int64) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "reduce_sum_fp16x16_1D" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def reduce_sum_2D(): def default(): @@ -263,42 +263,42 @@ def default(): y = np.array([2, 4]).astype(np.int64) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "reduce_sum_fp16x16_2D_default" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, false)", name) + [x], y, "input_0.reduce_sum(0, false)", name) def keepdims(): x = np.array([0, 1, 2, 3]).astype(np.int64).reshape(2, 2) y = np.array([2, 4]).astype(np.int64).reshape(1, 2) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "reduce_sum_fp16x16_2D_keepdims" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(0, true)", name) + [x], y, "input_0.reduce_sum(0, true)", name) def axis_1(): x = np.array([0, 1, 2, 3]).astype(np.int64).reshape(2, 2) y = np.array([1, 5]).astype(np.int64) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "reduce_sum_fp16x16_2D_axis_1" make_node([x], [y], name) make_test( - [x], y, "x.reduce_sum(1, false)", name) + [x], y, "input_0.reduce_sum(1, false)", name) default() keepdims() diff --git a/nodegen/node/relu.py b/nodegen/node/relu.py index eb1032906..5e72850b5 100644 --- a/nodegen/node/relu.py +++ b/nodegen/node/relu.py @@ -41,9 +41,9 @@ def relu_fp8x23(): y = layer(x).numpy() x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "relu_fp8x23" make_node([x], [y], name) @@ -57,9 +57,9 @@ def relu_fp16x16(): y = layer(x).numpy() x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "relu_fp16x16" make_node([x], [y], name) diff --git a/nodegen/node/sigmoid.py b/nodegen/node/sigmoid.py index 5a4090473..0f5052eae 100644 --- a/nodegen/node/sigmoid.py +++ b/nodegen/node/sigmoid.py @@ -7,127 +7,33 @@ class Sigmoid(RunAll): @staticmethod - def sigmoid_i32(): - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() + def fp8x23(): + x = np.random.uniform(-3, 3, (2, 2)).astype(np.float32) + y = tf.keras.activations.sigmoid(x).numpy() - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x = Tensor(Dtype.FP8x23, x.shape, to_fp( + x.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) - name = "sigmoid_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sigmoid_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def sigmoid_i8(): - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sigmoid_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sigmoid_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() + name = "sigmoid_fp8x23" + make_node([x], [y], name) + make_test([x], y, "NNTrait::sigmoid(@input_0)", + name, Trait.NN) @staticmethod - def sigmoid_u32(): - def fp8x23(): - x = np.random.randint(0, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sigmoid_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(0, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sigmoid_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def sigmoid_fp(): - def fp8x23(): - x = np.random.uniform(-3, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() - - x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sigmoid_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) + def fp16x16(): + x = np.random.uniform(-3, 3, (2, 2)).astype(np.float32) + y = tf.keras.activations.sigmoid(x).numpy() - def fp16x16(): - x = np.random.uniform(-3, 3, (2, 2)).astype(np.float32) - y = tf.keras.activations.sigmoid(x).numpy() + x = Tensor(Dtype.FP16x16, x.shape, to_fp( + x.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) - x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + name = "sigmoid_fp16x16" + make_node([x], [y], name) + make_test([x], y, "NNTrait::sigmoid(@input_0)", + name, Trait.NN) - name = "sigmoid_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::sigmoid(@input_0)", - name, Trait.NN) - fp8x23() - fp16x16() diff --git a/nodegen/node/sin.py b/nodegen/node/sin.py index da1995ce1..e62eb38d8 100644 --- a/nodegen/node/sin.py +++ b/nodegen/node/sin.py @@ -4,110 +4,20 @@ class Sin(RunAll): - - @staticmethod - def sin_i32(): - - def fp8x23(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.int32) - y = np.sin(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sin_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sin()", name) - - def fp16x16(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.int32) - y = np.sin(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sin_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sin()", name) - - fp8x23() - fp16x16() - - @staticmethod - def sin_i8(): - - def fp8x23(): - x = np.random.randint(-10, 5, (2, 2)).astype(np.int8) - y = np.sin(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sin_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sin()", name) - - def fp16x16(): - x = np.random.randint(-10, 127, (2, 2)).astype(np.int32) - y = np.sin(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sin_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sin()", name) - - fp8x23() - fp16x16() - - @staticmethod - def sin_u32(): - - def fp8x23(): - x = np.random.randint(0, 127, (2, 2)).astype(np.uint32) - y = np.sin(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sin_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sin()", name) - - def fp16x16(): - x = np.random.randint(0, 127, (2, 2)).astype(np.uint32) - y = np.sin(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sin_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sin()", name) - - fp8x23() - fp16x16() - + @staticmethod def sin_fp8x23(): x = np.random.uniform(-3, 7, (2, 2)).astype(np.float64) y = np.sin(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "sin_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.sin()", name) + make_test([x], y, "input_0.sin()", name) @staticmethod def sin_fp16x16(): @@ -115,10 +25,10 @@ def sin_fp16x16(): y = np.sin(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "sin_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.sin()", name) + make_test([x], y, "input_0.sin()", name) diff --git a/nodegen/node/sinh.py b/nodegen/node/sinh.py index 6b2117a59..27710d3ed 100644 --- a/nodegen/node/sinh.py +++ b/nodegen/node/sinh.py @@ -5,109 +5,19 @@ class Sinh(RunAll): - @staticmethod - def sinh_i32(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.sinh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sinh_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.sinh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sinh_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def sinh_i8(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = np.sinh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sinh_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.sinh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sinh_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def sinh_u32(): - - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.sinh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sinh_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.sinh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sinh_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) - - fp8x23() - fp16x16() - @staticmethod def sinh_fp8x23(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = np.sinh(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "sinh_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) + make_test([x], y, "input_0.sinh()", name) @staticmethod def sinh_fp16x16(): @@ -115,10 +25,10 @@ def sinh_fp16x16(): y = np.sinh(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "sinh_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.sinh()", name) + make_test([x], y, "input_0.sinh()", name) diff --git a/nodegen/node/slice.py b/nodegen/node/slice.py new file mode 100644 index 000000000..b87ec3bc9 --- /dev/null +++ b/nodegen/node/slice.py @@ -0,0 +1,155 @@ +import numpy as np +from nodegen.node import RunAll +from ..helpers import make_node, make_test, to_fp, Tensor, Dtype, FixedImpl + + +class Slice(RunAll): + @staticmethod + def slice_u32(): + def slice_2D(): + x = np.random.randint(0, 255, (2, 4)).astype(np.uint32) + y = x[0:2, 2:4] + + x = Tensor(Dtype.U32, x.shape, x.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "slice_u32_2d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span()))", name) + + def slice_3D(): + x = np.random.randint(0, 255, (20, 10, 5)).astype(np.uint32) + y = x[0:3, 0:10:3] + + x = Tensor(Dtype.U32, x.shape, x.flatten()) + y = Tensor(Dtype.U32, y.shape, y.flatten()) + + name = "slice_u32_3d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span()))", name) + + slice_2D() + slice_3D() + + @staticmethod + def slice_i32(): + def slice_2D(): + x = np.random.randint(-127, 127, (2, 4)).astype(np.int32) + y = x[0:2, 2:4] + + x = Tensor(Dtype.I32, x.shape, x.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "slice_i32_2d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span()))", name) + + def slice_3D(): + x = np.random.randint(-127, 127, (20, 10, 5)).astype(np.int32) + y = x[0:3, 0:10:3] + + x = Tensor(Dtype.I32, x.shape, x.flatten()) + y = Tensor(Dtype.I32, y.shape, y.flatten()) + + name = "slice_i32_3d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span()))", name) + + + slice_2D() + slice_3D() + + @staticmethod + def slice_i8(): + def slice_2D(): + x = np.random.randint(-127, 127, (2, 4)).astype(np.int8) + y = x[0:2, 2:4] + + x = Tensor(Dtype.I8, x.shape, x.flatten()) + y = Tensor(Dtype.I8, y.shape, y.flatten()) + + name = "slice_i8_2d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span()))", name) + + def slice_3D(): + x = np.random.randint(-127, 127, (20, 10, 5)).astype(np.int8) + y = x[0:3, 0:10:3] + + x = Tensor(Dtype.I8, x.shape, x.flatten()) + y = Tensor(Dtype.I8, y.shape, y.flatten()) + + name = "slice_i8_3d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span()))", name) + + slice_2D() + slice_3D() + + @staticmethod + def slice_fp8x23(): + def slice_2D(): + x = to_fp(np.random.randint(-127, 127, (2, 4) + ).astype(np.int64), FixedImpl.FP8x23) + y = x[0:2, 2:4] + + x = Tensor(Dtype.FP8x23, x.shape, x.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "slice_fp8x23_2d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span()))", name) + + def slice_3D(): + x = to_fp(np.random.randint(-127, 127, (20, 10, 5) + ).astype(np.int64), FixedImpl.FP8x23) + y = x[0:3, 0:10:3] + + x = Tensor(Dtype.FP8x23, x.shape, x.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) + + name = "slice_fp8x23_3d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span()))", name) + + slice_2D() + slice_3D() + + @staticmethod + def slice_fp16x16(): + def slice_2D(): + x = to_fp(np.random.randint(-127, 127, (2, 4) + ).astype(np.int64), FixedImpl.FP16x16) + y = x[0:2, 2:4] + + x = Tensor(Dtype.FP16x16, x.shape, x.flatten()) + y = Tensor(Dtype.FP16x16, y.shape, y.flatten()) + + name = "slice_fp16x16_2d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span()))", name) + + def slice_3D(): + x = to_fp(np.random.randint(-127, 127, (20, 10, 5) + ).astype(np.int64), FixedImpl.FP16x16) + y = x[0:3, 0:10:3] + + x = Tensor(Dtype.FP16x16, x.shape, x.flatten()) + y = Tensor(Dtype.FP16x16, y.shape, y.flatten()) + + name = "slice_fp16x16_3d" + make_node([x], [y], name) + make_test( + [x], y, "input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span()))", name) + + slice_2D() + slice_3D() diff --git a/nodegen/node/softmax.py b/nodegen/node/softmax.py index 041c21a72..2c42b9844 100644 --- a/nodegen/node/softmax.py +++ b/nodegen/node/softmax.py @@ -12,128 +12,34 @@ def softmax(x: np.ndarray, axis: int = -1) -> np.ndarray: class Softmax(RunAll): - @staticmethod - def softmax_i32(): - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = softmax(x, 0) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softmax_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = softmax(x, 1) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softmax_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 1)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def softmax_i8(): - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = softmax(x, 1) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softmax_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 1)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = softmax(x, 0) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softmax_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 0)", - name, Trait.NN) - - fp8x23() - fp16x16() @staticmethod - def softmax_u32(): - def fp8x23(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = softmax(x, 1) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softmax_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 1)", - name, Trait.NN) + def fp8x23(): + x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) + y = softmax(x, 0) - def fp16x16(): - x = np.random.randint(0, 3, (2, 2)).astype(np.int32) - y = softmax(x, 0) + x = Tensor(Dtype.FP8x23, x.shape, to_fp( + x.flatten(), FixedImpl.FP8x23)) + y = Tensor(Dtype.FP8x23, y.shape, to_fp( + y.flatten(), FixedImpl.FP8x23)) - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softmax_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 0)", - name, Trait.NN) - - fp8x23() - fp16x16() + name = "softmax_fp8x23" + make_node([x], [y], name) + make_test([x], y, "NNTrait::softmax(@input_0, 0)", + name, Trait.NN) @staticmethod - def softmax_fp(): - def fp8x23(): - x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) - y = softmax(x, 0) - - x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softmax_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) - y = softmax(x, 1) + def fp16x16(): + x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) + y = softmax(x, 1) - x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x = Tensor(Dtype.FP16x16, x.shape, to_fp( + x.flatten(), FixedImpl.FP16x16)) + y = Tensor(Dtype.FP16x16, y.shape, to_fp( + y.flatten(), FixedImpl.FP16x16)) - name = "softmax_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softmax(@input_0, 1)", - name, Trait.NN) + name = "softmax_fp16x16" + make_node([x], [y], name) + make_test([x], y, "NNTrait::softmax(@input_0, 1)", + name, Trait.NN) - fp8x23() - fp16x16() diff --git a/nodegen/node/softplus.py b/nodegen/node/softplus.py index 0783f39cb..9c8b72106 100644 --- a/nodegen/node/softplus.py +++ b/nodegen/node/softplus.py @@ -9,99 +9,6 @@ def softplus(x: np.ndarray) -> np.ndarray: class Softplus(RunAll): - @staticmethod - def softplus_i32(): - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = softplus(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softplus_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softplus(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = softplus(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softplus_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softplus(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def softplus_i8(): - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = softplus(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softplus_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softplus(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = softplus(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softplus_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softplus(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def softplus_u32(): - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.int32) - y = softplus(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softplus_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softplus(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.int32) - y = softplus(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softplus_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softplus(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - @staticmethod def softplus_fp(): def fp8x23(): @@ -109,9 +16,9 @@ def fp8x23(): y = softplus(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "softplus_fp8x23" make_node([x], [y], name) @@ -123,9 +30,9 @@ def fp16x16(): y = softplus(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "softplus_fp16x16" make_node([x], [y], name) diff --git a/nodegen/node/softsign.py b/nodegen/node/softsign.py index 6d00955b2..381d3e2d7 100644 --- a/nodegen/node/softsign.py +++ b/nodegen/node/softsign.py @@ -9,99 +9,6 @@ def softsign(x: np.ndarray) -> np.ndarray: class Softsign(RunAll): - @staticmethod - def softsign_i32(): - def fp8x23(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int32) - y = softsign(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softsign_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softsign(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int32) - y = softsign(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softsign_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softsign(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def softsign_i8(): - def fp8x23(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int8) - y = softsign(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softsign_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softsign(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(-5, 9, (2, 2)).astype(np.int8) - y = softsign(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softsign_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softsign(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - - @staticmethod - def softsign_u32(): - def fp8x23(): - x = np.random.randint(0, 9, (2, 2)).astype(np.int32) - y = softsign(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "softsign_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softsign(@input_0)", - name, Trait.NN) - - def fp16x16(): - x = np.random.randint(0, 9, (2, 2)).astype(np.int32) - y = softsign(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "softsign_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "NNTrait::softsign(@input_0)", - name, Trait.NN) - - fp8x23() - fp16x16() - @staticmethod def softsign_fp(): def fp8x23(): @@ -109,9 +16,9 @@ def fp8x23(): y = softsign(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "softsign_fp8x23" make_node([x], [y], name) @@ -123,9 +30,9 @@ def fp16x16(): y = softsign(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "softsign_fp16x16" make_node([x], [y], name) diff --git a/nodegen/node/sqrt.py b/nodegen/node/sqrt.py index 7bc150944..62222c43b 100644 --- a/nodegen/node/sqrt.py +++ b/nodegen/node/sqrt.py @@ -2,97 +2,8 @@ from nodegen.node import RunAll from ..helpers import make_node, make_test, to_fp, Tensor, Dtype, FixedImpl -class Sqrt(RunAll): - - @staticmethod - def sqrt_i32(): - - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.int32) - y = np.sqrt(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sqrt_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.int32) - y = np.sqrt(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sqrt_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) - - fp8x23() - fp16x16() - - @staticmethod - def sqrt_i8(): - - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.int8) - y = np.sqrt(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - name = "sqrt_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.int32) - y = np.sqrt(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sqrt_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) - - fp8x23() - fp16x16() - - @staticmethod - def sqrt_u32(): - - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.sqrt(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "sqrt_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.sqrt(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "sqrt_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) - - fp8x23() - fp16x16() +class Sqrt(RunAll): @staticmethod def sqrt_fp8x23(): @@ -100,13 +11,13 @@ def sqrt_fp8x23(): y = np.sqrt(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "sqrt_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) + make_test([x], y, "input_0.sqrt()", name) @staticmethod def sqrt_fp16x16(): @@ -114,10 +25,10 @@ def sqrt_fp16x16(): y = np.sqrt(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "sqrt_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.sqrt()", name) + make_test([x], y, "input_0.sqrt()", name) diff --git a/nodegen/node/sub.py b/nodegen/node/sub.py index f941b6668..b16ef020f 100644 --- a/nodegen/node/sub.py +++ b/nodegen/node/sub.py @@ -105,11 +105,11 @@ def default(): z = x - y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "sub_fp8x23" make_node([x, y], [z], name) @@ -121,11 +121,11 @@ def broadcast(): z = x - y x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.FP8x23, z.shape, to_fp( - z.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + z.flatten(), FixedImpl.FP8x23)) name = "sub_fp8x23_broadcast" make_node([x, y], [z], name) @@ -142,11 +142,11 @@ def default(): z = x - y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "sub_fp16x16" make_node([x, y], [z], name) @@ -158,11 +158,11 @@ def broadcast(): z = x - y x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.FP16x16, z.shape, to_fp( - z.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + z.flatten(), FixedImpl.FP16x16)) name = "sub_fp16x16_broadcast" make_node([x, y], [z], name) diff --git a/nodegen/node/tanh.py b/nodegen/node/tanh.py index 70813a516..f09dc1342 100644 --- a/nodegen/node/tanh.py +++ b/nodegen/node/tanh.py @@ -5,109 +5,19 @@ class Tanh(RunAll): - @staticmethod - def tanh_i32(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.tanh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "tanh_i32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.tanh(x) - - x = Tensor(Dtype.I32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "tanh_i32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def tanh_i8(): - - def fp8x23(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) - y = np.tanh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "tanh_i8_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) - - def fp16x16(): - x = np.random.randint(-3, 3, (2, 2)).astype(np.int32) - y = np.tanh(x) - - x = Tensor(Dtype.I8, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "tanh_i8_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) - - fp8x23() - fp16x16() - - @staticmethod - def tanh_u32(): - - def fp8x23(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.tanh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) - - name = "tanh_u32_fp8x23" - make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) - - def fp16x16(): - x = np.random.randint(0, 6, (2, 2)).astype(np.uint32) - y = np.tanh(x) - - x = Tensor(Dtype.U32, x.shape, x.flatten(), FixedImpl.FP16x16) - y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) - - name = "tanh_u32_fp16x16" - make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) - - fp8x23() - fp16x16() - @staticmethod def tanh_fp8x23(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = np.tanh(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) name = "tanh_fp8x23" make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) + make_test([x], y, "input_0.tanh()", name) @staticmethod def tanh_fp16x16(): @@ -115,10 +25,10 @@ def tanh_fp16x16(): y = np.tanh(x) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) name = "tanh_fp16x16" make_node([x], [y], name) - make_test([x], y, "x.tanh()", name) + make_test([x], y, "input_0.tanh()", name) diff --git a/nodegen/node/transpose.py b/nodegen/node/transpose.py index 39f5f0518..f18e82faf 100644 --- a/nodegen/node/transpose.py +++ b/nodegen/node/transpose.py @@ -99,8 +99,8 @@ def transpose_2D(): ).astype(np.int64), FixedImpl.FP8x23) y = np.transpose(x, [1, 0]) - x = Tensor(Dtype.FP8x23, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, y.flatten(), FixedImpl.FP8x23) + x = Tensor(Dtype.FP8x23, x.shape, x.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) name = "transpose_fp8x23_2d" make_node([x], [y], name) @@ -112,8 +112,8 @@ def transpose_3D(): ).astype(np.int64), FixedImpl.FP8x23) y = np.transpose(x, [1, 2, 0]) - x = Tensor(Dtype.FP8x23, x.shape, x.flatten(), FixedImpl.FP8x23) - y = Tensor(Dtype.FP8x23, y.shape, y.flatten(), FixedImpl.FP8x23) + x = Tensor(Dtype.FP8x23, x.shape, x.flatten()) + y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) name = "transpose_fp8x23_3d" make_node([x], [y], name) diff --git a/nodegen/node/xor.py b/nodegen/node/xor.py index 5d5a7466a..0b77a0f5a 100644 --- a/nodegen/node/xor.py +++ b/nodegen/node/xor.py @@ -106,9 +106,9 @@ def default(): z = np.logical_xor(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "xor_fp8x23" @@ -121,9 +121,9 @@ def broadcast(): z = np.logical_xor(x, y) x = Tensor(Dtype.FP8x23, x.shape, to_fp( - x.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( - y.flatten(), FixedImpl.FP8x23), FixedImpl.FP8x23) + y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "xor_fp8x23_broadcast" @@ -141,9 +141,9 @@ def default(): z = np.logical_xor(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "xor_fp16x16" @@ -156,9 +156,9 @@ def broadcast(): z = np.logical_xor(x, y) x = Tensor(Dtype.FP16x16, x.shape, to_fp( - x.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( - y.flatten(), FixedImpl.FP16x16), FixedImpl.FP16x16) + y.flatten(), FixedImpl.FP16x16)) z = Tensor(Dtype.U32, z.shape, z.flatten()) name = "xor_fp16x16_broadcast" diff --git a/src/lib.cairo b/src/lib.cairo index 4b62df94d..7cc13d360 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -1,4 +1,3 @@ -mod performance; mod operators; mod numbers; mod tests; diff --git a/src/numbers.cairo b/src/numbers.cairo index 33d5f87bc..b8fc69cb8 100644 --- a/src/numbers.cairo +++ b/src/numbers.cairo @@ -1,3 +1,1709 @@ mod fixed_point; mod signed_integer; +use orion::numbers::signed_integer::integer_trait::IntegerTrait; +use orion::numbers::fixed_point::core::FixedTrait; + +// Common methods from Fixed Point and Signed Integers. +trait NumberTrait { + fn new(mag: MAG, sign: bool) -> T; + fn new_unscaled(mag: MAG, sign: bool) -> T; + fn from_felt(val: felt252) -> T; + fn abs(self: T) -> T; + fn ceil(self: T) -> T; + fn exp(self: T) -> T; + fn exp2(self: T) -> T; + fn floor(self: T) -> T; + fn ln(self: T) -> T; + fn log2(self: T) -> T; + fn log10(self: T) -> T; + fn pow(self: T, b: T) -> T; + fn round(self: T) -> T; + fn sqrt(self: T) -> T; + fn acos(self: T) -> T; + fn asin(self: T) -> T; + fn atan(self: T) -> T; + fn cos(self: T) -> T; + fn sin(self: T) -> T; + fn tan(self: T) -> T; + fn acosh(self: T) -> T; + fn asinh(self: T) -> T; + fn atanh(self: T) -> T; + fn cosh(self: T) -> T; + fn sinh(self: T) -> T; + fn tanh(self: T) -> T; + fn zero() -> T; + fn is_zero(self: T) -> bool; + fn one() -> T; + fn is_one(self: T) -> bool; + fn neg_one() -> T; + fn min_value() -> T; + fn max_value() -> T; + fn min(self: T, other: T) -> T; + fn max(self: T, other: T) -> T; + fn mag(self: T) -> MAG; + fn is_neg(self: T) -> bool; + fn xor(lhs: T, rhs: T) -> bool; + fn or(lhs: T, rhs: T) -> bool; +} + +use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23}; +use orion::numbers::fixed_point::implementations::fp8x23::math::core as core_fp8x23; +use orion::numbers::fixed_point::implementations::fp8x23::math::comp as comp_fp8x23; + +impl FP8x23Number of NumberTrait { + fn new(mag: u32, sign: bool) -> FP8x23 { + FP8x23Impl::new(mag, sign) + } + + fn new_unscaled(mag: u32, sign: bool) -> FP8x23 { + FP8x23Impl::new_unscaled(mag, sign) + } + + fn from_felt(val: felt252) -> FP8x23 { + FP8x23Impl::from_felt(val) + } + + fn ceil(self: FP8x23) -> FP8x23 { + FP8x23Impl::ceil(self) + } + + fn exp(self: FP8x23) -> FP8x23 { + FP8x23Impl::exp(self) + } + + fn exp2(self: FP8x23) -> FP8x23 { + FP8x23Impl::exp2(self) + } + + fn floor(self: FP8x23) -> FP8x23 { + FP8x23Impl::floor(self) + } + + fn ln(self: FP8x23) -> FP8x23 { + FP8x23Impl::ln(self) + } + + fn log2(self: FP8x23) -> FP8x23 { + FP8x23Impl::log2(self) + } + + fn log10(self: FP8x23) -> FP8x23 { + FP8x23Impl::log10(self) + } + + fn pow(self: FP8x23, b: FP8x23) -> FP8x23 { + FP8x23Impl::pow(self, b) + } + + fn round(self: FP8x23) -> FP8x23 { + FP8x23Impl::round(self) + } + + fn sqrt(self: FP8x23) -> FP8x23 { + FP8x23Impl::sqrt(self) + } + + fn acos(self: FP8x23) -> FP8x23 { + FP8x23Impl::acos(self) + } + + fn asin(self: FP8x23) -> FP8x23 { + FP8x23Impl::asin(self) + } + + fn atan(self: FP8x23) -> FP8x23 { + FP8x23Impl::atan(self) + } + + fn cos(self: FP8x23) -> FP8x23 { + FP8x23Impl::cos(self) + } + + fn sin(self: FP8x23) -> FP8x23 { + FP8x23Impl::sin(self) + } + + fn tan(self: FP8x23) -> FP8x23 { + FP8x23Impl::tan(self) + } + + fn acosh(self: FP8x23) -> FP8x23 { + FP8x23Impl::acosh(self) + } + + fn asinh(self: FP8x23) -> FP8x23 { + FP8x23Impl::asinh(self) + } + + fn atanh(self: FP8x23) -> FP8x23 { + FP8x23Impl::atanh(self) + } + + fn cosh(self: FP8x23) -> FP8x23 { + FP8x23Impl::cosh(self) + } + + fn sinh(self: FP8x23) -> FP8x23 { + FP8x23Impl::sinh(self) + } + + fn tanh(self: FP8x23) -> FP8x23 { + FP8x23Impl::tanh(self) + } + + fn zero() -> FP8x23 { + FP8x23Impl::ZERO() + } + fn is_zero(self: FP8x23) -> bool { + core_fp8x23::eq(@self, @FP8x23Impl::ZERO()) + } + + fn one() -> FP8x23 { + FP8x23Impl::ONE() + } + + fn neg_one() -> FP8x23 { + FP8x23 { mag: core_fp8x23::ONE, sign: true } + } + + fn is_one(self: FP8x23) -> bool { + core_fp8x23::eq(@self, @FP8x23Impl::ONE()) + } + + fn abs(self: FP8x23) -> FP8x23 { + core_fp8x23::abs(self) + } + + fn min_value() -> FP8x23 { + FP8x23 { mag: core_fp8x23::MAX, sign: true } + } + + fn max_value() -> FP8x23 { + FP8x23 { mag: core_fp8x23::MAX, sign: false } + } + + fn min(self: FP8x23, other: FP8x23) -> FP8x23 { + comp_fp8x23::min(self, other) + } + + fn max(self: FP8x23, other: FP8x23) -> FP8x23 { + comp_fp8x23::max(self, other) + } + + fn mag(self: FP8x23) -> u32 { + self.mag + } + + fn is_neg(self: FP8x23) -> bool { + self.sign + } + + fn xor(lhs: FP8x23, rhs: FP8x23) -> bool { + comp_fp8x23::xor(lhs, rhs) + } + + fn or(lhs: FP8x23, rhs: FP8x23) -> bool { + comp_fp8x23::or(lhs, rhs) + } +} + +use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16}; +use orion::numbers::fixed_point::implementations::fp16x16::math::core as core_fp16x16; +use orion::numbers::fixed_point::implementations::fp16x16::math::comp as comp_fp16x16; + +impl FP16x16Number of NumberTrait { + fn new(mag: u32, sign: bool) -> FP16x16 { + FP16x16Impl::new(mag, sign) + } + + fn new_unscaled(mag: u32, sign: bool) -> FP16x16 { + FP16x16Impl::new_unscaled(mag, sign) + } + + fn from_felt(val: felt252) -> FP16x16 { + FP16x16Impl::from_felt(val) + } + + fn ceil(self: FP16x16) -> FP16x16 { + FP16x16Impl::ceil(self) + } + + fn exp(self: FP16x16) -> FP16x16 { + FP16x16Impl::exp(self) + } + + fn exp2(self: FP16x16) -> FP16x16 { + FP16x16Impl::exp2(self) + } + + fn floor(self: FP16x16) -> FP16x16 { + FP16x16Impl::floor(self) + } + + fn ln(self: FP16x16) -> FP16x16 { + FP16x16Impl::ln(self) + } + + fn log2(self: FP16x16) -> FP16x16 { + FP16x16Impl::log2(self) + } + + fn log10(self: FP16x16) -> FP16x16 { + FP16x16Impl::log10(self) + } + + fn pow(self: FP16x16, b: FP16x16) -> FP16x16 { + FP16x16Impl::pow(self, b) + } + + fn round(self: FP16x16) -> FP16x16 { + FP16x16Impl::round(self) + } + + fn sqrt(self: FP16x16) -> FP16x16 { + FP16x16Impl::sqrt(self) + } + + fn acos(self: FP16x16) -> FP16x16 { + FP16x16Impl::acos(self) + } + + fn asin(self: FP16x16) -> FP16x16 { + FP16x16Impl::asin(self) + } + + fn atan(self: FP16x16) -> FP16x16 { + FP16x16Impl::atan(self) + } + + fn cos(self: FP16x16) -> FP16x16 { + FP16x16Impl::cos(self) + } + + fn sin(self: FP16x16) -> FP16x16 { + FP16x16Impl::sin(self) + } + + fn tan(self: FP16x16) -> FP16x16 { + FP16x16Impl::tan(self) + } + + fn acosh(self: FP16x16) -> FP16x16 { + FP16x16Impl::acosh(self) + } + + fn asinh(self: FP16x16) -> FP16x16 { + FP16x16Impl::asinh(self) + } + + fn atanh(self: FP16x16) -> FP16x16 { + FP16x16Impl::atanh(self) + } + + fn cosh(self: FP16x16) -> FP16x16 { + FP16x16Impl::cosh(self) + } + + fn sinh(self: FP16x16) -> FP16x16 { + FP16x16Impl::sinh(self) + } + + fn tanh(self: FP16x16) -> FP16x16 { + FP16x16Impl::tanh(self) + } + + fn zero() -> FP16x16 { + FP16x16Impl::ZERO() + } + fn is_zero(self: FP16x16) -> bool { + core_fp16x16::eq(@self, @FP16x16Impl::ZERO()) + } + + fn one() -> FP16x16 { + FP16x16Impl::ONE() + } + + fn neg_one() -> FP16x16 { + FP16x16 { mag: core_fp16x16::ONE, sign: true } + } + + fn is_one(self: FP16x16) -> bool { + core_fp16x16::eq(@self, @FP16x16Impl::ONE()) + } + + fn abs(self: FP16x16) -> FP16x16 { + core_fp16x16::abs(self) + } + + fn min_value() -> FP16x16 { + FP16x16 { mag: core_fp16x16::MAX, sign: true } + } + + fn max_value() -> FP16x16 { + FP16x16 { mag: core_fp16x16::MAX, sign: false } + } + + fn min(self: FP16x16, other: FP16x16) -> FP16x16 { + comp_fp16x16::min(self, other) + } + + fn max(self: FP16x16, other: FP16x16) -> FP16x16 { + comp_fp16x16::max(self, other) + } + + fn mag(self: FP16x16) -> u32 { + self.mag + } + + fn is_neg(self: FP16x16) -> bool { + self.sign + } + + fn xor(lhs: FP16x16, rhs: FP16x16) -> bool { + comp_fp16x16::xor(lhs, rhs) + } + + fn or(lhs: FP16x16, rhs: FP16x16) -> bool { + comp_fp16x16::or(lhs, rhs) + } +} + +use orion::numbers::fixed_point::implementations::fp64x64::core::{FP64x64Impl, FP64x64}; +use orion::numbers::fixed_point::implementations::fp64x64::core as core_fp64x64; +use orion::numbers::fixed_point::implementations::fp64x64::comp as comp_fp64x64; +use cubit::f128 as fp64x64; + +impl FP64x64Number of NumberTrait { + fn new(mag: u128, sign: bool) -> FP64x64 { + FP64x64Impl::new(mag, sign) + } + + fn new_unscaled(mag: u128, sign: bool) -> FP64x64 { + FP64x64Impl::new_unscaled(mag, sign) + } + + fn from_felt(val: felt252) -> FP64x64 { + FP64x64Impl::from_felt(val) + } + + fn ceil(self: FP64x64) -> FP64x64 { + FP64x64Impl::ceil(self) + } + + fn exp(self: FP64x64) -> FP64x64 { + FP64x64Impl::exp(self) + } + + fn exp2(self: FP64x64) -> FP64x64 { + FP64x64Impl::exp2(self) + } + + fn floor(self: FP64x64) -> FP64x64 { + FP64x64Impl::floor(self) + } + + fn ln(self: FP64x64) -> FP64x64 { + FP64x64Impl::ln(self) + } + + fn log2(self: FP64x64) -> FP64x64 { + FP64x64Impl::log2(self) + } + + fn log10(self: FP64x64) -> FP64x64 { + FP64x64Impl::log10(self) + } + + fn pow(self: FP64x64, b: FP64x64) -> FP64x64 { + FP64x64Impl::pow(self, b) + } + + fn round(self: FP64x64) -> FP64x64 { + FP64x64Impl::round(self) + } + + fn sqrt(self: FP64x64) -> FP64x64 { + FP64x64Impl::sqrt(self) + } + + fn acos(self: FP64x64) -> FP64x64 { + FP64x64Impl::acos(self) + } + + fn asin(self: FP64x64) -> FP64x64 { + FP64x64Impl::asin(self) + } + + fn atan(self: FP64x64) -> FP64x64 { + FP64x64Impl::atan(self) + } + + fn cos(self: FP64x64) -> FP64x64 { + FP64x64Impl::cos(self) + } + + fn sin(self: FP64x64) -> FP64x64 { + FP64x64Impl::sin(self) + } + + fn tan(self: FP64x64) -> FP64x64 { + FP64x64Impl::tan(self) + } + + fn acosh(self: FP64x64) -> FP64x64 { + FP64x64Impl::acosh(self) + } + + fn asinh(self: FP64x64) -> FP64x64 { + FP64x64Impl::asinh(self) + } + + fn atanh(self: FP64x64) -> FP64x64 { + FP64x64Impl::atanh(self) + } + + fn cosh(self: FP64x64) -> FP64x64 { + FP64x64Impl::cosh(self) + } + + fn sinh(self: FP64x64) -> FP64x64 { + FP64x64Impl::sinh(self) + } + + fn tanh(self: FP64x64) -> FP64x64 { + FP64x64Impl::tanh(self) + } + + fn zero() -> FP64x64 { + FP64x64Impl::ZERO() + } + fn is_zero(self: FP64x64) -> bool { + fp64x64::core::eq(@self, @FP64x64Impl::ZERO()) + } + + fn one() -> FP64x64 { + FP64x64Impl::ONE() + } + + fn neg_one() -> FP64x64 { + FP64x64 { mag: core_fp64x64::ONE, sign: true } + } + + fn is_one(self: FP64x64) -> bool { + core_fp64x64::eq(@self, @FP64x64Impl::ONE()) + } + + fn abs(self: FP64x64) -> FP64x64 { + fp64x64::core::abs(self) + } + + fn min_value() -> FP64x64 { + FP64x64 { mag: core_fp64x64::MAX, sign: true } + } + + fn max_value() -> FP64x64 { + FP64x64 { mag: core_fp64x64::MAX, sign: false } + } + + fn min(self: FP64x64, other: FP64x64) -> FP64x64 { + fp64x64::comp::min(self, other) + } + + fn max(self: FP64x64, other: FP64x64) -> FP64x64 { + fp64x64::comp::max(self, other) + } + + fn mag(self: FP64x64) -> u128 { + self.mag + } + + fn is_neg(self: FP64x64) -> bool { + self.sign + } + + fn xor(lhs: FP64x64, rhs: FP64x64) -> bool { + comp_fp64x64::xor(lhs, rhs) + } + + fn or(lhs: FP64x64, rhs: FP64x64) -> bool { + comp_fp64x64::or(lhs, rhs) + } +} + +use orion::numbers::fixed_point::implementations::fp32x32::core::{FP32x32Impl, FP32x32}; +use orion::numbers::fixed_point::implementations::fp32x32::core as core_fp32x32; +use orion::numbers::fixed_point::implementations::fp32x32::comp as comp_fp32x32; +use cubit::f64 as fp32x32; + +impl FP32x32Number of NumberTrait { + fn new(mag: u64, sign: bool) -> FP32x32 { + FP32x32Impl::new(mag, sign) + } + + fn new_unscaled(mag: u64, sign: bool) -> FP32x32 { + FP32x32Impl::new_unscaled(mag, sign) + } + + fn from_felt(val: felt252) -> FP32x32 { + FP32x32Impl::from_felt(val) + } + + fn ceil(self: FP32x32) -> FP32x32 { + FP32x32Impl::ceil(self) + } + + fn exp(self: FP32x32) -> FP32x32 { + FP32x32Impl::exp(self) + } + + fn exp2(self: FP32x32) -> FP32x32 { + FP32x32Impl::exp2(self) + } + + fn floor(self: FP32x32) -> FP32x32 { + FP32x32Impl::floor(self) + } + + fn ln(self: FP32x32) -> FP32x32 { + FP32x32Impl::ln(self) + } + + fn log2(self: FP32x32) -> FP32x32 { + FP32x32Impl::log2(self) + } + + fn log10(self: FP32x32) -> FP32x32 { + FP32x32Impl::log10(self) + } + + fn pow(self: FP32x32, b: FP32x32) -> FP32x32 { + FP32x32Impl::pow(self, b) + } + + fn round(self: FP32x32) -> FP32x32 { + FP32x32Impl::round(self) + } + + fn sqrt(self: FP32x32) -> FP32x32 { + FP32x32Impl::sqrt(self) + } + + fn acos(self: FP32x32) -> FP32x32 { + FP32x32Impl::acos(self) + } + + fn asin(self: FP32x32) -> FP32x32 { + FP32x32Impl::asin(self) + } + + fn atan(self: FP32x32) -> FP32x32 { + FP32x32Impl::atan(self) + } + + fn cos(self: FP32x32) -> FP32x32 { + FP32x32Impl::cos(self) + } + + fn sin(self: FP32x32) -> FP32x32 { + FP32x32Impl::sin(self) + } + + fn tan(self: FP32x32) -> FP32x32 { + FP32x32Impl::tan(self) + } + + fn acosh(self: FP32x32) -> FP32x32 { + FP32x32Impl::acosh(self) + } + + fn asinh(self: FP32x32) -> FP32x32 { + FP32x32Impl::asinh(self) + } + + fn atanh(self: FP32x32) -> FP32x32 { + FP32x32Impl::atanh(self) + } + + fn cosh(self: FP32x32) -> FP32x32 { + FP32x32Impl::cosh(self) + } + + fn sinh(self: FP32x32) -> FP32x32 { + FP32x32Impl::sinh(self) + } + + fn tanh(self: FP32x32) -> FP32x32 { + FP32x32Impl::tanh(self) + } + + fn zero() -> FP32x32 { + FP32x32Impl::ZERO() + } + fn is_zero(self: FP32x32) -> bool { + fp32x32::core::eq(@self, @FP32x32Impl::ZERO()) + } + + fn one() -> FP32x32 { + FP32x32Impl::ONE() + } + + fn neg_one() -> FP32x32 { + FP32x32 { mag: core_fp32x32::ONE, sign: true } + } + + fn is_one(self: FP32x32) -> bool { + core_fp32x32::eq(@self, @FP32x32Impl::ONE()) + } + + fn abs(self: FP32x32) -> FP32x32 { + fp32x32::core::abs(self) + } + + fn min_value() -> FP32x32 { + FP32x32 { mag: core_fp32x32::MAX, sign: true } + } + + fn max_value() -> FP32x32 { + FP32x32 { mag: core_fp32x32::MAX, sign: false } + } + + fn min(self: FP32x32, other: FP32x32) -> FP32x32 { + fp32x32::comp::min(self, other) + } + + fn max(self: FP32x32, other: FP32x32) -> FP32x32 { + fp32x32::comp::max(self, other) + } + + fn mag(self: FP32x32) -> u64 { + self.mag + } + + fn is_neg(self: FP32x32) -> bool { + self.sign + } + + fn xor(lhs: FP32x32, rhs: FP32x32) -> bool { + comp_fp32x32::xor(lhs, rhs) + } + + fn or(lhs: FP32x32, rhs: FP32x32) -> bool { + comp_fp32x32::or(lhs, rhs) + } +} + +use orion::numbers::signed_integer::i8 as i8_core; +use orion::numbers::signed_integer::i8::i8; + +impl I8Number of NumberTrait { + fn new(mag: u8, sign: bool) -> i8 { + i8 { mag, sign } + } + + fn new_unscaled(mag: u8, sign: bool) -> i8 { + i8 { mag, sign } + } + + fn from_felt(val: felt252) -> i8 { + panic(array!['not supported!']) + } + + fn ceil(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn exp(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn exp2(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn floor(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn ln(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn log2(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn log10(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn pow(self: i8, b: i8) -> i8 { + panic(array!['not supported!']) + } + + fn round(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn sqrt(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn acos(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn asin(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn atan(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn cos(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn sin(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn tan(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn acosh(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn asinh(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn atanh(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn cosh(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn sinh(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn tanh(self: i8) -> i8 { + panic(array!['not supported!']) + } + + fn zero() -> i8 { + i8 { mag: 0, sign: false } + } + fn is_zero(self: i8) -> bool { + i8_core::i8_eq(self, i8 { mag: 0, sign: false }) + } + + fn one() -> i8 { + i8 { mag: 1, sign: false } + } + + fn neg_one() -> i8 { + i8 { mag: 1, sign: true } + } + + fn is_one(self: i8) -> bool { + i8_core::i8_eq(self, i8 { mag: 1, sign: false }) + } + + fn abs(self: i8) -> i8 { + i8_core::i8_abs(self) + } + + fn min_value() -> i8 { + i8 { mag: 128, sign: true } + } + + fn max_value() -> i8 { + i8 { mag: 127, sign: false } + } + + fn min(self: i8, other: i8) -> i8 { + i8_core::i8_min(self, other) + } + + fn max(self: i8, other: i8) -> i8 { + i8_core::i8_max(self, other) + } + + fn mag(self: i8) -> u8 { + self.mag + } + + fn is_neg(self: i8) -> bool { + self.sign + } + + fn xor(lhs: i8, rhs: i8) -> bool { + if (lhs.mag == 0 || rhs.mag == 0) && lhs.mag != rhs.mag { + return true; + } else { + return false; + } + } + + fn or(lhs: i8, rhs: i8) -> bool { + if (lhs.mag == 0 && rhs.mag == 0) { + return false; + } else { + return true; + } + } +} + +use orion::numbers::signed_integer::i16 as i16_core; +use orion::numbers::signed_integer::i16::i16; + +impl i16Number of NumberTrait { + fn new(mag: u16, sign: bool) -> i16 { + i16 { mag, sign } + } + + fn new_unscaled(mag: u16, sign: bool) -> i16 { + i16 { mag, sign } + } + + fn from_felt(val: felt252) -> i16 { + panic(array!['not supported!']) + } + + fn ceil(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn exp(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn exp2(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn floor(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn ln(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn log2(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn log10(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn pow(self: i16, b: i16) -> i16 { + panic(array!['not supported!']) + } + + fn round(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn sqrt(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn acos(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn asin(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn atan(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn cos(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn sin(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn tan(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn acosh(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn asinh(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn atanh(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn cosh(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn sinh(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn tanh(self: i16) -> i16 { + panic(array!['not supported!']) + } + + fn zero() -> i16 { + i16 { mag: 0, sign: false } + } + fn is_zero(self: i16) -> bool { + i16_core::i16_eq(self, i16 { mag: 0, sign: false }) + } + + fn one() -> i16 { + i16 { mag: 1, sign: false } + } + + fn neg_one() -> i16 { + i16 { mag: 1, sign: true } + } + + fn is_one(self: i16) -> bool { + i16_core::i16_eq(self, i16 { mag: 1, sign: false }) + } + + fn abs(self: i16) -> i16 { + i16_core::i16_abs(self) + } + + fn min_value() -> i16 { + i16 { mag: 32768, sign: true } + } + + fn max_value() -> i16 { + i16 { mag: 32767, sign: false } + } + + fn min(self: i16, other: i16) -> i16 { + i16_core::i16_min(self, other) + } + + fn max(self: i16, other: i16) -> i16 { + i16_core::i16_max(self, other) + } + + fn mag(self: i16) -> u16 { + self.mag + } + + fn is_neg(self: i16) -> bool { + self.sign + } + + fn xor(lhs: i16, rhs: i16) -> bool { + if (lhs.mag == 0 || rhs.mag == 0) && lhs.mag != rhs.mag { + return true; + } else { + return false; + } + } + + fn or(lhs: i16, rhs: i16) -> bool { + if (lhs.mag == 0 && rhs.mag == 0) { + return false; + } else { + return true; + } + } +} + +use orion::numbers::signed_integer::i32 as i32_core; +use orion::numbers::signed_integer::i32::i32; + +impl i32Number of NumberTrait { + fn new(mag: u32, sign: bool) -> i32 { + i32 { mag, sign } + } + + fn new_unscaled(mag: u32, sign: bool) -> i32 { + i32 { mag, sign } + } + + fn from_felt(val: felt252) -> i32 { + panic(array!['not supported!']) + } + + fn ceil(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn exp(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn exp2(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn floor(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn ln(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn log2(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn log10(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn pow(self: i32, b: i32) -> i32 { + panic(array!['not supported!']) + } + + fn round(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn sqrt(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn acos(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn asin(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn atan(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn cos(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn sin(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn tan(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn acosh(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn asinh(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn atanh(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn cosh(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn sinh(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn tanh(self: i32) -> i32 { + panic(array!['not supported!']) + } + + fn zero() -> i32 { + i32 { mag: 0, sign: false } + } + fn is_zero(self: i32) -> bool { + i32_core::i32_eq(self, i32 { mag: 0, sign: false }) + } + + fn one() -> i32 { + i32 { mag: 1, sign: false } + } + + fn neg_one() -> i32 { + i32 { mag: 1, sign: true } + } + + fn is_one(self: i32) -> bool { + i32_core::i32_eq(self, i32 { mag: 1, sign: false }) + } + + fn abs(self: i32) -> i32 { + i32_core::i32_abs(self) + } + + fn min_value() -> i32 { + i32 { mag: 2147483648, sign: true } + } + + fn max_value() -> i32 { + i32 { mag: 2147483647, sign: false } + } + + fn min(self: i32, other: i32) -> i32 { + i32_core::i32_min(self, other) + } + + fn max(self: i32, other: i32) -> i32 { + i32_core::i32_max(self, other) + } + + fn mag(self: i32) -> u32 { + self.mag + } + + fn is_neg(self: i32) -> bool { + self.sign + } + + fn xor(lhs: i32, rhs: i32) -> bool { + if (lhs.mag == 0 || rhs.mag == 0) && lhs.mag != rhs.mag { + return true; + } else { + return false; + } + } + + fn or(lhs: i32, rhs: i32) -> bool { + if (lhs.mag == 0 && rhs.mag == 0) { + return false; + } else { + return true; + } + } +} + +use orion::numbers::signed_integer::i64 as i64_core; +use orion::numbers::signed_integer::i64::i64; + +impl i64Number of NumberTrait { + fn new(mag: u64, sign: bool) -> i64 { + i64 { mag, sign } + } + + fn new_unscaled(mag: u64, sign: bool) -> i64 { + i64 { mag, sign } + } + + fn from_felt(val: felt252) -> i64 { + panic(array!['not supported!']) + } + + fn ceil(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn exp(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn exp2(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn floor(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn ln(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn log2(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn log10(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn pow(self: i64, b: i64) -> i64 { + panic(array!['not supported!']) + } + + fn round(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn sqrt(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn acos(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn asin(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn atan(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn cos(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn sin(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn tan(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn acosh(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn asinh(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn atanh(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn cosh(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn sinh(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn tanh(self: i64) -> i64 { + panic(array!['not supported!']) + } + + fn zero() -> i64 { + i64 { mag: 0, sign: false } + } + fn is_zero(self: i64) -> bool { + i64_core::i64_eq(self, i64 { mag: 0, sign: false }) + } + + fn one() -> i64 { + i64 { mag: 1, sign: false } + } + + fn neg_one() -> i64 { + i64 { mag: 1, sign: true } + } + + fn is_one(self: i64) -> bool { + i64_core::i64_eq(self, i64 { mag: 1, sign: false }) + } + + fn abs(self: i64) -> i64 { + i64_core::i64_abs(self) + } + + fn min_value() -> i64 { + i64 { mag: 9223372036854775808, sign: true } + } + + fn max_value() -> i64 { + i64 { mag: 9223372036854775807, sign: false } + } + + fn min(self: i64, other: i64) -> i64 { + i64_core::i64_min(self, other) + } + + fn max(self: i64, other: i64) -> i64 { + i64_core::i64_max(self, other) + } + + fn mag(self: i64) -> u64 { + self.mag + } + + fn is_neg(self: i64) -> bool { + self.sign + } + + fn xor(lhs: i64, rhs: i64) -> bool { + if (lhs.mag == 0 || rhs.mag == 0) && lhs.mag != rhs.mag { + return true; + } else { + return false; + } + } + + fn or(lhs: i64, rhs: i64) -> bool { + if (lhs.mag == 0 && rhs.mag == 0) { + return false; + } else { + return true; + } + } +} + +use orion::numbers::signed_integer::i128 as i128_core; +use orion::numbers::signed_integer::i128::i128; + +impl i128Number of NumberTrait { + fn new(mag: u128, sign: bool) -> i128 { + i128 { mag, sign } + } + + fn new_unscaled(mag: u128, sign: bool) -> i128 { + i128 { mag, sign } + } + + fn from_felt(val: felt252) -> i128 { + panic(array!['not supported!']) + } + + fn ceil(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn exp(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn exp2(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn floor(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn ln(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn log2(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn log10(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn pow(self: i128, b: i128) -> i128 { + panic(array!['not supported!']) + } + + fn round(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn sqrt(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn acos(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn asin(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn atan(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn cos(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn sin(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn tan(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn acosh(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn asinh(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn atanh(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn cosh(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn sinh(self: i128) -> i128 { + panic(array!['not supported!']) + } + + fn tanh(self: i128) -> i128 { + panic(array!['not supported!']) + } + + + fn zero() -> i128 { + i128 { mag: 0, sign: false } + } + fn is_zero(self: i128) -> bool { + i128_core::i128_eq(self, i128 { mag: 0, sign: false }) + } + + fn one() -> i128 { + i128 { mag: 1, sign: false } + } + + fn neg_one() -> i128 { + i128 { mag: 1, sign: true } + } + + fn is_one(self: i128) -> bool { + i128_core::i128_eq(self, i128 { mag: 1, sign: false }) + } + + fn abs(self: i128) -> i128 { + i128_core::i128_abs(self) + } + + fn min_value() -> i128 { + i128 { mag: 170141183460469231731687303715884105728, sign: true } + } + + fn max_value() -> i128 { + i128 { mag: 170141183460469231731687303715884105727, sign: false } + } + + fn min(self: i128, other: i128) -> i128 { + i128_core::i128_min(self, other) + } + + fn max(self: i128, other: i128) -> i128 { + i128_core::i128_max(self, other) + } + + fn mag(self: i128) -> u128 { + self.mag + } + + fn is_neg(self: i128) -> bool { + self.sign + } + + fn xor(lhs: i128, rhs: i128) -> bool { + if (lhs.mag == 0 || rhs.mag == 0) && lhs.mag != rhs.mag { + return true; + } else { + return false; + } + } + + fn or(lhs: i128, rhs: i128) -> bool { + if (lhs.mag == 0 && rhs.mag == 0) { + return false; + } else { + return true; + } + } +} + +impl u32Number of NumberTrait { + fn new(mag: u32, sign: bool) -> u32 { + mag + } + + fn new_unscaled(mag: u32, sign: bool) -> u32 { + mag + } + + fn from_felt(val: felt252) -> u32 { + panic(array!['not supported!']) + } + + fn ceil(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn exp(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn exp2(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn floor(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn ln(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn log2(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn log10(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn pow(self: u32, b: u32) -> u32 { + panic(array!['not supported!']) + } + + fn round(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn sqrt(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn acos(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn asin(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn atan(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn cos(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn sin(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn tan(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn acosh(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn asinh(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn atanh(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn cosh(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn sinh(self: u32) -> u32 { + panic(array!['not supported!']) + } + + fn tanh(self: u32) -> u32 { + panic(array!['not supported!']) + } + + + fn zero() -> u32 { + 0 + } + fn is_zero(self: u32) -> bool { + self == 0 + } + + fn one() -> u32 { + 1 + } + + fn neg_one() -> u32 { + panic(array!['not supported']) + } + + fn is_one(self: u32) -> bool { + self == 1 + } + + fn abs(self: u32) -> u32 { + self + } + + fn min_value() -> u32 { + 0 + } + + fn max_value() -> u32 { + 4294967295 + } + + fn min(self: u32, other: u32) -> u32 { + if self < other { + return self; + } else { + other + } + } + + fn max(self: u32, other: u32) -> u32 { + if self > other { + return self; + } else { + other + } + } + + fn mag(self: u32) -> u32 { + self + } + + fn is_neg(self: u32) -> bool { + false + } + + fn xor(lhs: u32, rhs: u32) -> bool { + if (lhs == 0 || rhs == 0) && lhs != rhs { + return true; + } else { + return false; + } + } + + fn or(lhs: u32, rhs: u32) -> bool { + if (lhs == 0 && rhs == 0) { + return false; + } else { + return true; + } + } +} diff --git a/src/numbers/fixed_point/core.cairo b/src/numbers/fixed_point/core.cairo index 24cac1fe9..166389a16 100644 --- a/src/numbers/fixed_point/core.cairo +++ b/src/numbers/fixed_point/core.cairo @@ -1,16 +1,3 @@ -/// A struct representing a fixed point number. -#[derive(Serde, Copy, Drop)] -struct FixedType { - mag: u32, - sign: bool -} - -/// A struct listing fixed point implementations. -#[derive(Serde, Copy, Drop)] -enum FixedImpl { - FP8x23: (), - FP16x16: () -} /// Trait /// @@ -47,18 +34,18 @@ enum FixedImpl { /// sinh - Returns the value of the hyperbolic sine of the fixed point number. /// tanh - Returns the value of the hyperbolic tangent of the fixed point number. /// -trait FixedTrait { +trait FixedTrait { /// # FixedTrait::new /// /// ```rust - /// fn new(mag: u32, sign: bool) -> FixedType; + /// fn new(mag: MAG, sign: bool) -> T; /// ``` /// /// Constructs a new fixed point instance. /// /// ## Args /// - /// * `mag`(`u32`) - The magnitude of the fixed point. + /// * `mag`(`MAG`) - The magnitude of the fixed point. /// * `sign`(`bool`) - The sign of the fixed point, where `true` represents a negative number. /// /// ## Returns @@ -68,28 +55,27 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - /// - /// fn new_fp_example() -> FixedType { + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; + /// + /// fn new_fp_example() -> FP16x16 { /// // We can call `new` function as follows. /// FixedTrait::new(65536, false) /// } /// >>> {mag: 65536, sign: false} // = 1 in FP16x16 /// ``` /// - fn new(mag: u32, sign: bool) -> FixedType; + fn new(mag: MAG, sign: bool) -> T; /// # FixedTrait::new\_unscaled /// /// ```rust - /// fn new_unscaled(mag: u32, sign: bool) -> FixedType; + /// fn new_unscaled(mag: MAG, sign: bool) -> T; /// ``` /// /// Creates a new fixed point instance with the specified unscaled magnitude and sign. /// /// ## Args /// - /// `mag`(`u32`) - The unscaled magnitude of the fixed point. + /// `mag`(`MAG`) - The unscaled magnitude of the fixed point. /// `sign`(`bool`) - The sign of the fixed point, where `true` represents a negative number. /// /// ## Returns @@ -99,29 +85,28 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn new_unscaled_example() -> FixedType { + /// fn new_unscaled_example() -> FP16x16 { /// // We can call `new_unscaled` function as follows. /// FixedTrait::new_unscaled(1, false) /// } /// >>> {mag: 65536, sign: false} /// ``` /// - fn new_unscaled(mag: u32, sign: bool) -> FixedType; + fn new_unscaled(mag: MAG, sign: bool) -> T; /// # FixedTrait::from\_felt /// /// /// ```rust - /// fn from_felt(val: felt252) -> FixedType; + /// fn from_felt(val: felt252) -> T; /// ``` /// /// Creates a new fixed point instance from a felt252 value. /// /// ## Args /// - /// * `val`(`felt252`) - `felt252` value to convert in FixedType + /// * `val`(`felt252`) - `felt252` value to convert in fixed point. /// /// ## Returns /// @@ -130,25 +115,27 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// fn from_felt_example() -> FixedType { + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; + /// + /// fn from_felt_example() -> FP16x16 { /// // We can call `from_felt` function as follows . - /// FixedTrait::from_felt(190054); + /// FixedTrait::from_felt(190054) /// } /// >>> {mag: 190054, sign: false} // = 2.9 /// ``` /// - fn from_felt(val: felt252) -> FixedType; + fn from_felt(val: felt252) -> T; /// # fp.abs /// /// ```rust - /// fn abs(self: FixedType) -> FixedType; + /// fn abs(self: T) -> T; /// ``` /// /// Returns the absolute value of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -157,10 +144,10 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; + /// /// - /// fn abs_fp_example() -> FixedType { + /// fn abs_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(1, true); /// @@ -170,18 +157,18 @@ trait FixedTrait { /// >>> {mag: 65536, sign: false} // = 1 /// ``` /// - fn abs(self: FixedType) -> FixedType; + fn abs(self: T) -> T; /// # fp.ceil /// /// ```rust - /// fn ceil(self: FixedType) -> FixedType; + /// fn ceil(self: T) -> T; /// ``` /// /// Returns the smallest integer greater than or equal to the fixed point number. /// /// ## Args /// - /// *`self`(`FixedType`) - The input fixed point + /// *`self`(`T`) - The input fixed point /// /// ## Returns /// @@ -190,10 +177,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn ceil_fp_example() -> FixedType { + /// fn ceil_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::from_felt(190054); // 2.9 /// @@ -203,18 +189,18 @@ trait FixedTrait { /// >>> {mag: 196608, sign: false} // = 3 /// ``` /// - fn ceil(self: FixedType) -> FixedType; + fn ceil(self: T) -> T; /// # fp.exp /// /// ```rust - /// fn exp(self: FixedType) -> FixedType; + /// fn exp(self: T) -> T; /// ``` /// /// Returns the value of e raised to the power of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -223,10 +209,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn exp_fp_example() -> FixedType { + /// fn exp_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -236,18 +221,18 @@ trait FixedTrait { /// >>> {mag: 484249, sign: false} // = 7.389056317241236 /// ``` /// - fn exp(self: FixedType) -> FixedType; + fn exp(self: T) -> T; /// # fp.exp2 /// /// ```rust - /// fn exp2(self: FixedType) -> FixedType; + /// fn exp2(self: T) -> T; /// ``` /// /// Returns the value of 2 raised to the power of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -256,10 +241,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn exp2_fp_example() -> FixedType { + /// fn exp2_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -269,18 +253,18 @@ trait FixedTrait { /// >>> {mag: 262143, sign: false} // = 3.99999957248 /// ``` /// - fn exp2(self: FixedType) -> FixedType; + fn exp2(self: T) -> T; /// # fp.floor /// /// ```rust - /// fn floor(self: FixedType) -> FixedType; + /// fn floor(self: T) -> T; /// ``` /// /// Returns the largest integer less than or equal to the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -289,10 +273,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn floor_fp_example() -> FixedType { + /// fn floor_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::from_felt(190054); // 2.9 /// @@ -302,19 +285,19 @@ trait FixedTrait { /// >>> {mag: 131072, sign: false} // = 2 /// ``` /// - fn floor(self: FixedType) -> FixedType; + fn floor(self: T) -> T; /// # fp.ln /// /// /// ```rust - /// fn ln(self: FixedType) -> FixedType; + /// fn ln(self: T) -> T; /// ``` /// /// Returns the natural logarithm of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -323,10 +306,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn ln_fp_example() -> FixedType { + /// fn ln_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(1, false); /// @@ -336,18 +318,18 @@ trait FixedTrait { /// >>> {mag: 0, sign: false} /// ``` /// - fn ln(self: FixedType) -> FixedType; + fn ln(self: T) -> T; /// # fp.log2 /// /// ```rust - /// fn log2(self: FixedType) -> FixedType; + /// fn log2(self: T) -> T; /// ``` /// /// Returns the base-2 logarithm of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Panics /// @@ -360,10 +342,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn log2_fp_example() -> FixedType { + /// fn log2_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(3, false); /// @@ -373,18 +354,18 @@ trait FixedTrait { /// >>> {mag: 103872, sign: false} // = 1.58496250072 /// ``` /// - fn log2(self: FixedType) -> FixedType; + fn log2(self: T) -> T; /// # fp.log10 /// /// ```rust - /// fn log10(self: FixedType) -> FixedType; + /// fn log10(self: T) -> T; /// ``` /// /// Returns the base-10 logarithm of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -393,10 +374,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn log10_fp_example() -> FixedType { + /// fn log10_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(3, false); /// @@ -406,19 +386,19 @@ trait FixedTrait { /// >>> {mag: 31269, sign: false} // = 0.47712125472 /// ``` /// - fn log10(self: FixedType) -> FixedType; + fn log10(self: T) -> T; /// # fp.pow /// /// ```rust - /// fn pow(self: FixedType, b: FixedType) -> FixedType; + /// fn pow(self: T, b: T) -> T; /// ``` /// /// Returns the result of raising the fixed point number to the power of another fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point. - /// * `b`(`FixedType`) - The exponent fixed point number. + /// * `self`(`T`) - The input fixed point. + /// * `b`(`T`) - The exponent fixed point number. /// /// ## Returns /// @@ -427,10 +407,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn pow_fp_example() -> FixedType { + /// fn pow_fp_example() -> FP16x16 { /// // We instantiate FixedTrait points here. /// let a = FixedTrait::new_unscaled(3, false); /// let b = FixedTrait::new_unscaled(4, false); @@ -441,18 +420,18 @@ trait FixedTrait { /// >>> {mag: 5308416, sign: false} // = 81 /// ``` /// - fn pow(self: FixedType, b: FixedType) -> FixedType; + fn pow(self: T, b: T) -> T; /// # fp.round /// /// ```rust - /// fn round(self: FixedType) -> FixedType; + /// fn round(self: T) -> T; /// ``` /// /// Rounds the fixed point number to the nearest whole number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -462,10 +441,9 @@ trait FixedTrait { /// /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn round_fp_example() -> FixedType { + /// fn round_fp_example() -> FP16x16 { /// // We instantiate FixedTrait points here. /// let a = FixedTrait::from_felt(190054); // 2.9 /// @@ -475,18 +453,18 @@ trait FixedTrait { /// >>> {mag: 196608, sign: false} // = 3 /// ``` /// - fn round(self: FixedType) -> FixedType; + fn round(self: T) -> T; /// # fp.sqrt /// /// ```rust - /// fn sqrt(self: FixedType) -> FixedType; + /// fn sqrt(self: T) -> T; /// ``` /// /// Returns the square root of the fixed point number. /// /// ## Args /// - /// `self`(`FixedType`) - The input fixed point + /// `self`(`T`) - The input fixed point /// /// ## Panics /// @@ -499,10 +477,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn sqrt_fp_example() -> FixedType { + /// fn sqrt_fp_example() -> FP16x16 { /// // We instantiate FixedTrait points here. /// let a = FixedTrait::new_unscaled(9, false); /// @@ -512,18 +489,18 @@ trait FixedTrait { /// >>> {mag: 196608, sign: false} // = 3 /// ``` /// - fn sqrt(self: FixedType) -> FixedType; + fn sqrt(self: T) -> T; /// # fp.acos /// /// ```rust - /// fn acos(self: FixedType) -> FixedType; + /// fn acos(self: T) -> T; /// ``` /// /// Returns the arccosine (inverse of cosine) of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -532,10 +509,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn acos_fp_example() -> FixedType { + /// fn acos_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(1, true); /// @@ -545,18 +521,18 @@ trait FixedTrait { /// >>> {mag: 205887, sign: false} // = 3.14159265 /// ``` /// - fn acos(self: FixedType) -> FixedType; + fn acos(self: T) -> T; /// # fp.acos_fast /// /// ```rust - /// fn acos_fast(self: FixedType) -> FixedType; + /// fn acos_fast(self: T) -> T; /// ``` /// /// Returns the arccosine (inverse of cosine) of the fixed point number faster with LUT. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -565,10 +541,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn acos_fast_fp_example() -> FixedType { + /// fn acos_fast_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(1, true); /// @@ -578,18 +553,18 @@ trait FixedTrait { /// >>> {mag: 205887, sign: false} // = 3.14159265 /// ``` /// - fn acos_fast(self: FixedType) -> FixedType; + fn acos_fast(self: T) -> T; /// # fp.asin /// /// ```rust - /// fn asin(self: FixedType) -> FixedType; + /// fn asin(self: T) -> T; /// ``` /// /// Returns the arcsine (inverse of sine) of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -598,10 +573,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn asin_fp_example() -> FixedType { + /// fn asin_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(1, false); /// @@ -611,18 +585,18 @@ trait FixedTrait { /// >>> {mag: 102943, sign: true} // = 1.57079633 /// ``` /// - fn asin(self: FixedType) -> FixedType; + fn asin(self: T) -> T; /// # fp.asin_fast /// /// ```rust - /// fn asin_fast(self: FixedType) -> FixedType; + /// fn asin_fast(self: T) -> T; /// ``` /// /// Returns the arcsine (inverse of sine) of the fixed point number faster with LUT. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -631,10 +605,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn asin_fast_fp_example() -> FixedType { + /// fn asin_fast_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(1, false); /// @@ -644,18 +617,18 @@ trait FixedTrait { /// >>> {mag: 102943, sign: true} // = 1.57079633 /// ``` /// - fn asin_fast(self: FixedType) -> FixedType; + fn asin_fast(self: T) -> T; /// # fp.atan /// /// ```rust - /// fn atan(self: FixedType) -> FixedType; + /// fn atan(self: T) -> T; /// ``` /// /// Returns the arctangent (inverse of tangent) of the input fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -664,10 +637,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn atan_fp_example() -> FixedType { + /// fn atan_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -677,18 +649,18 @@ trait FixedTrait { /// >>> {mag: 72558, sign: false} // = 1.10714872 /// ``` /// - fn atan(self: FixedType) -> FixedType; + fn atan(self: T) -> T; /// # fp.atan_fast /// /// ```rust - /// fn atan_fast(self: FixedType) -> FixedType; + /// fn atan_fast(self: T) -> T; /// ``` /// /// Returns the arctangent (inverse of tangent) of the input fixed point number faster with LUT. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -697,10 +669,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn atan_fast_fp_example() -> FixedType { + /// fn atan_fast_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -710,18 +681,18 @@ trait FixedTrait { /// >>> {mag: 72558, sign: false} // = 1.10714872 /// ``` /// - fn atan_fast(self: FixedType) -> FixedType; + fn atan_fast(self: T) -> T; /// # fp.cos /// /// ```rust - /// fn cos(self: FixedType) -> FixedType; + /// fn cos(self: T) -> T; /// ``` /// /// Returns the cosine of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -730,10 +701,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn cos_fp_example() -> FixedType { + /// fn cos_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -743,18 +713,18 @@ trait FixedTrait { /// >>> {mag: 27273, sign: true} // = -0.41614684 /// ``` /// - fn cos(self: FixedType) -> FixedType; + fn cos(self: T) -> T; /// # fp.cos_fast /// /// ```rust - /// fn cos_fast(self: FixedType) -> FixedType; + /// fn cos_fast(self: T) -> T; /// ``` /// /// Returns the cosine of the fixed point number fast with LUT. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -763,10 +733,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn cos_fast_fp_example() -> FixedType { + /// fn cos_fast_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -776,18 +745,18 @@ trait FixedTrait { /// >>> {mag: 27273, sign: true} // = -0.41614684 /// ``` /// - fn cos_fast(self: FixedType) -> FixedType; + fn cos_fast(self: T) -> T; /// # fp.sin /// /// ```rust - /// fn sin(self: FixedType) -> FixedType; + /// fn sin(self: T) -> T; /// ``` /// /// Returns the sine of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -796,10 +765,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn sin_fp_example() -> FixedType { + /// fn sin_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -809,18 +777,18 @@ trait FixedTrait { /// >>> {mag: 59592, sign: false} // = 0.90929743 /// ``` /// - fn sin(self: FixedType) -> FixedType; + fn sin(self: T) -> T; /// # fp.sin_fast /// /// ```rust - /// fn sin_fast(self: FixedType) -> FixedType; + /// fn sin_fast(self: T) -> T; /// ``` /// /// Returns the sine of the fixed point number faster with LUT. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -829,10 +797,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn sin_fast_fp_example() -> FixedType { + /// fn sin_fast_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -842,18 +809,18 @@ trait FixedTrait { /// >>> {mag: 59592, sign: false} // = 0.90929743 /// ``` /// - fn sin_fast(self: FixedType) -> FixedType; + fn sin_fast(self: T) -> T; /// # fp.tan /// /// ```rust - /// fn tan(self: FixedType) -> FixedType; + /// fn tan(self: T) -> T; /// ``` /// /// Returns the tangent of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -862,10 +829,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn tan_fp_example() -> FixedType { + /// fn tan_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -875,18 +841,18 @@ trait FixedTrait { /// >>> {mag: 143199, sign: true} // = -2.18503986 /// ``` /// - fn tan(self: FixedType) -> FixedType; + fn tan(self: T) -> T; /// # fp.tan_fast /// /// ```rust - /// fn tan_fast(self: FixedType) -> FixedType; + /// fn tan_fast(self: T) -> T; /// ``` /// /// Returns the tangent of the fixed point number faster with LUT. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -895,10 +861,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn tan_fast_fp_example() -> FixedType { + /// fn tan_fast_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -908,18 +873,18 @@ trait FixedTrait { /// >>> {mag: 143199, sign: true} // = -2.18503986 /// ``` /// - fn tan_fast(self: FixedType) -> FixedType; + fn tan_fast(self: T) -> T; /// # fp.acosh /// /// ```rust - /// fn acosh(self: FixedType) -> FixedType; + /// fn acosh(self: T) -> T; /// ``` /// /// Returns the value of the inverse hyperbolic cosine of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -928,10 +893,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn acosh_fp_example() -> FixedType { + /// fn acosh_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -941,18 +905,18 @@ trait FixedTrait { /// >>> {mag: 86308, sign: false} // = 1.3169579 /// ``` /// - fn acosh(self: FixedType) -> FixedType; + fn acosh(self: T) -> T; /// # fp.asinh /// /// ```rust - /// fn asinh(self: FixedType) -> FixedType; + /// fn asinh(self: T) -> T; /// ``` /// /// Returns the value of the inverse hyperbolic sine of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -961,10 +925,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn asinh_fp_example() -> FixedType { + /// fn asinh_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -974,18 +937,18 @@ trait FixedTrait { /// >>> {mag: 94610, sign: false} // = 1.44363548 /// ``` /// - fn asinh(self: FixedType) -> FixedType; + fn asinh(self: T) -> T; /// # fp.atanh /// /// ```rust - /// fn atanh(self: FixedType) -> FixedType; + /// fn atanh(self: T) -> T; /// ``` /// /// Returns the value of the inverse hyperbolic tangent of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -994,10 +957,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn atanh_fp_example() -> FixedType { + /// fn atanh_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::from_felt(32768); // 0.5 /// @@ -1007,18 +969,18 @@ trait FixedTrait { /// >>> {mag: 35999, sign: false} // = 0.54930614 /// ``` /// - fn atanh(self: FixedType) -> FixedType; + fn atanh(self: T) -> T; /// # fp.cosh /// /// ```rust - /// fn cosh(self: FixedType) -> FixedType; + /// fn cosh(self: T) -> T; /// ``` /// /// Returns the value of the hyperbolic cosine of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -1027,10 +989,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn cosh_fp_example() -> FixedType { + /// fn cosh_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -1040,18 +1001,18 @@ trait FixedTrait { /// >>> {mag: 246559, sign: false} // = 3.76219569 /// ``` /// - fn cosh(self: FixedType) -> FixedType; + fn cosh(self: T) -> T; /// # fp.sinh /// /// ```rust - /// fn sinh(self: FixedType) -> FixedType; + /// fn sinh(self: T) -> T; /// ``` /// /// Returns the value of the hyperbolic sine of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -1060,10 +1021,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn sinh_fp_example() -> FixedType { + /// fn sinh_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -1073,18 +1033,18 @@ trait FixedTrait { /// >>> {mag: 237690, sign: false} // = 3.62686041 /// ``` /// - fn sinh(self: FixedType) -> FixedType; + fn sinh(self: T) -> T; /// # fp.tanh /// /// ```rust - /// fn tanh(self: FixedType) -> FixedType; + /// fn tanh(self: T) -> T; /// ``` /// /// Returns the value of the hyperbolic tangent of the fixed point number. /// /// ## Args /// - /// * `self`(`FixedType`) - The input fixed point + /// * `self`(`T`) - The input fixed point /// /// ## Returns /// @@ -1093,10 +1053,9 @@ trait FixedTrait { /// ## Examples /// /// ```rust - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + /// use orion::numbers::{FP16x16, FP16x16Impl, FixedTrait}; /// - /// fn tanh_fp_example() -> FixedType { + /// fn tanh_fp_example() -> FP16x16 { /// // We instantiate fixed point here. /// let fp = FixedTrait::new_unscaled(2, false); /// @@ -1106,8 +1065,8 @@ trait FixedTrait { /// >>> {mag: 63179, sign: false} // = 0.96402758 /// ``` /// - fn tanh(self: FixedType) -> FixedType; + fn tanh(self: T) -> T; - fn ZERO() -> FixedType; - fn ONE() -> FixedType; + fn ZERO() -> T; + fn ONE() -> T; } diff --git a/src/numbers/fixed_point/implementations.cairo b/src/numbers/fixed_point/implementations.cairo index 1d909f404..033abaa1d 100644 --- a/src/numbers/fixed_point/implementations.cairo +++ b/src/numbers/fixed_point/implementations.cairo @@ -1,2 +1,4 @@ mod fp8x23; mod fp16x16; +mod fp64x64; +mod fp32x32; \ No newline at end of file diff --git a/src/numbers/fixed_point/implementations/fp16x16/core.cairo b/src/numbers/fixed_point/implementations/fp16x16/core.cairo index 62ab1d1ed..28dfc3197 100644 --- a/src/numbers/fixed_point/implementations/fp16x16/core.cairo +++ b/src/numbers/fixed_point/implementations/fp16x16/core.cairo @@ -5,10 +5,17 @@ use result::{ResultTrait, ResultTraitImpl}; use traits::{TryInto, Into}; use orion::numbers::signed_integer::{i32::i32, i8::i8}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; +use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp16x16::math::{core, trig, hyp}; use orion::numbers::fixed_point::utils; +/// A struct representing a fixed point number. +#[derive(Serde, Copy, Drop)] +struct FP16x16 { + mag: u32, + sign: bool +} + // CONSTANTS const TWO: u32 = 131072; // 2 ** 17 @@ -17,169 +24,169 @@ const HALF: u32 = 32768; // 2 ** 15 const MAX: u32 = 2147483648; // 2 ** 31 -impl FP16x16Impl of FixedTrait { - fn ZERO() -> FixedType { - return FixedType { mag: 0, sign: false }; +impl FP16x16Impl of FixedTrait { + fn ZERO() -> FP16x16 { + return FP16x16 { mag: 0, sign: false }; } - fn ONE() -> FixedType { - return FixedType { mag: ONE, sign: false }; + fn ONE() -> FP16x16 { + return FP16x16 { mag: ONE, sign: false }; } - fn new(mag: u32, sign: bool) -> FixedType { - return FixedType { mag: mag, sign: sign }; + fn new(mag: u32, sign: bool) -> FP16x16 { + return FP16x16 { mag: mag, sign: sign }; } - fn new_unscaled(mag: u32, sign: bool) -> FixedType { - return FixedType { mag: mag * ONE, sign: sign }; + fn new_unscaled(mag: u32, sign: bool) -> FP16x16 { + return FP16x16 { mag: mag * ONE, sign: sign }; } - fn from_felt(val: felt252) -> FixedType { + fn from_felt(val: felt252) -> FP16x16 { let mag = integer::u32_try_from_felt252(utils::felt_abs(val)).unwrap(); return FixedTrait::new(mag, utils::felt_sign(val)); } - fn abs(self: FixedType) -> FixedType { + fn abs(self: FP16x16) -> FP16x16 { return core::abs(self); } - fn acos(self: FixedType) -> FixedType { + fn acos(self: FP16x16) -> FP16x16 { return trig::acos_fast(self); } - fn acos_fast(self: FixedType) -> FixedType { + fn acos_fast(self: FP16x16) -> FP16x16 { return trig::acos_fast(self); } - fn acosh(self: FixedType) -> FixedType { + fn acosh(self: FP16x16) -> FP16x16 { return hyp::acosh(self); } - fn asin(self: FixedType) -> FixedType { + fn asin(self: FP16x16) -> FP16x16 { return trig::asin_fast(self); } - fn asin_fast(self: FixedType) -> FixedType { + fn asin_fast(self: FP16x16) -> FP16x16 { return trig::asin_fast(self); } - fn asinh(self: FixedType) -> FixedType { + fn asinh(self: FP16x16) -> FP16x16 { return hyp::asinh(self); } - fn atan(self: FixedType) -> FixedType { + fn atan(self: FP16x16) -> FP16x16 { return trig::atan_fast(self); } - fn atan_fast(self: FixedType) -> FixedType { + fn atan_fast(self: FP16x16) -> FP16x16 { return trig::atan_fast(self); } - fn atanh(self: FixedType) -> FixedType { + fn atanh(self: FP16x16) -> FP16x16 { return hyp::atanh(self); } - fn ceil(self: FixedType) -> FixedType { + fn ceil(self: FP16x16) -> FP16x16 { return core::ceil(self); } - fn cos(self: FixedType) -> FixedType { + fn cos(self: FP16x16) -> FP16x16 { return trig::cos_fast(self); } - fn cos_fast(self: FixedType) -> FixedType { + fn cos_fast(self: FP16x16) -> FP16x16 { return trig::cos_fast(self); } - fn cosh(self: FixedType) -> FixedType { + fn cosh(self: FP16x16) -> FP16x16 { return hyp::cosh(self); } - fn floor(self: FixedType) -> FixedType { + fn floor(self: FP16x16) -> FP16x16 { return core::floor(self); } // Calculates the natural exponent of x: e^x - fn exp(self: FixedType) -> FixedType { + fn exp(self: FP16x16) -> FP16x16 { return core::exp(self); } // Calculates the binary exponent of x: 2^x - fn exp2(self: FixedType) -> FixedType { + fn exp2(self: FP16x16) -> FP16x16 { return core::exp2(self); } // Calculates the natural logarithm of x: ln(x) // self must be greater than zero - fn ln(self: FixedType) -> FixedType { + fn ln(self: FP16x16) -> FP16x16 { return core::ln(self); } // Calculates the binary logarithm of x: log2(x) // self must be greather than zero - fn log2(self: FixedType) -> FixedType { + fn log2(self: FP16x16) -> FP16x16 { return core::log2(self); } // Calculates the base 10 log of x: log10(x) // self must be greater than zero - fn log10(self: FixedType) -> FixedType { + fn log10(self: FP16x16) -> FP16x16 { return core::log10(self); } // Calclates the value of x^y and checks for overflow before returning // self is a fixed point value // b is a fixed point value - fn pow(self: FixedType, b: FixedType) -> FixedType { + fn pow(self: FP16x16, b: FP16x16) -> FP16x16 { return core::pow(self, b); } - fn round(self: FixedType) -> FixedType { + fn round(self: FP16x16) -> FP16x16 { return core::round(self); } - fn sin(self: FixedType) -> FixedType { + fn sin(self: FP16x16) -> FP16x16 { return trig::sin_fast(self); } - fn sin_fast(self: FixedType) -> FixedType { + fn sin_fast(self: FP16x16) -> FP16x16 { return trig::sin_fast(self); } - fn sinh(self: FixedType) -> FixedType { + fn sinh(self: FP16x16) -> FP16x16 { return hyp::sinh(self); } // Calculates the square root of a fixed point value // x must be positive - fn sqrt(self: FixedType) -> FixedType { + fn sqrt(self: FP16x16) -> FP16x16 { return core::sqrt(self); } - fn tan(self: FixedType) -> FixedType { + fn tan(self: FP16x16) -> FP16x16 { return trig::tan_fast(self); } - fn tan_fast(self: FixedType) -> FixedType { + fn tan_fast(self: FP16x16) -> FP16x16 { return trig::tan_fast(self); } - fn tanh(self: FixedType) -> FixedType { + fn tanh(self: FP16x16) -> FP16x16 { return hyp::tanh(self); } } -impl FP16x16Print of PrintTrait { - fn print(self: FixedType) { +impl FP16x16Print of PrintTrait { + fn print(self: FP16x16) { self.sign.print(); self.mag.print(); } } // Into a raw felt without unscaling -impl FP16x16IntoFelt252 of Into { - fn into(self: FixedType) -> felt252 { +impl FP16x16IntoFelt252 of Into { + fn into(self: FP16x16) -> felt252 { let mag_felt = self.mag.into(); if self.sign { @@ -190,21 +197,21 @@ impl FP16x16IntoFelt252 of Into { } } -impl FP16x16IntoI32 of Into { - fn into(self: FixedType) -> i32 { +impl FP16x16IntoI32 of Into { + fn into(self: FP16x16) -> i32 { _i32_into_fp(self) } } -impl FP16x16TryIntoI8 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP16x16TryIntoI8 of TryInto { + fn try_into(self: FP16x16) -> Option { _i8_try_from_fp(self) } } -impl FP16x16TryIntoU128 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP16x16TryIntoU128 of TryInto { + fn try_into(self: FP16x16) -> Option { if self.sign { return Option::None(()); } else { @@ -214,8 +221,8 @@ impl FP16x16TryIntoU128 of TryInto { } } -impl FP16x16TryIntoU64 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP16x16TryIntoU64 of TryInto { + fn try_into(self: FP16x16) -> Option { if self.sign { return Option::None(()); } else { @@ -225,8 +232,8 @@ impl FP16x16TryIntoU64 of TryInto { } } -impl FP16x16TryIntoU32 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP16x16TryIntoU32 of TryInto { + fn try_into(self: FP16x16) -> Option { if self.sign { return Option::None(()); } else { @@ -236,8 +243,8 @@ impl FP16x16TryIntoU32 of TryInto { } } -impl FP16x16TryIntoU16 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP16x16TryIntoU16 of TryInto { + fn try_into(self: FP16x16) -> Option { if self.sign { Option::None(()) } else { @@ -247,8 +254,8 @@ impl FP16x16TryIntoU16 of TryInto { } } -impl FP16x16TryIntoU8 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP16x16TryIntoU8 of TryInto { + fn try_into(self: FP16x16) -> Option { if self.sign { Option::None(()) } else { @@ -258,113 +265,114 @@ impl FP16x16TryIntoU8 of TryInto { } } -impl FP16x16PartialEq of PartialEq { +impl FP16x16PartialEq of PartialEq { #[inline(always)] - fn eq(lhs: @FixedType, rhs: @FixedType) -> bool { + fn eq(lhs: @FP16x16, rhs: @FP16x16) -> bool { return core::eq(lhs, rhs); } #[inline(always)] - fn ne(lhs: @FixedType, rhs: @FixedType) -> bool { + fn ne(lhs: @FP16x16, rhs: @FP16x16) -> bool { return core::ne(lhs, rhs); } } -impl FP16x16Add of Add { - fn add(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP16x16Add of Add { + fn add(lhs: FP16x16, rhs: FP16x16) -> FP16x16 { return core::add(lhs, rhs); } } -impl FP16x16AddEq of AddEq { +impl FP16x16AddEq of AddEq { #[inline(always)] - fn add_eq(ref self: FixedType, other: FixedType) { + fn add_eq(ref self: FP16x16, other: FP16x16) { self = Add::add(self, other); } } -impl FP16x16Sub of Sub { - fn sub(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP16x16Sub of Sub { + fn sub(lhs: FP16x16, rhs: FP16x16) -> FP16x16 { return core::sub(lhs, rhs); } } -impl FP16x16SubEq of SubEq { +impl FP16x16SubEq of SubEq { #[inline(always)] - fn sub_eq(ref self: FixedType, other: FixedType) { + fn sub_eq(ref self: FP16x16, other: FP16x16) { self = Sub::sub(self, other); } } -impl FP16x16Mul of Mul { - fn mul(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP16x16Mul of Mul { + fn mul(lhs: FP16x16, rhs: FP16x16) -> FP16x16 { return core::mul(lhs, rhs); } } -impl FP16x16MulEq of MulEq { +impl FP16x16MulEq of MulEq { #[inline(always)] - fn mul_eq(ref self: FixedType, other: FixedType) { + fn mul_eq(ref self: FP16x16, other: FP16x16) { self = Mul::mul(self, other); } } -impl FP16x16Div of Div { - fn div(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP16x16Div of Div { + fn div(lhs: FP16x16, rhs: FP16x16) -> FP16x16 { return core::div(lhs, rhs); } } -impl FP16x16DivEq of DivEq { +impl FP16x16DivEq of DivEq { #[inline(always)] - fn div_eq(ref self: FixedType, other: FixedType) { + fn div_eq(ref self: FP16x16, other: FP16x16) { self = Div::div(self, other); } } -impl FP16x16PartialOrd of PartialOrd { +impl FP16x16PartialOrd of PartialOrd { #[inline(always)] - fn ge(lhs: FixedType, rhs: FixedType) -> bool { + fn ge(lhs: FP16x16, rhs: FP16x16) -> bool { return core::ge(lhs, rhs); } #[inline(always)] - fn gt(lhs: FixedType, rhs: FixedType) -> bool { + fn gt(lhs: FP16x16, rhs: FP16x16) -> bool { return core::gt(lhs, rhs); } #[inline(always)] - fn le(lhs: FixedType, rhs: FixedType) -> bool { + fn le(lhs: FP16x16, rhs: FP16x16) -> bool { return core::le(lhs, rhs); } #[inline(always)] - fn lt(lhs: FixedType, rhs: FixedType) -> bool { + fn lt(lhs: FP16x16, rhs: FP16x16) -> bool { return core::lt(lhs, rhs); } } -impl FP16x16Neg of Neg { +impl FP16x16Neg of Neg { #[inline(always)] - fn neg(a: FixedType) -> FixedType { + fn neg(a: FP16x16) -> FP16x16 { return core::neg(a); } } -impl FP16x16Rem of Rem { +impl FP16x16Rem of Rem { #[inline(always)] - fn rem(lhs: FixedType, rhs: FixedType) -> FixedType { + fn rem(lhs: FP16x16, rhs: FP16x16) -> FP16x16 { return core::rem(lhs, rhs); } } + /// INTERNAL -fn _i32_into_fp(x: FixedType) -> i32 { +fn _i32_into_fp(x: FP16x16) -> i32 { i32 { mag: x.mag / ONE, sign: x.sign } } -fn _i8_try_from_fp(x: FixedType) -> Option { +fn _i8_try_from_fp(x: FP16x16) -> Option { let unscaled_mag: Option = (x.mag / ONE).try_into(); match unscaled_mag { diff --git a/src/numbers/fixed_point/implementations/fp16x16/helpers.cairo b/src/numbers/fixed_point/implementations/fp16x16/helpers.cairo index 732d2c8c0..01fb7d5c6 100644 --- a/src/numbers/fixed_point/implementations/fp16x16/helpers.cairo +++ b/src/numbers/fixed_point/implementations/fp16x16/helpers.cairo @@ -2,14 +2,14 @@ use debug::PrintTrait; use traits::Into; use orion::numbers::fixed_point::implementations::fp16x16::core::{ - HALF, ONE, TWO, FixedType, FP16x16Impl, FP16x16Sub, FP16x16Div, FixedTrait, FP16x16Print + HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Sub, FP16x16Div, FixedTrait, FP16x16Print }; const DEFAULT_PRECISION: u32 = 7; // 1e-4 // To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`. // To use `custom_precision` of 430_u32: `Option::Some(430_u32)`. -fn assert_precise(result: FixedType, expected: felt252, msg: felt252, custom_precision: Option) { +fn assert_precise(result: FP16x16, expected: felt252, msg: felt252, custom_precision: Option) { let precision = match custom_precision { Option::Some(val) => val, Option::None(_) => DEFAULT_PRECISION, @@ -23,7 +23,7 @@ fn assert_precise(result: FixedType, expected: felt252, msg: felt252, custom_pre } } -fn assert_relative(result: FixedType, expected: felt252, msg: felt252, custom_precision: Option) { +fn assert_relative(result: FP16x16, expected: felt252, msg: felt252, custom_precision: Option) { let precision = match custom_precision { Option::Some(val) => val, Option::None(_) => DEFAULT_PRECISION, diff --git a/src/numbers/fixed_point/implementations/fp16x16/math/comp.cairo b/src/numbers/fixed_point/implementations/fp16x16/math/comp.cairo index 9c23e6ea0..3aa3219b5 100644 --- a/src/numbers/fixed_point/implementations/fp16x16/math/comp.cairo +++ b/src/numbers/fixed_point/implementations/fp16x16/math/comp.cairo @@ -1,8 +1,8 @@ use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FixedType, FixedTrait, FP16x16Impl, FP16x16PartialOrd, FP16x16PartialEq + FP16x16, FixedTrait, FP16x16Impl, FP16x16PartialOrd, FP16x16PartialEq }; -fn max(a: FixedType, b: FixedType) -> FixedType { +fn max(a: FP16x16, b: FP16x16) -> FP16x16 { if (a >= b) { return a; } else { @@ -10,7 +10,7 @@ fn max(a: FixedType, b: FixedType) -> FixedType { } } -fn min(a: FixedType, b: FixedType) -> FixedType { +fn min(a: FP16x16, b: FP16x16) -> FP16x16 { if (a <= b) { return a; } else { @@ -18,7 +18,7 @@ fn min(a: FixedType, b: FixedType) -> FixedType { } } -fn xor(a: FixedType, b: FixedType) -> bool { +fn xor(a: FP16x16, b: FP16x16) -> bool { if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) { return true; } else { @@ -26,7 +26,7 @@ fn xor(a: FixedType, b: FixedType) -> bool { } } -fn or(a: FixedType, b: FixedType) -> bool { +fn or(a: FP16x16, b: FP16x16) -> bool { let zero = FixedTrait::new(0, false); if a == zero && b == zero { return false; diff --git a/src/numbers/fixed_point/implementations/fp16x16/math/core.cairo b/src/numbers/fixed_point/implementations/fp16x16/math/core.cairo index d20fac0aa..db517475c 100644 --- a/src/numbers/fixed_point/implementations/fp16x16/math/core.cairo +++ b/src/numbers/fixed_point/implementations/fp16x16/math/core.cairo @@ -5,7 +5,7 @@ use traits::{Into, TryInto}; use integer::{u32_safe_divmod, u32_as_non_zero, u32_wide_mul}; use orion::numbers::fixed_point::implementations::fp16x16::core::{ - HALF, ONE, FixedType, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul, + HALF, ONE, MAX, FP16x16, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul, FP16x16MulEq, FP16x16TryIntoU128, FP16x16PartialEq, FP16x16PartialOrd, FP16x16SubEq, FP16x16Neg, FP16x16Div, FP16x16IntoFelt252, FixedTrait }; @@ -13,11 +13,11 @@ use orion::numbers::fixed_point::implementations::fp16x16::math::lut; // PUBLIC -fn abs(a: FixedType) -> FixedType { +fn abs(a: FP16x16) -> FP16x16 { return FixedTrait::new(a.mag, false); } -fn add(a: FixedType, b: FixedType) -> FixedType { +fn add(a: FP16x16, b: FP16x16) -> FP16x16 { if a.sign == b.sign { return FixedTrait::new(a.mag + b.mag, a.sign); } @@ -33,7 +33,7 @@ fn add(a: FixedType, b: FixedType) -> FixedType { } } -fn ceil(a: FixedType) -> FixedType { +fn ceil(a: FP16x16) -> FP16x16 { let (div, rem) = u32_safe_divmod(a.mag, u32_as_non_zero(ONE)); if rem == 0 { @@ -47,7 +47,7 @@ fn ceil(a: FixedType) -> FixedType { } } -fn div(a: FixedType, b: FixedType) -> FixedType { +fn div(a: FP16x16, b: FP16x16) -> FP16x16 { let a_u64 = integer::u32_wide_mul(a.mag, ONE); let res_u64 = a_u64 / b.mag.into(); @@ -55,17 +55,17 @@ fn div(a: FixedType, b: FixedType) -> FixedType { return FixedTrait::new(res_u64.try_into().unwrap(), a.sign ^ b.sign); } -fn eq(a: @FixedType, b: @FixedType) -> bool { +fn eq(a: @FP16x16, b: @FP16x16) -> bool { return (*a.mag == *b.mag) && (*a.sign == *b.sign); } // Calculates the natural exponent of x: e^x -fn exp(a: FixedType) -> FixedType { +fn exp(a: FP16x16) -> FP16x16 { return exp2(FixedTrait::new(94548, false) * a); // log2(e) * 2^23 ≈ 12102203 } // Calculates the binary exponent of x: 2^x -fn exp2(a: FixedType) -> FixedType { +fn exp2(a: FP16x16) -> FP16x16 { if (a.mag == 0) { return FixedTrait::ONE(); } @@ -93,11 +93,11 @@ fn exp2(a: FixedType) -> FixedType { } } -fn exp2_int(exp: u32) -> FixedType { +fn exp2_int(exp: u32) -> FP16x16 { return FixedTrait::new_unscaled(lut::exp2(exp), false); } -fn floor(a: FixedType) -> FixedType { +fn floor(a: FP16x16) -> FP16x16 { let (div, rem) = integer::u32_safe_divmod(a.mag, u32_as_non_zero(ONE)); if rem == 0 { @@ -109,7 +109,7 @@ fn floor(a: FixedType) -> FixedType { } } -fn ge(a: FixedType, b: FixedType) -> bool { +fn ge(a: FP16x16, b: FP16x16) -> bool { if a.sign != b.sign { return !a.sign; } else { @@ -117,7 +117,7 @@ fn ge(a: FixedType, b: FixedType) -> bool { } } -fn gt(a: FixedType, b: FixedType) -> bool { +fn gt(a: FP16x16, b: FP16x16) -> bool { if a.sign != b.sign { return !a.sign; } else { @@ -125,7 +125,7 @@ fn gt(a: FixedType, b: FixedType) -> bool { } } -fn le(a: FixedType, b: FixedType) -> bool { +fn le(a: FP16x16, b: FP16x16) -> bool { if a.sign != b.sign { return a.sign; } else { @@ -135,13 +135,13 @@ fn le(a: FixedType, b: FixedType) -> bool { // Calculates the natural logarithm of x: ln(x) // self must be greater than zero -fn ln(a: FixedType) -> FixedType { +fn ln(a: FP16x16) -> FP16x16 { return FixedTrait::new(45426, false) * log2(a); // ln(2) = 0.693... } // Calculates the binary logarithm of x: log2(x) // self must be greather than zero -fn log2(a: FixedType) -> FixedType { +fn log2(a: FP16x16) -> FP16x16 { assert(a.sign == false, 'must be positive'); if (a.mag == ONE) { @@ -173,11 +173,11 @@ fn log2(a: FixedType) -> FixedType { // Calculates the base 10 log of x: log10(x) // self must be greater than zero -fn log10(a: FixedType) -> FixedType { +fn log10(a: FP16x16) -> FP16x16 { return FixedTrait::new(19728, false) * log2(a); // log10(2) = 0.301... } -fn lt(a: FixedType, b: FixedType) -> bool { +fn lt(a: FP16x16, b: FP16x16) -> bool { if a.sign != b.sign { return a.sign; } else { @@ -185,18 +185,18 @@ fn lt(a: FixedType, b: FixedType) -> bool { } } -fn mul(a: FixedType, b: FixedType) -> FixedType { +fn mul(a: FP16x16, b: FP16x16) -> FP16x16 { let prod_u128 = integer::u32_wide_mul(a.mag, b.mag); // Re-apply sign return FixedTrait::new((prod_u128 / ONE.into()).try_into().unwrap(), a.sign ^ b.sign); } -fn ne(a: @FixedType, b: @FixedType) -> bool { +fn ne(a: @FP16x16, b: @FP16x16) -> bool { return (*a.mag != *b.mag) || (*a.sign != *b.sign); } -fn neg(a: FixedType) -> FixedType { +fn neg(a: FP16x16) -> FP16x16 { if a.mag == 0 { return a; } else if !a.sign { @@ -207,9 +207,9 @@ fn neg(a: FixedType) -> FixedType { } // Calclates the value of x^y and checks for overflow before returning -// self is a FixedType point value -// b is a FixedType point value -fn pow(a: FixedType, b: FixedType) -> FixedType { +// self is a FP16x16 point value +// b is a FP16x16 point value +fn pow(a: FP16x16, b: FP16x16) -> FP16x16 { let (div, rem) = integer::u32_safe_divmod(b.mag, u32_as_non_zero(ONE)); // use the more performant integer pow when y is an int @@ -222,7 +222,7 @@ fn pow(a: FixedType, b: FixedType) -> FixedType { } // Calclates the value of a^b and checks for overflow before returning -fn pow_int(a: FixedType, b: u32, sign: bool) -> FixedType { +fn pow_int(a: FP16x16, b: u32, sign: bool) -> FP16x16 { let mut x = a; let mut n = b; @@ -255,11 +255,11 @@ fn pow_int(a: FixedType, b: u32, sign: bool) -> FixedType { return x * y; } -fn rem(a: FixedType, b: FixedType) -> FixedType { +fn rem(a: FP16x16, b: FP16x16) -> FP16x16 { return a - floor(a / b) * b; } -fn round(a: FixedType) -> FixedType { +fn round(a: FP16x16) -> FP16x16 { let (div, rem) = integer::u32_safe_divmod(a.mag, u32_as_non_zero(ONE)); if (HALF <= rem) { @@ -269,16 +269,16 @@ fn round(a: FixedType) -> FixedType { } } -// Calculates the square root of a FixedType point value +// Calculates the square root of a FP16x16 point value // x must be positive -fn sqrt(a: FixedType) -> FixedType { +fn sqrt(a: FP16x16) -> FP16x16 { assert(a.sign == false, 'must be positive'); let root = integer::u64_sqrt(a.mag.into() * ONE.into()); return FixedTrait::new(root.into(), false); } -fn sub(a: FixedType, b: FixedType) -> FixedType { +fn sub(a: FP16x16, b: FP16x16) -> FP16x16 { return add(a, -b); } @@ -291,36 +291,36 @@ use orion::numbers::fixed_point::implementations::fp16x16::math::trig::{PI, HALF #[test] fn test_into() { - let a = FixedTrait::new_unscaled(5, false); + let a = FixedTrait::::new_unscaled(5, false); assert(a.mag == 5 * ONE, 'invalid result'); } #[test] fn test_try_into_u128() { // Positive unscaled - let a = FixedTrait::new_unscaled(5, false); + let a = FixedTrait::::new_unscaled(5, false); assert(a.try_into().unwrap() == 5_u128, 'invalid result'); // Positive scaled - let b = FixedTrait::new(5 * ONE, false); + let b = FixedTrait::::new(5 * ONE, false); assert(b.try_into().unwrap() == 5_u128, 'invalid result'); // Zero - let d = FixedTrait::new_unscaled(0, false); + let d = FixedTrait::::new_unscaled(0, false); assert(d.try_into().unwrap() == 0_u128, 'invalid result'); } #[test] #[should_panic] fn test_negative_try_into_u128() { - let a = FixedTrait::new_unscaled(1, true); + let a = FixedTrait::::new_unscaled(1, true); let a: u128 = a.try_into().unwrap(); } #[test] #[available_gas(1000000)] fn test_acos() { - let a = FixedTrait::ONE(); + let a = FixedTrait::::ONE(); assert(a.acos().into() == 0, 'invalid one'); } @@ -375,7 +375,7 @@ fn test_sqrt() { #[test] #[available_gas(100000)] fn test_msb() { - let a = FixedTrait::new_unscaled(100, false); + let a = FixedTrait::::new_unscaled(100, false); let (msb, div) = lut::msb(a.mag / ONE); assert(msb == 6, 'invalid msb'); assert(div == 64, 'invalid msb ceil'); @@ -474,7 +474,7 @@ fn test_add_eq() { let mut a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(2, false); a += b; - assert(a == FixedTrait::new_unscaled(3, false), 'invalid result'); + assert(a == FixedTrait::::new_unscaled(3, false), 'invalid result'); } #[test] @@ -482,7 +482,7 @@ fn test_sub() { let a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, false); let c = a - b; - assert(c == FixedTrait::new_unscaled(3, false), 'false result invalid'); + assert(c == FixedTrait::::new_unscaled(3, false), 'false result invalid'); } #[test] @@ -490,14 +490,14 @@ fn test_sub_eq() { let mut a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, false); a -= b; - assert(a == FixedTrait::new_unscaled(3, false), 'invalid result'); + assert(a == FixedTrait::::new_unscaled(3, false), 'invalid result'); } #[test] #[available_gas(100000)] fn test_mul_pos() { - let a = FixedType { mag: 190054, sign: false }; - let b = FixedType { mag: 190054, sign: false }; + let a = FP16x16 { mag: 190054, sign: false }; + let b = FP16x16 { mag: 190054, sign: false }; let c = a * b; assert(c.mag == 551155, 'invalid result'); } @@ -507,7 +507,7 @@ fn test_mul_neg() { let a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, true); let c = a * b; - assert(c == FixedTrait::new_unscaled(10, true), 'invalid result'); + assert(c == FixedTrait::::new_unscaled(10, true), 'invalid result'); } #[test] @@ -515,13 +515,13 @@ fn test_mul_eq() { let mut a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, true); a *= b; - assert(a == FixedTrait::new_unscaled(10, true), 'invalid result'); + assert(a == FixedTrait::::new_unscaled(10, true), 'invalid result'); } #[test] fn test_div() { let a = FixedTrait::new_unscaled(10, false); - let b = FixedTrait::new(190054, false); // 2.9 + let b = FixedTrait::::new(190054, false); // 2.9 let c = a / b; assert(c.mag == 225986, 'invalid pos decimal'); // 3.4482758620689653 } @@ -530,7 +530,7 @@ fn test_div() { fn test_le() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a <= a, 'a <= a'); assert(a <= b == false, 'a <= b'); @@ -549,7 +549,7 @@ fn test_le() { fn test_lt() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a < a == false, 'a < a'); assert(a < b == false, 'a < b'); @@ -568,7 +568,7 @@ fn test_lt() { fn test_ge() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a >= a, 'a >= a'); assert(a >= b, 'a >= b'); @@ -587,7 +587,7 @@ fn test_ge() { fn test_gt() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a > a == false, 'a > a'); assert(a > b, 'a > b'); @@ -605,7 +605,7 @@ fn test_gt() { #[test] #[available_gas(1000000)] fn test_cos() { - let a = FixedTrait::new(HALF_PI, false); + let a = FixedTrait::::new(HALF_PI, false); assert(a.cos().into() == 0, 'invalid half pi'); } @@ -619,6 +619,6 @@ fn test_sin() { #[test] #[available_gas(2000000)] fn test_tan() { - let a = FixedTrait::new(HALF_PI / 2, false); + let a = FixedTrait::::new(HALF_PI / 2, false); assert(a.tan().mag == 65536, 'invalid quarter pi'); } diff --git a/src/numbers/fixed_point/implementations/fp16x16/math/hyp.cairo b/src/numbers/fixed_point/implementations/fp16x16/math/hyp.cairo index 08485dcc4..c411c3879 100644 --- a/src/numbers/fixed_point/implementations/fp16x16/math/hyp.cairo +++ b/src/numbers/fixed_point/implementations/fp16x16/math/hyp.cairo @@ -1,43 +1,43 @@ use core::debug::PrintTrait; use orion::numbers::fixed_point::implementations::fp16x16::core::{ - HALF, ONE, TWO, FixedType, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul, + HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Add, FP16x16AddEq, FP16x16Sub, FP16x16Mul, FP16x16MulEq, FP16x16TryIntoU128, FP16x16PartialEq, FP16x16PartialOrd, FP16x16SubEq, FP16x16Neg, FP16x16Div, FP16x16IntoFelt252, FixedTrait }; // Calculates hyperbolic cosine of a (fixed point) -fn cosh(a: FixedType) -> FixedType { +fn cosh(a: FP16x16) -> FP16x16 { let ea = a.exp(); return (ea + (FixedTrait::ONE() / ea)) / FixedTrait::new(TWO, false); } // Calculates hyperbolic sine of a (fixed point) -fn sinh(a: FixedType) -> FixedType { +fn sinh(a: FP16x16) -> FP16x16 { let ea = a.exp(); return (ea - (FixedTrait::ONE() / ea)) / FixedTrait::new(TWO, false); } // Calculates hyperbolic tangent of a (fixed point) -fn tanh(a: FixedType) -> FixedType { +fn tanh(a: FP16x16) -> FP16x16 { let ea = a.exp(); let ea_i = FixedTrait::ONE() / ea; return (ea - ea_i) / (ea + ea_i); } // Calculates inverse hyperbolic cosine of a (fixed point) -fn acosh(a: FixedType) -> FixedType { +fn acosh(a: FP16x16) -> FP16x16 { let root = (a * a - FixedTrait::ONE()).sqrt(); return (a + root).ln(); } // Calculates inverse hyperbolic sine of a (fixed point) -fn asinh(a: FixedType) -> FixedType { +fn asinh(a: FP16x16) -> FP16x16 { let root = (a * a + FixedTrait::ONE()).sqrt(); return (a + root).ln(); } // Calculates inverse hyperbolic tangent of a (fixed point) -fn atanh(a: FixedType) -> FixedType { +fn atanh(a: FP16x16) -> FP16x16 { let one = FixedTrait::ONE(); let ln_arg = (one + a) / (one - a); return ln_arg.ln() / FixedTrait::new(TWO, false); diff --git a/src/numbers/fixed_point/implementations/fp16x16/math/trig.cairo b/src/numbers/fixed_point/implementations/fp16x16/math/trig.cairo index 9341f34d8..00e81db24 100644 --- a/src/numbers/fixed_point/implementations/fp16x16/math/trig.cairo +++ b/src/numbers/fixed_point/implementations/fp16x16/math/trig.cairo @@ -4,7 +4,7 @@ use option::OptionTrait; use orion::numbers::fixed_point::implementations::fp16x16::math::lut; use orion::numbers::fixed_point::implementations::fp16x16::core::{ - HALF, ONE, TWO, FixedType, FP16x16Impl, FP16x16Add, FP16x16Sub, FP16x16Mul, FP16x16Div, + HALF, ONE, TWO, FP16x16, FP16x16Impl, FP16x16Add, FP16x16Sub, FP16x16Mul, FP16x16Div, FP16x16IntoFelt252, FixedTrait }; @@ -18,7 +18,7 @@ const HALF_PI: u32 = 102944; // Calculates arccos(a) for -1 <= a <= 1 (fixed point) // arccos(a) = arcsin(sqrt(1 - a^2)) - arctan identity has discontinuity at zero -fn acos(a: FixedType) -> FixedType { +fn acos(a: FP16x16) -> FP16x16 { let asin_arg = (FixedTrait::ONE() - a * a).sqrt(); // will fail if a > 1 let asin_res = asin(asin_arg); @@ -29,7 +29,7 @@ fn acos(a: FixedType) -> FixedType { } } -fn acos_fast(a: FixedType) -> FixedType { +fn acos_fast(a: FP16x16) -> FP16x16 { let asin_arg = (FixedTrait::ONE() - a * a).sqrt(); // will fail if a > 1 let asin_res = asin_fast(asin_arg); @@ -42,7 +42,7 @@ fn acos_fast(a: FixedType) -> FixedType { // Calculates arcsin(a) for -1 <= a <= 1 (fixed point) // arcsin(a) = arctan(a / sqrt(1 - a^2)) -fn asin(a: FixedType) -> FixedType { +fn asin(a: FP16x16) -> FP16x16 { if (a.mag == ONE) { return FixedTrait::new(HALF_PI, a.sign); } @@ -51,7 +51,7 @@ fn asin(a: FixedType) -> FixedType { return atan(a / div); } -fn asin_fast(a: FixedType) -> FixedType { +fn asin_fast(a: FP16x16) -> FP16x16 { if (a.mag == ONE) { return FixedTrait::new(HALF_PI, a.sign); } @@ -62,7 +62,7 @@ fn asin_fast(a: FixedType) -> FixedType { // Calculates arctan(a) (fixed point) // See https://stackoverflow.com/a/50894477 for range adjustments -fn atan(a: FixedType) -> FixedType { +fn atan(a: FP16x16) -> FP16x16 { let mut at = a.abs(); let mut shift = false; let mut invert = false; @@ -104,7 +104,7 @@ fn atan(a: FixedType) -> FixedType { } -fn atan_fast(a: FixedType) -> FixedType { +fn atan_fast(a: FP16x16) -> FP16x16 { let mut at = a.abs(); let mut shift = false; let mut invert = false; @@ -132,22 +132,22 @@ fn atan_fast(a: FixedType) -> FixedType { } if (invert) { - res = res - FixedTrait::new(HALF_PI, false); + res = res - FixedTrait::::new(HALF_PI, false); } return FixedTrait::new(res.mag, a.sign); } // Calculates cos(a) with a in radians (fixed point) -fn cos(a: FixedType) -> FixedType { +fn cos(a: FP16x16) -> FP16x16 { return sin(FixedTrait::new(HALF_PI, false) - a); } -fn cos_fast(a: FixedType) -> FixedType { +fn cos_fast(a: FP16x16) -> FP16x16 { return sin_fast(FixedTrait::new(HALF_PI, false) - a); } -fn sin(a: FixedType) -> FixedType { +fn sin(a: FP16x16) -> FP16x16 { let a1 = a.mag % TWO_PI; let (whole_rem, partial_rem) = u32_safe_divmod(a1, u32_as_non_zero(PI)); let a2 = FixedTrait::new(partial_rem, false); @@ -157,7 +157,7 @@ fn sin(a: FixedType) -> FixedType { return FixedTrait::new(loop_res.mag, a.sign ^ partial_sign && loop_res.mag != 0); } -fn sin_fast(a: FixedType) -> FixedType { +fn sin_fast(a: FP16x16) -> FP16x16 { let a1 = a.mag % TWO_PI; let (whole_rem, mut partial_rem) = u32_safe_divmod(a1, u32_as_non_zero(PI)); let partial_sign = whole_rem == 1; @@ -169,20 +169,20 @@ fn sin_fast(a: FixedType) -> FixedType { let (start, low, high) = lut::sin(partial_rem); let partial_step = FixedTrait::new(partial_rem - start, false) / FixedTrait::new(402, false); let res = partial_step * (FixedTrait::new(high, false) - FixedTrait::new(low, false)) - + FixedTrait::new(low, false); + + FixedTrait::::new(low, false); return FixedTrait::new(res.mag, a.sign ^ partial_sign && res.mag != 0); } // Calculates tan(a) with a in radians (fixed point) -fn tan(a: FixedType) -> FixedType { +fn tan(a: FP16x16) -> FP16x16 { let sinx = sin(a); let cosx = cos(a); assert(cosx.mag != 0, 'tan undefined'); return sinx / cosx; } -fn tan_fast(a: FixedType) -> FixedType { +fn tan_fast(a: FP16x16) -> FP16x16 { let sinx = sin_fast(a); let cosx = cos_fast(a); assert(cosx.mag != 0, 'tan undefined'); @@ -190,7 +190,7 @@ fn tan_fast(a: FixedType) -> FixedType { } // Helper function to calculate Taylor series for sin -fn _sin_loop(a: FixedType, i: u32, acc: FixedType) -> FixedType { +fn _sin_loop(a: FP16x16, i: u32, acc: FP16x16) -> FP16x16 { let div = (2 * i + 2) * (2 * i + 3); let term = a * a * acc / FixedTrait::new_unscaled(div, false); let new_acc = FixedTrait::ONE() - term; diff --git a/src/numbers/fixed_point/implementations/fp32x32.cairo b/src/numbers/fixed_point/implementations/fp32x32.cairo new file mode 100644 index 000000000..6e1271f5b --- /dev/null +++ b/src/numbers/fixed_point/implementations/fp32x32.cairo @@ -0,0 +1,2 @@ +mod core; +mod comp; \ No newline at end of file diff --git a/src/numbers/fixed_point/implementations/fp32x32/comp.cairo b/src/numbers/fixed_point/implementations/fp32x32/comp.cairo new file mode 100644 index 000000000..60cae2ab3 --- /dev/null +++ b/src/numbers/fixed_point/implementations/fp32x32/comp.cairo @@ -0,0 +1,19 @@ +use orion::numbers::{FP32x32, FixedTrait}; +use orion::numbers::FP32x32Impl; + +fn xor(a: FP32x32, b: FP32x32) -> bool { + if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) { + return true; + } else { + return false; + } +} + +fn or(a: FP32x32, b: FP32x32) -> bool { + let zero = FixedTrait::new(0, false); + if a == zero && b == zero { + return false; + } else { + return true; + } +} diff --git a/src/numbers/fixed_point/implementations/fp32x32/core.cairo b/src/numbers/fixed_point/implementations/fp32x32/core.cairo new file mode 100644 index 000000000..7225bc498 --- /dev/null +++ b/src/numbers/fixed_point/implementations/fp32x32/core.cairo @@ -0,0 +1,354 @@ +use debug::PrintTrait; + +use option::OptionTrait; +use result::{ResultTrait, ResultTraitImpl}; +use traits::{TryInto, Into}; + +use cubit::f64 as fp32x32; +use cubit::f64::Fixed as FP32x32; +use cubit::f64::ONE; +use cubit::f64::types::fixed; + +use orion::numbers::fixed_point::core::{FixedTrait}; +use orion::numbers::fixed_point::utils; +use orion::numbers::{i32, i8}; + +const MAX: u64 = 9223372036854775808; + +impl FP32x32Impl of FixedTrait { + fn ZERO() -> FP32x32 { + return FP32x32 { mag: 0, sign: false }; + } + + fn ONE() -> FP32x32 { + return FP32x32 { mag: ONE, sign: false }; + } + + fn new(mag: u64, sign: bool) -> FP32x32 { + return FP32x32 { mag: mag, sign: sign }; + } + + fn new_unscaled(mag: u64, sign: bool) -> FP32x32 { + return FP32x32 { mag: mag * ONE, sign: sign }; + } + + fn from_felt(val: felt252) -> FP32x32 { + let mag = integer::u64_try_from_felt252(utils::felt_abs(val)).unwrap(); + return FixedTrait::new(mag, utils::felt_sign(val)); + } + + fn abs(self: FP32x32) -> FP32x32 { + return fp32x32::core::abs(self); + } + + fn acos(self: FP32x32) -> FP32x32 { + return fp32x32::trig::acos_fast(self); + } + + fn acos_fast(self: FP32x32) -> FP32x32 { + return fp32x32::trig::acos_fast(self); + } + + fn acosh(self: FP32x32) -> FP32x32 { + return fp32x32::hyp::acosh(self); + } + + fn asin(self: FP32x32) -> FP32x32 { + return fp32x32::trig::asin_fast(self); + } + + fn asin_fast(self: FP32x32) -> FP32x32 { + return fp32x32::trig::asin_fast(self); + } + + fn asinh(self: FP32x32) -> FP32x32 { + return fp32x32::hyp::asinh(self); + } + + fn atan(self: FP32x32) -> FP32x32 { + return fp32x32::trig::atan_fast(self); + } + + fn atan_fast(self: FP32x32) -> FP32x32 { + return fp32x32::trig::atan_fast(self); + } + + fn atanh(self: FP32x32) -> FP32x32 { + return fp32x32::hyp::atanh(self); + } + + fn ceil(self: FP32x32) -> FP32x32 { + return fp32x32::core::ceil(self); + } + + fn cos(self: FP32x32) -> FP32x32 { + return fp32x32::trig::cos_fast(self); + } + + fn cos_fast(self: FP32x32) -> FP32x32 { + return fp32x32::trig::cos_fast(self); + } + + fn cosh(self: FP32x32) -> FP32x32 { + return fp32x32::hyp::cosh(self); + } + + fn floor(self: FP32x32) -> FP32x32 { + return fp32x32::core::floor(self); + } + + // Calculates the natural exponent of x: e^x + fn exp(self: FP32x32) -> FP32x32 { + return fp32x32::core::exp(self); + } + + // Calculates the binary exponent of x: 2^x + fn exp2(self: FP32x32) -> FP32x32 { + return fp32x32::core::exp2(self); + } + + // Calculates the natural logarithm of x: ln(x) + // self must be greater than zero + fn ln(self: FP32x32) -> FP32x32 { + return fp32x32::core::ln(self); + } + + // Calculates the binary logarithm of x: log2(x) + // self must be greather than zero + fn log2(self: FP32x32) -> FP32x32 { + return fp32x32::core::log2(self); + } + + // Calculates the base 10 log of x: log10(x) + // self must be greater than zero + fn log10(self: FP32x32) -> FP32x32 { + return fp32x32::core::log10(self); + } + + // Calclates the value of x^y and checks for overflow before returning + // self is a fixed point value + // b is a fixed point value + fn pow(self: FP32x32, b: FP32x32) -> FP32x32 { + return fp32x32::core::pow(self, b); + } + + fn round(self: FP32x32) -> FP32x32 { + return fp32x32::core::round(self); + } + + fn sin(self: FP32x32) -> FP32x32 { + return fp32x32::trig::sin_fast(self); + } + + fn sin_fast(self: FP32x32) -> FP32x32 { + return fp32x32::trig::sin_fast(self); + } + + fn sinh(self: FP32x32) -> FP32x32 { + return fp32x32::hyp::sinh(self); + } + + // Calculates the square root of a fixed point value + // x must be positive + fn sqrt(self: FP32x32) -> FP32x32 { + return fp32x32::core::sqrt(self); + } + + fn tan(self: FP32x32) -> FP32x32 { + return fp32x32::trig::tan_fast(self); + } + + fn tan_fast(self: FP32x32) -> FP32x32 { + return fp32x32::trig::tan_fast(self); + } + + fn tanh(self: FP32x32) -> FP32x32 { + return fp32x32::hyp::tanh(self); + } +} + + +impl FP32x32Print of PrintTrait { + fn print(self: FP32x32) { + self.sign.print(); + self.mag.print(); + } +} + +// Into a raw felt without unscaling +impl FP32x32IntoFelt252 of Into { + fn into(self: FP32x32) -> felt252 { + let mag_felt = self.mag.into(); + + if self.sign { + return mag_felt * -1; + } else { + return mag_felt * 1; + } + } +} + +impl FP32x32TryIntoU64 of TryInto { + fn try_into(self: FP32x32) -> Option { + if self.sign { + return Option::None(()); + } else { + // Unscale the magnitude and round down + return Option::Some((self.mag / ONE).into()); + } + } +} + +impl FP32x32TryIntoU16 of TryInto { + fn try_into(self: FP32x32) -> Option { + if self.sign { + Option::None(()) + } else { + // Unscale the magnitude and round down + return (self.mag / ONE).try_into(); + } + } +} + +impl FP32x32TryIntoU32 of TryInto { + fn try_into(self: FP32x32) -> Option { + if self.sign { + Option::None(()) + } else { + // Unscale the magnitude and round down + return (self.mag / ONE).try_into(); + } + } +} + +impl FP32x32TryIntoU8 of TryInto { + fn try_into(self: FP32x32) -> Option { + if self.sign { + Option::None(()) + } else { + // Unscale the magnitude and round down + return (self.mag / ONE).try_into(); + } + } +} + +impl FP32x32TryIntoI8 of TryInto { + fn try_into(self: FP32x32) -> Option { + _i8_try_from_fp(self) + } +} + +impl FP32x32PartialEq of PartialEq { + #[inline(always)] + fn eq(lhs: @FP32x32, rhs: @FP32x32) -> bool { + return fp32x32::core::eq(lhs, rhs); + } + + #[inline(always)] + fn ne(lhs: @FP32x32, rhs: @FP32x32) -> bool { + return fp32x32::core::ne(lhs, rhs); + } +} + +impl FP32x32Add of Add { + fn add(lhs: FP32x32, rhs: FP32x32) -> FP32x32 { + return fp32x32::core::add(lhs, rhs); + } +} + +impl FP32x32AddEq of AddEq { + #[inline(always)] + fn add_eq(ref self: FP32x32, other: FP32x32) { + self = fp32x32::core::add(self, other); + } +} + +impl FP32x32Sub of Sub { + fn sub(lhs: FP32x32, rhs: FP32x32) -> FP32x32 { + return fp32x32::core::sub(lhs, rhs); + } +} + +impl FP32x32SubEq of SubEq { + #[inline(always)] + fn sub_eq(ref self: FP32x32, other: FP32x32) { + self = fp32x32::core::sub(self, other); + } +} + +impl FP32x32Mul of Mul { + fn mul(lhs: FP32x32, rhs: FP32x32) -> FP32x32 { + return fp32x32::core::mul(lhs, rhs); + } +} + +impl FP32x32MulEq of MulEq { + #[inline(always)] + fn mul_eq(ref self: FP32x32, other: FP32x32) { + self = fp32x32::core::mul(self, other); + } +} + +impl FP32x32Div of Div { + fn div(lhs: FP32x32, rhs: FP32x32) -> FP32x32 { + return fp32x32::core::div(lhs, rhs); + } +} + +impl FP32x32DivEq of DivEq { + #[inline(always)] + fn div_eq(ref self: FP32x32, other: FP32x32) { + self = fp32x32::core::div(self, other); + } +} + +impl FP32x32PartialOrd of PartialOrd { + #[inline(always)] + fn ge(lhs: FP32x32, rhs: FP32x32) -> bool { + return fp32x32::core::ge(lhs, rhs); + } + + #[inline(always)] + fn gt(lhs: FP32x32, rhs: FP32x32) -> bool { + return fp32x32::core::gt(lhs, rhs); + } + + #[inline(always)] + fn le(lhs: FP32x32, rhs: FP32x32) -> bool { + return fp32x32::core::le(lhs, rhs); + } + + #[inline(always)] + fn lt(lhs: FP32x32, rhs: FP32x32) -> bool { + return fp32x32::core::lt(lhs, rhs); + } +} + +impl FP32x32Neg of Neg { + #[inline(always)] + fn neg(a: FP32x32) -> FP32x32 { + return fp32x32::core::neg(a); + } +} + +impl FP32x32Rem of Rem { + #[inline(always)] + fn rem(lhs: FP32x32, rhs: FP32x32) -> FP32x32 { + return fp32x32::core::rem(lhs, rhs); + } +} + +fn eq(a: @FP32x32, b: @FP32x32) -> bool { + return (*a.mag == *b.mag) && (*a.sign == *b.sign); +} + +/// INTERNAL + +fn _i8_try_from_fp(x: FP32x32) -> Option { + let unscaled_mag: Option = (x.mag / ONE).try_into(); + + match unscaled_mag { + Option::Some(val) => Option::Some(i8 { mag: unscaled_mag.unwrap(), sign: x.sign }), + Option::None(_) => Option::None(()) + } +} diff --git a/src/numbers/fixed_point/implementations/fp64x64.cairo b/src/numbers/fixed_point/implementations/fp64x64.cairo new file mode 100644 index 000000000..6e1271f5b --- /dev/null +++ b/src/numbers/fixed_point/implementations/fp64x64.cairo @@ -0,0 +1,2 @@ +mod core; +mod comp; \ No newline at end of file diff --git a/src/numbers/fixed_point/implementations/fp64x64/comp.cairo b/src/numbers/fixed_point/implementations/fp64x64/comp.cairo new file mode 100644 index 000000000..d26a3180f --- /dev/null +++ b/src/numbers/fixed_point/implementations/fp64x64/comp.cairo @@ -0,0 +1,19 @@ +use orion::numbers::{FP64x64, FixedTrait}; +use orion::numbers::FP64x64Impl; + +fn xor(a: FP64x64, b: FP64x64) -> bool { + if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) { + return true; + } else { + return false; + } +} + +fn or(a: FP64x64, b: FP64x64) -> bool { + let zero = FixedTrait::new(0, false); + if a == zero && b == zero { + return false; + } else { + return true; + } +} diff --git a/src/numbers/fixed_point/implementations/fp64x64/core.cairo b/src/numbers/fixed_point/implementations/fp64x64/core.cairo new file mode 100644 index 000000000..e3a357a8b --- /dev/null +++ b/src/numbers/fixed_point/implementations/fp64x64/core.cairo @@ -0,0 +1,352 @@ +use debug::PrintTrait; + +use option::OptionTrait; +use result::{ResultTrait, ResultTraitImpl}; +use traits::{TryInto, Into}; + +use cubit::f128 as fp64x64; +use cubit::f128::types::Fixed as FP64x64; +use cubit::f128::ONE_u128 as ONE; +use cubit::f128::core::MAX_u128 as MAX; + +use orion::numbers::fixed_point::core::{FixedTrait}; +use orion::numbers::fixed_point::utils; +use orion::numbers::{i32, i8}; + +impl FP64x64Impl of FixedTrait { + fn ZERO() -> FP64x64 { + return FP64x64 { mag: 0, sign: false }; + } + + fn ONE() -> FP64x64 { + return FP64x64 { mag: ONE, sign: false }; + } + + fn new(mag: u128, sign: bool) -> FP64x64 { + return FP64x64 { mag: mag, sign: sign }; + } + + fn new_unscaled(mag: u128, sign: bool) -> FP64x64 { + return FP64x64 { mag: mag * ONE, sign: sign }; + } + + fn from_felt(val: felt252) -> FP64x64 { + let mag = integer::u128_try_from_felt252(utils::felt_abs(val)).unwrap(); + return FixedTrait::new(mag, utils::felt_sign(val)); + } + + fn abs(self: FP64x64) -> FP64x64 { + return fp64x64::core::abs(self); + } + + fn acos(self: FP64x64) -> FP64x64 { + return fp64x64::trig::acos_fast(self); + } + + fn acos_fast(self: FP64x64) -> FP64x64 { + return fp64x64::trig::acos_fast(self); + } + + fn acosh(self: FP64x64) -> FP64x64 { + return fp64x64::hyp::acosh(self); + } + + fn asin(self: FP64x64) -> FP64x64 { + return fp64x64::trig::asin_fast(self); + } + + fn asin_fast(self: FP64x64) -> FP64x64 { + return fp64x64::trig::asin_fast(self); + } + + fn asinh(self: FP64x64) -> FP64x64 { + return fp64x64::hyp::asinh(self); + } + + fn atan(self: FP64x64) -> FP64x64 { + return fp64x64::trig::atan_fast(self); + } + + fn atan_fast(self: FP64x64) -> FP64x64 { + return fp64x64::trig::atan_fast(self); + } + + fn atanh(self: FP64x64) -> FP64x64 { + return fp64x64::hyp::atanh(self); + } + + fn ceil(self: FP64x64) -> FP64x64 { + return fp64x64::core::ceil(self); + } + + fn cos(self: FP64x64) -> FP64x64 { + return fp64x64::trig::cos_fast(self); + } + + fn cos_fast(self: FP64x64) -> FP64x64 { + return fp64x64::trig::cos_fast(self); + } + + fn cosh(self: FP64x64) -> FP64x64 { + return fp64x64::hyp::cosh(self); + } + + fn floor(self: FP64x64) -> FP64x64 { + return fp64x64::core::floor(self); + } + + // Calculates the natural exponent of x: e^x + fn exp(self: FP64x64) -> FP64x64 { + return fp64x64::core::exp(self); + } + + // Calculates the binary exponent of x: 2^x + fn exp2(self: FP64x64) -> FP64x64 { + return fp64x64::core::exp2(self); + } + + // Calculates the natural logarithm of x: ln(x) + // self must be greater than zero + fn ln(self: FP64x64) -> FP64x64 { + return fp64x64::core::ln(self); + } + + // Calculates the binary logarithm of x: log2(x) + // self must be greather than zero + fn log2(self: FP64x64) -> FP64x64 { + return fp64x64::core::log2(self); + } + + // Calculates the base 10 log of x: log10(x) + // self must be greater than zero + fn log10(self: FP64x64) -> FP64x64 { + return fp64x64::core::log10(self); + } + + // Calclates the value of x^y and checks for overflow before returning + // self is a fixed point value + // b is a fixed point value + fn pow(self: FP64x64, b: FP64x64) -> FP64x64 { + return fp64x64::core::pow(self, b); + } + + fn round(self: FP64x64) -> FP64x64 { + return fp64x64::core::round(self); + } + + fn sin(self: FP64x64) -> FP64x64 { + return fp64x64::trig::sin_fast(self); + } + + fn sin_fast(self: FP64x64) -> FP64x64 { + return fp64x64::trig::sin_fast(self); + } + + fn sinh(self: FP64x64) -> FP64x64 { + return fp64x64::hyp::sinh(self); + } + + // Calculates the square root of a fixed point value + // x must be positive + fn sqrt(self: FP64x64) -> FP64x64 { + return fp64x64::core::sqrt(self); + } + + fn tan(self: FP64x64) -> FP64x64 { + return fp64x64::trig::tan_fast(self); + } + + fn tan_fast(self: FP64x64) -> FP64x64 { + return fp64x64::trig::tan_fast(self); + } + + fn tanh(self: FP64x64) -> FP64x64 { + return fp64x64::hyp::tanh(self); + } +} + + +impl FP64x64Print of PrintTrait { + fn print(self: FP64x64) { + self.sign.print(); + self.mag.print(); + } +} + +// Into a raw felt without unscaling +impl FP64x64IntoFelt252 of Into { + fn into(self: FP64x64) -> felt252 { + let mag_felt = self.mag.into(); + + if self.sign { + return mag_felt * -1; + } else { + return mag_felt * 1; + } + } +} + +impl FP64x64TryIntoU128 of TryInto { + fn try_into(self: FP64x64) -> Option { + if self.sign { + return Option::None(()); + } else { + // Unscale the magnitude and round down + return Option::Some((self.mag / ONE).into()); + } + } +} + +impl FP64x64TryIntoU16 of TryInto { + fn try_into(self: FP64x64) -> Option { + if self.sign { + Option::None(()) + } else { + // Unscale the magnitude and round down + return (self.mag / ONE).try_into(); + } + } +} + +impl FP64x64TryIntoU32 of TryInto { + fn try_into(self: FP64x64) -> Option { + if self.sign { + Option::None(()) + } else { + // Unscale the magnitude and round down + return (self.mag / ONE).try_into(); + } + } +} + +impl FP64x64TryIntoU8 of TryInto { + fn try_into(self: FP64x64) -> Option { + if self.sign { + Option::None(()) + } else { + // Unscale the magnitude and round down + return (self.mag / ONE).try_into(); + } + } +} + +impl FP64x64TryIntoI8 of TryInto { + fn try_into(self: FP64x64) -> Option { + _i8_try_from_fp(self) + } +} + +impl FP64x64PartialEq of PartialEq { + #[inline(always)] + fn eq(lhs: @FP64x64, rhs: @FP64x64) -> bool { + return fp64x64::core::eq(lhs, rhs); + } + + #[inline(always)] + fn ne(lhs: @FP64x64, rhs: @FP64x64) -> bool { + return fp64x64::core::ne(lhs, rhs); + } +} + +impl FP64x64Add of Add { + fn add(lhs: FP64x64, rhs: FP64x64) -> FP64x64 { + return fp64x64::core::add(lhs, rhs); + } +} + +impl FP64x64AddEq of AddEq { + #[inline(always)] + fn add_eq(ref self: FP64x64, other: FP64x64) { + self = fp64x64::core::add(self, other); + } +} + +impl FP64x64Sub of Sub { + fn sub(lhs: FP64x64, rhs: FP64x64) -> FP64x64 { + return fp64x64::core::sub(lhs, rhs); + } +} + +impl FP64x64SubEq of SubEq { + #[inline(always)] + fn sub_eq(ref self: FP64x64, other: FP64x64) { + self = fp64x64::core::sub(self, other); + } +} + +impl FP64x64Mul of Mul { + fn mul(lhs: FP64x64, rhs: FP64x64) -> FP64x64 { + return fp64x64::core::mul(lhs, rhs); + } +} + +impl FP64x64MulEq of MulEq { + #[inline(always)] + fn mul_eq(ref self: FP64x64, other: FP64x64) { + self = fp64x64::core::mul(self, other); + } +} + +impl FP64x64Div of Div { + fn div(lhs: FP64x64, rhs: FP64x64) -> FP64x64 { + return fp64x64::core::div(lhs, rhs); + } +} + +impl FP64x64DivEq of DivEq { + #[inline(always)] + fn div_eq(ref self: FP64x64, other: FP64x64) { + self = fp64x64::core::div(self, other); + } +} + +impl FP64x64PartialOrd of PartialOrd { + #[inline(always)] + fn ge(lhs: FP64x64, rhs: FP64x64) -> bool { + return fp64x64::core::ge(lhs, rhs); + } + + #[inline(always)] + fn gt(lhs: FP64x64, rhs: FP64x64) -> bool { + return fp64x64::core::gt(lhs, rhs); + } + + #[inline(always)] + fn le(lhs: FP64x64, rhs: FP64x64) -> bool { + return fp64x64::core::le(lhs, rhs); + } + + #[inline(always)] + fn lt(lhs: FP64x64, rhs: FP64x64) -> bool { + return fp64x64::core::lt(lhs, rhs); + } +} + +impl FP64x64Neg of Neg { + #[inline(always)] + fn neg(a: FP64x64) -> FP64x64 { + return fp64x64::core::neg(a); + } +} + +impl FP64x64Rem of Rem { + #[inline(always)] + fn rem(lhs: FP64x64, rhs: FP64x64) -> FP64x64 { + return fp64x64::core::rem(lhs, rhs); + } +} + +fn eq(a: @FP64x64, b: @FP64x64) -> bool { + return (*a.mag == *b.mag) && (*a.sign == *b.sign); +} + +/// INTERNAL + +fn _i8_try_from_fp(x: FP64x64) -> Option { + let unscaled_mag: Option = (x.mag / ONE).try_into(); + + match unscaled_mag { + Option::Some(val) => Option::Some(i8 { mag: unscaled_mag.unwrap(), sign: x.sign }), + Option::None(_) => Option::None(()) + } +} diff --git a/src/numbers/fixed_point/implementations/fp8x23/core.cairo b/src/numbers/fixed_point/implementations/fp8x23/core.cairo index 88d64beb2..6063a948c 100644 --- a/src/numbers/fixed_point/implementations/fp8x23/core.cairo +++ b/src/numbers/fixed_point/implementations/fp8x23/core.cairo @@ -5,10 +5,17 @@ use result::{ResultTrait, ResultTraitImpl}; use traits::{TryInto, Into}; use orion::numbers::signed_integer::{i32::i32, i8::i8}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; +use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_point::implementations::fp8x23::math::{core, trig, hyp}; use orion::numbers::fixed_point::utils; +/// A struct representing a fixed point number. +#[derive(Serde, Copy, Drop)] +struct FP8x23 { + mag: u32, + sign: bool +} + // CONSTANTS const TWO: u32 = 16777216; // 2 ** 24 @@ -17,169 +24,169 @@ const HALF: u32 = 4194304; // 2 ** 22 const MAX: u32 = 2147483648; // 2 ** 31 -impl FP8x23Impl of FixedTrait { - fn ZERO() -> FixedType { - return FixedType { mag: 0, sign: false }; +impl FP8x23Impl of FixedTrait { + fn ZERO() -> FP8x23 { + return FP8x23 { mag: 0, sign: false }; } - fn ONE() -> FixedType { - return FixedType { mag: ONE, sign: false }; + fn ONE() -> FP8x23 { + return FP8x23 { mag: ONE, sign: false }; } - fn new(mag: u32, sign: bool) -> FixedType { - return FixedType { mag: mag, sign: sign }; + fn new(mag: u32, sign: bool) -> FP8x23 { + return FP8x23 { mag: mag, sign: sign }; } - fn new_unscaled(mag: u32, sign: bool) -> FixedType { - return FixedType { mag: mag * ONE, sign: sign }; + fn new_unscaled(mag: u32, sign: bool) -> FP8x23 { + return FP8x23 { mag: mag * ONE, sign: sign }; } - fn from_felt(val: felt252) -> FixedType { + fn from_felt(val: felt252) -> FP8x23 { let mag = integer::u32_try_from_felt252(utils::felt_abs(val)).unwrap(); return FixedTrait::new(mag, utils::felt_sign(val)); } - fn abs(self: FixedType) -> FixedType { + fn abs(self: FP8x23) -> FP8x23 { return core::abs(self); } - fn acos(self: FixedType) -> FixedType { + fn acos(self: FP8x23) -> FP8x23 { return trig::acos_fast(self); } - fn acos_fast(self: FixedType) -> FixedType { + fn acos_fast(self: FP8x23) -> FP8x23 { return trig::acos_fast(self); } - fn acosh(self: FixedType) -> FixedType { + fn acosh(self: FP8x23) -> FP8x23 { return hyp::acosh(self); } - fn asin(self: FixedType) -> FixedType { + fn asin(self: FP8x23) -> FP8x23 { return trig::asin_fast(self); } - fn asin_fast(self: FixedType) -> FixedType { + fn asin_fast(self: FP8x23) -> FP8x23 { return trig::asin_fast(self); } - fn asinh(self: FixedType) -> FixedType { + fn asinh(self: FP8x23) -> FP8x23 { return hyp::asinh(self); } - fn atan(self: FixedType) -> FixedType { + fn atan(self: FP8x23) -> FP8x23 { return trig::atan_fast(self); } - fn atan_fast(self: FixedType) -> FixedType { + fn atan_fast(self: FP8x23) -> FP8x23 { return trig::atan_fast(self); } - fn atanh(self: FixedType) -> FixedType { + fn atanh(self: FP8x23) -> FP8x23 { return hyp::atanh(self); } - fn ceil(self: FixedType) -> FixedType { + fn ceil(self: FP8x23) -> FP8x23 { return core::ceil(self); } - fn cos(self: FixedType) -> FixedType { + fn cos(self: FP8x23) -> FP8x23 { return trig::cos_fast(self); } - fn cos_fast(self: FixedType) -> FixedType { + fn cos_fast(self: FP8x23) -> FP8x23 { return trig::cos_fast(self); } - fn cosh(self: FixedType) -> FixedType { + fn cosh(self: FP8x23) -> FP8x23 { return hyp::cosh(self); } - fn floor(self: FixedType) -> FixedType { + fn floor(self: FP8x23) -> FP8x23 { return core::floor(self); } // Calculates the natural exponent of x: e^x - fn exp(self: FixedType) -> FixedType { + fn exp(self: FP8x23) -> FP8x23 { return core::exp(self); } // Calculates the binary exponent of x: 2^x - fn exp2(self: FixedType) -> FixedType { + fn exp2(self: FP8x23) -> FP8x23 { return core::exp2(self); } // Calculates the natural logarithm of x: ln(x) // self must be greater than zero - fn ln(self: FixedType) -> FixedType { + fn ln(self: FP8x23) -> FP8x23 { return core::ln(self); } // Calculates the binary logarithm of x: log2(x) // self must be greather than zero - fn log2(self: FixedType) -> FixedType { + fn log2(self: FP8x23) -> FP8x23 { return core::log2(self); } // Calculates the base 10 log of x: log10(x) // self must be greater than zero - fn log10(self: FixedType) -> FixedType { + fn log10(self: FP8x23) -> FP8x23 { return core::log10(self); } // Calclates the value of x^y and checks for overflow before returning // self is a fixed point value // b is a fixed point value - fn pow(self: FixedType, b: FixedType) -> FixedType { + fn pow(self: FP8x23, b: FP8x23) -> FP8x23 { return core::pow(self, b); } - fn round(self: FixedType) -> FixedType { + fn round(self: FP8x23) -> FP8x23 { return core::round(self); } - fn sin(self: FixedType) -> FixedType { + fn sin(self: FP8x23) -> FP8x23 { return trig::sin_fast(self); } - fn sin_fast(self: FixedType) -> FixedType { + fn sin_fast(self: FP8x23) -> FP8x23 { return trig::sin_fast(self); } - fn sinh(self: FixedType) -> FixedType { + fn sinh(self: FP8x23) -> FP8x23 { return hyp::sinh(self); } // Calculates the square root of a fixed point value // x must be positive - fn sqrt(self: FixedType) -> FixedType { + fn sqrt(self: FP8x23) -> FP8x23 { return core::sqrt(self); } - fn tan(self: FixedType) -> FixedType { + fn tan(self: FP8x23) -> FP8x23 { return trig::tan_fast(self); } - fn tan_fast(self: FixedType) -> FixedType { + fn tan_fast(self: FP8x23) -> FP8x23 { return trig::tan_fast(self); } - fn tanh(self: FixedType) -> FixedType { + fn tanh(self: FP8x23) -> FP8x23 { return hyp::tanh(self); } } -impl FP8x23Print of PrintTrait { - fn print(self: FixedType) { +impl FP8x23Print of PrintTrait { + fn print(self: FP8x23) { self.sign.print(); self.mag.print(); } } // Into a raw felt without unscaling -impl FP8x23IntoFelt252 of Into { - fn into(self: FixedType) -> felt252 { +impl FP8x23IntoFelt252 of Into { + fn into(self: FP8x23) -> felt252 { let mag_felt = self.mag.into(); if self.sign { @@ -190,8 +197,8 @@ impl FP8x23IntoFelt252 of Into { } } -impl FP8x23TryIntoU128 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP8x23TryIntoU128 of TryInto { + fn try_into(self: FP8x23) -> Option { if self.sign { return Option::None(()); } else { @@ -201,8 +208,8 @@ impl FP8x23TryIntoU128 of TryInto { } } -impl FP8x23TryIntoU64 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP8x23TryIntoU64 of TryInto { + fn try_into(self: FP8x23) -> Option { if self.sign { return Option::None(()); } else { @@ -212,8 +219,8 @@ impl FP8x23TryIntoU64 of TryInto { } } -impl FP8x23TryIntoU32 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP8x23TryIntoU32 of TryInto { + fn try_into(self: FP8x23) -> Option { if self.sign { return Option::None(()); } else { @@ -223,8 +230,8 @@ impl FP8x23TryIntoU32 of TryInto { } } -impl FP8x23TryIntoU16 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP8x23TryIntoU16 of TryInto { + fn try_into(self: FP8x23) -> Option { if self.sign { Option::None(()) } else { @@ -234,8 +241,8 @@ impl FP8x23TryIntoU16 of TryInto { } } -impl FP8x23TryIntoU8 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP8x23TryIntoU8 of TryInto { + fn try_into(self: FP8x23) -> Option { if self.sign { Option::None(()) } else { @@ -245,125 +252,125 @@ impl FP8x23TryIntoU8 of TryInto { } } -impl FP8x23IntoI32 of Into { - fn into(self: FixedType) -> i32 { +impl FP8x23IntoI32 of Into { + fn into(self: FP8x23) -> i32 { _i32_into_fp(self) } } -impl FP8x23TryIntoI8 of TryInto { - fn try_into(self: FixedType) -> Option { +impl FP8x23TryIntoI8 of TryInto { + fn try_into(self: FP8x23) -> Option { _i8_try_from_fp(self) } } -impl FP8x23PartialEq of PartialEq { +impl FP8x23PartialEq of PartialEq { #[inline(always)] - fn eq(lhs: @FixedType, rhs: @FixedType) -> bool { + fn eq(lhs: @FP8x23, rhs: @FP8x23) -> bool { return core::eq(lhs, rhs); } #[inline(always)] - fn ne(lhs: @FixedType, rhs: @FixedType) -> bool { + fn ne(lhs: @FP8x23, rhs: @FP8x23) -> bool { return core::ne(lhs, rhs); } } -impl FP8x23Add of Add { - fn add(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP8x23Add of Add { + fn add(lhs: FP8x23, rhs: FP8x23) -> FP8x23 { return core::add(lhs, rhs); } } -impl FP8x23AddEq of AddEq { +impl FP8x23AddEq of AddEq { #[inline(always)] - fn add_eq(ref self: FixedType, other: FixedType) { + fn add_eq(ref self: FP8x23, other: FP8x23) { self = Add::add(self, other); } } -impl FP8x23Sub of Sub { - fn sub(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP8x23Sub of Sub { + fn sub(lhs: FP8x23, rhs: FP8x23) -> FP8x23 { return core::sub(lhs, rhs); } } -impl FP8x23SubEq of SubEq { +impl FP8x23SubEq of SubEq { #[inline(always)] - fn sub_eq(ref self: FixedType, other: FixedType) { + fn sub_eq(ref self: FP8x23, other: FP8x23) { self = Sub::sub(self, other); } } -impl FP8x23Mul of Mul { - fn mul(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP8x23Mul of Mul { + fn mul(lhs: FP8x23, rhs: FP8x23) -> FP8x23 { return core::mul(lhs, rhs); } } -impl FP8x23MulEq of MulEq { +impl FP8x23MulEq of MulEq { #[inline(always)] - fn mul_eq(ref self: FixedType, other: FixedType) { + fn mul_eq(ref self: FP8x23, other: FP8x23) { self = Mul::mul(self, other); } } -impl FP8x23Div of Div { - fn div(lhs: FixedType, rhs: FixedType) -> FixedType { +impl FP8x23Div of Div { + fn div(lhs: FP8x23, rhs: FP8x23) -> FP8x23 { return core::div(lhs, rhs); } } -impl FP8x23DivEq of DivEq { +impl FP8x23DivEq of DivEq { #[inline(always)] - fn div_eq(ref self: FixedType, other: FixedType) { + fn div_eq(ref self: FP8x23, other: FP8x23) { self = Div::div(self, other); } } -impl FP8x23PartialOrd of PartialOrd { +impl FP8x23PartialOrd of PartialOrd { #[inline(always)] - fn ge(lhs: FixedType, rhs: FixedType) -> bool { + fn ge(lhs: FP8x23, rhs: FP8x23) -> bool { return core::ge(lhs, rhs); } #[inline(always)] - fn gt(lhs: FixedType, rhs: FixedType) -> bool { + fn gt(lhs: FP8x23, rhs: FP8x23) -> bool { return core::gt(lhs, rhs); } #[inline(always)] - fn le(lhs: FixedType, rhs: FixedType) -> bool { + fn le(lhs: FP8x23, rhs: FP8x23) -> bool { return core::le(lhs, rhs); } #[inline(always)] - fn lt(lhs: FixedType, rhs: FixedType) -> bool { + fn lt(lhs: FP8x23, rhs: FP8x23) -> bool { return core::lt(lhs, rhs); } } -impl FP8x23Neg of Neg { +impl FP8x23Neg of Neg { #[inline(always)] - fn neg(a: FixedType) -> FixedType { + fn neg(a: FP8x23) -> FP8x23 { return core::neg(a); } } -impl FP8x23Rem of Rem { +impl FP8x23Rem of Rem { #[inline(always)] - fn rem(lhs: FixedType, rhs: FixedType) -> FixedType { + fn rem(lhs: FP8x23, rhs: FP8x23) -> FP8x23 { return core::rem(lhs, rhs); } } /// INTERNAL -fn _i32_into_fp(x: FixedType) -> i32 { +fn _i32_into_fp(x: FP8x23) -> i32 { i32 { mag: x.mag / ONE, sign: x.sign } } -fn _i8_try_from_fp(x: FixedType) -> Option { +fn _i8_try_from_fp(x: FP8x23) -> Option { let unscaled_mag: Option = (x.mag / ONE).try_into(); match unscaled_mag { diff --git a/src/numbers/fixed_point/implementations/fp8x23/helpers.cairo b/src/numbers/fixed_point/implementations/fp8x23/helpers.cairo index 4eb0244e5..e63b1fe6a 100644 --- a/src/numbers/fixed_point/implementations/fp8x23/helpers.cairo +++ b/src/numbers/fixed_point/implementations/fp8x23/helpers.cairo @@ -2,16 +2,14 @@ use debug::PrintTrait; use traits::Into; use orion::numbers::fixed_point::implementations::fp8x23::core::{ - HALF, ONE, TWO, FixedType, FP8x23Impl, FP8x23Sub, FP8x23Div, FixedTrait, FP8x23Print + HALF, ONE, TWO, FP8x23, FP8x23Sub, FP8x23Div, FixedTrait, FP8x23Print }; const DEFAULT_PRECISION: u32 = 8; // 1e-6 // To use `DEFAULT_PRECISION`, final arg is: `Option::None(())`. // To use `custom_precision` of 430_u32: `Option::Some(430_u32)`. -fn assert_precise( - result: FixedType, expected: felt252, msg: felt252, custom_precision: Option -) { +fn assert_precise(result: FP8x23, expected: felt252, msg: felt252, custom_precision: Option) { let precision = match custom_precision { Option::Some(val) => val, Option::None(_) => DEFAULT_PRECISION, @@ -25,9 +23,7 @@ fn assert_precise( } } -fn assert_relative( - result: FixedType, expected: felt252, msg: felt252, custom_precision: Option -) { +fn assert_relative(result: FP8x23, expected: felt252, msg: felt252, custom_precision: Option) { let precision = match custom_precision { Option::Some(val) => val, Option::None(_) => DEFAULT_PRECISION, diff --git a/src/numbers/fixed_point/implementations/fp8x23/math/comp.cairo b/src/numbers/fixed_point/implementations/fp8x23/math/comp.cairo index de2ba6780..53b1f2e1d 100644 --- a/src/numbers/fixed_point/implementations/fp8x23/math/comp.cairo +++ b/src/numbers/fixed_point/implementations/fp8x23/math/comp.cairo @@ -1,8 +1,8 @@ use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FixedType, FixedTrait, FP8x23Impl, FP8x23PartialOrd, FP8x23PartialEq + FP8x23, FixedTrait, FP8x23PartialOrd, FP8x23PartialEq }; -fn max(a: FixedType, b: FixedType) -> FixedType { +fn max(a: FP8x23, b: FP8x23) -> FP8x23 { if (a >= b) { return a; } else { @@ -10,7 +10,7 @@ fn max(a: FixedType, b: FixedType) -> FixedType { } } -fn min(a: FixedType, b: FixedType) -> FixedType { +fn min(a: FP8x23, b: FP8x23) -> FP8x23 { if (a <= b) { return a; } else { @@ -18,7 +18,7 @@ fn min(a: FixedType, b: FixedType) -> FixedType { } } -fn xor(a: FixedType, b: FixedType) -> bool { +fn xor(a: FP8x23, b: FP8x23) -> bool { if (a == FixedTrait::new(0, false) || b == FixedTrait::new(0, false)) && (a != b) { return true; } else { @@ -26,7 +26,7 @@ fn xor(a: FixedType, b: FixedType) -> bool { } } -fn or(a: FixedType, b: FixedType) -> bool { +fn or(a: FP8x23, b: FP8x23) -> bool { let zero = FixedTrait::new(0, false); if a == zero && b == zero { return false; diff --git a/src/numbers/fixed_point/implementations/fp8x23/math/core.cairo b/src/numbers/fixed_point/implementations/fp8x23/math/core.cairo index 6398fbbd4..82bfda0b9 100644 --- a/src/numbers/fixed_point/implementations/fp8x23/math/core.cairo +++ b/src/numbers/fixed_point/implementations/fp8x23/math/core.cairo @@ -5,7 +5,7 @@ use traits::{Into, TryInto}; use integer::{u32_safe_divmod, u32_as_non_zero, u32_wide_mul}; use orion::numbers::fixed_point::implementations::fp8x23::core::{ - HALF, ONE, FixedType, FP8x23Impl, FP8x23Add, FP8x23AddEq, FP8x23Sub, FP8x23Mul, FP8x23MulEq, + HALF, ONE, MAX, FP8x23, FP8x23Add, FP8x23Impl, FP8x23AddEq, FP8x23Sub, FP8x23Mul, FP8x23MulEq, FP8x23TryIntoU128, FP8x23PartialEq, FP8x23PartialOrd, FP8x23SubEq, FP8x23Neg, FP8x23Div, FP8x23IntoFelt252, FixedTrait }; @@ -13,11 +13,11 @@ use orion::numbers::fixed_point::implementations::fp8x23::math::lut; // PUBLIC -fn abs(a: FixedType) -> FixedType { +fn abs(a: FP8x23) -> FP8x23 { return FixedTrait::new(a.mag, false); } -fn add(a: FixedType, b: FixedType) -> FixedType { +fn add(a: FP8x23, b: FP8x23) -> FP8x23 { if a.sign == b.sign { return FixedTrait::new(a.mag + b.mag, a.sign); } @@ -33,7 +33,7 @@ fn add(a: FixedType, b: FixedType) -> FixedType { } } -fn ceil(a: FixedType) -> FixedType { +fn ceil(a: FP8x23) -> FP8x23 { let (div, rem) = u32_safe_divmod(a.mag, u32_as_non_zero(ONE)); if rem == 0 { @@ -47,7 +47,7 @@ fn ceil(a: FixedType) -> FixedType { } } -fn div(a: FixedType, b: FixedType) -> FixedType { +fn div(a: FP8x23, b: FP8x23) -> FP8x23 { let a_u64 = integer::u32_wide_mul(a.mag, ONE); let res_u64 = a_u64 / b.mag.into(); @@ -55,17 +55,17 @@ fn div(a: FixedType, b: FixedType) -> FixedType { return FixedTrait::new(res_u64.try_into().unwrap(), a.sign ^ b.sign); } -fn eq(a: @FixedType, b: @FixedType) -> bool { +fn eq(a: @FP8x23, b: @FP8x23) -> bool { return (*a.mag == *b.mag) && (*a.sign == *b.sign); } // Calculates the natural exponent of x: e^x -fn exp(a: FixedType) -> FixedType { +fn exp(a: FP8x23) -> FP8x23 { return exp2(FixedTrait::new(12102203, false) * a); // log2(e) * 2^23 ≈ 12102203 } // Calculates the binary exponent of x: 2^x -fn exp2(a: FixedType) -> FixedType { +fn exp2(a: FP8x23) -> FP8x23 { if (a.mag == 0) { return FixedTrait::ONE(); } @@ -94,11 +94,11 @@ fn exp2(a: FixedType) -> FixedType { } } -fn exp2_int(exp: u32) -> FixedType { +fn exp2_int(exp: u32) -> FP8x23 { return FixedTrait::new_unscaled(lut::exp2(exp), false); } -fn floor(a: FixedType) -> FixedType { +fn floor(a: FP8x23) -> FP8x23 { let (div, rem) = integer::u32_safe_divmod(a.mag, u32_as_non_zero(ONE)); if rem == 0 { @@ -110,7 +110,7 @@ fn floor(a: FixedType) -> FixedType { } } -fn ge(a: FixedType, b: FixedType) -> bool { +fn ge(a: FP8x23, b: FP8x23) -> bool { if a.sign != b.sign { return !a.sign; } else { @@ -118,7 +118,7 @@ fn ge(a: FixedType, b: FixedType) -> bool { } } -fn gt(a: FixedType, b: FixedType) -> bool { +fn gt(a: FP8x23, b: FP8x23) -> bool { if a.sign != b.sign { return !a.sign; } else { @@ -126,7 +126,7 @@ fn gt(a: FixedType, b: FixedType) -> bool { } } -fn le(a: FixedType, b: FixedType) -> bool { +fn le(a: FP8x23, b: FP8x23) -> bool { if a.sign != b.sign { return a.sign; } else { @@ -136,13 +136,13 @@ fn le(a: FixedType, b: FixedType) -> bool { // Calculates the natural logarithm of x: ln(x) // self must be greater than zero -fn ln(a: FixedType) -> FixedType { +fn ln(a: FP8x23) -> FP8x23 { return FixedTrait::new(5814540, false) * log2(a); // ln(2) = 0.693... } // Calculates the binary logarithm of x: log2(x) // self must be greather than zero -fn log2(a: FixedType) -> FixedType { +fn log2(a: FP8x23) -> FP8x23 { assert(a.sign == false, 'must be positive'); if (a.mag == ONE) { @@ -174,11 +174,11 @@ fn log2(a: FixedType) -> FixedType { // Calculates the base 10 log of x: log10(x) // self must be greater than zero -fn log10(a: FixedType) -> FixedType { +fn log10(a: FP8x23) -> FP8x23 { return FixedTrait::new(2525223, false) * log2(a); // log10(2) = 0.301... } -fn lt(a: FixedType, b: FixedType) -> bool { +fn lt(a: FP8x23, b: FP8x23) -> bool { if a.sign != b.sign { return a.sign; } else { @@ -186,18 +186,18 @@ fn lt(a: FixedType, b: FixedType) -> bool { } } -fn mul(a: FixedType, b: FixedType) -> FixedType { +fn mul(a: FP8x23, b: FP8x23) -> FP8x23 { let prod_u128 = integer::u32_wide_mul(a.mag, b.mag); // Re-apply sign return FixedTrait::new((prod_u128 / ONE.into()).try_into().unwrap(), a.sign ^ b.sign); } -fn ne(a: @FixedType, b: @FixedType) -> bool { +fn ne(a: @FP8x23, b: @FP8x23) -> bool { return (*a.mag != *b.mag) || (*a.sign != *b.sign); } -fn neg(a: FixedType) -> FixedType { +fn neg(a: FP8x23) -> FP8x23 { if a.mag == 0 { return a; } else if !a.sign { @@ -208,9 +208,9 @@ fn neg(a: FixedType) -> FixedType { } // Calclates the value of x^y and checks for overflow before returning -// self is a FixedType point value -// b is a FixedType point value -fn pow(a: FixedType, b: FixedType) -> FixedType { +// self is a FP8x23 point value +// b is a FP8x23 point value +fn pow(a: FP8x23, b: FP8x23) -> FP8x23 { let (div, rem) = integer::u32_safe_divmod(b.mag, u32_as_non_zero(ONE)); // use the more performant integer pow when y is an int @@ -223,7 +223,7 @@ fn pow(a: FixedType, b: FixedType) -> FixedType { } // Calclates the value of a^b and checks for overflow before returning -fn pow_int(a: FixedType, b: u32, sign: bool) -> FixedType { +fn pow_int(a: FP8x23, b: u32, sign: bool) -> FP8x23 { let mut x = a; let mut n = b; @@ -256,11 +256,11 @@ fn pow_int(a: FixedType, b: u32, sign: bool) -> FixedType { return x * y; } -fn rem(a: FixedType, b: FixedType) -> FixedType { +fn rem(a: FP8x23, b: FP8x23) -> FP8x23 { return a - floor(a / b) * b; } -fn round(a: FixedType) -> FixedType { +fn round(a: FP8x23) -> FP8x23 { let (div, rem) = integer::u32_safe_divmod(a.mag, u32_as_non_zero(ONE)); if (HALF <= rem) { @@ -270,56 +270,58 @@ fn round(a: FixedType) -> FixedType { } } -// Calculates the square root of a FixedType point value +// Calculates the square root of a FP8x23 point value // x must be positive -fn sqrt(a: FixedType) -> FixedType { +fn sqrt(a: FP8x23) -> FP8x23 { assert(a.sign == false, 'must be positive'); let root = integer::u64_sqrt(a.mag.into() * ONE.into()); return FixedTrait::new(root.into(), false); } -fn sub(a: FixedType, b: FixedType) -> FixedType { +fn sub(a: FP8x23, b: FP8x23) -> FP8x23 { return add(a, -b); } // Tests -------------------------------------------------------------------------------------------------------------- -use orion::numbers::fixed_point::implementations::fp8x23::helpers::{assert_precise, assert_relative}; +use orion::numbers::fixed_point::implementations::fp8x23::helpers::{ + assert_precise, assert_relative +}; use orion::numbers::fixed_point::implementations::fp8x23::math::trig::{PI, HALF_PI}; #[test] fn test_into() { - let a = FixedTrait::new_unscaled(5, false); + let a = FixedTrait::::new_unscaled(5, false); assert(a.mag == 5 * ONE, 'invalid result'); } #[test] fn test_try_into_u128() { // Positive unscaled - let a = FixedTrait::new_unscaled(5, false); + let a = FixedTrait::::new_unscaled(5, false); assert(a.try_into().unwrap() == 5_u128, 'invalid result'); // Positive scaled - let b = FixedTrait::new(5 * ONE, false); + let b = FixedTrait::::new(5 * ONE, false); assert(b.try_into().unwrap() == 5_u128, 'invalid result'); // Zero - let d = FixedTrait::new_unscaled(0, false); + let d = FixedTrait::::new_unscaled(0, false); assert(d.try_into().unwrap() == 0_u128, 'invalid result'); } #[test] #[should_panic] fn test_negative_try_into_u128() { - let a = FixedTrait::new_unscaled(1, true); + let a = FixedTrait::::new_unscaled(1, true); let a: u128 = a.try_into().unwrap(); } #[test] #[available_gas(1000000)] fn test_acos() { - let a = FixedTrait::ONE(); + let a = FixedTrait::::ONE(); assert(a.acos().into() == 0, 'invalid one'); } @@ -374,7 +376,7 @@ fn test_sqrt() { #[test] #[available_gas(100000)] fn test_msb() { - let a = FixedTrait::new_unscaled(100, false); + let a = FixedTrait::::new_unscaled(100, false); let (msb, div) = lut::msb(a.mag / ONE); assert(msb == 6, 'invalid msb'); assert(div == 64, 'invalid msb ceil'); @@ -473,7 +475,7 @@ fn test_add_eq() { let mut a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(2, false); a += b; - assert(a == FixedTrait::new_unscaled(3, false), 'invalid result'); + assert(a == FixedTrait::::new_unscaled(3, false), 'invalid result'); } #[test] @@ -481,7 +483,7 @@ fn test_sub() { let a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, false); let c = a - b; - assert(c == FixedTrait::new_unscaled(3, false), 'false result invalid'); + assert(c == FixedTrait::::new_unscaled(3, false), 'false result invalid'); } #[test] @@ -489,14 +491,14 @@ fn test_sub_eq() { let mut a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, false); a -= b; - assert(a == FixedTrait::new_unscaled(3, false), 'invalid result'); + assert(a == FixedTrait::::new_unscaled(3, false), 'invalid result'); } #[test] #[available_gas(100000)] fn test_mul_pos() { - let a = FixedType { mag: 24326963, sign: false }; - let b = FixedType { mag: 24326963, sign: false }; + let a = FP8x23 { mag: 24326963, sign: false }; + let b = FP8x23 { mag: 24326963, sign: false }; let c = a * b; assert(c.mag == 70548192, 'invalid result'); } @@ -506,7 +508,7 @@ fn test_mul_neg() { let a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, true); let c = a * b; - assert(c == FixedTrait::new_unscaled(10, true), 'invalid result'); + assert(c == FixedTrait::::new_unscaled(10, true), 'invalid result'); } #[test] @@ -514,13 +516,13 @@ fn test_mul_eq() { let mut a = FixedTrait::new_unscaled(5, false); let b = FixedTrait::new_unscaled(2, true); a *= b; - assert(a == FixedTrait::new_unscaled(10, true), 'invalid result'); + assert(a == FixedTrait::::new_unscaled(10, true), 'invalid result'); } #[test] fn test_div() { let a = FixedTrait::new_unscaled(10, false); - let b = FixedTrait::new(24326963, false); // 2.9 + let b = FixedTrait::::new(24326963, false); // 2.9 let c = a / b; assert(c.mag == 28926234, 'invalid pos decimal'); // 3.4482758620689653 } @@ -529,7 +531,7 @@ fn test_div() { fn test_le() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a <= a, 'a <= a'); assert(a <= b == false, 'a <= b'); @@ -548,7 +550,7 @@ fn test_le() { fn test_lt() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a < a == false, 'a < a'); assert(a < b == false, 'a < b'); @@ -567,7 +569,7 @@ fn test_lt() { fn test_ge() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a >= a, 'a >= a'); assert(a >= b, 'a >= b'); @@ -586,7 +588,7 @@ fn test_ge() { fn test_gt() { let a = FixedTrait::new_unscaled(1, false); let b = FixedTrait::new_unscaled(0, false); - let c = FixedTrait::new_unscaled(1, true); + let c = FixedTrait::::new_unscaled(1, true); assert(a > a == false, 'a > a'); assert(a > b, 'a > b'); @@ -604,7 +606,7 @@ fn test_gt() { #[test] #[available_gas(1000000)] fn test_cos() { - let a = FixedTrait::new(HALF_PI, false); + let a = FixedTrait::::new(HALF_PI, false); assert(a.cos().into() == 0, 'invalid half pi'); } @@ -618,6 +620,6 @@ fn test_sin() { #[test] #[available_gas(2000000)] fn test_tan() { - let a = FixedTrait::new(HALF_PI / 2, false); + let a = FixedTrait::::new(HALF_PI / 2, false); assert(a.tan().mag == 8388608, 'invalid quarter pi'); } diff --git a/src/numbers/fixed_point/implementations/fp8x23/math/hyp.cairo b/src/numbers/fixed_point/implementations/fp8x23/math/hyp.cairo index 1f87a235d..a81faf9c9 100644 --- a/src/numbers/fixed_point/implementations/fp8x23/math/hyp.cairo +++ b/src/numbers/fixed_point/implementations/fp8x23/math/hyp.cairo @@ -1,43 +1,43 @@ use core::debug::PrintTrait; use orion::numbers::fixed_point::implementations::fp8x23::core::{ - HALF, ONE, TWO, FixedType, FP8x23Impl, FP8x23Add, FP8x23AddEq, FP8x23Sub, FP8x23Mul, FP8x23MulEq, + HALF, ONE, TWO, FP8x23, FP8x23Impl, FP8x23Add, FP8x23AddEq, FP8x23Sub, FP8x23Mul, FP8x23MulEq, FP8x23TryIntoU128, FP8x23PartialEq, FP8x23PartialOrd, FP8x23SubEq, FP8x23Neg, FP8x23Div, FP8x23IntoFelt252, FixedTrait }; // Calculates hyperbolic cosine of a (fixed point) -fn cosh(a: FixedType) -> FixedType { +fn cosh(a: FP8x23) -> FP8x23 { let ea = a.exp(); return (ea + (FixedTrait::ONE() / ea)) / FixedTrait::new(TWO, false); } // Calculates hyperbolic sine of a (fixed point) -fn sinh(a: FixedType) -> FixedType { +fn sinh(a: FP8x23) -> FP8x23 { let ea = a.exp(); return (ea - (FixedTrait::ONE() / ea)) / FixedTrait::new(TWO, false); } // Calculates hyperbolic tangent of a (fixed point) -fn tanh(a: FixedType) -> FixedType { +fn tanh(a: FP8x23) -> FP8x23 { let ea = a.exp(); let ea_i = FixedTrait::ONE() / ea; return (ea - ea_i) / (ea + ea_i); } // Calculates inverse hyperbolic cosine of a (fixed point) -fn acosh(a: FixedType) -> FixedType { +fn acosh(a: FP8x23) -> FP8x23 { let root = (a * a - FixedTrait::ONE()).sqrt(); return (a + root).ln(); } // Calculates inverse hyperbolic sine of a (fixed point) -fn asinh(a: FixedType) -> FixedType { +fn asinh(a: FP8x23) -> FP8x23 { let root = (a * a + FixedTrait::ONE()).sqrt(); return (a + root).ln(); } // Calculates inverse hyperbolic tangent of a (fixed point) -fn atanh(a: FixedType) -> FixedType { +fn atanh(a: FP8x23) -> FP8x23 { let one = FixedTrait::ONE(); let ln_arg = (one + a) / (one - a); return ln_arg.ln() / FixedTrait::new(TWO, false); diff --git a/src/numbers/fixed_point/implementations/fp8x23/math/trig.cairo b/src/numbers/fixed_point/implementations/fp8x23/math/trig.cairo index 00ef22fa0..b998f1a4b 100644 --- a/src/numbers/fixed_point/implementations/fp8x23/math/trig.cairo +++ b/src/numbers/fixed_point/implementations/fp8x23/math/trig.cairo @@ -4,8 +4,8 @@ use option::OptionTrait; use orion::numbers::fixed_point::implementations::fp8x23::math::lut; use orion::numbers::fixed_point::implementations::fp8x23::core::{ - HALF, ONE, TWO, FixedType, FP8x23Impl, FP8x23Add, FP8x23Sub, FP8x23Mul, FP8x23Div, FP8x23IntoFelt252, - FixedTrait + HALF, ONE, TWO, FP8x23, FP8x23Impl, FP8x23Add, FP8x23Sub, FP8x23Mul, FP8x23Div, + FP8x23IntoFelt252, FixedTrait }; // CONSTANTS @@ -18,7 +18,7 @@ const HALF_PI: u32 = 13176795; // Calculates arccos(a) for -1 <= a <= 1 (fixed point) // arccos(a) = arcsin(sqrt(1 - a^2)) - arctan identity has discontinuity at zero -fn acos(a: FixedType) -> FixedType { +fn acos(a: FP8x23) -> FP8x23 { let asin_arg = (FixedTrait::ONE() - a * a).sqrt(); // will fail if a > 1 let asin_res = asin(asin_arg); @@ -29,7 +29,7 @@ fn acos(a: FixedType) -> FixedType { } } -fn acos_fast(a: FixedType) -> FixedType { +fn acos_fast(a: FP8x23) -> FP8x23 { let asin_arg = (FixedTrait::ONE() - a * a).sqrt(); // will fail if a > 1 let asin_res = asin_fast(asin_arg); @@ -42,7 +42,7 @@ fn acos_fast(a: FixedType) -> FixedType { // Calculates arcsin(a) for -1 <= a <= 1 (fixed point) // arcsin(a) = arctan(a / sqrt(1 - a^2)) -fn asin(a: FixedType) -> FixedType { +fn asin(a: FP8x23) -> FP8x23 { if (a.mag == ONE) { return FixedTrait::new(HALF_PI, a.sign); } @@ -51,7 +51,7 @@ fn asin(a: FixedType) -> FixedType { return atan(a / div); } -fn asin_fast(a: FixedType) -> FixedType { +fn asin_fast(a: FP8x23) -> FP8x23 { if (a.mag == ONE) { return FixedTrait::new(HALF_PI, a.sign); } @@ -62,7 +62,7 @@ fn asin_fast(a: FixedType) -> FixedType { // Calculates arctan(a) (fixed point) // See https://stackoverflow.com/a/50894477 for range adjustments -fn atan(a: FixedType) -> FixedType { +fn atan(a: FP8x23) -> FP8x23 { let mut at = a.abs(); let mut shift = false; let mut invert = false; @@ -103,7 +103,7 @@ fn atan(a: FixedType) -> FixedType { return FixedTrait::new(res.mag, a.sign); } -fn atan_fast(a: FixedType) -> FixedType { +fn atan_fast(a: FP8x23) -> FP8x23 { let mut at = a.abs(); let mut shift = false; let mut invert = false; @@ -131,22 +131,22 @@ fn atan_fast(a: FixedType) -> FixedType { } if (invert) { - res = res - FixedTrait::new(HALF_PI, false); + res = res - FixedTrait::::new(HALF_PI, false); } return FixedTrait::new(res.mag, a.sign); } // Calculates cos(a) with a in radians (fixed point) -fn cos(a: FixedType) -> FixedType { +fn cos(a: FP8x23) -> FP8x23 { return sin(FixedTrait::new(HALF_PI, false) - a); } -fn cos_fast(a: FixedType) -> FixedType { +fn cos_fast(a: FP8x23) -> FP8x23 { return sin_fast(FixedTrait::new(HALF_PI, false) - a); } -fn sin(a: FixedType) -> FixedType { +fn sin(a: FP8x23) -> FP8x23 { let a1 = a.mag % TWO_PI; let (whole_rem, partial_rem) = u32_safe_divmod(a1, u32_as_non_zero(PI)); let a2 = FixedTrait::new(partial_rem, false); @@ -156,7 +156,7 @@ fn sin(a: FixedType) -> FixedType { return FixedTrait::new(loop_res.mag, a.sign ^ partial_sign && loop_res.mag != 0); } -fn sin_fast(a: FixedType) -> FixedType { +fn sin_fast(a: FP8x23) -> FP8x23 { let a1 = a.mag % TWO_PI; let (whole_rem, mut partial_rem) = u32_safe_divmod(a1, u32_as_non_zero(PI)); let partial_sign = whole_rem == 1; @@ -168,20 +168,20 @@ fn sin_fast(a: FixedType) -> FixedType { let (start, low, high) = lut::sin(partial_rem); let partial_step = FixedTrait::new(partial_rem - start, false) / FixedTrait::new(51472, false); let res = partial_step * (FixedTrait::new(high, false) - FixedTrait::new(low, false)) - + FixedTrait::new(low, false); + + FixedTrait::::new(low, false); return FixedTrait::new(res.mag, a.sign ^ partial_sign && res.mag != 0); } // Calculates tan(a) with a in radians (fixed point) -fn tan(a: FixedType) -> FixedType { +fn tan(a: FP8x23) -> FP8x23 { let sinx = sin(a); let cosx = cos(a); assert(cosx.mag != 0, 'tan undefined'); return sinx / cosx; } -fn tan_fast(a: FixedType) -> FixedType { +fn tan_fast(a: FP8x23) -> FP8x23 { let sinx = sin_fast(a); let cosx = cos_fast(a); assert(cosx.mag != 0, 'tan undefined'); @@ -189,7 +189,7 @@ fn tan_fast(a: FixedType) -> FixedType { } // Helper function to calculate Taylor series for sin -fn _sin_loop(a: FixedType, i: u32, acc: FixedType) -> FixedType { +fn _sin_loop(a: FP8x23, i: u32, acc: FP8x23) -> FP8x23 { let div = (2 * i + 2) * (2 * i + 3); let term = a * a * acc / FixedTrait::new_unscaled(div, false); let new_acc = FixedTrait::ONE() - term; @@ -205,7 +205,9 @@ fn _sin_loop(a: FixedType, i: u32, acc: FixedType) -> FixedType { use traits::Into; -use orion::numbers::fixed_point::implementations::fp8x23::helpers::{assert_precise, assert_relative}; +use orion::numbers::fixed_point::implementations::fp8x23::helpers::{ + assert_precise, assert_relative +}; #[test] #[available_gas(3000000)] diff --git a/src/numbers/signed_integer/i128.cairo b/src/numbers/signed_integer/i128.cairo index 6889e3550..865ebbc45 100644 --- a/src/numbers/signed_integer/i128.cairo +++ b/src/numbers/signed_integer/i128.cairo @@ -2,7 +2,6 @@ use traits::Into; use orion::numbers::signed_integer::integer_trait::IntegerTrait; - // ====================== INT 128 ====================== // i128 represents a 128-bit integer. @@ -159,7 +158,6 @@ impl i128Neg of Neg { } } - // Checks if the given i128 integer is zero and has the correct sign. // # Arguments // * `x` - The i128 integer to check. diff --git a/src/numbers/signed_integer/i16.cairo b/src/numbers/signed_integer/i16.cairo index 3689f150a..7dbbe0d5b 100644 --- a/src/numbers/signed_integer/i16.cairo +++ b/src/numbers/signed_integer/i16.cairo @@ -2,7 +2,6 @@ use traits::Into; use orion::numbers::signed_integer::integer_trait::IntegerTrait; - // ====================== INT 16 ====================== // i16 represents a 16-bit integer. @@ -159,7 +158,6 @@ impl i16Neg of Neg { } } - // Checks if the given i16 integer is zero and has the correct sign. // # Arguments // * `x` - The i16 integer to check. diff --git a/src/numbers/signed_integer/i32.cairo b/src/numbers/signed_integer/i32.cairo index 04a2ca148..2434a2963 100644 --- a/src/numbers/signed_integer/i32.cairo +++ b/src/numbers/signed_integer/i32.cairo @@ -5,7 +5,6 @@ use traits::Into; use orion::numbers::signed_integer::integer_trait::IntegerTrait; use orion::numbers::signed_integer::i8::i8; - // ====================== INT 32 ====================== // i32 represents a 32-bit integer. @@ -489,4 +488,4 @@ fn ensure_non_negative_zero(mag: u32, sign: bool) -> i32 { } else { IntegerTrait::::new(mag, sign) } -} \ No newline at end of file +} diff --git a/src/numbers/signed_integer/i64.cairo b/src/numbers/signed_integer/i64.cairo index 070bc3133..27624d6a9 100644 --- a/src/numbers/signed_integer/i64.cairo +++ b/src/numbers/signed_integer/i64.cairo @@ -2,7 +2,6 @@ use traits::Into; use orion::numbers::signed_integer::integer_trait::IntegerTrait; - // ====================== INT 64 ====================== // i64 represents a 64-bit integer. @@ -159,7 +158,6 @@ impl i64Neg of Neg { } } - // Checks if the given i64 integer is zero and has the correct sign. // # Arguments // * `x` - The i64 integer to check. diff --git a/src/numbers/signed_integer/i8.cairo b/src/numbers/signed_integer/i8.cairo index aed7c3338..21ff97219 100644 --- a/src/numbers/signed_integer/i8.cairo +++ b/src/numbers/signed_integer/i8.cairo @@ -2,10 +2,11 @@ use traits::Into; use orion::numbers::signed_integer::integer_trait::IntegerTrait; use orion::numbers::signed_integer::i32::i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::ONE as ONE_fp8x23; -use orion::numbers::fixed_point::implementations::fp16x16::core::ONE as ONE_fp16x16; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - +use orion::numbers::fixed_point::implementations::fp8x23::core::{ONE as ONE_fp8x23, FP8x23}; +use orion::numbers::fixed_point::implementations::fp16x16::core::{ONE as ONE_fp16x16, FP16x16}; +use orion::numbers::fixed_point::implementations::fp64x64::core::{ONE as ONE_fp64x64, FP64x64}; +use orion::numbers::fixed_point::implementations::fp32x32::core::{ONE as ONE_fp32x32, FP32x32}; +use orion::numbers::fixed_point::core::FixedTrait; // ====================== INT 8 ====================== @@ -171,19 +172,33 @@ impl I8IntoI32 of Into { } // Implements the Into trait for i8 to fp_8x23. -impl I8IntoFP8x23 of Into { - fn into(self: i8) -> FixedType { +impl I8IntoFP8x23 of Into { + fn into(self: i8) -> FP8x23 { i8_to_fp8x23(self) } } // Implements the Into trait for i8 to fp_16x16. -impl I8IntoFP16x16 of Into { - fn into(self: i8) -> FixedType { +impl I8IntoFP16x16 of Into { + fn into(self: i8) -> FP16x16 { i8_to_fp16x16(self) } } +// Implements the Into trait for i8 to fp_64x64. +impl I8IntoFP64x64 of Into { + fn into(self: i8) -> FP64x64 { + i8_to_fp64x64(self) + } +} + +// Implements the Into trait for i8 to fp_32x32. +impl I8IntoFP32x32 of Into { + fn into(self: i8) -> FP32x32 { + i8_to_fp32x32(self) + } +} + // Checks if the given i8 integer is zero and has the correct sign. // # Arguments // * `x` - The i8 integer to check. @@ -496,14 +511,20 @@ fn i8_to_i32(x: i8) -> i32 { i32 { mag: x.mag.into(), sign: x.sign } } -use debug::PrintTrait; +fn i8_to_fp8x23(x: i8) -> FP8x23 { + FP8x23 { mag: x.mag.into() * ONE_fp8x23, sign: x.sign } +} -fn i8_to_fp8x23(x: i8) -> FixedType { - FixedType { mag: x.mag.into() * ONE_fp8x23, sign: x.sign } +fn i8_to_fp16x16(x: i8) -> FP16x16 { + FP16x16 { mag: x.mag.into() * ONE_fp16x16, sign: x.sign } } -fn i8_to_fp16x16(x: i8) -> FixedType { - FixedType { mag: x.mag.into() * ONE_fp16x16, sign: x.sign } +fn i8_to_fp64x64(x: i8) -> FP64x64 { + FP64x64 { mag: x.mag.into() * ONE_fp64x64, sign: x.sign } +} + +fn i8_to_fp32x32(x: i8) -> FP32x32 { + FP32x32 { mag: x.mag.into() * ONE_fp32x32, sign: x.sign } } fn ensure_non_negative_zero(mag: u8, sign: bool) -> i8 { @@ -512,4 +533,4 @@ fn ensure_non_negative_zero(mag: u8, sign: bool) -> i8 { } else { IntegerTrait::::new(mag, sign) } -} \ No newline at end of file +} diff --git a/src/numbers/signed_integer/integer_trait.cairo b/src/numbers/signed_integer/integer_trait.cairo index 8757313bb..5f56bc363 100644 --- a/src/numbers/signed_integer/integer_trait.cairo +++ b/src/numbers/signed_integer/integer_trait.cairo @@ -5,21 +5,21 @@ /// abs - Computes the absolute value of the given `signed_integer` /// max - Returns the maximum between two `signed_integer` /// min - Returns the minimum between two `signed_integer` -trait IntegerTrait { +trait IntegerTrait { /// # IntegerTrait::new /// /// ```rust - /// fn new(mag: U, sign: bool) -> T; + /// fn new(mag: MAG, sign: bool) -> T; /// ``` /// /// Returns a new signed integer. /// /// ## Args /// - /// * `mag`(`U`) - The magnitude of the integer. + /// * `mag`(`MAG`) - The magnitude of the integer. /// * `sign`(`bool`) - The sign of the integer, where `true` represents a negative number. /// - /// > _`` generic type depends on the uint type (u8, u16, u32, u64, u128)._ + /// > _`` generic type depends on the uint type (u8, u16, u32, u64, u128)._ /// /// ## Panics /// @@ -45,7 +45,7 @@ trait IntegerTrait { /// >>> panics with "int: out of range" /// ``` /// - fn new(mag: U, sign: bool) -> T; + fn new(mag: MAG, sign: bool) -> T; /// # int.div_rem /// /// ```rust diff --git a/src/operators/nn.cairo b/src/operators/nn.cairo index 48729ebfd..1f7a3abe5 100644 --- a/src/operators/nn.cairo +++ b/src/operators/nn.cairo @@ -1,3 +1,11 @@ mod core; mod implementations; mod functional; + +use orion::operators::nn::core::NNTrait; + +use orion::operators::nn::implementations::nn_fp8x23::FP8x23NN; +use orion::operators::nn::implementations::nn_fp16x16::FP16x16NN; +use orion::operators::nn::implementations::nn_i8::I8NN; +use orion::operators::nn::implementations::nn_i32::I32NN; +use orion::operators::nn::implementations::nn_u32::U32NN; diff --git a/src/operators/nn/core.cairo b/src/operators/nn/core.cairo index 8006d65d7..476616e30 100644 --- a/src/operators/nn/core.cairo +++ b/src/operators/nn/core.cairo @@ -1,5 +1,4 @@ use orion::operators::tensor::core::Tensor; -use orion::numbers::fixed_point::core::{FixedType}; /// Trait /// @@ -37,11 +36,9 @@ trait NNTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; + /// use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; + /// use orion::operators::nn::{NNTrait, I32NN}; + /// use orion::numbers::{i32, IntegerTrait}; /// /// fn relu_example() -> Tensor { /// let tensor = TensorTrait::::new( @@ -51,8 +48,8 @@ trait NNTrait { /// IntegerTrait::new(2, false), /// IntegerTrait::new(1, true), /// IntegerTrait::new(2, true), - /// ].span(), - /// extra: Option::None(()) + /// ] + /// .span(), /// ); /// /// return NNTrait::relu(@tensor); @@ -64,7 +61,7 @@ trait NNTrait { /// # NNTrait::softmax /// /// ```rust - /// fn softmax(tensor: @Tensor, axis: usize) -> Tensor; + /// fn softmax(tensor: @Tensor, axis: usize) -> Tensor; /// ``` /// /// Applies the Softmax function to an n-dimensional input Tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range \[0,1] and sum to 1. @@ -82,29 +79,29 @@ trait NNTrait { /// /// A Tensor of fixed point numbers with the same shape than the input Tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; + /// use orion::operators::nn::{NNTrait, FP8x23NN}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn softmax_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn softmax_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2, 2].span(), /// data: array![ - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(1, false), - /// IntegerTrait::new(2, false), - /// IntegerTrait::new(3, false), - /// ].span(), - /// extra: Option::Some(extra) + /// NNTrait::new(0, false), + /// NNTrait::new(1, false), + /// NNTrait::new(2, false), + /// NNTrait::new(3, false), + /// ] + /// .span(), /// ); /// /// return NNTrait::softmax(@tensor, 1); @@ -114,11 +111,11 @@ trait NNTrait { /// // [[0.2689, 0.7311],[0.2689, 0.7311]] /// ``` /// - fn softmax(tensor: @Tensor, axis: usize) -> Tensor; + fn softmax(tensor: @Tensor, axis: usize) -> Tensor; /// # NNTrait::logsoftmax /// /// ```rust - /// fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor + /// fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor /// ``` /// /// Applies the natural log to Softmax function to an n-dimensional input Tensor consisting of values in the range \[0,1]. @@ -136,29 +133,29 @@ trait NNTrait { /// /// A Tensor of fixed point numbers with the same shape than the input Tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; + /// use orion::operators::nn::{NNTrait, FP8x23NN}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn logsoftmax_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn logsoftmax_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2, 2].span(), /// data: array![ - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(1, false), - /// IntegerTrait::new(2, false), - /// IntegerTrait::new(3, false), - /// ].span(), - /// extra: Option::Some(extra) + /// FixedTrait::new(0, false), + /// FixedTrait::new(1, false), + /// FixedTrait::new(2, false), + /// FixedTrait::new(3, false), + /// ] + /// .span(), /// ); /// /// return NNTrait::logsoftmax(@tensor, 1); @@ -174,11 +171,11 @@ trait NNTrait { /// // [[-1.3134, -0.3132],[-1.3134, -0.3132]] /// ``` /// - fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor; + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor; /// # NNTrait::sigmoid /// /// ```rust - /// fn sigmoid(tensor: @Tensor) -> Tensor; + /// fn sigmoid(tensor: @Tensor) -> Tensor; /// ``` /// /// Applies the Sigmoid function to an n-dimensional input tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range \[0,1]. @@ -195,30 +192,29 @@ trait NNTrait { /// /// A Tensor of fixed point numbers with the same shape than the input Tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; + /// use orion::operators::nn::{NNTrait, FP8x23NN}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn sigmoid_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn sigmoid_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2, 2].span(), /// data: array![ - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(1, false), - /// IntegerTrait::new(2, false), - /// IntegerTrait::new(3, false), + /// FixedTrait::new(0, false), + /// FixedTrait::new(1, false), + /// FixedTrait::new(2, false), + /// FixedTrait::new(3, false), /// ] /// .span(), - /// extra: Option::Some(extra) /// ); /// /// return NNTrait::sigmoid(@tensor); @@ -228,11 +224,11 @@ trait NNTrait { /// // [[0.5, 0.7310586],[0.88079703, 0.95257413]] /// ``` /// - fn sigmoid(tensor: @Tensor) -> Tensor; + fn sigmoid(tensor: @Tensor) -> Tensor; /// # NNTrait::softsign /// /// ```rust - /// fn softsign(tensor: @Tensor) -> Tensor; + /// fn softsign(tensor: @Tensor) -> Tensor; /// ``` /// /// Applies the Softsign function to an n-dimensional input Tensor such that the elements of the n-dimensional output Tensor lie in the range \[-1,1]. @@ -249,30 +245,29 @@ trait NNTrait { /// /// A Tensor of fixed point numbers with the same shape than the input Tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; + /// use orion::operators::nn::{NNTrait, FP8x23NN}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn softsign_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn softsign_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2, 2].span(), /// data: array![ - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(1, false), - /// IntegerTrait::new(2, false), - /// IntegerTrait::new(3, false), + /// FixedTrait::new(0, false), + /// FixedTrait::new(1, false), + /// FixedTrait::new(2, false), + /// FixedTrait::new(3, false), /// ] /// .span(), - /// extra: Option::Some(extra) /// ); /// /// return NNTrait::softsign(@tensor); @@ -282,11 +277,11 @@ trait NNTrait { /// // [[0, 0.5],[0.67, 0.75]] /// ``` /// - fn softsign(tensor: @Tensor) -> Tensor; + fn softsign(tensor: @Tensor) -> Tensor; /// # NNTrait::softplus /// /// ```rust - /// fn softplus(tensor: @Tensor) -> Tensor; + /// fn softplus(tensor: @Tensor) -> Tensor; /// ``` /// /// Applies the Softplus function to an n-dimensional input Tensor such that the elements of the n-dimensional output Tensor lie in the range \[-1,1]. @@ -303,30 +298,29 @@ trait NNTrait { /// /// A Tensor of fixed point numbers with the same shape than the input Tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; + /// use orion::operators::nn::{NNTrait, FP8x23NN}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn softplus_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn softplus_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2, 2].span(), /// data: array![ - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(1, false), - /// IntegerTrait::new(2, false), - /// IntegerTrait::new(3, false), + /// FixedTrait::new(0, false), + /// FixedTrait::new(1, false), + /// FixedTrait::new(2, false), + /// FixedTrait::new(3, false), /// ] /// .span(), - /// extra: Option::Some(extra) /// ); /// /// return NNTrait::softplus(@tensor); @@ -336,7 +330,7 @@ trait NNTrait { /// // [[0.6931452, 1.31326096],[2.12692796, 3.04858728]] /// ``` /// - fn softplus(tensor: @Tensor) -> Tensor; + fn softplus(tensor: @Tensor) -> Tensor; /// # NNTrait::linear /// /// ```rust @@ -364,24 +358,18 @@ trait NNTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::fixed_point::core::{FixedImpl, FixedType}; + /// use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; + /// use orion::operators::nn::{NNTrait, I32NN}; + /// use orion::numbers::{i32, IntegerTrait}; /// /// fn linear_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// /// // We instantiate inputs here. /// let inputs = TensorTrait::::new( /// shape: array![3].span(), /// data: array![ - /// IntegerTrait::new(71, true), IntegerTrait::new(38, false), IntegerTrait::new(62, false), + /// IntegerTrait::new(71, true), IntegerTrait::new(38, false), IntegerTrait::new(62, false), /// ] /// .span(), - /// extra: Option::Some(extra) /// ); /// /// // We instantiate weights here. @@ -394,18 +382,14 @@ trait NNTrait { /// IntegerTrait::new(33, true), /// IntegerTrait::new(34, true), /// IntegerTrait::new(20, true), - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// /// // We instantiate bias here. /// let bias = TensorTrait::::new( /// shape: array![2].span(), - /// data: array![ - /// IntegerTrait::new(61, false), - /// IntegerTrait::new(61, true), - /// ].span(), - /// extra: Option::Some(extra) + /// data: array![IntegerTrait::new(61, false), IntegerTrait::new(61, true),].span(), /// ); /// /// return NNTrait::linear(inputs, weights, bias); @@ -417,7 +401,7 @@ trait NNTrait { /// # NNTrait::leaky_relu /// /// ```rust - /// fn leaky_relu(inputs: @Tensor, alpha: @FixedType) -> Tensor + /// fn leaky_relu(inputs: @Tensor, alpha: @T) -> Tensor /// ``` /// /// Applies the leaky rectified linear unit (Leaky ReLU) activation function element-wise to a given tensor. @@ -426,38 +410,36 @@ trait NNTrait { /// /// ## Args /// * `inputs`(`@Tensor`) - A snapshot of a tensor to which the Leaky ReLU function will be applied. - /// * `alpha`(`@FixedType`) - A snapshot of a FixedType scalar that defines the alpha value of the Leaky ReLU function. + /// * `alpha`(`@T`) - A snapshot of a fixed point scalar that defines the alpha value of the Leaky ReLU function. /// /// ## Returns - /// A new FixedType tensor with the same shape as the input tensor and the Leaky ReLU function applied element-wise. + /// A new fixed point tensor with the same shape as the input tensor and the Leaky ReLU function applied element-wise. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::operators::nn::core::NNTrait; - /// use orion::operators::nn::implementations::impl_nn_i32::NN_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::fixed_point::core::{FixedImpl, FixedType, FixedTrait}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23}; + /// use orion::operators::nn::{NNTrait, FP8x23NN}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn leaky_relu_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn leaky_relu_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2, 3].span(), /// data: array![ - /// IntegerTrait::new(1, false), - /// IntegerTrait::new(2, false), - /// IntegerTrait::new(1, true), - /// IntegerTrait::new(2, true), - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(0, false), + /// FixedTrait::new(1, false), + /// FixedTrait::new(2, false), + /// FixedTrait::new(1, true), + /// FixedTrait::new(2, true), + /// FixedTrait::new(0, false), + /// FixedTrait::new(0, false), /// ] /// .span(), - /// extra: Option::Some(extra) /// ); /// let alpha = FixedTrait::from_felt(838861); // 0.1 /// @@ -468,5 +450,5 @@ trait NNTrait { /// [[1, 2, 0.1], [0.2, 0, 0]] /// ``` /// - fn leaky_relu(inputs: @Tensor, alpha: @FixedType) -> Tensor; + fn leaky_relu(inputs: @Tensor, alpha: @T) -> Tensor; } diff --git a/src/operators/nn/functional/leaky_relu.cairo b/src/operators/nn/functional/leaky_relu.cairo index ad2ea3655..5ad8c3e02 100644 --- a/src/operators/nn/functional/leaky_relu.cairo +++ b/src/operators/nn/functional/leaky_relu.cairo @@ -1,3 +1,44 @@ -mod leaky_relu_i8; -mod leaky_relu_i32; -mod leaky_relu_fp; \ No newline at end of file +use core::traits::Into; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; +use orion::numbers::NumberTrait; + + +/// Cf: NNTrait::leaky_relu docstring +fn leaky_relu< + T, + MAG, + impl FNumber: NumberTrait, + impl FTensor: TensorTrait, + impl FPartialOrd: PartialOrd, + impl FMul: Mul, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut z: Tensor, alpha: @T +) -> Tensor { + assert(*alpha < NumberTrait::one(), 'alpha must be less than 1'); + + let mut data_result = ArrayTrait::::new(); + + loop { + match z.data.pop_front() { + Option::Some(item) => { + if (*item >= NumberTrait::zero()) { + data_result.append(*item); + } else { + data_result.append(*item * *alpha); + }; + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(z.shape, data_result.span()); +} diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_fp.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_fp.cairo deleted file mode 100644 index 1a2b31adf..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; \ No newline at end of file diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_fp/core.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_fp/core.cairo deleted file mode 100644 index 70b3b1dfb..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::leaky_relu::leaky_relu_fp::{fp16x16, fp8x23}; - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu_fp(z: @Tensor, alpha: @FixedType, ) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::leaky_relu(*z, alpha)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::leaky_relu(*z, alpha)), - }, - Option::None(_) => Option::Some((fp16x16::leaky_relu(*z, alpha))), - }, - Option::None(_) => Option::Some((fp16x16::leaky_relu(*z, alpha))), - } -} - diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_fp/fp16x16.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_fp/fp16x16.cairo deleted file mode 100644 index 4fa4941a8..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_fp/fp16x16.cairo +++ /dev/null @@ -1,36 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, ONE, FP16x16Mul, FP16x16PartialOrd -}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu(mut z: Tensor, alpha: @FixedType) -> Tensor { - assert(*alpha.mag < ONE, 'alpha must be less than 1_fp'); - - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - if (*item >= FixedType { mag: 0, sign: false }) { - data_result.append(*item); - } else { - data_result.append(*item * *alpha); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_fp/fp8x23.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_fp/fp8x23.cairo deleted file mode 100644 index 8bc99f415..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_fp/fp8x23.cairo +++ /dev/null @@ -1,36 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, ONE, FP8x23Mul, FP8x23PartialOrd -}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu(mut z: Tensor, alpha: @FixedType) -> Tensor { - assert(*alpha.mag < ONE, 'alpha must be less than 1_fp'); - - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - if (*item >= FixedType { mag: 0, sign: false }) { - data_result.append(*item); - } else { - data_result.append(*item * *alpha); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i32.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i32/core.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i32/core.cairo deleted file mode 100644 index 8b0148183..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i32/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::leaky_relu::leaky_relu_i32::fp16x16; -use orion::operators::nn::functional::leaky_relu::leaky_relu_i32::fp8x23; - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu_i32(z: @Tensor, alpha: @FixedType, ) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::leaky_relu(*z, alpha)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::leaky_relu(*z, alpha)), - }, - Option::None(_) => Option::Some((fp16x16::leaky_relu(*z, alpha))), - }, - Option::None(_) => Option::Some((fp16x16::leaky_relu(*z, alpha))), - } -} - diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i32/fp16x16.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i32/fp16x16.cairo deleted file mode 100644 index d467a0d66..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i32/fp16x16.cairo +++ /dev/null @@ -1,38 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, ONE, FP16x16Mul}; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu(mut z: Tensor, alpha: @FixedType) -> Tensor { - assert(*alpha.mag < ONE, 'alpha must be less than 1_fp'); - - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_index = FixedTrait::new_unscaled((*item.mag).into(), (*item).sign); - if (*item >= i32 { mag: 0, sign: false }) { - data_result.append(fp_current_index); - } else { - data_result.append(fp_current_index * *alpha); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i32/fp8x23.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i32/fp8x23.cairo deleted file mode 100644 index 97ac7ad82..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i32/fp8x23.cairo +++ /dev/null @@ -1,37 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, ONE, FP8x23Mul}; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu(mut z: Tensor, alpha: @FixedType) -> Tensor { - assert(*alpha.mag < ONE, 'alpha must be less than 1_fp'); - - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_index = FixedTrait::new_unscaled((*item.mag).into(), (*item).sign); - if (*item >= i32 { mag: 0, sign: false }) { - data_result.append(fp_current_index); - } else { - data_result.append(fp_current_index * *alpha); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i8.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i8/core.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i8/core.cairo deleted file mode 100644 index 55a8b5ea9..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i8/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::leaky_relu::leaky_relu_i8::fp16x16; -use orion::operators::nn::functional::leaky_relu::leaky_relu_i8::fp8x23; - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu_i8(z: @Tensor, alpha: @FixedType) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::leaky_relu(*z, alpha)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::leaky_relu(*z, alpha)), - }, - Option::None(_) => Option::Some((fp16x16::leaky_relu(*z, alpha))), - }, - Option::None(_) => Option::Some((fp16x16::leaky_relu(*z, alpha))), - } -} - diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i8/fp16x16.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i8/fp16x16.cairo deleted file mode 100644 index dd81d8af8..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i8/fp16x16.cairo +++ /dev/null @@ -1,38 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, ONE, FP16x16Mul}; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu(mut z: Tensor, alpha: @FixedType) -> Tensor { - assert(*alpha.mag < ONE, 'alpha must be less than 1_fp'); - - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_index = FixedTrait::new_unscaled((*item.mag).into(), (*item).sign); - if (*item >= i8 { mag: 0, sign: false }) { - data_result.append(fp_current_index); - } else { - data_result.append(fp_current_index * *alpha); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/leaky_relu/leaky_relu_i8/fp8x23.cairo b/src/operators/nn/functional/leaky_relu/leaky_relu_i8/fp8x23.cairo deleted file mode 100644 index f36b68542..000000000 --- a/src/operators/nn/functional/leaky_relu/leaky_relu_i8/fp8x23.cairo +++ /dev/null @@ -1,37 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, ONE, FP8x23Mul}; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: NNTrait::leaky_relu docstring -fn leaky_relu(mut z: Tensor, alpha: @FixedType) -> Tensor { - assert(*alpha.mag < ONE, 'alpha must be less than 1_fp'); - - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_index = FixedTrait::new_unscaled((*item.mag).into(), (*item).sign); - if (*item >= i8 { mag: 0, sign: false }) { - data_result.append(fp_current_index); - } else { - data_result.append(fp_current_index * *alpha); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/linear.cairo b/src/operators/nn/functional/linear.cairo index e57948580..b65e0cee7 100644 --- a/src/operators/nn/functional/linear.cairo +++ b/src/operators/nn/functional/linear.cairo @@ -1,4 +1,24 @@ -mod linear_i8; -mod linear_i32; -mod linear_u32; -mod linear_fp; \ No newline at end of file +use array::SpanTrait; + +use orion::numbers::NumberTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: NNTrait::linear docstring +fn linear< + T, + impl TTensor: TensorTrait, + impl TAddTensor: Add>, + impl TCopy: Copy, + impl TDrop: Drop +>( + z: Tensor, weights: Tensor, bias: Tensor +) -> Tensor { + assert(z.shape.len() == 1, 'input tensor must be 1D'); + assert(weights.shape.len() == 2, 'weights tensor must be 2D'); + assert(bias.shape.len() == 1, 'bias tensor must be 1D'); + + let dot = weights.matmul(@z); + let sum = dot + bias; + + return sum; +} diff --git a/src/operators/nn/functional/linear/linear_fp.cairo b/src/operators/nn/functional/linear/linear_fp.cairo deleted file mode 100644 index 04c3d1dfa..000000000 --- a/src/operators/nn/functional/linear/linear_fp.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorAdd}; -use orion::performance::core::PerfomanceTrait; - -/// Cf: NNTrait::linear docstring -fn linear_fp( - z: Tensor, weights: Tensor, bias: Tensor -) -> Tensor { - assert(z.shape.len() == 1, 'input tensor must be 1D'); - assert(weights.shape.len() == 2, 'weights tensor must be 2D'); - assert(bias.shape.len() == 1, 'bias tensor must be 1D'); - - let dot = weights.matmul(@z); - let sum = dot + bias; - - return sum; -} diff --git a/src/operators/nn/functional/linear/linear_i32.cairo b/src/operators/nn/functional/linear/linear_i32.cairo deleted file mode 100644 index a7620abb2..000000000 --- a/src/operators/nn/functional/linear/linear_i32.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use array::SpanTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorAdd}; -use orion::performance::core::PerfomanceTrait; - -/// Cf: NNTrait::linear docstring -fn linear_i32(z: Tensor, weights: Tensor, bias: Tensor) -> Tensor { - assert(z.shape.len() == 1, 'input tensor must be 1D'); - assert(weights.shape.len() == 2, 'weights tensor must be 2D'); - assert(bias.shape.len() == 1, 'bias tensor must be 1D'); - - let dot = weights.matmul(@z); - let sum = dot + bias; - - return sum; -} diff --git a/src/operators/nn/functional/linear/linear_i8.cairo b/src/operators/nn/functional/linear/linear_i8.cairo deleted file mode 100644 index 23f2f4065..000000000 --- a/src/operators/nn/functional/linear/linear_i8.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use array::SpanTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorAdd}; -use orion::performance::core::PerfomanceTrait; - -/// Cf: NNTrait::linear docstring -fn linear_i8(z: Tensor, weights: Tensor, bias: Tensor) -> Tensor { - assert(z.shape.len() == 1, 'input tensor must be 1D'); - assert(weights.shape.len() == 2, 'weights tensor must be 2D'); - assert(bias.shape.len() == 1, 'bias tensor must be 1D'); - - let dot = weights.matmul(@z); - let sum = dot + bias; - - return sum; -} diff --git a/src/operators/nn/functional/linear/linear_u32.cairo b/src/operators/nn/functional/linear/linear_u32.cairo deleted file mode 100644 index 9a0d005f6..000000000 --- a/src/operators/nn/functional/linear/linear_u32.cairo +++ /dev/null @@ -1,17 +0,0 @@ -use array::SpanTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorAdd}; -use orion::performance::core::PerfomanceTrait; - -/// Cf: NNTrait::linear docstring -fn linear_u32(z: Tensor, weights: Tensor, bias: Tensor) -> Tensor { - assert(z.shape.len() == 1, 'input tensor must be 1D'); - assert(weights.shape.len() == 2, 'weights tensor must be 2D'); - assert(bias.shape.len() == 1, 'bias tensor must be 1D'); - - let dot = weights.matmul(@z); - let sum = dot + bias; - - return sum; -} diff --git a/src/operators/nn/functional/logsoftmax.cairo b/src/operators/nn/functional/logsoftmax.cairo index 546f91976..6d19cbb62 100644 --- a/src/operators/nn/functional/logsoftmax.cairo +++ b/src/operators/nn/functional/logsoftmax.cairo @@ -1,4 +1,18 @@ -mod logsoftmax_u32; -mod logsoftmax_i32; -mod logsoftmax_i8; -mod logsoftmax_fp; \ No newline at end of file +use array::SpanTrait; + +use orion::numbers::NumberTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: NNTrait::logsoftmax docstring +fn logsoftmax< + T, impl TTensor: TensorTrait, impl TDivTensor: Div>, impl TDrop: Drop +>( + z: @Tensor, axis: usize +) -> Tensor { + let exp_tensor = z.exp(); + let sum = exp_tensor.reduce_sum(axis, true); + let softmax = exp_tensor / sum; + let logsoftmax = softmax.log(); + + return logsoftmax; +} diff --git a/src/operators/nn/functional/logsoftmax/logsoftmax_fp.cairo b/src/operators/nn/functional/logsoftmax/logsoftmax_fp.cairo deleted file mode 100644 index 99141dfb0..000000000 --- a/src/operators/nn/functional/logsoftmax/logsoftmax_fp.cairo +++ /dev/null @@ -1,13 +0,0 @@ -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv}; -use orion::numbers::fixed_point::core::FixedType; - -/// Cf: NNTrait::logsoftmax docstring -fn logsoftmax_fp(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - let logsoftmax = softmax.log(); - - return logsoftmax; -} diff --git a/src/operators/nn/functional/logsoftmax/logsoftmax_i32.cairo b/src/operators/nn/functional/logsoftmax/logsoftmax_i32.cairo deleted file mode 100644 index ac5631fba..000000000 --- a/src/operators/nn/functional/logsoftmax/logsoftmax_i32.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_i32::Tensor_i32, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; -use orion::numbers::fixed_point::core::FixedType; - -/// Cf: NNTrait::logsoftmax docstring -fn logsoftmax_i32(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - let logsoftmax = softmax.log(); - - return logsoftmax; -} diff --git a/src/operators/nn/functional/logsoftmax/logsoftmax_i8.cairo b/src/operators/nn/functional/logsoftmax/logsoftmax_i8.cairo deleted file mode 100644 index c8ae1387b..000000000 --- a/src/operators/nn/functional/logsoftmax/logsoftmax_i8.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_i8::Tensor_i8, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; -use orion::numbers::fixed_point::core::FixedType; - -/// Cf: NNTrait::logsoftmax docstring -fn logsoftmax_i8(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - let logsoftmax = softmax.log(); - - return logsoftmax; -} diff --git a/src/operators/nn/functional/logsoftmax/logsoftmax_u32.cairo b/src/operators/nn/functional/logsoftmax/logsoftmax_u32.cairo deleted file mode 100644 index d750b9f21..000000000 --- a/src/operators/nn/functional/logsoftmax/logsoftmax_u32.cairo +++ /dev/null @@ -1,15 +0,0 @@ -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_u32::Tensor_u32, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; -use orion::numbers::fixed_point::core::FixedType; - -/// Cf: NNTrait::logsoftmax docstring -fn logsoftmax_u32(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - let logsoftmax = softmax.log(); - - return logsoftmax; -} diff --git a/src/operators/nn/functional/relu.cairo b/src/operators/nn/functional/relu.cairo index f78f0796f..f8f1bb99d 100644 --- a/src/operators/nn/functional/relu.cairo +++ b/src/operators/nn/functional/relu.cairo @@ -1,3 +1,38 @@ -mod relu_i32; -mod relu_i8; -mod relu_fp; \ No newline at end of file +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::NumberTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: NNTrait::relu docstring +fn relu< + T, + MAG, + impl TTensor: TensorTrait, + impl TNumber: NumberTrait, + impl TPartialOrd: PartialOrd, + impl TCopy: Copy, + impl TDrop: Drop +>( + mut z: Tensor +) -> Tensor { + let mut data_result = ArrayTrait::::new(); + + loop { + match z.data.pop_front() { + Option::Some(item) => { + if (*item) < NumberTrait::zero() { + data_result.append(NumberTrait::zero()); + } else { + data_result.append(*item); + }; + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(z.shape, data_result.span()); +} diff --git a/src/operators/nn/functional/relu/relu_fp.cairo b/src/operators/nn/functional/relu/relu_fp.cairo deleted file mode 100644 index 1a2b31adf..000000000 --- a/src/operators/nn/functional/relu/relu_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; \ No newline at end of file diff --git a/src/operators/nn/functional/relu/relu_fp/core.cairo b/src/operators/nn/functional/relu/relu_fp/core.cairo deleted file mode 100644 index 7dc3b9577..000000000 --- a/src/operators/nn/functional/relu/relu_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::relu::relu_fp::{fp16x16, fp8x23}; - -/// Cf: NNTrait::relu docstring -fn relu_fp(z: @Tensor) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::relu(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::relu(*z)), - }, - Option::None(_) => Option::Some((fp16x16::relu(*z))), - }, - Option::None(_) => Option::Some((fp16x16::relu(*z))), - } -} - diff --git a/src/operators/nn/functional/relu/relu_fp/fp16x16.cairo b/src/operators/nn/functional/relu/relu_fp/fp16x16.cairo deleted file mode 100644 index b07d10af7..000000000 --- a/src/operators/nn/functional/relu/relu_fp/fp16x16.cairo +++ /dev/null @@ -1,31 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialOrd; - -/// Cf: NNTrait::relu docstring -fn relu(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - if (*item < FixedType { mag: 0, sign: false }) { - data_result.append(FixedType { mag: 0, sign: false }); - } else { - data_result.append(*item); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/relu/relu_fp/fp8x23.cairo b/src/operators/nn/functional/relu/relu_fp/fp8x23.cairo deleted file mode 100644 index 83158c661..000000000 --- a/src/operators/nn/functional/relu/relu_fp/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23PartialOrd; - -/// Cf: NNTrait::relu docstring -fn relu(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - if (*item < FixedType { mag: 0, sign: false }) { - data_result.append(FixedType { mag: 0, sign: false }); - } else { - data_result.append(*item); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/relu/relu_i32.cairo b/src/operators/nn/functional/relu/relu_i32.cairo deleted file mode 100644 index c0bfefc3f..000000000 --- a/src/operators/nn/functional/relu/relu_i32.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - - -/// Cf: NNTrait::relu docstring -fn relu_i32(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - if (*item) < IntegerTrait::new(0, false) { - data_result.append(IntegerTrait::new(0, false)); - } else { - data_result.append(*item); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/relu/relu_i8.cairo b/src/operators/nn/functional/relu/relu_i8.cairo deleted file mode 100644 index c4de1a447..000000000 --- a/src/operators/nn/functional/relu/relu_i8.cairo +++ /dev/null @@ -1,31 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - - -/// Cf: NNTrait::relu docstring -fn relu_i8(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - if (*item) < IntegerTrait::new(0, false) { - data_result.append(IntegerTrait::new(0, false)); - } else { - data_result.append(*item); - }; - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/sigmoid.cairo b/src/operators/nn/functional/sigmoid.cairo index 8d9cdcadc..23f444e23 100644 --- a/src/operators/nn/functional/sigmoid.cairo +++ b/src/operators/nn/functional/sigmoid.cairo @@ -1,4 +1,43 @@ -mod sigmoid_u32; -mod sigmoid_i32; -mod sigmoid_i8; -mod sigmoid_fp; \ No newline at end of file +use core::traits::Into; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; +use orion::numbers::NumberTrait; + +/// Cf: NNTrait::sigmoid docstring +fn sigmoid< + T, + MAG, + impl TNumber: NumberTrait, + impl TTensor: TensorTrait, + impl TPartialOrd: PartialOrd, + impl TAdd: Add, + impl TMul: Mul, + impl TDiv: Div, + impl TCopy: Copy, + impl TDrop: Drop, +>( + mut z: Tensor +) -> Tensor { + let mut data_result = ArrayTrait::::new(); + + loop { + match z.data.pop_front() { + Option::Some(item) => { + let result = NumberTrait::one() + / (NumberTrait::one() + (*item * NumberTrait::neg_one()).exp()); + data_result.append(result); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(z.shape, data_result.span()); +} + diff --git a/src/operators/nn/functional/sigmoid/core.cairo b/src/operators/nn/functional/sigmoid/core.cairo deleted file mode 100644 index 8b1378917..000000000 --- a/src/operators/nn/functional/sigmoid/core.cairo +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_fp.cairo b/src/operators/nn/functional/sigmoid/sigmoid_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/sigmoid/sigmoid_fp/core.cairo b/src/operators/nn/functional/sigmoid/sigmoid_fp/core.cairo deleted file mode 100644 index 1a354bdc4..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_fp/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::sigmoid::sigmoid_fp::fp8x23; -use orion::operators::nn::functional::sigmoid::sigmoid_fp::fp16x16; - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_fp(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sigmoid_fp(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sigmoid_fp(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_fp(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_fp(*z)), - } -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_fp/fp16x16.cairo b/src/operators/nn/functional/sigmoid/sigmoid_fp/fp16x16.cairo deleted file mode 100644 index a2d67638d..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_fp/fp16x16.cairo +++ /dev/null @@ -1,33 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Mul, FP16x16Div -}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_fp(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let result = FixedTrait::ONE() - / (FixedTrait::ONE() + (*item * FixedType { mag: 65536, sign: true }).exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_fp/fp8x23.cairo b/src/operators/nn/functional/sigmoid/sigmoid_fp/fp8x23.cairo deleted file mode 100644 index 2c73eeec7..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_fp/fp8x23.cairo +++ /dev/null @@ -1,33 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23Add, FP8x23Mul, FP8x23Div -}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_fp(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let result = FixedTrait::ONE() - / (FixedTrait::ONE() + (*item * FixedType { mag: 8388608, sign: true }).exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i32.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i32/core.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i32/core.cairo deleted file mode 100644 index 8c5cb405c..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i32/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::signed_integer::{i32::i32}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::sigmoid::sigmoid_i32::fp8x23; -use orion::operators::nn::functional::sigmoid::sigmoid_i32::fp16x16; - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_i32(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sigmoid_i32(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sigmoid_i32(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_i32(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_i32(*z)), - } -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i32/fp16x16.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i32/fp16x16.cairo deleted file mode 100644 index fdc720686..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i32/fp16x16.cairo +++ /dev/null @@ -1,38 +0,0 @@ -use core::debug::PrintTrait; -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_i32(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let current_item = *item * IntegerTrait::new(1, true); - let fp_current_index = FixedTrait::new_unscaled( - current_item.mag.into(), current_item.sign - ); - let result = FixedTrait::ONE() / (FixedTrait::ONE() + fp_current_index.exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i32/fp8x23.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i32/fp8x23.cairo deleted file mode 100644 index 01aa8d1f0..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i32/fp8x23.cairo +++ /dev/null @@ -1,34 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_i32(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let current_item = *item * IntegerTrait::new(1, true); - let fp_current_index = FixedTrait::new_unscaled( - current_item.mag.into(), current_item.sign - ); - let result = FixedTrait::ONE() / (FixedTrait::ONE() + fp_current_index.exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i8.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i8/core.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i8/core.cairo deleted file mode 100644 index 6120b1095..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i8/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::signed_integer::{i8::i8}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::sigmoid::sigmoid_i8::fp8x23; -use orion::operators::nn::functional::sigmoid::sigmoid_i8::fp16x16; - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_i8(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sigmoid_i8(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sigmoid_i8(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_i8(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_i8(*z)), - } -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i8/fp16x16.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i8/fp16x16.cairo deleted file mode 100644 index b3a5dbc06..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i8/fp16x16.cairo +++ /dev/null @@ -1,36 +0,0 @@ -use core::debug::PrintTrait; -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16Add, FP16x16Div}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_i8(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let current_item = *item * IntegerTrait::new(1, true); - let fp_current_index = FixedTrait::new_unscaled( - current_item.mag.into(), current_item.sign - ); - let result = FixedTrait::ONE() / (FixedTrait::ONE() + fp_current_index.exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_i8/fp8x23.cairo b/src/operators/nn/functional/sigmoid/sigmoid_i8/fp8x23.cairo deleted file mode 100644 index 5e0f1e3d6..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_i8/fp8x23.cairo +++ /dev/null @@ -1,34 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_i8(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let current_item = *item * IntegerTrait::new(1, true); - let fp_current_index = FixedTrait::new_unscaled( - current_item.mag.into(), current_item.sign - ); - let result = FixedTrait::ONE() / (FixedTrait::ONE() + fp_current_index.exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/sigmoid/sigmoid_u32.cairo b/src/operators/nn/functional/sigmoid/sigmoid_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/sigmoid/sigmoid_u32/core.cairo b/src/operators/nn/functional/sigmoid/sigmoid_u32/core.cairo deleted file mode 100644 index f02791963..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::sigmoid::sigmoid_u32::fp8x23; -use orion::operators::nn::functional::sigmoid::sigmoid_u32::fp16x16; - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_u32(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sigmoid_u32(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sigmoid_u32(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_u32(*z)), - }, - Option::None(_) => Option::Some(fp16x16::sigmoid_u32(*z)), - } -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_u32/fp16x16.cairo b/src/operators/nn/functional/sigmoid/sigmoid_u32/fp16x16.cairo deleted file mode 100644 index 256d37458..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_u32/fp16x16.cairo +++ /dev/null @@ -1,37 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_u32(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let neg_fp_current_item = if *item == 0 { - FixedTrait::new(0, false) - } else { - FixedTrait::new_unscaled((*item).into(), true) - }; - let result = FixedTrait::ONE() / (FixedTrait::ONE() + neg_fp_current_item.exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/sigmoid/sigmoid_u32/fp8x23.cairo b/src/operators/nn/functional/sigmoid/sigmoid_u32/fp8x23.cairo deleted file mode 100644 index fae2e3d6e..000000000 --- a/src/operators/nn/functional/sigmoid/sigmoid_u32/fp8x23.cairo +++ /dev/null @@ -1,35 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; - - -/// Cf: NNTrait::sigmoid docstring -fn sigmoid_u32(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let neg_fp_current_item = if *item == 0 { - FixedTrait::new(0, false) - } else { - FixedTrait::new_unscaled((*item).into(), true) - }; - let result = FixedTrait::ONE() / (FixedTrait::ONE() + neg_fp_current_item.exp()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softmax.cairo b/src/operators/nn/functional/softmax.cairo index 2127b4cce..528856265 100644 --- a/src/operators/nn/functional/softmax.cairo +++ b/src/operators/nn/functional/softmax.cairo @@ -1,4 +1,21 @@ -mod softmax_u32; -mod softmax_i32; -mod softmax_i8; -mod softmax_fp; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: NNTrait::softmax docstring +fn softmax< + T, + impl TTensor: TensorTrait, + impl TTensor: TensorTrait, + impl TTensorDiv: Div>, + impl TCopy: Copy, + impl TDrop: Drop, +>( + z: @Tensor, axis: usize +) -> Tensor { + let exp_tensor = z.exp(); + let sum = exp_tensor.reduce_sum(axis, true); + let softmax = exp_tensor / sum; + + return softmax; +} + diff --git a/src/operators/nn/functional/softmax/softmax_fp.cairo b/src/operators/nn/functional/softmax/softmax_fp.cairo deleted file mode 100644 index dbba51611..000000000 --- a/src/operators/nn/functional/softmax/softmax_fp.cairo +++ /dev/null @@ -1,15 +0,0 @@ -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_i8::Tensor_i8, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; -use orion::numbers::fixed_point::core::FixedType; - -/// Cf: NNTrait::softmax docstring -fn softmax_fp(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - - return softmax; -} - diff --git a/src/operators/nn/functional/softmax/softmax_i32.cairo b/src/operators/nn/functional/softmax/softmax_i32.cairo deleted file mode 100644 index 074f65f30..000000000 --- a/src/operators/nn/functional/softmax/softmax_i32.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_i32::Tensor_i32, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; -use orion::numbers::fixed_point::core::FixedType; - -/// Cf: NNTrait::softmax docstring -fn softmax_i32(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - - return softmax; -} - diff --git a/src/operators/nn/functional/softmax/softmax_i8.cairo b/src/operators/nn/functional/softmax/softmax_i8.cairo deleted file mode 100644 index 7c14ef98f..000000000 --- a/src/operators/nn/functional/softmax/softmax_i8.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_i8::Tensor_i8, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; -use orion::numbers::fixed_point::core::FixedType; - -/// Cf: NNTrait::softmax docstring -fn softmax_i8(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - - return softmax; -} - diff --git a/src/operators/nn/functional/softmax/softmax_u32.cairo b/src/operators/nn/functional/softmax/softmax_u32.cairo deleted file mode 100644 index 1339308dd..000000000 --- a/src/operators/nn/functional/softmax/softmax_u32.cairo +++ /dev/null @@ -1,15 +0,0 @@ -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::{ - impl_tensor_u32::Tensor_u32, impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv} -}; -use orion::numbers::fixed_point::core::FixedType; - - -/// Cf: NNTrait::softmax docstring -fn softmax_u32(z: @Tensor, axis: usize) -> Tensor { - let exp_tensor = z.exp(); - let sum = exp_tensor.reduce_sum(axis, true); - let softmax = exp_tensor / sum; - - return softmax; -} diff --git a/src/operators/nn/functional/softplus.cairo b/src/operators/nn/functional/softplus.cairo index 99f7ba457..1d98a848b 100644 --- a/src/operators/nn/functional/softplus.cairo +++ b/src/operators/nn/functional/softplus.cairo @@ -1,4 +1,40 @@ -mod softplus_u32; -mod softplus_i32; -mod softplus_i8; -mod softplus_fp; \ No newline at end of file +use core::traits::Into; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; +use orion::numbers::NumberTrait; + + +/// Cf: NNTrait::softplus docstring +fn softplus< + T, + MAG, + impl TTensor: TensorTrait, + impl TFixed: FixedTrait, + impl TPartialOrd: PartialOrd, + impl TAdd: Add, + impl TDiv: Div, + impl TCopy: Copy, + impl TDrop: Drop, +>( + mut z: Tensor +) -> Tensor { + let mut data_result = ArrayTrait::::new(); + + loop { + match z.data.pop_front() { + Option::Some(item) => { + let result = (FixedTrait::ONE() + (*item).exp()).ln(); + data_result.append(result); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(z.shape, data_result.span()); +} diff --git a/src/operators/nn/functional/softplus/softplus_fp.cairo b/src/operators/nn/functional/softplus/softplus_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softplus/softplus_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softplus/softplus_fp/core.cairo b/src/operators/nn/functional/softplus/softplus_fp/core.cairo deleted file mode 100644 index 5bcf692d4..000000000 --- a/src/operators/nn/functional/softplus/softplus_fp/core.cairo +++ /dev/null @@ -1,21 +0,0 @@ -use core::debug::PrintTrait; - -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softplus::softplus_fp::fp16x16; -use orion::operators::nn::functional::softplus::softplus_fp::fp8x23; - -/// Cf: NNTrait::softplus docstring -fn softplus_fp(z: @Tensor) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softplus(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softplus(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softplus((*z))) - }, - Option::None(_) => Option::Some(fp16x16::softplus(*z)), - } -} - diff --git a/src/operators/nn/functional/softplus/softplus_fp/fp16x16.cairo b/src/operators/nn/functional/softplus/softplus_fp/fp16x16.cairo deleted file mode 100644 index 786d95e4c..000000000 --- a/src/operators/nn/functional/softplus/softplus_fp/fp16x16.cairo +++ /dev/null @@ -1,32 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let result = (FixedTrait::ONE() + (*item).exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softplus/softplus_fp/fp8x23.cairo b/src/operators/nn/functional/softplus/softplus_fp/fp8x23.cairo deleted file mode 100644 index 230deeecc..000000000 --- a/src/operators/nn/functional/softplus/softplus_fp/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let result = (FixedTrait::ONE() + (*item).exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softplus/softplus_i32.cairo b/src/operators/nn/functional/softplus/softplus_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softplus/softplus_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softplus/softplus_i32/core.cairo b/src/operators/nn/functional/softplus/softplus_i32/core.cairo deleted file mode 100644 index cd852b8f7..000000000 --- a/src/operators/nn/functional/softplus/softplus_i32/core.cairo +++ /dev/null @@ -1,22 +0,0 @@ -use core::debug::PrintTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softplus::softplus_i32::fp16x16; -use orion::operators::nn::functional::softplus::softplus_i32::fp8x23; - -/// Cf: NNTrait::softplus docstring -fn softplus_i32(z: @Tensor) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softplus(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softplus(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softplus(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softplus(*z)), - } -} - diff --git a/src/operators/nn/functional/softplus/softplus_i32/fp16x16.cairo b/src/operators/nn/functional/softplus/softplus_i32/fp16x16.cairo deleted file mode 100644 index 827d090b8..000000000 --- a/src/operators/nn/functional/softplus/softplus_i32/fp16x16.cairo +++ /dev/null @@ -1,34 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled(*item.mag, *item.sign); - let result = (FixedTrait::ONE() + fp_current_item.exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softplus/softplus_i32/fp8x23.cairo b/src/operators/nn/functional/softplus/softplus_i32/fp8x23.cairo deleted file mode 100644 index ecdbbbebc..000000000 --- a/src/operators/nn/functional/softplus/softplus_i32/fp8x23.cairo +++ /dev/null @@ -1,32 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled(*item.mag, *item.sign); - let result = (FixedTrait::ONE() + fp_current_item.exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softplus/softplus_i8.cairo b/src/operators/nn/functional/softplus/softplus_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softplus/softplus_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softplus/softplus_i8/core.cairo b/src/operators/nn/functional/softplus/softplus_i8/core.cairo deleted file mode 100644 index 428df1100..000000000 --- a/src/operators/nn/functional/softplus/softplus_i8/core.cairo +++ /dev/null @@ -1,22 +0,0 @@ -use core::debug::PrintTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softplus::softplus_i8::fp16x16; -use orion::operators::nn::functional::softplus::softplus_i8::fp8x23; - -/// Cf: NNTrait::softplus docstring -fn softplus_i8(z: @Tensor) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softplus(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softplus(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softplus(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softplus(*z)), - } -} - diff --git a/src/operators/nn/functional/softplus/softplus_i8/fp16x16.cairo b/src/operators/nn/functional/softplus/softplus_i8/fp16x16.cairo deleted file mode 100644 index d91b2ac22..000000000 --- a/src/operators/nn/functional/softplus/softplus_i8/fp16x16.cairo +++ /dev/null @@ -1,32 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16Add, FP16x16Div}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled((*item.mag).into(), *item.sign); - let result = (FixedTrait::ONE() + fp_current_item.exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softplus/softplus_i8/fp8x23.cairo b/src/operators/nn/functional/softplus/softplus_i8/fp8x23.cairo deleted file mode 100644 index 006fb90d9..000000000 --- a/src/operators/nn/functional/softplus/softplus_i8/fp8x23.cairo +++ /dev/null @@ -1,32 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled((*item.mag).into(), *item.sign); - let result = (FixedTrait::ONE() + fp_current_item.exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softplus/softplus_u32.cairo b/src/operators/nn/functional/softplus/softplus_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softplus/softplus_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softplus/softplus_u32/core.cairo b/src/operators/nn/functional/softplus/softplus_u32/core.cairo deleted file mode 100644 index c79d5bb3b..000000000 --- a/src/operators/nn/functional/softplus/softplus_u32/core.cairo +++ /dev/null @@ -1,21 +0,0 @@ -use core::debug::PrintTrait; - -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softplus::softplus_u32::fp16x16; -use orion::operators::nn::functional::softplus::softplus_u32::fp8x23; - -/// Cf: NNTrait::softplus docstring -fn softplus_u32(z: @Tensor) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softplus(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softplus(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softplus(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softplus(*z)), - } -} - diff --git a/src/operators/nn/functional/softplus/softplus_u32/fp16x16.cairo b/src/operators/nn/functional/softplus/softplus_u32/fp16x16.cairo deleted file mode 100644 index 68bb7e3a7..000000000 --- a/src/operators/nn/functional/softplus/softplus_u32/fp16x16.cairo +++ /dev/null @@ -1,34 +0,0 @@ -use core::debug::PrintTrait; -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled((*item).into(), false); - let result = (FixedTrait::ONE() + fp_current_item.exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softplus/softplus_u32/fp8x23.cairo b/src/operators/nn/functional/softplus/softplus_u32/fp8x23.cairo deleted file mode 100644 index 526e89ad7..000000000 --- a/src/operators/nn/functional/softplus/softplus_u32/fp8x23.cairo +++ /dev/null @@ -1,31 +0,0 @@ -use core::debug::PrintTrait; -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softplus docstring -fn softplus(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled((*item).into(), false); - let result = (FixedTrait::ONE() + fp_current_item.exp()).ln(); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/softsign.cairo b/src/operators/nn/functional/softsign.cairo index 0029311e6..7d88ae2ce 100644 --- a/src/operators/nn/functional/softsign.cairo +++ b/src/operators/nn/functional/softsign.cairo @@ -1,4 +1,40 @@ -mod softsign_u32; -mod softsign_i32; -mod softsign_i8; -mod softsign_fp; \ No newline at end of file +use core::traits::Into; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; +use orion::numbers::NumberTrait; + + +/// Cf: NNTrait::softsign docstring +fn softsign< + T, + MAG, + impl TTensor: TensorTrait, + impl TFixed: FixedTrait, + impl TPartialOrd: PartialOrd, + impl TAdd: Add, + impl TDiv: Div, + impl TCopy: Copy, + impl TDrop: Drop, +>( + mut z: Tensor +) -> Tensor { + let mut data_result = ArrayTrait::new(); + + loop { + match z.data.pop_front() { + Option::Some(item) => { + let result = *item / (FixedTrait::ONE() + (*item).abs()); + data_result.append(result); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(z.shape, data_result.span()); +} diff --git a/src/operators/nn/functional/softsign/softsign_fp.cairo b/src/operators/nn/functional/softsign/softsign_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softsign/softsign_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softsign/softsign_fp/core.cairo b/src/operators/nn/functional/softsign/softsign_fp/core.cairo deleted file mode 100644 index 5a4b33428..000000000 --- a/src/operators/nn/functional/softsign/softsign_fp/core.cairo +++ /dev/null @@ -1,21 +0,0 @@ -use core::debug::PrintTrait; - -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softsign::softsign_fp::fp16x16; -use orion::operators::nn::functional::softsign::softsign_fp::fp8x23; - -/// Cf: NNTrait::softsign docstring -fn softsign_fp(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softsign(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - } -} - diff --git a/src/operators/nn/functional/softsign/softsign_fp/fp16x16.cairo b/src/operators/nn/functional/softsign/softsign_fp/fp16x16.cairo deleted file mode 100644 index d19e16ebf..000000000 --- a/src/operators/nn/functional/softsign/softsign_fp/fp16x16.cairo +++ /dev/null @@ -1,31 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let result = *item / (FixedTrait::ONE() + (*item).abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/softsign/softsign_fp/fp8x23.cairo b/src/operators/nn/functional/softsign/softsign_fp/fp8x23.cairo deleted file mode 100644 index 03845f022..000000000 --- a/src/operators/nn/functional/softsign/softsign_fp/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let result = *item / (FixedTrait::ONE() + (*item).abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softsign/softsign_i32.cairo b/src/operators/nn/functional/softsign/softsign_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softsign/softsign_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softsign/softsign_i32/core.cairo b/src/operators/nn/functional/softsign/softsign_i32/core.cairo deleted file mode 100644 index 458a29977..000000000 --- a/src/operators/nn/functional/softsign/softsign_i32/core.cairo +++ /dev/null @@ -1,22 +0,0 @@ -use core::debug::PrintTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softsign::softsign_i32::fp16x16; -use orion::operators::nn::functional::softsign::softsign_i32::fp8x23; - -/// Cf: NNTrait::softsign docstring -fn softsign_i32(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softsign(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - } -} - diff --git a/src/operators/nn/functional/softsign/softsign_i32/fp16x16.cairo b/src/operators/nn/functional/softsign/softsign_i32/fp16x16.cairo deleted file mode 100644 index afa00ba2e..000000000 --- a/src/operators/nn/functional/softsign/softsign_i32/fp16x16.cairo +++ /dev/null @@ -1,34 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled(*item.mag, *item.sign); - let result = fp_current_item / (FixedTrait::ONE() + fp_current_item.abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softsign/softsign_i32/fp8x23.cairo b/src/operators/nn/functional/softsign/softsign_i32/fp8x23.cairo deleted file mode 100644 index 409c664db..000000000 --- a/src/operators/nn/functional/softsign/softsign_i32/fp8x23.cairo +++ /dev/null @@ -1,32 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled(*item.mag, *item.sign); - let result = fp_current_item / (FixedTrait::ONE() + fp_current_item.abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softsign/softsign_i8.cairo b/src/operators/nn/functional/softsign/softsign_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softsign/softsign_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softsign/softsign_i8/core.cairo b/src/operators/nn/functional/softsign/softsign_i8/core.cairo deleted file mode 100644 index 09d7ef6e6..000000000 --- a/src/operators/nn/functional/softsign/softsign_i8/core.cairo +++ /dev/null @@ -1,22 +0,0 @@ -use core::debug::PrintTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softsign::softsign_i8::fp16x16; -use orion::operators::nn::functional::softsign::softsign_i8::fp8x23; - -/// Cf: NNTrait::softsign docstring -fn softsign_i8(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softsign(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - } -} - diff --git a/src/operators/nn/functional/softsign/softsign_i8/fp16x16.cairo b/src/operators/nn/functional/softsign/softsign_i8/fp16x16.cairo deleted file mode 100644 index de90a9903..000000000 --- a/src/operators/nn/functional/softsign/softsign_i8/fp16x16.cairo +++ /dev/null @@ -1,34 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled((*item.mag).into(), *item.sign); - let result = fp_current_item / (FixedTrait::ONE() + fp_current_item.abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softsign/softsign_i8/fp8x23.cairo b/src/operators/nn/functional/softsign/softsign_i8/fp8x23.cairo deleted file mode 100644 index 64642f6fa..000000000 --- a/src/operators/nn/functional/softsign/softsign_i8/fp8x23.cairo +++ /dev/null @@ -1,32 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled((*item.mag).into(), *item.sign); - let result = fp_current_item / (FixedTrait::ONE() + fp_current_item.abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/nn/functional/softsign/softsign_u32.cairo b/src/operators/nn/functional/softsign/softsign_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/nn/functional/softsign/softsign_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/nn/functional/softsign/softsign_u32/core.cairo b/src/operators/nn/functional/softsign/softsign_u32/core.cairo deleted file mode 100644 index b5531ed5b..000000000 --- a/src/operators/nn/functional/softsign/softsign_u32/core.cairo +++ /dev/null @@ -1,21 +0,0 @@ -use core::debug::PrintTrait; - -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::nn::functional::softsign::softsign_u32::fp16x16; -use orion::operators::nn::functional::softsign::softsign_u32::fp8x23; - -/// Cf: NNTrait::softsign docstring -fn softsign_u32(z: @Tensor) -> Option::> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::softsign(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - }, - Option::None(_) => Option::Some(fp16x16::softsign(*z)), - } -} - diff --git a/src/operators/nn/functional/softsign/softsign_u32/fp16x16.cairo b/src/operators/nn/functional/softsign/softsign_u32/fp16x16.cairo deleted file mode 100644 index bdb36d514..000000000 --- a/src/operators/nn/functional/softsign/softsign_u32/fp16x16.cairo +++ /dev/null @@ -1,32 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Div -}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled(*item, false); - let result = fp_current_item / (FixedTrait::ONE() + fp_current_item.abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/functional/softsign/softsign_u32/fp8x23.cairo b/src/operators/nn/functional/softsign/softsign_u32/fp8x23.cairo deleted file mode 100644 index e4fdb7033..000000000 --- a/src/operators/nn/functional/softsign/softsign_u32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23Add, FP8x23Div}; - - -/// Cf: NNTrait::softsign docstring -fn softsign(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - let fp_current_item = FixedTrait::new_unscaled(*item, false); - let result = fp_current_item / (FixedTrait::ONE() + fp_current_item.abs()); - data_result.append(result); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/nn/implementations.cairo b/src/operators/nn/implementations.cairo index 09360b762..465f4e596 100644 --- a/src/operators/nn/implementations.cairo +++ b/src/operators/nn/implementations.cairo @@ -1,4 +1,7 @@ -mod impl_nn_i8; -mod impl_nn_i32; -mod impl_nn_u32; -mod impl_nn_fp; \ No newline at end of file +mod nn_i8; +mod nn_i32; +mod nn_u32; +mod nn_fp8x23; +mod nn_fp16x16; +mod nn_fp64x64; +mod nn_fp32x32; \ No newline at end of file diff --git a/src/operators/nn/implementations/impl_nn_fp.cairo b/src/operators/nn/implementations/impl_nn_fp.cairo deleted file mode 100644 index 2f8cbb7ee..000000000 --- a/src/operators/nn/implementations/impl_nn_fp.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use core::option::OptionTrait; -use orion::operators::tensor::core::Tensor; -use orion::operators::nn::core::NNTrait; -use orion::operators::nn::functional::relu::relu_fp::core::relu_fp; -use orion::operators::nn::functional::sigmoid::sigmoid_fp::core::sigmoid_fp; -use orion::operators::nn::functional::softmax::softmax_fp::softmax_fp; -use orion::operators::nn::functional::logsoftmax::logsoftmax_fp::logsoftmax_fp; -use orion::operators::nn::functional::softsign::softsign_fp::core::softsign_fp; -use orion::operators::nn::functional::softplus::softplus_fp::core::softplus_fp; -use orion::operators::nn::functional::linear::linear_fp::linear_fp; -use orion::operators::nn::functional::leaky_relu::leaky_relu_fp::core::leaky_relu_fp; -use orion::numbers::fixed_point::core::FixedType; - - -impl NN_fp of NNTrait { - fn relu(tensor: @Tensor) -> Tensor { - relu_fp(tensor).unwrap() - } - - fn sigmoid(tensor: @Tensor) -> Tensor { - sigmoid_fp(tensor).unwrap() - } - - fn softmax(tensor: @Tensor, axis: usize) -> Tensor { - softmax_fp(tensor, axis) - } - - fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { - logsoftmax_fp(tensor, axis) - } - - fn softsign(tensor: @Tensor) -> Tensor { - softsign_fp(tensor).unwrap() - } - - fn softplus(tensor: @Tensor) -> Tensor { - softplus_fp(tensor).unwrap() - } - - fn linear( - inputs: Tensor, weights: Tensor, bias: Tensor - ) -> Tensor { - linear_fp(inputs, weights, bias) - } - - fn leaky_relu(inputs: @Tensor, alpha: @FixedType) -> Tensor { - leaky_relu_fp(inputs, alpha).unwrap() - } -} diff --git a/src/operators/nn/implementations/impl_nn_i32.cairo b/src/operators/nn/implementations/impl_nn_i32.cairo deleted file mode 100644 index e1e046592..000000000 --- a/src/operators/nn/implementations/impl_nn_i32.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use core::option::OptionTrait; -use orion::operators::tensor::core::Tensor; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::nn::core::{NNTrait}; -use orion::operators::nn::functional::relu::relu_i32::relu_i32; -use orion::operators::nn::functional::sigmoid::sigmoid_i32::core::sigmoid_i32; -use orion::operators::nn::functional::softmax::softmax_i32::softmax_i32; -use orion::operators::nn::functional::logsoftmax::logsoftmax_i32::logsoftmax_i32; -use orion::operators::nn::functional::softsign::softsign_i32::core::softsign_i32; -use orion::operators::nn::functional::softplus::softplus_i32::core::softplus_i32; -use orion::operators::nn::functional::linear::linear_i32::linear_i32; -use orion::operators::nn::functional::leaky_relu::leaky_relu_i32::core::leaky_relu_i32; -use orion::numbers::fixed_point::core::{FixedType}; - - -impl NN_i32 of NNTrait { - fn relu(tensor: @Tensor) -> Tensor { - relu_i32(*tensor) - } - - fn sigmoid(tensor: @Tensor) -> Tensor { - sigmoid_i32(tensor).unwrap() - } - - fn softmax(tensor: @Tensor, axis: usize) -> Tensor { - softmax_i32(tensor, axis) - } - - fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { - logsoftmax_i32(tensor, axis) - } - - fn softsign(tensor: @Tensor) -> Tensor { - softsign_i32(tensor).unwrap() - } - - fn softplus(tensor: @Tensor) -> Tensor { - softplus_i32(tensor).unwrap() - } - - fn linear(inputs: Tensor, weights: Tensor, bias: Tensor) -> Tensor { - linear_i32(inputs, weights, bias) - } - - fn leaky_relu(inputs: @Tensor, alpha: @FixedType) -> Tensor { - leaky_relu_i32(inputs, alpha).unwrap() - } -} diff --git a/src/operators/nn/implementations/impl_nn_i8.cairo b/src/operators/nn/implementations/impl_nn_i8.cairo deleted file mode 100644 index 3c9deaa8d..000000000 --- a/src/operators/nn/implementations/impl_nn_i8.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use core::option::OptionTrait; -use orion::operators::tensor::core::Tensor; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::nn::core::{NNTrait}; -use orion::operators::nn::functional::relu::relu_i8::relu_i8; -use orion::operators::nn::functional::sigmoid::sigmoid_i8::core::sigmoid_i8; -use orion::operators::nn::functional::softmax::softmax_i8::softmax_i8; -use orion::operators::nn::functional::logsoftmax::logsoftmax_i8::logsoftmax_i8; -use orion::operators::nn::functional::softsign::softsign_i8::core::softsign_i8; -use orion::operators::nn::functional::softplus::softplus_i8::core::softplus_i8; -use orion::operators::nn::functional::linear::linear_i8::linear_i8; -use orion::operators::nn::functional::leaky_relu::leaky_relu_i8::core::leaky_relu_i8; -use orion::numbers::fixed_point::core::{FixedType}; - - -impl NN_i8 of NNTrait { - fn relu(tensor: @Tensor) -> Tensor { - relu_i8(*tensor) - } - - fn sigmoid(tensor: @Tensor) -> Tensor { - sigmoid_i8(tensor).unwrap() - } - - fn softmax(tensor: @Tensor, axis: usize) -> Tensor { - softmax_i8(tensor, axis) - } - - fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { - logsoftmax_i8(tensor, axis) - } - - fn softsign(tensor: @Tensor) -> Tensor { - softsign_i8(tensor).unwrap() - } - - fn softplus(tensor: @Tensor) -> Tensor { - softplus_i8(tensor).unwrap() - } - - fn linear(inputs: Tensor, weights: Tensor, bias: Tensor) -> Tensor { - linear_i8(inputs, weights, bias) - } - - fn leaky_relu(inputs: @Tensor, alpha: @FixedType) -> Tensor { - leaky_relu_i8(inputs, alpha).unwrap() - } -} diff --git a/src/operators/nn/implementations/impl_nn_u32.cairo b/src/operators/nn/implementations/impl_nn_u32.cairo deleted file mode 100644 index decd930cd..000000000 --- a/src/operators/nn/implementations/impl_nn_u32.cairo +++ /dev/null @@ -1,45 +0,0 @@ -use core::option::OptionTrait; -use orion::operators::tensor::core::Tensor; -use orion::operators::nn::core::{NNTrait}; -use orion::operators::nn::functional::sigmoid::sigmoid_u32::core::sigmoid_u32; -use orion::operators::nn::functional::softmax::softmax_u32::softmax_u32; -use orion::operators::nn::functional::logsoftmax::logsoftmax_u32::logsoftmax_u32; -use orion::operators::nn::functional::softsign::softsign_u32::core::softsign_u32; -use orion::operators::nn::functional::softplus::softplus_u32::core::softplus_u32; -use orion::operators::nn::functional::linear::linear_u32::linear_u32; -use orion::numbers::fixed_point::core::{FixedType}; - - -impl NN_u32 of NNTrait { - fn relu(tensor: @Tensor) -> Tensor { - panic(array!['not supported with this dtype']) - } - - fn sigmoid(tensor: @Tensor) -> Tensor { - sigmoid_u32(tensor).unwrap() - } - - fn softmax(tensor: @Tensor, axis: usize) -> Tensor { - softmax_u32(tensor, axis) - } - - fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { - logsoftmax_u32(tensor, axis) - } - - fn softsign(tensor: @Tensor) -> Tensor { - softsign_u32(tensor).unwrap() - } - - fn softplus(tensor: @Tensor) -> Tensor { - softplus_u32(tensor).unwrap() - } - - fn linear(inputs: Tensor, weights: Tensor, bias: Tensor) -> Tensor { - linear_u32(inputs, weights, bias) - } - - fn leaky_relu(inputs: @Tensor, alpha: @FixedType) -> Tensor { - panic(array!['not supported with this dtype']) - } -} diff --git a/src/operators/nn/implementations/nn_fp16x16.cairo b/src/operators/nn/implementations/nn_fp16x16.cairo new file mode 100644 index 000000000..a0094de29 --- /dev/null +++ b/src/operators/nn/implementations/nn_fp16x16.cairo @@ -0,0 +1,45 @@ +use core::option::OptionTrait; + +use orion::operators::tensor::core::Tensor; +use orion::operators::nn::core::NNTrait; +use orion::operators::nn::functional; +use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16; +use orion::operators::tensor::implementations::tensor_fp16x16::{ + FP16x16Tensor, FP16x16TensorDiv, FP16x16TensorAdd +}; + +impl FP16x16NN of NNTrait { + fn relu(tensor: @Tensor) -> Tensor { + functional::relu::relu(*tensor) + } + + fn sigmoid(tensor: @Tensor) -> Tensor { + functional::sigmoid::sigmoid(*tensor) + } + + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::softmax::softmax(tensor, axis) + } + + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::logsoftmax::logsoftmax(tensor, axis) + } + + fn softsign(tensor: @Tensor) -> Tensor { + functional::softsign::softsign(*tensor) + } + + fn softplus(tensor: @Tensor) -> Tensor { + functional::softplus::softplus(*tensor) + } + + fn linear( + inputs: Tensor, weights: Tensor, bias: Tensor + ) -> Tensor { + functional::linear::linear(inputs, weights, bias) + } + + fn leaky_relu(inputs: @Tensor, alpha: @FP16x16) -> Tensor { + functional::leaky_relu::leaky_relu(*inputs, alpha) + } +} diff --git a/src/operators/nn/implementations/nn_fp32x32.cairo b/src/operators/nn/implementations/nn_fp32x32.cairo new file mode 100644 index 000000000..a550caa31 --- /dev/null +++ b/src/operators/nn/implementations/nn_fp32x32.cairo @@ -0,0 +1,45 @@ +use core::option::OptionTrait; + +use orion::operators::tensor::core::Tensor; +use orion::operators::nn::core::NNTrait; +use orion::operators::nn::functional; +use orion::numbers::fixed_point::implementations::fp32x32::core::{FP32x32, FP32x32Impl}; +use orion::operators::tensor::implementations::tensor_fp32x32::{ + FP32x32Tensor, FP32x32TensorDiv, FP32x32TensorAdd +}; + +impl FP32x32NN of NNTrait { + fn relu(tensor: @Tensor) -> Tensor { + functional::relu::relu(*tensor) + } + + fn sigmoid(tensor: @Tensor) -> Tensor { + functional::sigmoid::sigmoid(*tensor) + } + + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::softmax::softmax(tensor, axis) + } + + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::logsoftmax::logsoftmax(tensor, axis) + } + + fn softsign(tensor: @Tensor) -> Tensor { + functional::softsign::softsign(*tensor) + } + + fn softplus(tensor: @Tensor) -> Tensor { + functional::softplus::softplus(*tensor) + } + + fn linear( + inputs: Tensor, weights: Tensor, bias: Tensor + ) -> Tensor { + functional::linear::linear(inputs, weights, bias) + } + + fn leaky_relu(inputs: @Tensor, alpha: @FP32x32) -> Tensor { + functional::leaky_relu::leaky_relu(*inputs, alpha) + } +} diff --git a/src/operators/nn/implementations/nn_fp64x64.cairo b/src/operators/nn/implementations/nn_fp64x64.cairo new file mode 100644 index 000000000..bcd4be5db --- /dev/null +++ b/src/operators/nn/implementations/nn_fp64x64.cairo @@ -0,0 +1,45 @@ +use core::option::OptionTrait; + +use orion::operators::tensor::core::Tensor; +use orion::operators::nn::core::NNTrait; +use orion::operators::nn::functional; +use orion::numbers::fixed_point::implementations::fp64x64::core::{FP64x64, FP64x64Impl}; +use orion::operators::tensor::implementations::tensor_fp64x64::{ + FP64x64Tensor, FP64x64TensorDiv, FP64x64TensorAdd +}; + +impl FP64x64NN of NNTrait { + fn relu(tensor: @Tensor) -> Tensor { + functional::relu::relu(*tensor) + } + + fn sigmoid(tensor: @Tensor) -> Tensor { + functional::sigmoid::sigmoid(*tensor) + } + + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::softmax::softmax(tensor, axis) + } + + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::logsoftmax::logsoftmax(tensor, axis) + } + + fn softsign(tensor: @Tensor) -> Tensor { + functional::softsign::softsign(*tensor) + } + + fn softplus(tensor: @Tensor) -> Tensor { + functional::softplus::softplus(*tensor) + } + + fn linear( + inputs: Tensor, weights: Tensor, bias: Tensor + ) -> Tensor { + functional::linear::linear(inputs, weights, bias) + } + + fn leaky_relu(inputs: @Tensor, alpha: @FP64x64) -> Tensor { + functional::leaky_relu::leaky_relu(*inputs, alpha) + } +} diff --git a/src/operators/nn/implementations/nn_fp8x23.cairo b/src/operators/nn/implementations/nn_fp8x23.cairo new file mode 100644 index 000000000..305eeaba2 --- /dev/null +++ b/src/operators/nn/implementations/nn_fp8x23.cairo @@ -0,0 +1,45 @@ +use core::option::OptionTrait; + +use orion::operators::tensor::core::Tensor; +use orion::operators::nn::core::NNTrait; +use orion::operators::nn::functional; +use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23; +use orion::operators::tensor::implementations::tensor_fp8x23::{ + FP8x23Tensor, FP8x23TensorDiv, FP8x23TensorAdd +}; + +impl FP8x23NN of NNTrait { + fn relu(tensor: @Tensor) -> Tensor { + functional::relu::relu(*tensor) + } + + fn sigmoid(tensor: @Tensor) -> Tensor { + functional::sigmoid::sigmoid(*tensor) + } + + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::softmax::softmax(tensor, axis) + } + + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { + functional::logsoftmax::logsoftmax(tensor, axis) + } + + fn softsign(tensor: @Tensor) -> Tensor { + functional::softsign::softsign(*tensor) + } + + fn softplus(tensor: @Tensor) -> Tensor { + functional::softplus::softplus(*tensor) + } + + fn linear( + inputs: Tensor, weights: Tensor, bias: Tensor + ) -> Tensor { + functional::linear::linear(inputs, weights, bias) + } + + fn leaky_relu(inputs: @Tensor, alpha: @FP8x23) -> Tensor { + functional::leaky_relu::leaky_relu(*inputs, alpha) + } +} diff --git a/src/operators/nn/implementations/nn_i32.cairo b/src/operators/nn/implementations/nn_i32.cairo new file mode 100644 index 000000000..c74dfc268 --- /dev/null +++ b/src/operators/nn/implementations/nn_i32.cairo @@ -0,0 +1,41 @@ +use core::option::OptionTrait; + +use orion::operators::tensor::core::Tensor; +use orion::numbers::signed_integer::i32::i32; +use orion::operators::nn::core::NNTrait; +use orion::operators::nn::functional; +use orion::operators::tensor::implementations::tensor_i32::{I32Tensor, I32TensorAdd}; + +impl I32NN of NNTrait { + fn relu(tensor: @Tensor) -> Tensor { + functional::relu::relu(*tensor) + } + + fn sigmoid(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + panic(array!['not supported!']) + } + + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { + panic(array!['not supported!']) + } + + fn softsign(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn softplus(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn linear(inputs: Tensor, weights: Tensor, bias: Tensor) -> Tensor { + functional::linear::linear(inputs, weights, bias) + } + + fn leaky_relu(inputs: @Tensor, alpha: @i32) -> Tensor { + panic(array!['not supported!']) + } +} diff --git a/src/operators/nn/implementations/nn_i8.cairo b/src/operators/nn/implementations/nn_i8.cairo new file mode 100644 index 000000000..12e9812a1 --- /dev/null +++ b/src/operators/nn/implementations/nn_i8.cairo @@ -0,0 +1,41 @@ +use core::option::OptionTrait; + +use orion::operators::tensor::core::Tensor; +use orion::numbers::signed_integer::i8::i8; +use orion::operators::nn::core::NNTrait; +use orion::operators::nn::functional; +use orion::operators::tensor::implementations::tensor_i8::{I8Tensor, I8TensorAdd}; + +impl I8NN of NNTrait { + fn relu(tensor: @Tensor) -> Tensor { + functional::relu::relu(*tensor) + } + + fn sigmoid(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + panic(array!['not supported!']) + } + + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { + panic(array!['not supported!']) + } + + fn softsign(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn softplus(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn linear(inputs: Tensor, weights: Tensor, bias: Tensor) -> Tensor { + functional::linear::linear(inputs, weights, bias) + } + + fn leaky_relu(inputs: @Tensor, alpha: @i8) -> Tensor { + panic(array!['not supported!']) + } +} diff --git a/src/operators/nn/implementations/nn_u32.cairo b/src/operators/nn/implementations/nn_u32.cairo new file mode 100644 index 000000000..0da74d544 --- /dev/null +++ b/src/operators/nn/implementations/nn_u32.cairo @@ -0,0 +1,40 @@ +use core::option::OptionTrait; + +use orion::operators::tensor::core::Tensor; +use orion::operators::nn::core::NNTrait; +use orion::operators::nn::functional; +use orion::operators::tensor::implementations::tensor_u32::{U32Tensor, U32TensorAdd}; + +impl U32NN of NNTrait { + fn relu(tensor: @Tensor) -> Tensor { + functional::relu::relu(*tensor) + } + + fn sigmoid(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn softmax(tensor: @Tensor, axis: usize) -> Tensor { + panic(array!['not supported!']) + } + + fn logsoftmax(tensor: @Tensor, axis: usize) -> Tensor { + panic(array!['not supported!']) + } + + fn softsign(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn softplus(tensor: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn linear(inputs: Tensor, weights: Tensor, bias: Tensor) -> Tensor { + functional::linear::linear(inputs, weights, bias) + } + + fn leaky_relu(inputs: @Tensor, alpha: @u32) -> Tensor { + panic(array!['not supported!']) + } +} diff --git a/src/operators/tensor.cairo b/src/operators/tensor.cairo index 3a2e5fc9b..976102b52 100644 --- a/src/operators/tensor.cairo +++ b/src/operators/tensor.cairo @@ -2,4 +2,31 @@ mod core; mod helpers; mod math; mod linalg; +mod quantization; mod implementations; + +use orion::operators::tensor::core::{Tensor, TensorSerde, TensorTrait}; + +use orion::operators::tensor::implementations::tensor_fp8x23::{ + FP8x23Tensor, FP8x23TensorAdd, FP8x23TensorSub, FP8x23TensorMul, FP8x23TensorDiv, + FP8x23TensorPartialEq, +}; + +use orion::operators::tensor::implementations::tensor_fp16x16::{ + FP16x16Tensor, FP16x16TensorAdd, FP16x16TensorSub, FP16x16TensorMul, FP16x16TensorDiv, + FP16x16TensorPartialEq, +}; + +use orion::operators::tensor::implementations::tensor_i8::{ + I8Tensor, I8TensorAdd, I8TensorSub, I8TensorMul, I8TensorDiv, I8TensorPartialEq, +}; + +use orion::operators::tensor::implementations::tensor_i32::{ + I32Tensor, I32TensorAdd, I32TensorSub, I32TensorMul, I32TensorDiv, I32TensorPartialEq, + TensorI8IntoTensorI32 +}; + +use orion::operators::tensor::implementations::tensor_u32::{ + U32Tensor, U32TensorAdd, U32TensorSub, U32TensorMul, U32TensorDiv, U32TensorPartialEq +}; + diff --git a/src/operators/tensor/core.cairo b/src/operators/tensor/core.cairo index 9b6cb760a..b6806616e 100644 --- a/src/operators/tensor/core.cairo +++ b/src/operators/tensor/core.cairo @@ -2,20 +2,15 @@ use array::{ArrayTrait, SpanTrait}; use serde::Serde; use option::OptionTrait; +use alexandria_data_structures::array_ext::{SpanTraitExt}; use orion::operators::tensor::helpers::{len_from_shape, check_shape}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; +use orion::numbers::i8; #[derive(Copy, Drop)] struct Tensor { shape: Span, data: Span, - extra: Option -} - -#[derive(Serde, Copy, Drop)] -struct ExtraParams { - fixed_point: Option } //Implement TensorSerde @@ -23,15 +18,13 @@ impl TensorSerde, impl TDrop: Drop> of Serde, ref output: Array) { self.shape.serialize(ref output); self.data.serialize(ref output); - self.extra.serialize(ref output); } fn deserialize(ref serialized: Span) -> Option> { let shape: Span = Serde::>::deserialize(ref serialized)?; let data: Span = Serde::>::deserialize(ref serialized)?; - let extra: Option = Serde::>::deserialize(ref serialized)?; - Option::Some(Tensor { shape, data, extra }) + Option::Some(Tensor { shape, data }) } } @@ -75,12 +68,16 @@ impl TensorSerde, impl TDrop: Drop> of Serde { /// # tensor.new /// /// ```rust - /// fn new(shape: Span, data: Span, extra: Option) -> Tensor; + /// fn new(shape: Span, data: Span) -> Tensor; /// ``` /// /// Returns a new tensor with the given shape and data. @@ -89,7 +86,6 @@ trait TensorTrait { /// /// * `shape`(`Span`) - A span representing the shape of the tensor. /// * `data` (`Span`) - A span containing the array of elements. - /// * `extra` (`Option`) - A parameter for extra tensor options. /// /// ## Panics /// @@ -106,27 +102,22 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{ + /// TensorTrait, // we import the trait + /// Tensor, // we import the type + /// U32Tensor // we import the implementation. + /// }; /// /// // 1D TENSOR /// fn tensor_1D() -> Tensor { - /// let tensor = TensorTrait::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor = TensorTrait::new(shape: array![3].span(), data: array![0, 1, 2].span()); /// /// return tensor; /// } /// /// // 2D TENSOR /// fn tensor_2D() -> Tensor { - /// let tensor = TensorTrait::new( - /// shape: array![2, 2].span(), - /// data: array![0, 1, 2, 3].span(), - /// extra: Option::None(()) - /// ); + /// let tensor = TensorTrait::new(shape: array![2, 2].span(), data: array![0, 1, 2, 3].span()); /// /// return tensor; /// } @@ -134,16 +125,14 @@ trait TensorTrait { /// // 3D TENSOR /// fn tensor_3D() -> Tensor { /// let tensor = TensorTrait::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// return tensor; /// } /// ``` /// - fn new(shape: Span, data: Span, extra: Option) -> Tensor; + fn new(shape: Span, data: Span) -> Tensor; /// # tensor.at /// /// ```rust @@ -170,21 +159,16 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// /// fn at_example() -> u32 { /// let tensor = TensorTrait::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `at` function as follows. - /// return tensor.at( - /// indices: array![0, 1, 1].span() - /// ); + /// return tensor.at(indices: array![0, 1, 1].span()); /// } /// >>> 3 /// ``` @@ -211,15 +195,12 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn min_example() -> u32 { /// let tensor = TensorTrait::new( /// shape: array![2, 2, 2].span(), /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) /// ); /// /// // We can call `min` function as follows. @@ -250,15 +231,11 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn max_example() -> u32 { /// let tensor = TensorTrait::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `max` function as follows. @@ -288,15 +265,11 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn stride_example() -> Span { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `stride` function as follows. @@ -332,21 +305,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn ravel_index_example() -> usize { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `ravel_index` function as follows. - /// return tensor.ravel_index( - /// indices: array![1, 3, 0].span() - /// ); + /// return tensor.ravel_index(indices: array![1, 3, 0].span()); /// } /// >>> 10 /// // This means that the value of indices [1,3,0] @@ -380,15 +347,11 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn unravel_index_example() -> Span { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `unravel_index` function as follows. @@ -426,21 +389,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn reshape_tensor_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `reshape` function as follows. - /// return tensor.reshape( - /// target_shape: array![2,4].span() - /// ); + /// return tensor.reshape(target_shape: array![2, 4].span()); /// } /// >>> [[0,1,2,3], [4,5,6,7]] /// ``` @@ -472,21 +429,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn transpose_tensor_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `transpose` function as follows. - /// return tensor.transpose( - /// axes: array![1, 2, 0].span() - /// ); + /// return tensor.transpose(axes: array![1, 2, 0].span()); /// } /// >>> [[[0,4],[1,5]],[[2,6],[3,7]]] /// ``` @@ -519,22 +470,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn reduce_sum_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// // We can call `reduce_sum` function as follows. - /// return tensor.reduce_sum( - /// axis: 0, - /// keepdims: false - /// ); + /// return tensor.reduce_sum(axis: 0, keepdims: false); /// } /// >>> [[4,6],[8,10]] /// ``` @@ -570,22 +514,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn argmax_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), /// ); /// /// // We can call `argmax` function as follows. - /// return tensor.argmax( - /// axis: 2, - /// keepdims: Option::None(()), - /// select_last_index: Option::None(()) - /// ); + /// return tensor.argmax(axis: 2, keepdims: Option::None(()), select_last_index: Option::None(())); /// } /// >>> [[[1,1],[0,0]]] /// ``` @@ -594,22 +531,16 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn argmax_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), /// ); /// /// // We can call `argmax` function as follows. - /// return tensor.argmax( - /// axis: 2, - /// keepdims: Option::Some(false), - /// select_last_index: Option::None(()) - /// ); + /// return tensor + /// .argmax(axis: 2, keepdims: Option::Some(false), select_last_index: Option::None(())); /// } /// >>> [[1,1],[0,0]] /// ``` @@ -619,22 +550,16 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn argmax_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), /// ); /// /// // We can call `argmax` function as follows. - /// return tensor.argmax( - /// axis: 2, - /// keepdims: Option::None(()), - /// select_last_index: Option::Some(true) - /// ); + /// return tensor + /// .argmax(axis: 2, keepdims: Option::None(()), select_last_index: Option::Some(true)); /// } /// >>> [[[1,1],[1,1]]] /// ``` @@ -672,22 +597,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn argmin_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), /// ); /// /// // We can call `argmin` function as follows. - /// return tensor.argmin( - /// axis: 2, - /// keepdims: Option::None(()), - /// select_last_index: Option::None(()) - /// ); + /// return tensor.argmin(axis: 2, keepdims: Option::None(()), select_last_index: Option::None(())); /// } /// >>> [[[0,0],[0,0]]] /// @@ -697,22 +615,16 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn argmin_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), /// ); /// /// // We can call `argmin` function as follows. - /// return tensor.argmin( - /// axis: 2, - /// keepdims: Option::Some(false), - /// select_last_index: Option::None(()) - /// ); + /// return tensor + /// .argmin(axis: 2, keepdims: Option::Some(false), select_last_index: Option::None(())); /// } /// >>> [[0,0],[0,0]] /// ``` @@ -722,22 +634,16 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn argmin_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 4, 5, 5].span(), /// ); /// /// // We can call `argmin` function as follows. - /// return tensor.argmin( - /// axis: 2, - /// keepdims: Option::None(()), - /// select_last_index: Option::None(true) - /// ); + /// return tensor + /// .argmin(axis: 2, keepdims: Option::None(()), select_last_index: Option::Some(true)); /// } /// >>> [[[0,0],[1,1]]] /// ``` @@ -778,21 +684,12 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn dot_product_example() -> Tensor { - /// let tensor_1 = TensorTrait::::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_1 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// /// // We can call `matmul` function as follows. /// return tensor_1.matmul(@tensor_2); @@ -805,20 +702,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn matrix_mul_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![2, 2].span(), - /// data: array![244, 99, 109, 162].span(), - /// extra: Option::None(()) + /// shape: array![2, 2].span(), data: array![244, 99, 109, 162].span() /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![2, 2].span(), - /// data: array![151, 68, 121, 170].span(), - /// extra: Option::None(()) + /// shape: array![2, 2].span(), data: array![151, 68, 121, 170].span() /// ); /// /// // We can call `matmul` function as follows. @@ -832,21 +724,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn matrix_vec_mul_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// 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].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// /// // We can call `matmul` function as follows. /// return tensor_1.matmul(@tensor_2); @@ -858,7 +743,7 @@ trait TensorTrait { /// # tensor.exp /// /// ```rust - /// fn exp(self: @Tensor) -> Tensor; + /// fn exp(self: @Tensor) -> Tensor; /// ``` /// /// Computes the exponential of all elements of the input tensor. @@ -872,23 +757,29 @@ trait TensorTrait { /// /// ## Returns /// - /// Returns a new tensor in `FixedType` with the exponential of the elements of the input tensor. + /// Returns a new tensor in `T` with the exponential of the elements of the input tensor. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn exp_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; + /// fn exp_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2].span(), - /// data: array![0, 1, 2, 3].span(), - /// extra: Option::Some(extra) + /// shape: array![2, 2].span(), + /// data: array![ + /// FixedTrait::new_unscaled(0, false), + /// FixedTrait::new_unscaled(1, false), + /// FixedTrait::new_unscaled(2, false), + /// FixedTrait::new_unscaled(3, false), + /// ] /// ); /// /// // We can call `exp` function as follows. @@ -899,11 +790,11 @@ trait TensorTrait { /// // [[1, 2.718281],[7.38905, 20.085536]] /// ``` /// - fn exp(self: @Tensor) -> Tensor; + fn exp(self: @Tensor) -> Tensor; /// # tensor.log /// /// ```rust - /// fn log(self: @Tensor) -> Tensor; + /// fn log(self: @Tensor) -> Tensor; /// ``` /// /// Computes the natural log of all elements of the input tensor. @@ -917,23 +808,29 @@ trait TensorTrait { /// /// ## Returns /// - /// Returns a new tensor in `FixedType` with the natural log of the elements of the input tensor. + /// Returns a new tensor in `T` with the natural log of the elements of the input tensor. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn log_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; + /// fn log_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2].span(), - /// data: array![1, 2, 3, 100].span(), - /// extra: Option::Some(extra) + /// shape: array![2, 2].span(), + /// data: array![ + /// FixedTrait::new_unscaled(0, false), + /// FixedTrait::new_unscaled(1, false), + /// FixedTrait::new_unscaled(2, false), + /// FixedTrait::new_unscaled(100, false), + /// ] /// ); /// /// // We can call `log` function as follows. @@ -944,7 +841,7 @@ trait TensorTrait { /// /// [[0, 0.693147, 1.098612, 4.605170]] /// ``` /// - fn log(self: @Tensor) -> Tensor; + fn log(self: @Tensor) -> Tensor; /// #tensor.equal /// /// ```rust @@ -976,20 +873,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn eq_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), /// ); /// /// // We can call `equal` function as follows. @@ -1003,21 +895,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn eq_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// /// // We can call `equal` function as follows. /// return tensor_1.equal(@tensor_2); @@ -1057,20 +942,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn greater_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), /// ); /// /// // We can call `greater` function as follows. @@ -1084,21 +964,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn greater_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// /// // We can call `greater` function as follows. /// return tensor_1.greater(@tensor_2); @@ -1138,20 +1011,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn greater_equal_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), /// ); /// /// // We can call `greater_equal` function as follows. @@ -1165,21 +1033,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn greater_equal_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// /// // We can call `greater_equal` function as follows. /// return tensor_1.greater_equal(@tensor_2); @@ -1219,20 +1080,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn less_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), /// ); /// /// // We can call `less` function as follows. @@ -1246,21 +1102,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn less_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// /// // We can call `less` function as follows. /// return tensor_1.less(@tensor_2); @@ -1300,20 +1149,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn less_equal_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), /// ); /// /// // We can call `less_equal` function as follows. @@ -1327,21 +1171,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn less_equal_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3, 3].span(), - /// data: array![0,1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// - /// let tensor_2 = TensorTrait::::new( - /// shape: array![3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) - /// ); + /// let tensor_2 = TensorTrait::::new(shape: array![3].span(), data: array![0, 1, 2].span(),); /// /// // We can call `less_equal` function as follows. /// return tensor_1.less_equal(@tensor_2); @@ -1373,19 +1210,16 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32}; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; + /// use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor}; + /// use orion::numbers::{i32, IntegerTrait}; /// /// fn abs_example() -> Tensor { - /// let tensor = TensorTrait::::new( + /// let tensor = TensorTrait::new( /// shape: array![3].span(), /// data: array![ - /// IntegerTrait::new(1, true), - /// IntegerTrait::new(2, true), - /// IntegerTrait::new(3, false) - /// ].span(), - /// extra: Option::None(()) + /// IntegerTrait::new(1, true), IntegerTrait::new(2, true), IntegerTrait::new(3, false) + /// ] + /// .span(), /// ); /// /// return tensor.abs(); @@ -1412,26 +1246,27 @@ trait TensorTrait { /// A new `Tensor` of the same shape as the input tensor with /// the rounded up value of all elements in the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn ceil_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn ceil_example() -> Tensor { + /// let tensor = TensorTrait::new( /// shape: array![3].span(), /// data: array![ /// FixedTrait::new(29998, false), // 0.003576 /// FixedTrait::new(100663252, false), // 11.9999947548 /// FixedTrait::new(100663252, true) // -11.9999947548 - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// /// return tensor.ceil(); @@ -1458,19 +1293,20 @@ trait TensorTrait { /// A new `Tensor` of the same shape as the input tensor with /// the sine value of all elements in the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn sin_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn sin_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![3].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), @@ -1478,7 +1314,6 @@ trait TensorTrait { /// FixedTrait::new_unscaled(2, false) /// ] /// .span(), - /// extra: Option::Some(extra) /// ); /// /// return tensor.sin(); @@ -1488,7 +1323,7 @@ trait TensorTrait { /// // [0,0.8414...,0.9092...] /// ``` /// - fn sin(self: @Tensor) -> Tensor; + fn sin(self: @Tensor) -> Tensor; /// #tensor.cos /// /// ```rust @@ -1507,19 +1342,20 @@ trait TensorTrait { /// A new `Tensor` of the same shape as the input tensor with /// the cosine value of all elements in the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn cos_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn cos_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![3].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), @@ -1527,7 +1363,6 @@ trait TensorTrait { /// FixedTrait::new_unscaled(2, false) /// ] /// .span(), - /// extra: Option::Some(extra) /// ); /// /// return tensor.cos(); @@ -1537,7 +1372,7 @@ trait TensorTrait { /// // [1, 0.5403...,-0.4161] /// ``` /// - fn cos(self: @Tensor) -> Tensor; + fn cos(self: @Tensor) -> Tensor; /// # tensor.cumsum /// /// ```rust @@ -1568,22 +1403,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn cumsum_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// - /// return tensor.cumsum( - /// axis: 2, - /// exclusive: Option::None(()), - /// reverse: Option::None(()) - /// ); + /// return tensor.cumsum(axis: 2, exclusive: Option::None(()), reverse: Option::None(())); /// } /// >>> [[[0,1],[2,5]],[[4,9],[6,13]]] /// ``` @@ -1593,22 +1420,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn cumsum_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// - /// return tensor.cumsum( - /// axis: 2, - /// exclusive: Option::Some(true), - /// reverse: Option::None(()) - /// ); + /// return tensor.cumsum(axis: 2, exclusive: Option::Some(true), reverse: Option::None(())); /// } /// >>> [[[0,0],[0,2]],[[0,4],[0,6]]] /// ``` @@ -1618,22 +1437,14 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn cumsum_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// - /// return tensor.cumsum( - /// axis: 2, - /// exclusive: Option::Some(true), - /// reverse: Option::Some(true) - /// ); + /// return tensor.cumsum(axis: 2, exclusive: Option::Some(true), reverse: Option::Some(true)); /// } /// >>> [[[1,0],[3,0]],[[5,0],[7,0]]] /// ``` @@ -1669,12 +1480,6 @@ trait TensorTrait { /// Case 1: flatten with axis 0 /// /// ```rust - /// use array::{ArrayTrait, SpanTrait}; - /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// /// fn flatten_example() -> Tensor { /// let tensor = TensorTrait::::new( /// shape: array![2, 2, 2].span(), @@ -1692,15 +1497,11 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn flatten_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// return tensor.flatten(1); // equivalent to tensor.reshape(2,4) @@ -1713,15 +1514,11 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn flatten_example() -> Tensor { /// let tensor = TensorTrait::::new( - /// shape: array![2, 2, 2].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), - /// extra: Option::None(()) + /// shape: array![2, 2, 2].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), /// ); /// /// return tensor.flatten(2); // equivalent to tensor.reshape(4,2) @@ -1733,7 +1530,7 @@ trait TensorTrait { /// # tensor.sinh /// /// ```rust - /// fn sinh(self: @Tensor) -> Tensor; + /// fn sinh(self: @Tensor) -> Tensor; /// ``` /// /// Computes the hyperbolic sine of all elements of the input tensor. @@ -1747,43 +1544,44 @@ trait TensorTrait { /// /// ## Returns /// - /// Returns a new tensor in `FixedType` with the hyperbolic sine of the elements of the input tensor. + /// Returns a new tensor in `T` with the hyperbolic sine of the elements of the input tensor. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn sinh_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( - /// shape: array![2,2].span(), + /// fn sinh_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2, 2].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), /// FixedTrait::new_unscaled(1, false), /// FixedTrait::new_unscaled(2, false), /// FixedTrait::new_unscaled(3, false) - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// - /// return tensor.sinh(); + /// return tensor.sinh(); /// } /// >>> [[0,9858303],[30424311,84036026]] /// // The fixed point representation of /// // [[0, 1.175201],[3.62686, 10.0178749]] /// ``` /// - fn sinh(self: @Tensor) -> Tensor; + fn sinh(self: @Tensor) -> Tensor; /// # tensor.tanh /// /// ```rust - /// fn tanh(self: @Tensor) -> Tensor; + /// fn tanh(self: @Tensor) -> Tensor; /// ``` /// /// Computes the hyperbolic tangent of all elements of the input tensor. @@ -1797,43 +1595,44 @@ trait TensorTrait { /// /// ## Returns /// - /// Returns a new tensor in `FixedType` with the hyperbolic tangent of the elements of the input tensor. + /// Returns a new tensor in `T` with the hyperbolic tangent of the elements of the input tensor. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn tanh_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( - /// shape: array![2,2].span(), + /// fn tanh_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2, 2].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), /// FixedTrait::new_unscaled(1, false), /// FixedTrait::new_unscaled(2, false), /// FixedTrait::new_unscaled(3, false) - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// - /// return tensor.tanh(); + /// return tensor.tanh(); /// } /// >>> [[0,6388715],[8086850,8347125]] /// // The fixed point representation of /// // [[0, 0.761594],[0.96403, 0.9951]] /// ``` /// - fn tanh(self: @Tensor) -> Tensor; + fn tanh(self: @Tensor) -> Tensor; /// # tensor.cosh /// /// ```rust - /// fn cosh(self: @Tensor) -> Tensor; + /// fn cosh(self: @Tensor) -> Tensor; /// ``` /// /// Computes the hyperbolic cosine of all elements of the input tensor. @@ -1847,43 +1646,44 @@ trait TensorTrait { /// /// ## Returns /// - /// Returns a new tensor in `FixedType` with the hyperblic cosine of the elements of the input tensor. + /// Returns a new tensor in `T` with the hyperblic cosine of the elements of the input tensor. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn cosh_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( - /// shape: array![2,2].span(), + /// fn cosh_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2, 2].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), /// FixedTrait::new_unscaled(1, false), /// FixedTrait::new_unscaled(2, false), /// FixedTrait::new_unscaled(3, false) - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// - /// return tensor.cosh(); + /// return tensor.cosh(); /// } /// >>> [[8388608,12944299],[31559585,84453670]] /// // The fixed point representation of /// // [[, 1.54308],[3.762196, 10.067662]] /// ``` /// - fn cosh(self: @Tensor) -> Tensor; + fn cosh(self: @Tensor) -> Tensor; /// # tensor.asinh /// /// ```rust - /// fn asinh(self: @Tensor) -> Tensor; + /// fn asinh(self: @Tensor) -> Tensor; /// ``` /// /// Computes the inverse hyperbolic sine of all elements of the input tensor. @@ -1897,43 +1697,44 @@ trait TensorTrait { /// /// ## Returns /// - /// Returns a new tensor in `FixedType` with the hyperblic sine of the elements of the input tensor. + /// Returns a new tensor in `T` with the hyperblic sine of the elements of the input tensor. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn asinh_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( - /// shape: array![2,2].span(), + /// fn asinh_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2, 2].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), /// FixedTrait::new_unscaled(1, false), /// FixedTrait::new_unscaled(2, false), /// FixedTrait::new_unscaled(3, false) - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// - /// return tensor.asinh(); + /// return tensor.asinh(); /// } /// >>> [[0,7393498],[12110093,15254235]] /// // The fixed point representation of /// // [[0, 0.8814],[1.44364, 1.8185]] /// ``` /// - fn asinh(self: @Tensor) -> Tensor; + fn asinh(self: @Tensor) -> Tensor; /// # tensor.acosh /// /// ```rust - /// fn acosh(self: @Tensor) -> Tensor; + /// fn acosh(self: @Tensor) -> Tensor; /// ``` /// /// Computes the inverse hyperbolic cosine of all elements of the input tensor. @@ -1947,39 +1748,40 @@ trait TensorTrait { /// /// ## Returns /// - /// Returns a new tensor in `FixedType` with the hyperblic cosine of the elements of the input tensor. + /// Returns a new tensor in `T` with the hyperblic cosine of the elements of the input tensor. + /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. /// /// ## Examples /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn acosh_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( - /// shape: array![2,2].span(), + /// fn acosh_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2, 2].span(), /// data: array![ /// FixedTrait::new_unscaled(1, false), /// FixedTrait::new_unscaled(2, false), /// FixedTrait::new_unscaled(3, false), /// FixedTrait::new_unscaled(4, false) - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// - /// return tensor.acosh(); + /// return tensor.acosh(); /// } /// >>> [[0,11047444],[14786996,17309365]] /// // The fixed point representation of /// // [[0, 1.31696],[1.76275, 2.06344]] /// ``` /// - fn acosh(self: @Tensor) -> Tensor; + fn acosh(self: @Tensor) -> Tensor; /// #tensor.atan /// /// ```rust @@ -1998,36 +1800,37 @@ trait TensorTrait { /// A new `Tensor` of the same shape as the input tensor with /// the arctangent (inverse of tangent) value of all elements in the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn atan_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn atan_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![3].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), /// FixedTrait::new_unscaled(1, false), /// FixedTrait::new_unscaled(2, false), - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// - /// return tensor.atan(); + /// return tensor.atan(); /// } /// >>> [0,6588397,9287028] /// // The fixed point representation of /// // [0,0.7853...,1.1071...] /// ``` /// - fn atan(self: @Tensor) -> Tensor; + fn atan(self: @Tensor) -> Tensor; /// #tensor.asin /// /// ```rust @@ -2046,35 +1849,33 @@ trait TensorTrait { /// A new `Tensor` of the same shape as the input tensor with /// the arcsine value of all elements in the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn asin_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn asin_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2].span(), - /// data: array![ - /// FixedTrait::new_unscaled(0, false), - /// FixedTrait::new_unscaled(1, false), - /// ].span(), - /// extra: Option::Some(extra) + /// data: array![FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false),] + /// .span(), /// ); /// - /// return tensor.asin(); + /// return tensor.asin(); /// } /// >>> [0, 13176794] /// // The fixed point representation of /// // [0, 1.5707...] /// ``` /// - fn asin(self: @Tensor) -> Tensor; + fn asin(self: @Tensor) -> Tensor; /// #tensor.or /// /// ```rust @@ -2106,21 +1907,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn or_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// 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, 3, 4, 5, 9, 1, 5].span(), - /// extra: Option::None(()) + /// shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), /// ); /// /// return tensor_1.or(@tensor_2); @@ -2133,21 +1928,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn or_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![1, 3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) + /// shape: array![1, 3].span(), data: array![0, 1, 2].span(), /// ); /// /// return tensor_1.or(@tensor_2); @@ -2187,21 +1976,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn xor_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// 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, 3, 4, 5, 9, 1, 5].span(), - /// extra: Option::None(()) + /// shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 9, 1, 5].span(), /// ); /// /// return tensor_1.xor(@tensor_2); @@ -2214,21 +1997,15 @@ trait TensorTrait { /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; /// /// fn xor_example() -> Tensor { /// let tensor_1 = TensorTrait::::new( - /// shape: array![3, 3].span(), - /// data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), - /// extra: Option::None(()) + /// shape: array![3, 3].span(), data: array![0, 1, 2, 3, 4, 5, 6, 7, 8].span(), /// ); /// /// let tensor_2 = TensorTrait::::new( - /// shape: array![1, 3].span(), - /// data: array![0, 1, 2].span(), - /// extra: Option::None(()) + /// shape: array![1, 3].span(), data: array![0, 1, 2].span(), /// ); /// /// return tensor_1.xor(@tensor_2); @@ -2255,35 +2032,33 @@ trait TensorTrait { /// A new `Tensor` of the same shape as the input tensor with /// the arccosine value of all elements in the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn acos_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn acos_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![2].span(), - /// data: array![ - /// FixedTrait::new_unscaled(0, false), - /// FixedTrait::new_unscaled(1, false), - /// ].span(), - /// extra: Option::Some(extra) + /// data: array![FixedTrait::new_unscaled(0, false), FixedTrait::new_unscaled(1, false),] + /// .span(), /// ); /// - /// return tensor.acos(); + /// return tensor.acos(); /// } /// >>> [13176794, 0] /// // The fixed point representation of /// // [1.5707..., 0] /// ``` /// - fn acos(self: @Tensor) -> Tensor; + fn acos(self: @Tensor) -> Tensor; /// # tensor.onehot /// /// ```rust @@ -2307,28 +2082,31 @@ trait TensorTrait { /// /// A new `Tensor` one-hot encode of the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust - /// fn onehot_example() -> Tensor { /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FP8x23, FixedTrait}; /// - /// fn onehot_example() -> Tensor { - /// let tensor = TensorTrait::::new( - /// shape: array![2, 2].span(), - /// data: array![0, 1, 2, 3].span(), - /// extra: Option::None(()) - /// ); + /// fn onehot_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2,2].span(), + /// data: array![ + /// FixedTrait::new_unscaled(0, false), + /// FixedTrait::new_unscaled(1, false), + /// FixedTrait::new_unscaled(2, false), + /// FixedTrait::new_unscaled(3, false), + /// ] + /// .span(), + /// ); /// - /// return tensor.onehot( - /// depth: 3, - /// axis: Option::None(()), - /// values: array![0, 1].span() - /// ); + /// return tensor.onehot(depth: 3, axis: Option::None(()), values: array![0, 1].span()); /// } /// >>> [[1. 0. 0.] /// [0. 1. 0.] @@ -2356,26 +2134,27 @@ trait TensorTrait { /// A new `Tensor` of the same shape as the input tensor with /// the arctangent (inverse of tangent) value of all elements in the input tensor. /// + /// ## Type Constraints + /// + /// Constrain input and output types to fixed point tensors. + /// /// ## Example /// /// ```rust /// use array::{ArrayTrait, SpanTrait}; /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - /// use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; - /// use orion::numbers::fixed_point::core::{FixedType, FixedTrait, FixedImpl}; - /// use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + /// use orion::operators::tensor::{TensorTrait, Tensor, FP8x23Tensor}; + /// use orion::numbers::{FixedTrait, FP8x23}; /// - /// fn sqrt_example() -> Tensor { - /// let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - /// let tensor = TensorTrait::::new( + /// fn sqrt_example() -> Tensor { + /// let tensor = TensorTrait::::new( /// shape: array![3].span(), /// data: array![ /// FixedTrait::new_unscaled(0, false), /// FixedTrait::new_unscaled(1, false), /// FixedTrait::new_unscaled(2, false), - /// ].span(), - /// extra: Option::Some(extra) + /// ] + /// .span(), /// ); /// /// return tensor.sqrt(); @@ -2385,14 +2164,260 @@ trait TensorTrait { /// // [0,1,1.4142...] /// ``` /// - fn sqrt(self: @Tensor) -> Tensor; + fn sqrt(self: @Tensor) -> Tensor; + /// # tensor.concat + /// + /// ```rust + /// fn concat(tensors: Span>, axis: usize, ) -> Tensor; + /// ``` + /// + /// Concatenate a list of tensors into a single tensor. + /// + /// ## Args + /// + /// * `tensors`(` Span>,`) - Array of the input tensors. + /// * `axis`(`usize`) - Axis to concat on. + /// + /// ## Panics + /// + /// * Panic if tensor length is not greater than 1. + /// * Panics if dimension is not greater than axis. + /// + /// ## Returns + /// + /// A new `Tensor` concatenated tensor of the input tensors. + /// + /// ## Example + /// + /// ```rust + /// use array::{ArrayTrait, SpanTrait}; + /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; + /// + /// fn concat_example() -> Tensor { + /// let tensor1 = TensorTrait::new(shape: array![2, 2].span(), data: array![0, 1, 2, 3].span(),); + /// let tensor2 = TensorTrait::new(shape: array![2, 2].span(), data: array![0, 1, 2, 3].span(),); + /// let result = TensorTrait::concat(tensors: array![tensor1, tensor2].span(), axis: 0); + /// return result; + /// } + /// >>> [[0. 1.] + /// [2. 3.], + /// [0. 1.] + /// [2. 3.]] + /// + /// result.shape + /// >>> (4, 2) + /// + /// let result = TensorTrait::concat(tensors: array![tensor1, tensor2].span(), axis: 1); + /// return result; + /// } + /// >>> [[0. 1., 0., 1.] + /// [2. 3., 2., 3.]] + /// + /// result.shape + /// >>> (2, 4 ) + /// ``` + /// + fn concat(tensors: Span>, axis: usize,) -> Tensor; + /// # tensor.quantize_linear + /// + /// ```rust + /// fn quantize_linear(self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor) -> Tensor::; + /// ``` + /// + /// Quantizes a Tensor using linear quantization. + /// + /// The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point + /// to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, + /// and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. + /// The quantization formula is `y = saturate ((x / y_scale) + y_zero_point)`. For saturation, it saturates to `[-128, 127]`. + /// For (x / y_scale), it's rounding to the nearest even. + /// + /// ## Args + /// + /// * `self`(`@Tensor`) - The input tensor. + /// * `y_scale`(`@Tensor`) - Scale for doing quantization to get `y`. + /// * `y_zero_point`(`@Tensor`) - Zero point for doing quantization to get `y`. + /// + /// ## Returns + /// + /// A new `Tensor` with the same shape as the input tensor, containing the quantized values. + /// + /// ## Type Constraints + /// + /// u32 tensor, not supported. + /// + /// ## Examples + /// + /// ```rust + /// use array::{ArrayTrait, SpanTrait}; + /// + /// use orion::operators::tensor::{TensorTrait, Tensor, I8Tensor, I32Tensor}; + /// use orion::numbers::{i8, i32, IntegerTrait}; + /// + /// fn quantize_linear_example() -> Tensor { + /// // We instantiate a 1D Tensor here. + /// let x = TensorTrait::::new( + /// shape: array![6].span(), + /// data: array![ + /// IntegerTrait::new(0, false), + /// IntegerTrait::new(2, false), + /// IntegerTrait::new(3, false), + /// IntegerTrait::new(1000, false), + /// IntegerTrait::new(254, true), + /// IntegerTrait::new(1000, true), + /// ] + /// .span(), + /// ); + /// + /// // We instantiate the y_scale here. + /// let y_scale = TensorTrait::::new( + /// shape: array![1].span(), data: array![IntegerTrait::new(2, false)].span(), + /// ); + /// + /// // We instantiate the y_zero_point here. + /// let y_zero_point = TensorTrait::::new( + /// shape: array![1].span(), data: array![IntegerTrait::new(1, false)].span(), + /// ); + /// + /// return x.quantize_linear(@y_scale, @y_zero_point); + /// } + /// >>> [1, 2, 2, 127, -126, -128] + /// ``` + /// + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor::; + /// # tensor.dequantize_linear + /// + /// ```rust + /// fn dequantize_linear(self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor) -> Tensor::; + /// ``` + /// + /// Dequantizes a Tensor using linear dequantization. + /// + /// The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute + /// the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and + /// x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, + /// or a 1-D tensor for per-axis quantization. + /// + /// ## Args + /// + /// * `self`(`@Tensor`) - The input tensor. + /// * `x_scale`(`@Tensor`) - Scale for input `x`. + /// * `x_zero_point`(`@Tensor`) - Zero point for input `x`. + /// + /// ## Returns + /// + /// A new `Tensor` with the same shape as the input tensor, containing the dequantized values. + /// + /// ## Type Constraints + /// + /// u32 tensor, not supported. + /// + /// ## Examples + /// + /// ```rust + /// use array::{ArrayTrait, SpanTrait}; + /// + /// use orion::operators::tensor::{TensorTrait, Tensor, I8Tensor, I32Tensor}; + /// use orion::numbers::{i8, i32, IntegerTrait}; + /// + /// fn dequantize_linear_example() -> Tensor { + /// // We instantiate a 1D Tensor here. + /// let x = TensorTrait::::new( + /// shape: array![4].span(), + /// data: array![ + /// IntegerTrait::new(0, false), + /// IntegerTrait::new(3, false), + /// IntegerTrait::new(125, false), + /// IntegerTrait::new(127, false), + /// ] + /// .span(), + /// ); + /// + /// // We instantiate the x_scale here. + /// let x_scale = TensorTrait::::new( + /// shape: array![1].span(), data: array![IntegerTrait::new(2, false)].span(), + /// ); + /// + /// // We instantiate the x_zero_point here. + /// let x_zero_point = TensorTrait::::new( + /// shape: array![1].span(), data: array![IntegerTrait::new(0, false)].span(), + /// ); + /// + /// return x.dequantize_linear(@x_scale, @x_zero_point); + /// } + /// >>> [0, 6, 250, 254] + /// ``` + /// + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor::; + /// # tensor.slice + /// + /// ```rust + /// fn slice(self: @Tensor, starts: Span, ends: Span, axes: Option>, steps: Option>) -> Tensor; + /// ``` + /// + /// Produces a slice of the input tensor along multiple axes. + /// + /// ## Args + /// + /// * `self`(`@Tensor`) - Tensor of data to extract slices from. + /// * `starts`(Span) - 1-D tensor of starting indices of corresponding axis in `axes` + /// * `ends`(Span) - 1-D tensor of ending indices (exclusive) of corresponding axis in `axes` + /// * `axes`(Option>) - 1-D tensor of axes that `starts` and `ends` apply to. + /// * `steps`(Option>) - 1-D tensor of slice step of corresponding axis in `axes`. + /// + /// ## Panics + /// + /// * Panics if the length of starts is not equal to the length of ends. + /// * Panics if the length of starts is not equal to the length of axes. + /// * Panics if the length of starts is not equal to the length of steps. + /// + /// ## Returns + /// + /// A new `Tensor` slice of the input tensor. + /// + /// ## Example + /// + /// ```rust + /// use array::{ArrayTrait, SpanTrait}; + /// + /// use orion::operators::tensor::{TensorTrait, Tensor, U32Tensor}; + /// + /// fn slice_example() -> Tensor { + /// let tensor = TensorTrait::::new( + /// shape: array![2, 4].span(), + /// data: array![0, 1, 2, 3, 4, 5, 6, 7].span(), + /// ); + /// + /// return tensor.slice( + /// starts: array![0, 2].span(), + /// ends: array![2, 4].span(), + /// axis: Option::None(()), + /// steps: Option::Some(array![1, 1].span()) + /// ); + /// } + /// >>> [[2 3] + /// [6 7]] + /// ``` + /// + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor; } /// Cf: TensorTrait::new docstring -fn new_tensor(shape: Span, data: Span, extra: Option) -> Tensor { +fn new_tensor(shape: Span, data: Span) -> Tensor { check_shape::(shape, data); - Tensor:: { shape, data, extra } + Tensor:: { shape, data } } /// Cf: TensorTrait::ravel_index docstring @@ -2472,7 +2497,7 @@ fn stride(mut shape: Span) -> Span { /// Cf: TensorTrait::reshape docstring fn reshape(self: @Tensor, target_shape: Span) -> Tensor { - new_tensor(target_shape, *self.data, *self.extra) + new_tensor(target_shape, *self.data) } /// Cf: TensorTrait::at docstring @@ -2484,7 +2509,7 @@ fn at_tensor(self: @Tensor, indices: Span) -> @T { } // Return true if two tensor are equal -fn tensor_eq>(mut lhs: Tensor, mut rhs: Tensor, ) -> bool { +fn tensor_eq>(mut lhs: Tensor, mut rhs: Tensor,) -> bool { let mut is_eq = true; loop { @@ -2510,3 +2535,153 @@ fn tensor_eq>(mut lhs: Tensor, mut rhs: Tens return is_eq; } +/// Cf: TensorTrait::slice docstring +fn slice, impl TDrop: Drop>( + self: @Tensor, starts: Span, ends: Span, axes: Option>, steps: Option> +) -> Tensor { + let axes = match axes { + Option::Some(axes) => axes, + Option::None(_) => { + let mut ret: Array = ArrayTrait::new(); + let mut i: usize = 0; + let stop_i = starts.len() - 1; + loop { + ret.append(i); + if i == stop_i { + break (); + } + i += 1; + }; + ret.span() + }, + }; + let steps = match steps { + Option::Some(steps) => steps, + Option::None(_) => { + let mut ret: Array = ArrayTrait::new(); + let mut i: usize = 0; + let stop_i = starts.len() - 1; + loop { + ret.append(1); + if i == stop_i { + break (); + } + i += 1; + }; + ret.span() + }, + }; + assert(starts.len() == ends.len(), 'Ends and starts len unequal'); + assert(starts.len() == axes.len(), 'Axes and starts len unequal'); + assert(starts.len() == steps.len(), 'Steps and starts len unequal'); + + let mut is_empty: bool = false; + let mut output_shape: Array = ArrayTrait::new(); + let mut processed_starts: Array = ArrayTrait::new(); + let mut processed_ends: Array = ArrayTrait::new(); + let mut processed_steps: Array = ArrayTrait::new(); + + let mut i: usize = 0; + let stop_i = (*self.shape).len() - 1; + loop { + let (axis_index, is_found) = match axes.index_of(i) { + Option::Some(axis_index) => (axis_index, true), + Option::None(_) => (0, false), + }; + + let mut processed_params = (0, 0, 0, 0); + if is_found { + let mut start: usize = *(*self.shape).at(i); + let mut end: usize = 0; + if *starts.at(axis_index) < *(*self.shape).at(i) { + start = *starts.at(axis_index); + } + + if *(*self.shape).at(i) > *ends.at(axis_index) { + end = *ends.at(axis_index); + } + else { + end = *(*self.shape).at(i); + } + + if start >= end { + is_empty = true; + } else { + let dim = (end - start + (*steps.at(axis_index) - 1)) / *steps.at(axis_index); + + if dim == 0 { + is_empty = true; + } else { + processed_params = (start, end, *steps.at(axis_index), dim); + } + } + + } else { + processed_params = (0, *(*self.shape).at(i), 1, *(*self.shape).at(i)); + } + let (start, end, step, shape) = processed_params; + processed_starts.append(start); + processed_ends.append(end); + processed_steps.append(step); + output_shape.append(shape); + + if i == stop_i { + break (); + } + i += 1; + }; + + let mut output_data: Array = ArrayTrait::new(); + + if is_empty { + return Tensor:: {shape: output_shape.span(), data: output_data.span()}; + } + + let stop_j = (*self.data).len() - 1; + let stop_k = (*self.shape).len() - 1; + let mut j: usize = 0; + + let starts = processed_starts.span(); + let ends = processed_ends.span(); + let steps = processed_steps.span(); + loop { + let mut indices = unravel_index(j, *self.shape); + let mut is_included = false; + + let mut k: usize = 0; + loop { + let start = *(starts).at(k); + let end = *(ends).at(k); + let step = *(steps).at(k); + let index = *(indices).at(k); + + if index < start || index >= end { + is_included = false; + break (); + } + if (index - start) % step == 0 { + is_included = true; + } + else { + is_included = false; + break (); + } + + if k == stop_k { + break (); + } + k += 1; + }; + + if is_included { + output_data.append(*(*self.data).at(j)); + } + + if j == stop_j { + break (); + } + j += 1; + }; + + return Tensor:: {shape: output_shape.span(), data: output_data.span()}; +} diff --git a/src/operators/tensor/implementations.cairo b/src/operators/tensor/implementations.cairo index 821646433..a585b88a7 100644 --- a/src/operators/tensor/implementations.cairo +++ b/src/operators/tensor/implementations.cairo @@ -1,4 +1,7 @@ -mod impl_tensor_fp; -mod impl_tensor_i32; -mod impl_tensor_u32; -mod impl_tensor_i8; +mod tensor_u32; +mod tensor_i8; +mod tensor_i32; +mod tensor_fp8x23; +mod tensor_fp16x16; +mod tensor_fp64x64; +mod tensor_fp32x32; diff --git a/src/operators/tensor/implementations/impl_tensor_fp.cairo b/src/operators/tensor/implementations/impl_tensor_fp.cairo deleted file mode 100644 index bf8399ef6..000000000 --- a/src/operators/tensor/implementations/impl_tensor_fp.cairo +++ /dev/null @@ -1,398 +0,0 @@ -//! This module defines and implement a Tensor for FixedType values. - -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::FixedType; - -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, ExtraParams, TensorTrait, ravel_index, unravel_index, reshape, - at_tensor, tensor_eq -}; -use orion::operators::tensor::math::min::min_fp::core::min_in_tensor; -use orion::operators::tensor::math::max::max_fp::core::max_in_tensor; -use orion::operators::tensor::math::equal::equal_fp::core::equal; -use orion::operators::tensor::math::less::less_fp::core::less; -use orion::operators::tensor::math::less_equal::less_equal_fp::core::less_equal; -use orion::operators::tensor::math::abs::abs_fp::core::abs; -use orion::operators::tensor::math::ceil::ceil_fp::core::ceil; -use orion::operators::tensor::math::reduce_sum::reduce_sum_fp::core::reduce_sum; -use orion::operators::tensor::math::argmax::argmax_fp::core::argmax; -use orion::operators::tensor::math::argmin::argmin_fp::core::argmin; -use orion::operators::tensor::linalg::matmul::matmul_fp::core::matmul; -use orion::operators::tensor::linalg::transpose::transpose_fp::core::transpose; -use orion::operators::tensor::math::exp::exp_fp::core::exp; -use orion::operators::tensor::math::log::log_fp::core::log; -use orion::operators::tensor::math::arithmetic::arithmetic_fp::core::{add, sub, mul, div}; -use orion::operators::tensor::math::greater::greater_fp::core::greater; -use orion::operators::tensor::math::greater_equal::greater_equal_fp::core::greater_equal; -use orion::operators::tensor::math::cumsum::cumsum_fp::core::cumsum; -use orion::operators::tensor::math::flatten::flatten_fp::core::flatten; -use orion::operators::tensor::math::sinh::sinh_fp::core::sinh; -use orion::operators::tensor::math::tanh::tanh_fp::core::tanh; -use orion::operators::tensor::math::cosh::cosh_fp::core::cosh; -use orion::operators::tensor::math::acosh::acosh_fp::core::acosh; -use orion::operators::tensor::math::asinh::asinh_fp::core::asinh; -use orion::operators::tensor::math::sin::sin_fp::core::sin; -use orion::operators::tensor::math::cos::cos_fp::core::cos; -use orion::operators::tensor::math::asin::asin_fp::core::asin; -use orion::operators::tensor::math::atan::atan_fp::core::atan; -use orion::operators::tensor::math::xor::xor_fp::core::xor; -use orion::operators::tensor::math::or::or_fp::core::or; -use orion::operators::tensor::math::acos::acos_fp::core::acos; -use orion::operators::tensor::math::onehot::onehot_fp::core::onehot; -use orion::operators::tensor::math::sqrt::sqrt_fp::core::sqrt; - -impl Tensor_fp of TensorTrait { - fn new( - shape: Span, data: Span, extra: Option - ) -> Tensor { - new_tensor(shape, data, extra) - } - - fn at(self: @Tensor, indices: Span) -> FixedType { - *at_tensor(self, indices) - } - - fn min(self: @Tensor) -> FixedType { - min_in_tensor(*self.data, *self.extra).unwrap() - } - - fn max(self: @Tensor) -> FixedType { - max_in_tensor(*self.data, *self.extra).unwrap() - } - - fn stride(self: @Tensor) -> Span { - stride(*self.shape) - } - - fn ravel_index(self: @Tensor, indices: Span) -> usize { - ravel_index(*self.shape, indices) - } - - fn unravel_index(self: @Tensor, index: usize) -> Span { - unravel_index(index, *self.shape) - } - - fn reshape(self: @Tensor, target_shape: Span) -> Tensor { - reshape(self, target_shape) - } - - fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - reduce_sum(self, axis, keepdims).unwrap() - } - - fn argmax( - self: @Tensor, - axis: usize, - keepdims: Option, - select_last_index: Option - ) -> Tensor { - argmax(self, axis, keepdims, select_last_index).unwrap() - } - - fn argmin( - self: @Tensor, - axis: usize, - keepdims: Option, - select_last_index: Option - ) -> Tensor { - argmin(self, axis, keepdims, select_last_index).unwrap() - } - - fn transpose(self: @Tensor, axes: Span) -> Tensor { - transpose(self, axes).unwrap() - } - - fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - matmul(self, other).unwrap() - } - - fn exp(self: @Tensor) -> Tensor { - exp(self).unwrap() - } - - fn log(self: @Tensor) -> Tensor { - log(self).unwrap() - } - - fn equal(self: @Tensor, other: @Tensor) -> Tensor { - equal(self, other).unwrap() - } - - fn greater(self: @Tensor, other: @Tensor) -> Tensor { - greater(self, other).unwrap() - } - - fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { - greater_equal(self, other).unwrap() - } - - fn less(self: @Tensor, other: @Tensor) -> Tensor { - less(self, other).unwrap() - } - - fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { - less_equal(self, other).unwrap() - } - - fn abs(self: @Tensor) -> Tensor { - abs(*self).unwrap() - } - - fn ceil(self: @Tensor) -> Tensor { - ceil(self).unwrap() - } - - fn sin(self: @Tensor) -> Tensor { - sin(self).unwrap() - } - - fn cos(self: @Tensor) -> Tensor { - cos(self).unwrap() - } - - fn asin(self: @Tensor) -> Tensor { - asin(self).unwrap() - } - - fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option - ) -> Tensor { - cumsum(self, axis, exclusive, reverse).unwrap() - } - - fn flatten(self: @Tensor, axis: usize) -> Tensor { - flatten(self, axis).unwrap() - } - - fn sinh(self: @Tensor) -> Tensor { - sinh(self).unwrap() - } - - fn tanh(self: @Tensor) -> Tensor { - tanh(self).unwrap() - } - - fn cosh(self: @Tensor) -> Tensor { - cosh(self).unwrap() - } - - fn acosh(self: @Tensor) -> Tensor { - acosh(self).unwrap() - } - - fn asinh(self: @Tensor) -> Tensor { - asinh(self).unwrap() - } - - fn atan(self: @Tensor) -> Tensor { - atan(self).unwrap() - } - - fn xor(self: @Tensor, other: @Tensor) -> Tensor { - xor(self, other).unwrap() - } - - fn or(self: @Tensor, other: @Tensor) -> Tensor { - or(self, other).unwrap() - } - - fn acos(self: @Tensor) -> Tensor { - acos(*self).unwrap() - } - - fn onehot( - self: @Tensor, depth: usize, axis: Option, values: Span - ) -> Tensor { - onehot(self, depth, axis, values).unwrap() - } - - fn sqrt(self: @Tensor) -> Tensor { - sqrt(self).unwrap() - } -} - -/// Implements addition for `Tensor` using the `Add` trait. -impl FixedTypeTensorAdd of Add> { - /// Adds two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise addition. - fn add(lhs: Tensor, rhs: Tensor) -> Tensor { - add(@lhs, @rhs).unwrap() - } -} - -/// Implements subtraction for `Tensor` using the `Sub` trait. -impl FixedTypeTensorSub of Sub> { - /// Subtracts two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise subtraction. - fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { - sub(@lhs, @rhs).unwrap() - } -} - -/// Implements multiplication for `Tensor` using the `Mul` trait. -impl FixedTypeTensorMul of Mul> { - /// Multiplies two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise multiplication. - fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { - mul(@lhs, @rhs).unwrap() - } -} - -/// Implements division for `Tensor` using the `Div` trait. -impl FixedTypeTensorDiv of Div> { - /// Divides two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise division. - fn div(lhs: Tensor, rhs: Tensor) -> Tensor { - div(@lhs, @rhs).unwrap() - } -} - - -mod FP8x23Tensor { - use array::{ArrayTrait, SpanTrait}; - use option::OptionTrait; - use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23PartialEq, FP8x23Impl, FP8x23Sub, FP8x23Div - }; - use super::{Tensor, FixedType}; - - const PRECISION: u32 = 75497; // 0.009 - - fn relative_eq(lhs: @FixedType, rhs: @FixedType) -> bool { - let diff = *lhs - *rhs; - - let rel_diff = if *lhs.mag != 0 { - (diff / *lhs).mag - } else { - diff.mag - }; - - rel_diff <= PRECISION - } - - - fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor, ) -> bool { - let mut is_eq = true; - - loop { - if lhs.shape.len() == 0 || !is_eq { - break; - } - - is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); - }; - - if !is_eq { - return false; - } - - loop { - if lhs.data.len() == 0 || !is_eq { - break; - } - - is_eq = relative_eq(lhs.data.pop_front().unwrap(), rhs.data.pop_front().unwrap()); - }; - - return is_eq; - } - - /// Implements partial equal for two `Tensor` using the `PartialEq` trait. - impl FPTensorPartialEq of PartialEq> { - fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { - tensor_eq(*lhs, *rhs) - } - - fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { - !tensor_eq(*lhs, *rhs) - } - } -} - -mod FP16x16Tensor { - use array::{ArrayTrait, SpanTrait}; - use option::OptionTrait; - use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16PartialEq, FP16x16Impl, FP16x16Sub, FP16x16Div - }; - use super::{Tensor, FixedType}; - - const PRECISION: u32 = 589; // 0.009 - - fn relative_eq(lhs: @FixedType, rhs: @FixedType) -> bool { - let diff = *lhs - *rhs; - - let rel_diff = if *lhs.mag != 0 { - (diff / *lhs).mag - } else { - diff.mag - }; - - rel_diff <= PRECISION - } - - - fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor, ) -> bool { - let mut is_eq = true; - - loop { - if lhs.shape.len() == 0 || !is_eq { - break; - } - - is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); - }; - - if !is_eq { - return false; - } - - loop { - if lhs.data.len() == 0 || !is_eq { - break; - } - - is_eq = relative_eq(lhs.data.pop_front().unwrap(), rhs.data.pop_front().unwrap()); - }; - - return is_eq; - } - - /// Implements partial equal for two `Tensor` using the `PartialEq` trait. - impl FPTensorPartialEq of PartialEq> { - fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { - tensor_eq(*lhs, *rhs) - } - - fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { - !tensor_eq(*lhs, *rhs) - } - } -} diff --git a/src/operators/tensor/implementations/impl_tensor_i32.cairo b/src/operators/tensor/implementations/impl_tensor_i32.cairo deleted file mode 100644 index 8a2f2a545..000000000 --- a/src/operators/tensor/implementations/impl_tensor_i32.cairo +++ /dev/null @@ -1,277 +0,0 @@ -//! This module defines and implement a Tensor for i32 values. - -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::numbers::fixed_point::core::FixedType; - -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, ExtraParams, TensorTrait, ravel_index, unravel_index, reshape, - at_tensor, tensor_eq -}; -use orion::operators::tensor::math::min::min_i32::min_in_tensor; -use orion::operators::tensor::math::max::max_i32::max_in_tensor; -use orion::operators::tensor::math::reduce_sum::reduce_sum_i32::reduce_sum; -use orion::operators::tensor::math::argmax::argmax_i32::argmax; -use orion::operators::tensor::math::argmin::argmin_i32::argmin; -use orion::operators::tensor::math::equal::equal_i32::equal; -use orion::operators::tensor::math::greater::greater_i32::greater; -use orion::operators::tensor::math::greater_equal::greater_equal_i32::greater_equal; -use orion::operators::tensor::math::less::less_i32::less; -use orion::operators::tensor::math::less_equal::less_equal_i32::less_equal; -use orion::operators::tensor::math::abs::abs_i32::abs; -use orion::operators::tensor::linalg::matmul::matmul_i32::matmul; -use orion::operators::tensor::linalg::transpose::transpose_i32::transpose; -use orion::operators::tensor::math::exp::exp_i32::core::exp_i32; -use orion::operators::tensor::math::log::log_i32::core::log_i32; -use orion::operators::tensor::math::arithmetic::arithmetic_i32::{add, sub, mul, div}; -use orion::operators::tensor::math::cumsum::cumsum_i32::cumsum; -use orion::operators::tensor::math::flatten::flatten_i32::flatten; -use orion::operators::tensor::math::sinh::sinh_i32::core::sinh_i32; -use orion::operators::tensor::math::tanh::tanh_i32::core::tanh_i32; -use orion::operators::tensor::math::cosh::cosh_i32::core::cosh_i32; -use orion::operators::tensor::math::acosh::acosh_i32::core::acosh_i32; -use orion::operators::tensor::math::asinh::asinh_i32::core::asinh_i32; -use orion::operators::tensor::math::sin::sin_i32::core::sin_i32; -use orion::operators::tensor::math::cos::cos_i32::core::cos_i32; -use orion::operators::tensor::math::atan::atan_i32::core::atan_i32; -use orion::operators::tensor::math::xor::xor_i32::xor; -use orion::operators::tensor::math::or::or_i32::or; -use orion::operators::tensor::math::onehot::onehot_i32::onehot; -use orion::operators::tensor::math::sqrt::sqrt_i32::core::sqrt_i32; - -impl Tensor_i32 of TensorTrait { - fn new(shape: Span, data: Span, extra: Option) -> Tensor { - new_tensor(shape, data, extra) - } - - fn at(self: @Tensor, indices: Span) -> i32 { - *at_tensor(self, indices) - } - - fn min(self: @Tensor) -> i32 { - min_in_tensor(*self.data) - } - - fn max(self: @Tensor) -> i32 { - max_in_tensor(*self.data) - } - - fn stride(self: @Tensor) -> Span { - stride(*self.shape) - } - - fn ravel_index(self: @Tensor, indices: Span) -> usize { - ravel_index(*self.shape, indices) - } - - fn unravel_index(self: @Tensor, index: usize) -> Span { - unravel_index(index, *self.shape) - } - - fn reshape(self: @Tensor, target_shape: Span) -> Tensor { - reshape(self, target_shape) - } - - fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - reduce_sum(self, axis, keepdims) - } - - fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option - ) -> Tensor { - argmax(self, axis, keepdims, select_last_index) - } - - fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option - ) -> Tensor { - argmin(self, axis, keepdims, select_last_index) - } - - fn transpose(self: @Tensor, axes: Span) -> Tensor { - transpose(self, axes) - } - - fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - matmul(self, other) - } - - fn exp(self: @Tensor) -> Tensor { - exp_i32(self).unwrap() - } - - fn log(self: @Tensor) -> Tensor { - log_i32(self).unwrap() - } - - fn equal(self: @Tensor, other: @Tensor) -> Tensor { - equal(self, other) - } - - fn greater(self: @Tensor, other: @Tensor) -> Tensor { - greater(self, other) - } - - fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { - greater_equal(self, other) - } - - fn less(self: @Tensor, other: @Tensor) -> Tensor { - less(self, other) - } - - fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { - less_equal(self, other) - } - - fn abs(self: @Tensor) -> Tensor { - abs(*self) - } - - fn ceil(self: @Tensor) -> Tensor { - panic(array!['not supported with i32']) - } - - fn sin(self: @Tensor) -> Tensor { - sin_i32(self).unwrap() - } - - fn cos(self: @Tensor) -> Tensor { - cos_i32(self).unwrap() - } - - fn asin(self: @Tensor) -> Tensor { - panic(array!['not supported with i32']) - } - - fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option - ) -> Tensor { - cumsum(self, axis, exclusive, reverse) - } - - fn flatten(self: @Tensor, axis: usize) -> Tensor { - flatten(self, axis) - } - - fn sinh(self: @Tensor) -> Tensor { - sinh_i32(self).unwrap() - } - - fn tanh(self: @Tensor) -> Tensor { - tanh_i32(self).unwrap() - } - - fn cosh(self: @Tensor) -> Tensor { - cosh_i32(self).unwrap() - } - - fn acosh(self: @Tensor) -> Tensor { - acosh_i32(self).unwrap() - } - - fn asinh(self: @Tensor) -> Tensor { - asinh_i32(self).unwrap() - } - - fn atan(self: @Tensor) -> Tensor { - atan_i32(self).unwrap() - } - - fn xor(self: @Tensor, other: @Tensor) -> Tensor { - xor(self, other) - } - - fn or(self: @Tensor, other: @Tensor) -> Tensor { - or(self, other) - } - - fn acos(self: @Tensor) -> Tensor { - panic(array!['not supported with i32']) - } - - fn onehot( - self: @Tensor, depth: usize, axis: Option, values: Span - ) -> Tensor { - onehot(self, depth, axis, values) - } - - - fn sqrt(self: @Tensor) -> Tensor { - sqrt_i32(self).unwrap() - } -} - -/// Implements addition for `Tensor` using the `Add` trait. -impl i32TensorAdd of Add> { - /// Adds two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise addition. - fn add(lhs: Tensor, rhs: Tensor) -> Tensor { - add(@lhs, @rhs) - } -} - -/// Implements subtraction for `Tensor` using the `Sub` trait. -impl i32TensorSub of Sub> { - /// Subtracts two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise subtraction. - fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { - sub(@lhs, @rhs) - } -} - -/// Implements multiplication for `Tensor` using the `Mul` trait. -impl i32TensorMul of Mul> { - /// Multiplies two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise multiplication. - fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { - mul(@lhs, @rhs) - } -} - -/// Implements division for `Tensor` using the `Div` trait. -impl i32TensorDiv of Div> { - /// Divides two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise division. - fn div(lhs: Tensor, rhs: Tensor) -> Tensor { - div(@lhs, @rhs) - } -} - -/// Implements partial equal for two `Tensor` using the `PartialEq` trait. -impl i32TensorPartialEq of PartialEq> { - fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { - tensor_eq(*lhs, *rhs) - } - - fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { - !tensor_eq(*lhs, *rhs) - } -} diff --git a/src/operators/tensor/implementations/impl_tensor_i8.cairo b/src/operators/tensor/implementations/impl_tensor_i8.cairo deleted file mode 100644 index fceb99b33..000000000 --- a/src/operators/tensor/implementations/impl_tensor_i8.cairo +++ /dev/null @@ -1,350 +0,0 @@ -//! This module defines and implement a Tensor for i8 values. - -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::signed_integer::{i8::i8, i32::i32}; -use orion::numbers::signed_integer::i8::{i8_to_fp8x23, i8_to_fp16x16}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, ExtraParams, TensorTrait, ravel_index, unravel_index, reshape, - at_tensor, tensor_eq -}; -use orion::operators::tensor::math::min::min_i8::min_in_tensor; -use orion::operators::tensor::math::max::max_i8::max_in_tensor; -use orion::operators::tensor::math::reduce_sum::reduce_sum_i8::reduce_sum; -use orion::operators::tensor::math::argmax::argmax_i8::argmax; -use orion::operators::tensor::math::argmin::argmin_i8::argmin; -use orion::operators::tensor::math::equal::equal_i8::equal; -use orion::operators::tensor::math::greater::greater_i8::greater; -use orion::operators::tensor::math::greater_equal::greater_equal_i8::greater_equal; -use orion::operators::tensor::math::less::less_i8::less; -use orion::operators::tensor::math::less_equal::less_equal_i8::less_equal; -use orion::operators::tensor::math::abs::abs_i8::abs; -use orion::operators::tensor::linalg::matmul::matmul_i8::matmul; -use orion::operators::tensor::linalg::transpose::transpose_i8::transpose; -use orion::operators::tensor::math::exp::exp_i8::core::exp_i8; -use orion::operators::tensor::math::log::log_i8::core::log_i8; -use orion::operators::tensor::math::arithmetic::arithmetic_i8::{add, sub, mul, div}; -use orion::operators::tensor::math::cumsum::cumsum_i8::cumsum; -use orion::operators::tensor::math::flatten::flatten_i8::flatten; -use orion::operators::tensor::math::sinh::sinh_i8::core::sinh_i8; -use orion::operators::tensor::math::tanh::tanh_i8::core::tanh_i8; -use orion::operators::tensor::math::cosh::cosh_i8::core::cosh_i8; -use orion::operators::tensor::math::acosh::acosh_i8::core::acosh_i8; -use orion::operators::tensor::math::asinh::asinh_i8::core::asinh_i8; -use orion::operators::tensor::math::sin::sin_i8::core::sin_i8; -use orion::operators::tensor::math::cos::cos_i8::core::cos_i8; -use orion::operators::tensor::math::atan::atan_i8::core::atan_i8; -use orion::operators::tensor::math::xor::xor_i8::xor; -use orion::operators::tensor::math::or::or_i8::or; -use orion::operators::tensor::math::onehot::onehot_i8::onehot; -use orion::operators::tensor::math::sqrt::sqrt_i8::core::sqrt_i8; - -impl Tensor_i8 of TensorTrait { - fn new(shape: Span, data: Span, extra: Option) -> Tensor { - new_tensor(shape, data, extra) - } - - fn at(self: @Tensor, indices: Span) -> i8 { - *at_tensor(self, indices) - } - - fn min(self: @Tensor) -> i8 { - min_in_tensor(*self.data) - } - - fn max(self: @Tensor) -> i8 { - max_in_tensor(*self.data) - } - - fn stride(self: @Tensor) -> Span { - stride(*self.shape) - } - - fn ravel_index(self: @Tensor, indices: Span) -> usize { - ravel_index(*self.shape, indices) - } - - fn unravel_index(self: @Tensor, index: usize) -> Span { - unravel_index(index, *self.shape) - } - - fn reshape(self: @Tensor, target_shape: Span) -> Tensor { - reshape(self, target_shape) - } - - fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - reduce_sum(self, axis, keepdims) - } - - fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option - ) -> Tensor { - argmax(self, axis, keepdims, select_last_index) - } - - fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option - ) -> Tensor { - argmin(self, axis, keepdims, select_last_index) - } - - fn transpose(self: @Tensor, axes: Span) -> Tensor { - transpose(self, axes) - } - - fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - matmul(self, other) - } - - fn exp(self: @Tensor) -> Tensor { - exp_i8(self).unwrap() - } - - fn log(self: @Tensor) -> Tensor { - log_i8(self).unwrap() - } - - fn equal(self: @Tensor, other: @Tensor) -> Tensor { - equal(self, other) - } - - fn greater(self: @Tensor, other: @Tensor) -> Tensor { - greater(self, other) - } - - fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { - greater_equal(self, other) - } - - fn less(self: @Tensor, other: @Tensor) -> Tensor { - less(self, other) - } - - fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { - less_equal(self, other) - } - - fn abs(self: @Tensor) -> Tensor { - abs(*self) - } - - fn ceil(self: @Tensor) -> Tensor { - panic(array!['not supported with i8']) - } - - fn sin(self: @Tensor) -> Tensor { - sin_i8(self).unwrap() - } - - fn cos(self: @Tensor) -> Tensor { - cos_i8(self).unwrap() - } - - fn asin(self: @Tensor) -> Tensor { - panic(array!['not supported with i8']) - } - - fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option - ) -> Tensor { - cumsum(self, axis, exclusive, reverse) - } - - fn flatten(self: @Tensor, axis: usize) -> Tensor { - flatten(self, axis) - } - - fn sinh(self: @Tensor) -> Tensor { - sinh_i8(self).unwrap() - } - - fn tanh(self: @Tensor) -> Tensor { - tanh_i8(self).unwrap() - } - - fn cosh(self: @Tensor) -> Tensor { - cosh_i8(self).unwrap() - } - - fn acosh(self: @Tensor) -> Tensor { - acosh_i8(self).unwrap() - } - - fn asinh(self: @Tensor) -> Tensor { - asinh_i8(self).unwrap() - } - - fn atan(self: @Tensor) -> Tensor { - atan_i8(self).unwrap() - } - - fn xor(self: @Tensor, other: @Tensor) -> Tensor { - xor(self, other) - } - - fn or(self: @Tensor, other: @Tensor) -> Tensor { - or(self, other) - } - fn acos(self: @Tensor) -> Tensor { - panic(array!['not supported with i8']) - } - - fn onehot( - self: @Tensor, depth: usize, axis: Option, values: Span - ) -> Tensor { - onehot(self, depth, axis, values) - } - - fn sqrt(self: @Tensor) -> Tensor { - sqrt_i8(self).unwrap() - } -} - -/// Implements addition for `Tensor` using the `Add` trait. -impl i8TensorAdd of Add> { - /// Adds two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise addition. - fn add(lhs: Tensor, rhs: Tensor) -> Tensor { - add(@lhs, @rhs) - } -} - -/// Implements subtraction for `Tensor` using the `Sub` trait. -impl i8TensorSub of Sub> { - /// Subtracts two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise subtraction. - fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { - sub(@lhs, @rhs) - } -} - -/// Implements multiplication for `Tensor` using the `Mul` trait. -impl i8TensorMul of Mul> { - /// Multiplies two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise multiplication. - fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { - mul(@lhs, @rhs) - } -} - -/// Implements division for `Tensor` using the `Div` trait. -impl i8TensorDiv of Div> { - /// Divides two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise division. - fn div(lhs: Tensor, rhs: Tensor) -> Tensor { - div(@lhs, @rhs) - } -} - -// Implements the Into trait for i8 tensor to i32 tensor. -impl TensorI8IntoTensorI32 of Into, Tensor> { - fn into(self: Tensor) -> Tensor { - tensor_i8_to_tensor_i32(@self) - } -} - -// Implements the Into trait for i8 tensor to fp tensor. -impl TensorI8IntoTensorFP of Into, Tensor> { - fn into(self: Tensor) -> Tensor { - tensor_i8_to_tensor_fp(@self).unwrap() - } -} - -fn tensor_i8_to_tensor_i32(x: @Tensor) -> Tensor { - let mut result_data = ArrayTrait::::new(); - let mut data = *x.data; - - loop { - result_data.append((*data.pop_front().unwrap()).into()); - - if data.len() == 0 { - break (); - }; - }; - - return TensorTrait::new(*x.shape, result_data.span(), *x.extra); -} - -fn tensor_i8_to_tensor_fp(x: @Tensor) -> Option> { - match *x.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(tensor_i8_to_fp8x23(x)), - FixedImpl::FP16x16(()) => Option::Some(tensor_i8_to_fp16x16(x)), - }, - Option::None(_) => Option::Some(tensor_i8_to_fp16x16(x)), - }, - Option::None(_) => Option::Some(tensor_i8_to_fp16x16(x)), - } -} - -fn tensor_i8_to_fp8x23(x: @Tensor) -> Tensor { - let mut result_data = ArrayTrait::::new(); - let mut data = *x.data; - - loop { - result_data.append(i8_to_fp8x23(*data.pop_front().unwrap())); - - if data.len() == 0 { - break (); - }; - }; - - return TensorTrait::new(*x.shape, result_data.span(), *x.extra); -} - -fn tensor_i8_to_fp16x16(x: @Tensor) -> Tensor { - let mut result_data = ArrayTrait::::new(); - let mut data = *x.data; - - loop { - result_data.append(i8_to_fp16x16(*data.pop_front().unwrap())); - - if data.len() == 0 { - break (); - }; - }; - - return TensorTrait::new(*x.shape, result_data.span(), *x.extra); -} - -/// Implements partial equal for two `Tensor` using the `PartialEq` trait. -impl i8TensorPartialEq of PartialEq> { - fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { - tensor_eq(*lhs, *rhs) - } - - fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { - !tensor_eq(*lhs, *rhs) - } -} diff --git a/src/operators/tensor/implementations/impl_tensor_u32.cairo b/src/operators/tensor/implementations/impl_tensor_u32.cairo deleted file mode 100644 index a9b02a544..000000000 --- a/src/operators/tensor/implementations/impl_tensor_u32.cairo +++ /dev/null @@ -1,278 +0,0 @@ -//! This module defines and implement a Tensor for u32 values. - -use array::ArrayTrait; -use array::SpanTrait; -use core::option::OptionTrait; - -use orion::numbers::fixed_point::core::FixedType; - -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, TensorTrait, ExtraParams, ravel_index, unravel_index, reshape, - at_tensor, tensor_eq -}; -use orion::operators::tensor::math::min::min_u32::min_in_tensor; -use orion::operators::tensor::math::max::max_u32::max_in_tensor; -use orion::operators::tensor::math::reduce_sum::reduce_sum_u32::reduce_sum; -use orion::operators::tensor::math::argmax::argmax_u32::argmax; -use orion::operators::tensor::math::argmin::argmin_u32::argmin; -use orion::operators::tensor::linalg::matmul::matmul_u32::matmul; -use orion::operators::tensor::math::equal::equal_u32::equal; -use orion::operators::tensor::math::greater::greater_u32::greater; -use orion::operators::tensor::math::greater_equal::greater_equal_u32::greater_equal; -use orion::operators::tensor::math::less::less_u32::less; -use orion::operators::tensor::math::less_equal::less_equal_u32::less_equal; -use orion::operators::tensor::math::abs::abs_u32::abs; -use orion::operators::tensor::linalg::transpose::transpose_u32::transpose; -use orion::operators::tensor::math::exp::exp_u32::core::exp_u32; -use orion::operators::tensor::math::log::log_u32::core::log_u32; -use orion::operators::tensor::math::arithmetic::arithmetic_u32::{add, sub, mul, div}; -use orion::operators::tensor::math::cumsum::cumsum_u32::cumsum; -use orion::operators::tensor::math::flatten::flatten_u32::flatten; -use orion::operators::tensor::math::sinh::sinh_u32::core::sinh_u32; -use orion::operators::tensor::math::tanh::tanh_u32::core::tanh_u32; -use orion::operators::tensor::math::cosh::cosh_u32::core::cosh_u32; -use orion::operators::tensor::math::acosh::acosh_u32::core::acosh_u32; -use orion::operators::tensor::math::asinh::asinh_u32::core::asinh_u32; -use orion::operators::tensor::math::sin::sin_u32::core::sin_u32; -use orion::operators::tensor::math::cos::cos_u32::core::cos_u32; -use orion::operators::tensor::math::atan::atan_u32::core::atan_u32; -use orion::operators::tensor::math::xor::xor_u32::xor; -use orion::operators::tensor::math::or::or_u32::or; -use orion::operators::tensor::math::onehot::onehot_u32::onehot; -use orion::operators::tensor::math::sqrt::sqrt_u32::core::sqrt_u32; - - -impl Tensor_u32 of TensorTrait { - fn new(shape: Span, data: Span, extra: Option) -> Tensor { - new_tensor(shape, data, extra) - } - - fn at(self: @Tensor, indices: Span) -> u32 { - *at_tensor(self, indices) - } - - fn min(self: @Tensor) -> u32 { - min_in_tensor(*self.data) - } - - fn max(self: @Tensor) -> u32 { - max_in_tensor(*self.data) - } - - fn stride(self: @Tensor) -> Span { - stride(*self.shape) - } - - fn ravel_index(self: @Tensor, indices: Span) -> usize { - ravel_index(*self.shape, indices) - } - - fn unravel_index(self: @Tensor, index: usize) -> Span { - unravel_index(index, *self.shape) - } - - fn reshape(self: @Tensor, target_shape: Span) -> Tensor { - reshape(self, target_shape) - } - - fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - reduce_sum(self, axis, keepdims) - } - - fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option - ) -> Tensor { - argmax(self, axis, keepdims, select_last_index) - } - - fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option - ) -> Tensor { - argmin(self, axis, keepdims, select_last_index) - } - - fn transpose(self: @Tensor, axes: Span) -> Tensor { - transpose(self, axes) - } - - fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - matmul(self, other) - } - - fn exp(self: @Tensor) -> Tensor { - exp_u32(self).unwrap() - } - - fn log(self: @Tensor) -> Tensor { - log_u32(self).unwrap() - } - - fn equal(self: @Tensor, other: @Tensor) -> Tensor { - equal(self, other) - } - - fn greater(self: @Tensor, other: @Tensor) -> Tensor { - greater(self, other) - } - - fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { - greater_equal(self, other) - } - - fn less(self: @Tensor, other: @Tensor) -> Tensor { - less(self, other) - } - - fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { - less_equal(self, other) - } - - - fn abs(self: @Tensor) -> Tensor { - abs(self) - } - - fn ceil(self: @Tensor) -> Tensor { - panic(array!['not supported with u32']) - } - - fn sin(self: @Tensor) -> Tensor { - sin_u32(self).unwrap() - } - - fn cos(self: @Tensor) -> Tensor { - cos_u32(self).unwrap() - } - - fn asin(self: @Tensor) -> Tensor { - panic(array!['not supported with u32']) - } - - fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option - ) -> Tensor { - cumsum(self, axis, exclusive, reverse) - } - - fn flatten(self: @Tensor, axis: usize) -> Tensor { - flatten(self, axis) - } - - fn sinh(self: @Tensor) -> Tensor { - sinh_u32(self).unwrap() - } - - fn tanh(self: @Tensor) -> Tensor { - tanh_u32(self).unwrap() - } - - fn cosh(self: @Tensor) -> Tensor { - cosh_u32(self).unwrap() - } - - fn acosh(self: @Tensor) -> Tensor { - acosh_u32(self).unwrap() - } - - fn asinh(self: @Tensor) -> Tensor { - asinh_u32(self).unwrap() - } - - fn atan(self: @Tensor) -> Tensor { - atan_u32(self).unwrap() - } - - fn acos(self: @Tensor) -> Tensor { - panic(array!['not supported with u32']) - } - - fn xor(self: @Tensor, other: @Tensor) -> Tensor { - xor(self, other) - } - - fn or(self: @Tensor, other: @Tensor) -> Tensor { - or(self, other) - } - - fn onehot( - self: @Tensor, depth: usize, axis: Option, values: Span - ) -> Tensor { - onehot(self, depth, axis, values) - } - - fn sqrt(self: @Tensor) -> Tensor { - sqrt_u32(self).unwrap() - } -} - -/// Implements addition for `Tensor` using the `Add` trait. -impl u32TensorAdd of Add> { - /// Adds two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise addition. - fn add(lhs: Tensor, rhs: Tensor) -> Tensor { - add(@lhs, @rhs) - } -} - -/// Implements subtraction for `Tensor` using the `Sub` trait. -impl u32TensorSub of Sub> { - /// Subtracts two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise subtraction. - fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { - sub(@lhs, @rhs) - } -} - -/// Implements multiplication for `Tensor` using the `Mul` trait. -impl u32TensorMul of Mul> { - /// Multiplies two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise multiplication. - fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { - mul(@lhs, @rhs) - } -} - -/// Implements division for `Tensor` using the `Div` trait. -impl u32TensorDiv of Div> { - /// Divides two `Tensor` instances element-wise. - /// - /// # Arguments - /// * `lhs` - The first tensor. - /// * `rhs` - The second tensor. - /// - /// # Returns - /// * A `Tensor` instance representing the result of the element-wise division. - fn div(lhs: Tensor, rhs: Tensor) -> Tensor { - div(@lhs, @rhs) - } -} - -/// Implements partial equal for two `Tensor` using the `PartialEq` trait. -impl u32TensorPartialEq of PartialEq> { - fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { - tensor_eq(*lhs, *rhs) - } - - fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { - !tensor_eq(*lhs, *rhs) - } -} - diff --git a/src/operators/tensor/implementations/tensor_fp16x16.cairo b/src/operators/tensor/implementations/tensor_fp16x16.cairo new file mode 100644 index 000000000..5ea6494cc --- /dev/null +++ b/src/operators/tensor/implementations/tensor_fp16x16.cairo @@ -0,0 +1,347 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{TryInto, Into}; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape, at_tensor, +}; +use orion::operators::tensor::{math, linalg, quantization, core}; +use orion::numbers::{i8, NumberTrait, FP16x16}; +use orion::operators::tensor::implementations::{tensor_i8::I8Tensor, tensor_u32::U32Tensor}; + +impl FP16x16Tensor of TensorTrait { + fn new(shape: Span, data: Span) -> Tensor { + new_tensor(shape, data) + } + + fn at(self: @Tensor, indices: Span) -> FP16x16 { + *at_tensor(self, indices) + } + + fn min(self: @Tensor) -> FP16x16 { + math::min::min_in_tensor::(*self.data) + } + + fn max(self: @Tensor) -> FP16x16 { + math::max::max_in_tensor(*self.data) + } + + fn stride(self: @Tensor) -> Span { + stride(*self.shape) + } + + fn ravel_index(self: @Tensor, indices: Span) -> usize { + ravel_index(*self.shape, indices) + } + + fn unravel_index(self: @Tensor, index: usize) -> Span { + unravel_index(index, *self.shape) + } + + fn reshape(self: @Tensor, target_shape: Span) -> Tensor { + reshape(self, target_shape) + } + + fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { + math::reduce_sum::reduce_sum(self, axis, keepdims) + } + + fn argmax( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmax::argmax(self, axis, keepdims, select_last_index) + } + + fn argmin( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmin::argmin(self, axis, keepdims, select_last_index) + } + + fn transpose(self: @Tensor, axes: Span) -> Tensor { + linalg::transpose::transpose(self, axes) + } + + fn matmul(self: @Tensor, other: @Tensor) -> Tensor { + linalg::matmul::matmul(self, other) + } + + fn exp(self: @Tensor) -> Tensor { + math::exp::exp(*self) + } + + fn log(self: @Tensor) -> Tensor { + math::log::log(*self) + } + + fn equal(self: @Tensor, other: @Tensor) -> Tensor { + math::equal::equal(self, other) + } + + fn greater(self: @Tensor, other: @Tensor) -> Tensor { + math::greater::greater(self, other) + } + + fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::greater_equal::greater_equal(self, other) + } + + fn less(self: @Tensor, other: @Tensor) -> Tensor { + math::less::less(self, other) + } + + fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::less_equal::less_equal(self, other) + } + + fn abs(self: @Tensor) -> Tensor { + math::abs::abs(*self) + } + + fn ceil(self: @Tensor) -> Tensor { + math::ceil::ceil(*self) + } + + fn sin(self: @Tensor) -> Tensor { + math::sin::sin(*self) + } + + fn cos(self: @Tensor) -> Tensor { + math::cos::cos(*self) + } + + fn asin(self: @Tensor) -> Tensor { + math::asin::asin(*self) + } + + fn cumsum( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option + ) -> Tensor { + math::cumsum::cumsum(self, axis, exclusive, reverse) + } + + fn flatten(self: @Tensor, axis: usize) -> Tensor { + math::flatten::flatten(self, axis) + } + + fn sinh(self: @Tensor) -> Tensor { + math::sinh::sinh(*self) + } + + fn tanh(self: @Tensor) -> Tensor { + math::tanh::tanh(*self) + } + + fn cosh(self: @Tensor) -> Tensor { + math::cosh::cosh(*self) + } + + fn acosh(self: @Tensor) -> Tensor { + math::acosh::acosh(*self) + } + + fn asinh(self: @Tensor) -> Tensor { + math::asinh::asinh(*self) + } + + fn atan(self: @Tensor) -> Tensor { + math::atan::atan(*self) + } + + fn xor(self: @Tensor, other: @Tensor) -> Tensor { + math::xor::xor(self, other) + } + + fn or(self: @Tensor, other: @Tensor) -> Tensor { + math::or::or(self, other) + } + + fn acos(self: @Tensor) -> Tensor { + math::acos::acos(*self) + } + + fn onehot( + self: @Tensor, depth: usize, axis: Option, values: Span + ) -> Tensor { + math::onehot::onehot(self, depth, axis, values) + } + + fn sqrt(self: @Tensor) -> Tensor { + math::sqrt::sqrt(*self) + } + + fn concat(tensors: Span>, axis: usize,) -> Tensor { + math::concat::concat(tensors, axis) + } + + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor:: { + quantization::quantize_linear::quantize_linear( + self, + y_scale, + y_zero_point, + NumberTrait::new_unscaled(128, true), + NumberTrait::new_unscaled(127, false) + ) + } + + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor:: { + quantization::dequantize_linear::dequantize_linear(self, x_scale, x_zero_point) + } + + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor { + core::slice(self, starts, ends, axes, steps) + } +} + +/// Implements addition for `Tensor` using the `Add` trait. +impl FP16x16TensorAdd of Add> { + /// Adds two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise addition. + fn add(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::add(@lhs, @rhs) + } +} + +/// Implements subtraction for `Tensor` using the `Sub` trait. +impl FP16x16TensorSub of Sub> { + /// Subtracts two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise subtraction. + fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::sub(@lhs, @rhs) + } +} + +/// Implements multiplication for `Tensor` using the `Mul` trait. +impl FP16x16TensorMul of Mul> { + /// Multiplies two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise multiplication. + fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::mul(@lhs, @rhs) + } +} + +/// Implements division for `Tensor` using the `Div` trait. +impl FP16x16TensorDiv of Div> { + /// Divides two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise division. + fn div(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::div(@lhs, @rhs) + } +} + +/// Implements partial equal for two `Tensor` using the `PartialEq` trait. +impl FP16x16TensorPartialEq of PartialEq> { + fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { + tensor_eq(*lhs, *rhs) + } + + fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { + !tensor_eq(*lhs, *rhs) + } +} + +impl U32TryIntoU32 of TryInto { + fn try_into(self: u32) -> Option { + Option::Some(self) + } +} + +impl TensorI8IntoTensorFP16x16 of Into, Tensor> { + fn into(self: Tensor) -> Tensor { + tensor_i8_to_tensor_fp16x16(@self) + } +} + + +// Internals +const PRECISION: u32 = 589; // 0.009 + +fn relative_eq(lhs: @FP16x16, rhs: @FP16x16) -> bool { + let diff = *lhs - *rhs; + + let rel_diff = if *lhs.mag != 0 { + (diff / *lhs).mag + } else { + diff.mag + }; + + rel_diff <= PRECISION +} + + +fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor,) -> bool { + let mut is_eq = true; + + loop { + if lhs.shape.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); + }; + + if !is_eq { + return false; + } + + loop { + if lhs.data.len() == 0 || !is_eq { + break; + } + + is_eq = relative_eq(lhs.data.pop_front().unwrap(), rhs.data.pop_front().unwrap()); + }; + + return is_eq; +} + +fn tensor_i8_to_tensor_fp16x16(x: @Tensor) -> Tensor { + let mut result_data = ArrayTrait::::new(); + let mut data = *x.data; + + loop { + result_data.append((*data.pop_front().unwrap()).into()); + + if data.len() == 0 { + break (); + }; + }; + + return TensorTrait::new(*x.shape, result_data.span()); +} diff --git a/src/operators/tensor/implementations/tensor_fp32x32.cairo b/src/operators/tensor/implementations/tensor_fp32x32.cairo new file mode 100644 index 000000000..2c9539d7a --- /dev/null +++ b/src/operators/tensor/implementations/tensor_fp32x32.cairo @@ -0,0 +1,354 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{TryInto, Into}; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape, at_tensor, +}; +use orion::operators::tensor::{math, linalg, quantization, core}; +use orion::numbers::{i8, NumberTrait, FP32x32, FP32x32Impl}; +use orion::numbers::fixed_point::implementations::fp32x32::core::ONE; +use orion::operators::tensor::implementations::{tensor_i8::I8Tensor, tensor_u32::U32Tensor}; + +impl FP32x32Tensor of TensorTrait { + fn new(shape: Span, data: Span) -> Tensor { + new_tensor(shape, data) + } + + fn at(self: @Tensor, indices: Span) -> FP32x32 { + *at_tensor(self, indices) + } + + fn min(self: @Tensor) -> FP32x32 { + math::min::min_in_tensor::(*self.data) + } + + fn max(self: @Tensor) -> FP32x32 { + math::max::max_in_tensor(*self.data) + } + + fn stride(self: @Tensor) -> Span { + stride(*self.shape) + } + + fn ravel_index(self: @Tensor, indices: Span) -> usize { + ravel_index(*self.shape, indices) + } + + fn unravel_index(self: @Tensor, index: usize) -> Span { + unravel_index(index, *self.shape) + } + + fn reshape(self: @Tensor, target_shape: Span) -> Tensor { + reshape(self, target_shape) + } + + fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { + math::reduce_sum::reduce_sum(self, axis, keepdims) + } + + fn argmax( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmax::argmax(self, axis, keepdims, select_last_index) + } + + fn argmin( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmin::argmin(self, axis, keepdims, select_last_index) + } + + fn transpose(self: @Tensor, axes: Span) -> Tensor { + linalg::transpose::transpose(self, axes) + } + + fn matmul(self: @Tensor, other: @Tensor) -> Tensor { + linalg::matmul::matmul(self, other) + } + + fn exp(self: @Tensor) -> Tensor { + math::exp::exp(*self) + } + + fn log(self: @Tensor) -> Tensor { + math::log::log(*self) + } + + fn equal(self: @Tensor, other: @Tensor) -> Tensor { + math::equal::equal(self, other) + } + + fn greater(self: @Tensor, other: @Tensor) -> Tensor { + math::greater::greater(self, other) + } + + fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::greater_equal::greater_equal(self, other) + } + + fn less(self: @Tensor, other: @Tensor) -> Tensor { + math::less::less(self, other) + } + + fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::less_equal::less_equal(self, other) + } + + fn abs(self: @Tensor) -> Tensor { + math::abs::abs(*self) + } + + fn ceil(self: @Tensor) -> Tensor { + math::ceil::ceil(*self) + } + + fn sin(self: @Tensor) -> Tensor { + math::sin::sin(*self) + } + + fn cos(self: @Tensor) -> Tensor { + math::cos::cos(*self) + } + + fn asin(self: @Tensor) -> Tensor { + math::asin::asin(*self) + } + + fn cumsum( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option + ) -> Tensor { + math::cumsum::cumsum(self, axis, exclusive, reverse) + } + + fn flatten(self: @Tensor, axis: usize) -> Tensor { + math::flatten::flatten(self, axis) + } + + fn sinh(self: @Tensor) -> Tensor { + math::sinh::sinh(*self) + } + + fn tanh(self: @Tensor) -> Tensor { + math::tanh::tanh(*self) + } + + fn cosh(self: @Tensor) -> Tensor { + math::cosh::cosh(*self) + } + + fn acosh(self: @Tensor) -> Tensor { + math::acosh::acosh(*self) + } + + fn asinh(self: @Tensor) -> Tensor { + math::asinh::asinh(*self) + } + + fn atan(self: @Tensor) -> Tensor { + math::atan::atan(*self) + } + + fn xor(self: @Tensor, other: @Tensor) -> Tensor { + math::xor::xor(self, other) + } + + fn or(self: @Tensor, other: @Tensor) -> Tensor { + math::or::or(self, other) + } + + fn acos(self: @Tensor) -> Tensor { + math::acos::acos(*self) + } + + fn onehot( + self: @Tensor, depth: usize, axis: Option, values: Span + ) -> Tensor { + math::onehot::onehot(self, depth, axis, values) + } + + fn sqrt(self: @Tensor) -> Tensor { + math::sqrt::sqrt(*self) + } + + fn concat(tensors: Span>, axis: usize,) -> Tensor { + math::concat::concat(tensors, axis) + } + + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor:: { + quantization::quantize_linear::quantize_linear( + self, + y_scale, + y_zero_point, + NumberTrait::new_unscaled(128, true), + NumberTrait::new_unscaled(127, false) + ) + } + + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor:: { + quantization::dequantize_linear::dequantize_linear(self, x_scale, x_zero_point) + } + + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor { + core::slice(self, starts, ends, axes, steps) + } +} + +/// Implements addition for `Tensor` using the `Add` trait. +impl FP32x32TensorAdd of Add> { + /// Adds two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise addition. + fn add(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::add(@lhs, @rhs) + } +} + +/// Implements subtraction for `Tensor` using the `Sub` trait. +impl FP32x32TensorSub of Sub> { + /// Subtracts two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise subtraction. + fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::sub(@lhs, @rhs) + } +} + +/// Implements multiplication for `Tensor` using the `Mul` trait. +impl FP32x32TensorMul of Mul> { + /// Multiplies two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise multiplication. + fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::mul(@lhs, @rhs) + } +} + +/// Implements division for `Tensor` using the `Div` trait. +impl FP32x32TensorDiv of Div> { + /// Divides two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise division. + fn div(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::div(@lhs, @rhs) + } +} + +/// Implements partial equal for two `Tensor` using the `PartialEq` trait. +impl FP32x32TensorPartialEq of PartialEq> { + fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { + tensor_eq(*lhs, *rhs) + } + + fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { + !tensor_eq(*lhs, *rhs) + } +} + +impl U32TryIntoU64 of TryInto { + fn try_into(self: u32) -> Option { + Option::Some(self.into()) + } +} + +impl FP32x32TryIntoI8 of TryInto { + fn try_into(self: FP32x32) -> Option { + Option::Some(i8 { mag: (self.mag / ONE).try_into().unwrap(), sign: self.sign }) + } +} + +impl TensorI8IntoTensorFP32x32 of Into, Tensor> { + fn into(self: Tensor) -> Tensor { + tensor_i8_to_tensor_fp32x32(@self) + } +} + + +// Internals + +const PRECISION: u64 = 75497; // 0.009 + +fn relative_eq(lhs: @FP32x32, rhs: @FP32x32) -> bool { + let diff = *lhs - *rhs; + + let rel_diff = if *lhs.mag != 0 { + (diff / *lhs).mag + } else { + diff.mag + }; + + rel_diff <= PRECISION +} + +fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor,) -> bool { + let mut is_eq = true; + + loop { + if lhs.shape.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); + }; + + if !is_eq { + return false; + } + + loop { + if lhs.data.len() == 0 || !is_eq { + break; + } + + is_eq = relative_eq(lhs.data.pop_front().unwrap(), rhs.data.pop_front().unwrap()); + }; + + return is_eq; +} + +fn tensor_i8_to_tensor_fp32x32(x: @Tensor) -> Tensor { + let mut result_data = ArrayTrait::::new(); + let mut data = *x.data; + + loop { + result_data.append((*data.pop_front().unwrap()).into()); + + if data.len() == 0 { + break (); + }; + }; + + return TensorTrait::new(*x.shape, result_data.span()); +} diff --git a/src/operators/tensor/implementations/tensor_fp64x64.cairo b/src/operators/tensor/implementations/tensor_fp64x64.cairo new file mode 100644 index 000000000..24491138c --- /dev/null +++ b/src/operators/tensor/implementations/tensor_fp64x64.cairo @@ -0,0 +1,354 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{TryInto, Into}; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape, at_tensor, +}; +use orion::operators::tensor::{math, linalg, quantization, core}; +use orion::numbers::{i8, NumberTrait, FP64x64, FP64x64Impl}; +use orion::numbers::fixed_point::implementations::fp64x64::core::ONE; +use orion::operators::tensor::implementations::{tensor_i8::I8Tensor, tensor_u32::U32Tensor}; + +impl FP64x64Tensor of TensorTrait { + fn new(shape: Span, data: Span) -> Tensor { + new_tensor(shape, data) + } + + fn at(self: @Tensor, indices: Span) -> FP64x64 { + *at_tensor(self, indices) + } + + fn min(self: @Tensor) -> FP64x64 { + math::min::min_in_tensor::(*self.data) + } + + fn max(self: @Tensor) -> FP64x64 { + math::max::max_in_tensor(*self.data) + } + + fn stride(self: @Tensor) -> Span { + stride(*self.shape) + } + + fn ravel_index(self: @Tensor, indices: Span) -> usize { + ravel_index(*self.shape, indices) + } + + fn unravel_index(self: @Tensor, index: usize) -> Span { + unravel_index(index, *self.shape) + } + + fn reshape(self: @Tensor, target_shape: Span) -> Tensor { + reshape(self, target_shape) + } + + fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { + math::reduce_sum::reduce_sum(self, axis, keepdims) + } + + fn argmax( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmax::argmax(self, axis, keepdims, select_last_index) + } + + fn argmin( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmin::argmin(self, axis, keepdims, select_last_index) + } + + fn transpose(self: @Tensor, axes: Span) -> Tensor { + linalg::transpose::transpose(self, axes) + } + + fn matmul(self: @Tensor, other: @Tensor) -> Tensor { + linalg::matmul::matmul(self, other) + } + + fn exp(self: @Tensor) -> Tensor { + math::exp::exp(*self) + } + + fn log(self: @Tensor) -> Tensor { + math::log::log(*self) + } + + fn equal(self: @Tensor, other: @Tensor) -> Tensor { + math::equal::equal(self, other) + } + + fn greater(self: @Tensor, other: @Tensor) -> Tensor { + math::greater::greater(self, other) + } + + fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::greater_equal::greater_equal(self, other) + } + + fn less(self: @Tensor, other: @Tensor) -> Tensor { + math::less::less(self, other) + } + + fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::less_equal::less_equal(self, other) + } + + fn abs(self: @Tensor) -> Tensor { + math::abs::abs(*self) + } + + fn ceil(self: @Tensor) -> Tensor { + math::ceil::ceil(*self) + } + + fn sin(self: @Tensor) -> Tensor { + math::sin::sin(*self) + } + + fn cos(self: @Tensor) -> Tensor { + math::cos::cos(*self) + } + + fn asin(self: @Tensor) -> Tensor { + math::asin::asin(*self) + } + + fn cumsum( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option + ) -> Tensor { + math::cumsum::cumsum(self, axis, exclusive, reverse) + } + + fn flatten(self: @Tensor, axis: usize) -> Tensor { + math::flatten::flatten(self, axis) + } + + fn sinh(self: @Tensor) -> Tensor { + math::sinh::sinh(*self) + } + + fn tanh(self: @Tensor) -> Tensor { + math::tanh::tanh(*self) + } + + fn cosh(self: @Tensor) -> Tensor { + math::cosh::cosh(*self) + } + + fn acosh(self: @Tensor) -> Tensor { + math::acosh::acosh(*self) + } + + fn asinh(self: @Tensor) -> Tensor { + math::asinh::asinh(*self) + } + + fn atan(self: @Tensor) -> Tensor { + math::atan::atan(*self) + } + + fn xor(self: @Tensor, other: @Tensor) -> Tensor { + math::xor::xor(self, other) + } + + fn or(self: @Tensor, other: @Tensor) -> Tensor { + math::or::or(self, other) + } + + fn acos(self: @Tensor) -> Tensor { + math::acos::acos(*self) + } + + fn onehot( + self: @Tensor, depth: usize, axis: Option, values: Span + ) -> Tensor { + math::onehot::onehot(self, depth, axis, values) + } + + fn sqrt(self: @Tensor) -> Tensor { + math::sqrt::sqrt(*self) + } + + fn concat(tensors: Span>, axis: usize,) -> Tensor { + math::concat::concat(tensors, axis) + } + + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor:: { + quantization::quantize_linear::quantize_linear( + self, + y_scale, + y_zero_point, + NumberTrait::new_unscaled(128, true), + NumberTrait::new_unscaled(127, false) + ) + } + + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor:: { + quantization::dequantize_linear::dequantize_linear(self, x_scale, x_zero_point) + } + + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor { + core::slice(self, starts, ends, axes, steps) + } +} + +/// Implements addition for `Tensor` using the `Add` trait. +impl FP64x64TensorAdd of Add> { + /// Adds two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise addition. + fn add(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::add(@lhs, @rhs) + } +} + +/// Implements subtraction for `Tensor` using the `Sub` trait. +impl FP64x64TensorSub of Sub> { + /// Subtracts two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise subtraction. + fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::sub(@lhs, @rhs) + } +} + +/// Implements multiplication for `Tensor` using the `Mul` trait. +impl FP64x64TensorMul of Mul> { + /// Multiplies two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise multiplication. + fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::mul(@lhs, @rhs) + } +} + +/// Implements division for `Tensor` using the `Div` trait. +impl FP64x64TensorDiv of Div> { + /// Divides two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise division. + fn div(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::div(@lhs, @rhs) + } +} + +/// Implements partial equal for two `Tensor` using the `PartialEq` trait. +impl FP64x64TensorPartialEq of PartialEq> { + fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { + tensor_eq(*lhs, *rhs) + } + + fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { + !tensor_eq(*lhs, *rhs) + } +} + +impl U32TryIntoU128 of TryInto { + fn try_into(self: u32) -> Option { + Option::Some(self.into()) + } +} + +impl FP64x64TryIntoI8 of TryInto { + fn try_into(self: FP64x64) -> Option { + Option::Some(i8 { mag: (self.mag / ONE).try_into().unwrap(), sign: self.sign }) + } +} + +impl TensorI8IntoTensorFP64x64 of Into, Tensor> { + fn into(self: Tensor) -> Tensor { + tensor_i8_to_tensor_fp64x64(@self) + } +} + + +// Internals + +const PRECISION: u128 = 75497; // 0.009 + +fn relative_eq(lhs: @FP64x64, rhs: @FP64x64) -> bool { + let diff = *lhs - *rhs; + + let rel_diff = if *lhs.mag != 0 { + (diff / *lhs).mag + } else { + diff.mag + }; + + rel_diff <= PRECISION +} + +fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor,) -> bool { + let mut is_eq = true; + + loop { + if lhs.shape.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); + }; + + if !is_eq { + return false; + } + + loop { + if lhs.data.len() == 0 || !is_eq { + break; + } + + is_eq = relative_eq(lhs.data.pop_front().unwrap(), rhs.data.pop_front().unwrap()); + }; + + return is_eq; +} + +fn tensor_i8_to_tensor_fp64x64(x: @Tensor) -> Tensor { + let mut result_data = ArrayTrait::::new(); + let mut data = *x.data; + + loop { + result_data.append((*data.pop_front().unwrap()).into()); + + if data.len() == 0 { + break (); + }; + }; + + return TensorTrait::new(*x.shape, result_data.span()); +} diff --git a/src/operators/tensor/implementations/tensor_fp8x23.cairo b/src/operators/tensor/implementations/tensor_fp8x23.cairo new file mode 100644 index 000000000..6208a3355 --- /dev/null +++ b/src/operators/tensor/implementations/tensor_fp8x23.cairo @@ -0,0 +1,371 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{TryInto, Into}; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape, at_tensor, +}; +use orion::operators::tensor::{math, linalg, quantization, core}; +use orion::numbers::{i8, NumberTrait, FP8x23}; +use orion::operators::tensor::implementations::{tensor_i8::I8Tensor, tensor_u32::U32Tensor}; + +impl FP8x23Tensor of TensorTrait { + fn new(shape: Span, data: Span) -> Tensor { + new_tensor(shape, data) + } + + fn at(self: @Tensor, indices: Span) -> FP8x23 { + *at_tensor(self, indices) + } + + fn min(self: @Tensor) -> FP8x23 { + math::min::min_in_tensor::(*self.data) + } + + fn max(self: @Tensor) -> FP8x23 { + math::max::max_in_tensor(*self.data) + } + + fn stride(self: @Tensor) -> Span { + stride(*self.shape) + } + + fn ravel_index(self: @Tensor, indices: Span) -> usize { + ravel_index(*self.shape, indices) + } + + fn unravel_index(self: @Tensor, index: usize) -> Span { + unravel_index(index, *self.shape) + } + + fn reshape(self: @Tensor, target_shape: Span) -> Tensor { + reshape(self, target_shape) + } + + fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { + math::reduce_sum::reduce_sum(self, axis, keepdims) + } + + fn argmax( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmax::argmax(self, axis, keepdims, select_last_index) + } + + fn argmin( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmin::argmin(self, axis, keepdims, select_last_index) + } + + fn transpose(self: @Tensor, axes: Span) -> Tensor { + linalg::transpose::transpose(self, axes) + } + + fn matmul(self: @Tensor, other: @Tensor) -> Tensor { + linalg::matmul::matmul(self, other) + } + + fn exp(self: @Tensor) -> Tensor { + math::exp::exp(*self) + } + + fn log(self: @Tensor) -> Tensor { + math::log::log(*self) + } + + fn equal(self: @Tensor, other: @Tensor) -> Tensor { + math::equal::equal(self, other) + } + + fn greater(self: @Tensor, other: @Tensor) -> Tensor { + math::greater::greater(self, other) + } + + fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::greater_equal::greater_equal(self, other) + } + + fn less(self: @Tensor, other: @Tensor) -> Tensor { + math::less::less(self, other) + } + + fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::less_equal::less_equal(self, other) + } + + fn abs(self: @Tensor) -> Tensor { + math::abs::abs(*self) + } + + fn ceil(self: @Tensor) -> Tensor { + math::ceil::ceil(*self) + } + + fn sin(self: @Tensor) -> Tensor { + math::sin::sin(*self) + } + + fn cos(self: @Tensor) -> Tensor { + math::cos::cos(*self) + } + + fn asin(self: @Tensor) -> Tensor { + math::asin::asin(*self) + } + + fn cumsum( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option + ) -> Tensor { + math::cumsum::cumsum(self, axis, exclusive, reverse) + } + + fn flatten(self: @Tensor, axis: usize) -> Tensor { + math::flatten::flatten(self, axis) + } + + fn sinh(self: @Tensor) -> Tensor { + math::sinh::sinh(*self) + } + + fn tanh(self: @Tensor) -> Tensor { + math::tanh::tanh(*self) + } + + fn cosh(self: @Tensor) -> Tensor { + math::cosh::cosh(*self) + } + + fn acosh(self: @Tensor) -> Tensor { + math::acosh::acosh(*self) + } + + fn asinh(self: @Tensor) -> Tensor { + math::asinh::asinh(*self) + } + + fn atan(self: @Tensor) -> Tensor { + math::atan::atan(*self) + } + + fn xor(self: @Tensor, other: @Tensor) -> Tensor { + math::xor::xor(self, other) + } + + fn or(self: @Tensor, other: @Tensor) -> Tensor { + math::or::or(self, other) + } + + fn acos(self: @Tensor) -> Tensor { + math::acos::acos(*self) + } + + fn onehot( + self: @Tensor, depth: usize, axis: Option, values: Span + ) -> Tensor { + math::onehot::onehot(self, depth, axis, values) + } + + fn sqrt(self: @Tensor) -> Tensor { + math::sqrt::sqrt(*self) + } + + fn concat(tensors: Span>, axis: usize,) -> Tensor { + math::concat::concat(tensors, axis) + } + + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor:: { + quantization::quantize_linear::quantize_linear( + self, + y_scale, + y_zero_point, + NumberTrait::new_unscaled(128, true), + NumberTrait::new_unscaled(127, false) + ) + } + + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor:: { + quantization::dequantize_linear::dequantize_linear(self, x_scale, x_zero_point) + } + + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor { + core::slice(self, starts, ends, axes, steps) + } +} + +/// Implements addition for `Tensor` using the `Add` trait. +impl FP8x23TensorAdd< + FP8x23, + impl FP8x23Tensor: TensorTrait, + impl TAdd: Add, + impl TCopy: Copy, + impl TDrop: Drop +> of Add> { + /// Adds two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise addition. + fn add(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::add(@lhs, @rhs) + } +} + +/// Implements subtraction for `Tensor` using the `Sub` trait. +impl FP8x23TensorSub< + FP8x23, + impl FP8x23Tensor: TensorTrait, + impl TSub: Sub, + impl TCopy: Copy, + impl TDrop: Drop +> of Sub> { + /// Subtracts two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise subtraction. + fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::sub(@lhs, @rhs) + } +} + +/// Implements multiplication for `Tensor` using the `Mul` trait. +impl FP8x23TensorMul< + FP8x23, + impl FP8x23Tensor: TensorTrait, + impl TMul: Mul, + impl TCopy: Copy, + impl TDrop: Drop +> of Mul> { + /// Multiplies two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise multiplication. + fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::mul(@lhs, @rhs) + } +} + +/// Implements division for `Tensor` using the `Div` trait. +impl FP8x23TensorDiv< + FP8x23, + impl FP8x23Tensor: TensorTrait, + impl TDiv: Div, + impl TCopy: Copy, + impl TDrop: Drop +> of Div> { + /// Divides two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise division. + fn div(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::div(@lhs, @rhs) + } +} + +/// Implements partial equal for two `Tensor` using the `PartialEq` trait. +impl FP8x23TensorPartialEq of PartialEq> { + fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { + tensor_eq(*lhs, *rhs) + } + + fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { + !tensor_eq(*lhs, *rhs) + } +} + +impl U32TryIntoU32 of TryInto { + fn try_into(self: u32) -> Option { + Option::Some(self) + } +} + +impl TensorI8IntoTensorFP8x23 of Into, Tensor> { + fn into(self: Tensor) -> Tensor { + tensor_i8_to_tensor_fp8x23(@self) + } +} + + +// Internals + +const PRECISION: u32 = 75497; // 0.009 + +fn relative_eq(lhs: @FP8x23, rhs: @FP8x23) -> bool { + let diff = *lhs - *rhs; + + let rel_diff = if *lhs.mag != 0 { + (diff / *lhs).mag + } else { + diff.mag + }; + + rel_diff <= PRECISION +} + +fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor,) -> bool { + let mut is_eq = true; + + loop { + if lhs.shape.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); + }; + + if !is_eq { + return false; + } + + loop { + if lhs.data.len() == 0 || !is_eq { + break; + } + + is_eq = relative_eq(lhs.data.pop_front().unwrap(), rhs.data.pop_front().unwrap()); + }; + + return is_eq; +} + +fn tensor_i8_to_tensor_fp8x23(x: @Tensor) -> Tensor { + let mut result_data = ArrayTrait::::new(); + let mut data = *x.data; + + loop { + result_data.append((*data.pop_front().unwrap()).into()); + + if data.len() == 0 { + break (); + }; + }; + + return TensorTrait::new(*x.shape, result_data.span()); +} diff --git a/src/operators/tensor/implementations/tensor_i32.cairo b/src/operators/tensor/implementations/tensor_i32.cairo new file mode 100644 index 000000000..07e18051f --- /dev/null +++ b/src/operators/tensor/implementations/tensor_i32.cairo @@ -0,0 +1,334 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{TryInto, Into}; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape, at_tensor, +}; +use orion::operators::tensor::{math, linalg, quantization, core}; +use orion::numbers::{i32, i8, NumberTrait}; +use orion::operators::tensor::implementations::{tensor_u32::U32Tensor, tensor_i8::I8Tensor}; + + +impl I32Tensor of TensorTrait { + fn new(shape: Span, data: Span) -> Tensor { + new_tensor(shape, data) + } + + fn at(self: @Tensor, indices: Span) -> i32 { + *at_tensor(self, indices) + } + + fn min(self: @Tensor) -> i32 { + math::min::min_in_tensor::(*self.data) + } + + fn max(self: @Tensor) -> i32 { + math::max::max_in_tensor(*self.data) + } + + fn stride(self: @Tensor) -> Span { + stride(*self.shape) + } + + fn ravel_index(self: @Tensor, indices: Span) -> usize { + ravel_index(*self.shape, indices) + } + + fn unravel_index(self: @Tensor, index: usize) -> Span { + unravel_index(index, *self.shape) + } + + fn reshape(self: @Tensor, target_shape: Span) -> Tensor { + reshape(self, target_shape) + } + + fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { + math::reduce_sum::reduce_sum(self, axis, keepdims) + } + + fn argmax( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmax::argmax(self, axis, keepdims, select_last_index) + } + + fn argmin( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmin::argmin(self, axis, keepdims, select_last_index) + } + + fn transpose(self: @Tensor, axes: Span) -> Tensor { + linalg::transpose::transpose(self, axes) + } + + fn matmul(self: @Tensor, other: @Tensor) -> Tensor { + linalg::matmul::matmul(self, other) + } + + fn exp(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn log(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn equal(self: @Tensor, other: @Tensor) -> Tensor { + math::equal::equal(self, other) + } + + fn greater(self: @Tensor, other: @Tensor) -> Tensor { + math::greater::greater(self, other) + } + + fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::greater_equal::greater_equal(self, other) + } + + fn less(self: @Tensor, other: @Tensor) -> Tensor { + math::less::less(self, other) + } + + fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::less_equal::less_equal(self, other) + } + + fn abs(self: @Tensor) -> Tensor { + math::abs::abs(*self) + } + + fn ceil(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn sin(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cos(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn asin(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cumsum( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option + ) -> Tensor { + math::cumsum::cumsum(self, axis, exclusive, reverse) + } + + fn flatten(self: @Tensor, axis: usize) -> Tensor { + math::flatten::flatten(self, axis) + } + + fn sinh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn tanh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cosh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn acosh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn asinh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn atan(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn xor(self: @Tensor, other: @Tensor) -> Tensor { + math::xor::xor(self, other) + } + + fn or(self: @Tensor, other: @Tensor) -> Tensor { + math::or::or(self, other) + } + + fn acos(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn onehot( + self: @Tensor, depth: usize, axis: Option, values: Span + ) -> Tensor { + panic(array!['not supported!']) + } + + fn sqrt(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn concat(tensors: Span>, axis: usize,) -> Tensor { + math::concat::concat(tensors, axis) + } + + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor:: { + quantization::quantize_linear::quantize_linear( + self, + y_scale, + y_zero_point, + NumberTrait::new_unscaled(128, true), + NumberTrait::new_unscaled(127, false) + ) + } + + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor:: { + quantization::dequantize_linear::dequantize_linear(self, x_scale, x_zero_point) + } + + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor { + core::slice(self, starts, ends, axes, steps) + } +} + +/// Implements addition for `Tensor` using the `Add` trait. +impl I32TensorAdd of Add> { + /// Adds two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise addition. + fn add(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::add(@lhs, @rhs) + } +} + +/// Implements subtraction for `Tensor` using the `Sub` trait. +impl I32TensorSub of Sub> { + /// Subtracts two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise subtraction. + fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::sub(@lhs, @rhs) + } +} + +/// Implements multiplication for `Tensor` using the `Mul` trait. +impl I32TensorMul of Mul> { + /// Multiplies two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise multiplication. + fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::mul(@lhs, @rhs) + } +} + +/// Implements division for `Tensor` using the `Div` trait. +impl I32TensorDiv of Div> { + /// Divides two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise division. + fn div(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::div(@lhs, @rhs) + } +} + +/// Implements partial equal for two `Tensor` using the `PartialEq` trait. +impl I32TensorPartialEq of PartialEq> { + fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { + tensor_eq(*lhs, *rhs) + } + + fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { + !tensor_eq(*lhs, *rhs) + } +} + +impl I8TryIntoI8 of TryInto { + fn try_into(self: i32) -> Option { + Option::Some(self) + } +} + +impl TensorI8IntoTensorI32 of Into, Tensor> { + fn into(self: Tensor) -> Tensor { + tensor_i8_to_tensor_i32(@self) + } +} + + +// Internals + +fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor,) -> bool { + let mut is_eq = true; + + loop { + if lhs.shape.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); + }; + + if !is_eq { + return false; + } + + loop { + if lhs.data.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.data.pop_front().unwrap() == rhs.data.pop_front().unwrap(); + }; + + return is_eq; +} + +fn tensor_i8_to_tensor_i32(x: @Tensor) -> Tensor { + let mut result_data = ArrayTrait::::new(); + let mut data = *x.data; + + loop { + result_data.append((*data.pop_front().unwrap()).into()); + + if data.len() == 0 { + break (); + }; + }; + + return TensorTrait::new(*x.shape, result_data.span()); +} diff --git a/src/operators/tensor/implementations/tensor_i8.cairo b/src/operators/tensor/implementations/tensor_i8.cairo new file mode 100644 index 000000000..b83a7221e --- /dev/null +++ b/src/operators/tensor/implementations/tensor_i8.cairo @@ -0,0 +1,314 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{TryInto, Into}; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape, at_tensor, +}; +use orion::operators::tensor::{math, linalg, quantization, core}; +use orion::numbers::{i8, NumberTrait}; +use orion::operators::tensor::implementations::tensor_u32::U32Tensor; + +impl I8Tensor of TensorTrait { + fn new(shape: Span, data: Span) -> Tensor { + new_tensor(shape, data) + } + + fn at(self: @Tensor, indices: Span) -> i8 { + *at_tensor(self, indices) + } + + fn min(self: @Tensor) -> i8 { + math::min::min_in_tensor::(*self.data) + } + + fn max(self: @Tensor) -> i8 { + math::max::max_in_tensor(*self.data) + } + + fn stride(self: @Tensor) -> Span { + stride(*self.shape) + } + + fn ravel_index(self: @Tensor, indices: Span) -> usize { + ravel_index(*self.shape, indices) + } + + fn unravel_index(self: @Tensor, index: usize) -> Span { + unravel_index(index, *self.shape) + } + + fn reshape(self: @Tensor, target_shape: Span) -> Tensor { + reshape(self, target_shape) + } + + fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { + math::reduce_sum::reduce_sum(self, axis, keepdims) + } + + fn argmax( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmax::argmax(self, axis, keepdims, select_last_index) + } + + fn argmin( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmin::argmin(self, axis, keepdims, select_last_index) + } + + fn transpose(self: @Tensor, axes: Span) -> Tensor { + linalg::transpose::transpose(self, axes) + } + + fn matmul(self: @Tensor, other: @Tensor) -> Tensor { + linalg::matmul::matmul(self, other) + } + + fn exp(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn log(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn equal(self: @Tensor, other: @Tensor) -> Tensor { + math::equal::equal(self, other) + } + + fn greater(self: @Tensor, other: @Tensor) -> Tensor { + math::greater::greater(self, other) + } + + fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::greater_equal::greater_equal(self, other) + } + + fn less(self: @Tensor, other: @Tensor) -> Tensor { + math::less::less(self, other) + } + + fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::less_equal::less_equal(self, other) + } + + fn abs(self: @Tensor) -> Tensor { + math::abs::abs(*self) + } + + fn ceil(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn sin(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cos(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn asin(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cumsum( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option + ) -> Tensor { + math::cumsum::cumsum(self, axis, exclusive, reverse) + } + + fn flatten(self: @Tensor, axis: usize) -> Tensor { + math::flatten::flatten(self, axis) + } + + fn sinh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn tanh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cosh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn acosh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn asinh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn atan(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn xor(self: @Tensor, other: @Tensor) -> Tensor { + math::xor::xor(self, other) + } + + fn or(self: @Tensor, other: @Tensor) -> Tensor { + math::or::or(self, other) + } + + fn acos(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn onehot( + self: @Tensor, depth: usize, axis: Option, values: Span + ) -> Tensor { + panic(array!['not supported!']) + } + + fn sqrt(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn concat(tensors: Span>, axis: usize,) -> Tensor { + math::concat::concat(tensors, axis) + } + + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor:: { + quantization::quantize_linear::quantize_linear( + self, + y_scale, + y_zero_point, + NumberTrait::new_unscaled(128, true), + NumberTrait::new_unscaled(127, false) + ) + } + + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor:: { + quantization::dequantize_linear::dequantize_linear(self, x_scale, x_zero_point) + } + + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor { + core::slice(self, starts, ends, axes, steps) + } + +} + +/// Implements addition for `Tensor` using the `Add` trait. +impl I8TensorAdd of Add> { + /// Adds two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise addition. + fn add(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::add(@lhs, @rhs) + } +} + +/// Implements subtraction for `Tensor` using the `Sub` trait. +impl I8TensorSub of Sub> { + /// Subtracts two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise subtraction. + fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::sub(@lhs, @rhs) + } +} + +/// Implements multiplication for `Tensor` using the `Mul` trait. +impl I8TensorMul of Mul> { + /// Multiplies two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise multiplication. + fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::mul(@lhs, @rhs) + } +} + +/// Implements division for `Tensor` using the `Div` trait. +impl I8TensorDiv of Div> { + /// Divides two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise division. + fn div(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::div(@lhs, @rhs) + } +} + +/// Implements partial equal for two `Tensor` using the `PartialEq` trait. +impl I8TensorPartialEq of PartialEq> { + fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { + tensor_eq(*lhs, *rhs) + } + + fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { + !tensor_eq(*lhs, *rhs) + } +} + +impl I8TryIntoI8 of TryInto { + fn try_into(self: i8) -> Option { + Option::Some(self) + } +} + +// Internals + +fn tensor_eq( + mut lhs: Tensor, mut rhs: Tensor, +) -> bool { + let mut is_eq = true; + + loop { + if lhs.shape.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); + }; + + if !is_eq { + return false; + } + + loop { + if lhs.data.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.data.pop_front().unwrap() == rhs.data.pop_front().unwrap(); + }; + + return is_eq; +} diff --git a/src/operators/tensor/implementations/tensor_u32.cairo b/src/operators/tensor/implementations/tensor_u32.cairo new file mode 100644 index 000000000..2773d561a --- /dev/null +++ b/src/operators/tensor/implementations/tensor_u32.cairo @@ -0,0 +1,306 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{TryInto, Into}; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape, at_tensor, +}; +use orion::operators::tensor::{math, linalg, quantization, core}; +use orion::numbers::{i8, NumberTrait}; +use orion::operators::tensor::implementations::tensor_i8::I8Tensor; + +impl U32Tensor of TensorTrait { + fn new(shape: Span, data: Span) -> Tensor { + new_tensor(shape, data) + } + + fn at(self: @Tensor, indices: Span) -> u32 { + *at_tensor(self, indices) + } + + fn min(self: @Tensor) -> u32 { + math::min::min_in_tensor::(*self.data) + } + + fn max(self: @Tensor) -> u32 { + math::max::max_in_tensor(*self.data) + } + + fn stride(self: @Tensor) -> Span { + stride(*self.shape) + } + + fn ravel_index(self: @Tensor, indices: Span) -> usize { + ravel_index(*self.shape, indices) + } + + fn unravel_index(self: @Tensor, index: usize) -> Span { + unravel_index(index, *self.shape) + } + + fn reshape(self: @Tensor, target_shape: Span) -> Tensor { + reshape(self, target_shape) + } + + fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { + math::reduce_sum::reduce_sum(self, axis, keepdims) + } + + fn argmax( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmax::argmax(self, axis, keepdims, select_last_index) + } + + fn argmin( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option + ) -> Tensor { + math::argmin::argmin(self, axis, keepdims, select_last_index) + } + + fn transpose(self: @Tensor, axes: Span) -> Tensor { + linalg::transpose::transpose(self, axes) + } + + fn matmul(self: @Tensor, other: @Tensor) -> Tensor { + linalg::matmul::matmul(self, other) + } + + fn exp(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn log(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn equal(self: @Tensor, other: @Tensor) -> Tensor { + math::equal::equal(self, other) + } + + fn greater(self: @Tensor, other: @Tensor) -> Tensor { + math::greater::greater(self, other) + } + + fn greater_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::greater_equal::greater_equal(self, other) + } + + fn less(self: @Tensor, other: @Tensor) -> Tensor { + math::less::less(self, other) + } + + fn less_equal(self: @Tensor, other: @Tensor) -> Tensor { + math::less_equal::less_equal(self, other) + } + + fn abs(self: @Tensor) -> Tensor { + math::abs::abs(*self) + } + + fn ceil(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn sin(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cos(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn asin(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cumsum( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option + ) -> Tensor { + math::cumsum::cumsum(self, axis, exclusive, reverse) + } + + fn flatten(self: @Tensor, axis: usize) -> Tensor { + math::flatten::flatten(self, axis) + } + + fn sinh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn tanh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn cosh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn acosh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn asinh(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn atan(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn xor(self: @Tensor, other: @Tensor) -> Tensor { + math::xor::xor(self, other) + } + + fn or(self: @Tensor, other: @Tensor) -> Tensor { + math::or::or(self, other) + } + + fn acos(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn onehot( + self: @Tensor, depth: usize, axis: Option, values: Span + ) -> Tensor { + panic(array!['not supported!']) + } + + fn sqrt(self: @Tensor) -> Tensor { + panic(array!['not supported!']) + } + + fn concat(tensors: Span>, axis: usize,) -> Tensor { + math::concat::concat(tensors, axis) + } + + fn quantize_linear( + self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor + ) -> Tensor:: { + panic(array!['not supported!']) + } + + fn dequantize_linear( + self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor + ) -> Tensor:: { + panic(array!['not supported!']) + } + + fn slice( + self: @Tensor, + starts: Span, + ends: Span, + axes: Option>, + steps: Option> + ) -> Tensor { + core::slice(self, starts, ends, axes, steps) + } +} + +/// Implements addition for `Tensor` using the `Add` trait. +impl U32TensorAdd of Add> { + /// Adds two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise addition. + fn add(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::add(@lhs, @rhs) + } +} + +/// Implements subtraction for `Tensor` using the `Sub` trait. +impl U32TensorSub of Sub> { + /// Subtracts two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise subtraction. + fn sub(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::sub(@lhs, @rhs) + } +} + +/// Implements multiplication for `Tensor` using the `Mul` trait. +impl U32TensorMul of Mul> { + /// Multiplies two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise multiplication. + fn mul(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::mul(@lhs, @rhs) + } +} + +/// Implements division for `Tensor` using the `Div` trait. +impl U32TensorDiv of Div> { + /// Divides two `Tensor` instances element-wise. + /// + /// # Arguments + /// * `lhs` - The first tensor. + /// * `rhs` - The second tensor. + /// + /// # Returns + /// * A `Tensor` instance representing the result of the element-wise division. + fn div(lhs: Tensor, rhs: Tensor) -> Tensor { + math::arithmetic::div(@lhs, @rhs) + } +} + +/// Implements partial equal for two `Tensor` using the `PartialEq` trait. +impl U32TensorPartialEq of PartialEq> { + fn eq(lhs: @Tensor, rhs: @Tensor) -> bool { + tensor_eq(*lhs, *rhs) + } + + fn ne(lhs: @Tensor, rhs: @Tensor) -> bool { + !tensor_eq(*lhs, *rhs) + } +} + + +impl U32TryIntoI8 of TryInto { + fn try_into(self: u32) -> Option { + Option::Some(i8 { mag: self.try_into().unwrap(), sign: false }) + } +} + +// Internals + +fn tensor_eq(mut lhs: Tensor, mut rhs: Tensor,) -> bool { + let mut is_eq = true; + + loop { + if lhs.shape.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.shape.pop_front().unwrap() == rhs.shape.pop_front().unwrap(); + }; + + if !is_eq { + return false; + } + + loop { + if lhs.data.len() == 0 || !is_eq { + break; + } + + is_eq = lhs.data.pop_front().unwrap() == rhs.data.pop_front().unwrap(); + }; + + return is_eq; +} diff --git a/src/operators/tensor/linalg/matmul.cairo b/src/operators/tensor/linalg/matmul.cairo index 4905beeca..ca72ba74a 100644 --- a/src/operators/tensor/linalg/matmul.cairo +++ b/src/operators/tensor/linalg/matmul.cairo @@ -1,5 +1,251 @@ -mod matmul_i8; -mod matmul_i32; -mod matmul_u32; -mod matmul_fp; -mod helpers; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::NumberTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: TensorTrait::matmul docstring +fn matmul< + T, + MAG, + impl TTensor: TensorTrait, + impl TNumber: NumberTrait, + impl TMul: Mul, + impl TAddEq: AddEq, + impl TCopy: Copy, + impl TDrop: Drop +>( + self: @Tensor, other: @Tensor +) -> Tensor { + let self_shape = *self.shape; + let other_shape = *other.shape; + 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'); + + //! Case: Both tensors are 1-dimensional + if self_ndim == 1 && other_ndim == 1 { + let dot = dot_product((*self).data, (*other).data); + let mut result_shape = ArrayTrait::new(); + let mut result_data = ArrayTrait::new(); + result_shape.append(1); + 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); + + 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); + + return TensorTrait::new(result_shape, result.data); +} + +/// Computes the dot product of two 1-dimensional i32 tensors. +/// +/// # Arguments +/// * `vec1` - A span containing the data elements of the first vector as i32 elements. +/// * `vec2` - A span containing the data elements of the second vector as i32 elements. +/// +/// # Panics +/// * Panics if the lengths of the vectors do not match. +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * An i32 representing the dot product of the two vectors. +fn dot_product< + T, + MAG, + impl TNumber: NumberTrait, + impl TMul: Mul, + impl TAddEq: AddEq, + impl TCopy: Copy, + impl TDrop: Drop +>( + mut vec1: Span, mut vec2: Span +) -> T { + assert(vec1.len() == vec2.len(), 'vector lengths do not match'); + + let mut result: T = NumberTrait::zero(); + + loop { + match vec1.pop_front() { + Option::Some(vec1_item) => { + let element_product = *vec1_item * *vec2.pop_front().unwrap(); + result += element_product; + }, + Option::None(_) => { + break; + } + }; + }; + + return result; +} + + +/// Computes the matrix multiplication of two 2-dimensional i32 tensors. +/// +/// # Arguments +/// * `mat1` - A Span containing the data elements of the first matrix as i32 elements. +/// * `mat1_shape` - A Span containing the shape of the first matrix as usize elements. +/// * `mat2` - A Span containing the data elements of the second matrix as i32 elements. +/// * `mat2_shape` - A Span containing the shape of the second matrix as usize elements. +/// +/// # Panics +/// * Panics if the inner dimensions of the matrices do not match. +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * Returns the restulting i32 tensor. +fn matrix_multiply< + 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 m = *mat1_shape[0]; + let n = *mat1_shape[1]; + let p = *mat2_shape[1]; + + let mut result_data = ArrayTrait::new(); + let mut result_shape = ArrayTrait::new(); + result_shape.append(m); + result_shape.append(p); + + let mut i = 0_usize; + loop { + if i == m { + break (); + } + + let mut j = 0_usize; + loop { + if j == p { + break (); + } + + let mut sum: T = NumberTrait::zero(); + let mut k = 0_usize; + loop { + if k == n { + break (); + } + + let mat1_index = 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; + }; + + return TensorTrait::new(result_shape.span(), result_data.span()); +} + +/// Prepares the shape of a tensor for matrix multiplication. +/// +/// # Arguments +/// * `shape` - A mutable span representing the shape of the tensor. +/// * `is_first_tensor` - A boolean indicating whether the input tensor is the first (left) +/// tensor in the matrix multiplication operation. +/// +/// # Behavior +/// This function adjusts the shapes of the tensors based on their dimensionality: +/// * If the first tensor is 1-dimensional, a 1 is prepended to its shape. +/// * If the second tensor is 1-dimensional, a 1 is appended to its shape. +/// +/// # Panics +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * A span representing the adjusted shape of the tensor. +fn prepare_shape_for_matmul(mut shape: Span, is_first_tensor: bool) -> Span { + let ndim = shape.len(); + + if ndim == 1 && is_first_tensor { + // Prepend 1 to shape if it's 1-dimensional + let mut shape_adjusted = ArrayTrait::new(); + shape_adjusted.append(1); + + loop { + match shape.pop_front() { + Option::Some(item) => { + shape_adjusted.append(*item); + }, + Option::None(_) => { + break; + } + }; + }; + + return shape_adjusted.span(); + } else if ndim == 1 && !is_first_tensor { + // Append 1 to shape if it's 1-dimensional + let mut shape_adjusted = ArrayTrait::new(); + + loop { + match shape.pop_front() { + Option::Some(item) => { + shape_adjusted.append(*item); + }, + Option::None(_) => { + break; + } + }; + }; + + shape_adjusted.append(1); + + return shape_adjusted.span(); + } + + return shape; +} + +/// Adjusts the output shape of the matrix multiplication result based on the +/// original dimensionality of the input tensors. +/// +/// # Arguments +/// * `output_shape` - A mutable span representing the shape of the matrix multiplication result. +/// * `self_dim` - A usize representing the dimensionality of the first input tensor. +/// * `other_dim` - A usize representing the dimensionality of the second input tensor. +/// +/// # Behavior +/// This function adjusts the output shape based on the dimensionality of the input tensors: +/// * If the first input tensor was 1-dimensional, the prepended 1 is removed from the output shape. +/// * If the second input tensor was 1-dimensional, the appended 1 is removed from the output shape. +/// +/// # Returns +/// * A span representing the adjusted output shape of the matrix multiplication result. +fn adjust_output_shape_after_matmul( + mut output_shape: Span, self_dim: usize, other_dim: usize +) -> Span { + // If self_shape was 1-dimensional, remove the prepended 1 from the output_shape. + if self_dim == 1 { + let _ = output_shape.pop_front().unwrap(); + } + + // If other_shape was 1-dimensional, remove the appended 1 from the output_shape. + if other_dim == 1 { + let _ = output_shape.pop_back().unwrap(); + } + + return output_shape; +} diff --git a/src/operators/tensor/linalg/matmul/helpers.cairo b/src/operators/tensor/linalg/matmul/helpers.cairo deleted file mode 100644 index 60cf1167b..000000000 --- a/src/operators/tensor/linalg/matmul/helpers.cairo +++ /dev/null @@ -1,95 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - - -/// Prepares the shape of a tensor for matrix multiplication. -/// -/// # Arguments -/// * `shape` - A mutable span representing the shape of the tensor. -/// * `is_first_tensor` - A boolean indicating whether the input tensor is the first (left) -/// tensor in the matrix multiplication operation. -/// -/// # Behavior -/// This function adjusts the shapes of the tensors based on their dimensionality: -/// * If the first tensor is 1-dimensional, a 1 is prepended to its shape. -/// * If the second tensor is 1-dimensional, a 1 is appended to its shape. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A span representing the adjusted shape of the tensor. -fn prepare_shape_for_matmul(mut shape: Span, is_first_tensor: bool) -> Span { - let ndim = shape.len(); - - if ndim == 1 && is_first_tensor { - // Prepend 1 to shape if it's 1-dimensional - let mut shape_adjusted = ArrayTrait::new(); - shape_adjusted.append(1); - - loop { - match shape.pop_front() { - Option::Some(item) => { - shape_adjusted.append(*item); - }, - Option::None(_) => { - break; - } - }; - }; - - return shape_adjusted.span(); - } else if ndim == 1 && !is_first_tensor { - // Append 1 to shape if it's 1-dimensional - let mut shape_adjusted = ArrayTrait::new(); - - loop { - match shape.pop_front() { - Option::Some(item) => { - shape_adjusted.append(*item); - }, - Option::None(_) => { - break; - } - }; - }; - - shape_adjusted.append(1); - - return shape_adjusted.span(); - } - - return shape; -} - -/// Adjusts the output shape of the matrix multiplication result based on the -/// original dimensionality of the input tensors. -/// -/// # Arguments -/// * `output_shape` - A mutable span representing the shape of the matrix multiplication result. -/// * `self_dim` - A usize representing the dimensionality of the first input tensor. -/// * `other_dim` - A usize representing the dimensionality of the second input tensor. -/// -/// # Behavior -/// This function adjusts the output shape based on the dimensionality of the input tensors: -/// * If the first input tensor was 1-dimensional, the prepended 1 is removed from the output shape. -/// * If the second input tensor was 1-dimensional, the appended 1 is removed from the output shape. -/// -/// # Returns -/// * A span representing the adjusted output shape of the matrix multiplication result. -fn adjust_output_shape_after_matmul( - mut output_shape: Span, self_dim: usize, other_dim: usize -) -> Span { - // If self_shape was 1-dimensional, remove the prepended 1 from the output_shape. - if self_dim == 1 { - let _ = output_shape.pop_front().unwrap(); - } - - // If other_shape was 1-dimensional, remove the appended 1 from the output_shape. - if other_dim == 1 { - let _ = output_shape.pop_back().unwrap(); - } - - return output_shape; -} diff --git a/src/operators/tensor/linalg/matmul/matmul_fp.cairo b/src/operators/tensor/linalg/matmul/matmul_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/linalg/matmul/matmul_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/linalg/matmul/matmul_fp/core.cairo b/src/operators/tensor/linalg/matmul/matmul_fp/core.cairo deleted file mode 100644 index 4a1c3fa41..000000000 --- a/src/operators/tensor/linalg/matmul/matmul_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::linalg::matmul::matmul_fp::fp8x23; -use orion::operators::tensor::linalg::matmul::matmul_fp::fp16x16; - -/// Cf: TensorTrait::matmul docstring -fn matmul(self: @Tensor, other: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::matmul(self, other)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::matmul(self, other)), - }, - Option::None(_) => Option::Some((fp16x16::matmul(self, other))), - }, - Option::None(_) => Option::Some((fp16x16::matmul(self, other))), - } -} diff --git a/src/operators/tensor/linalg/matmul/matmul_fp/fp16x16.cairo b/src/operators/tensor/linalg/matmul/matmul_fp/fp16x16.cairo deleted file mode 100644 index 84168b030..000000000 --- a/src/operators/tensor/linalg/matmul/matmul_fp/fp16x16.cairo +++ /dev/null @@ -1,138 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - - -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Mul, FP16x16AddEq -}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, ExtraParams, TensorTrait}; -use orion::operators::tensor::linalg::matmul::helpers::{ - prepare_shape_for_matmul, adjust_output_shape_after_matmul -}; - -/// Cf: TensorTrait::matmul docstring -fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - let self_shape = *self.shape; - let other_shape = *other.shape; - 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'); - - //! Case: Both tensors are 1-dimensional - if self_ndim == 1 && other_ndim == 1 { - let dot = dot_product((*self).data, (*other).data); - let mut result_shape = ArrayTrait::new(); - let mut result_data = ArrayTrait::new(); - result_shape.append(1); - result_data.append(dot); - return TensorTrait::::new(result_shape.span(), result_data.span(), *self.extra); - } - - 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_shape = adjust_output_shape_after_matmul(result.shape, self_ndim, other_ndim); - - return TensorTrait::new(result_shape, result.data, *self.extra); -} - -/// Computes the dot product of two 1-dimensional FixedType tensors. -/// -/// # Arguments -/// * `vec1` - A span containing the data elements of the first vector as FixedType elements. -/// * `vec2` - A span containing the data elements of the second vector as FixedType elements. -/// -/// # Panics -/// * Panics if the lengths of the vectors do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An FixedType representing the dot product of the two vectors. -fn dot_product(mut vec1: Span, mut vec2: Span) -> FixedType { - assert(vec1.len() == vec2.len(), 'vector lengths do not match'); - - let mut result: FixedType = FixedTrait::new_unscaled(0, false); - - loop { - match vec1.pop_front() { - Option::Some(vec1_item) => { - let element_product = *vec1_item * *vec2.pop_front().unwrap(); - result += element_product; - }, - Option::None(_) => { - break; - } - }; - }; - - return result; -} - - -/// Computes the matrix multiplication of two 2-dimensional FixedType tensors. -/// -/// # Arguments -/// * `mat1` - A Span containing the data elements of the first matrix as FixedType elements. -/// * `mat1_shape` - A Span containing the shape of the first matrix as usize elements. -/// * `mat2` - A Span containing the data elements of the second matrix as FixedType elements. -/// * `mat2_shape` - A Span containing the shape of the second matrix as usize elements. -/// -/// # Panics -/// * Panics if the inner dimensions of the matrices do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * Returns the restulting FixedType tensor. -fn matrix_multiply( - mat1: Span, mat1_shape: Span, mat2: Span, mat2_shape: Span -) -> Tensor { - let m = *mat1_shape[0]; - let n = *mat1_shape[1]; - let p = *mat2_shape[1]; - - let mut result_data = ArrayTrait::new(); - let mut result_shape = ArrayTrait::new(); - result_shape.append(m); - result_shape.append(p); - - let mut i = 0_usize; - loop { - if i == m { - break (); - } - - let mut j = 0_usize; - loop { - if j == p { - break (); - } - - let mut sum: FixedType = FixedTrait::new_unscaled(0, false); - let mut k = 0_usize; - loop { - if k == n { - break (); - } - - let mat1_index = 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; - }; - - return TensorTrait::new(result_shape.span(), result_data.span(), Option::None(())); -} diff --git a/src/operators/tensor/linalg/matmul/matmul_fp/fp8x23.cairo b/src/operators/tensor/linalg/matmul/matmul_fp/fp8x23.cairo deleted file mode 100644 index 6588aebad..000000000 --- a/src/operators/tensor/linalg/matmul/matmul_fp/fp8x23.cairo +++ /dev/null @@ -1,138 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - - -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23Mul, FP8x23AddEq -}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, ExtraParams, TensorTrait}; -use orion::operators::tensor::linalg::matmul::helpers::{ - prepare_shape_for_matmul, adjust_output_shape_after_matmul -}; - -/// Cf: TensorTrait::matmul docstring -fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - let self_shape = *self.shape; - let other_shape = *other.shape; - 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'); - - //! Case: Both tensors are 1-dimensional - if self_ndim == 1 && other_ndim == 1 { - let dot = dot_product((*self).data, (*other).data); - let mut result_shape = ArrayTrait::new(); - let mut result_data = ArrayTrait::new(); - result_shape.append(1); - result_data.append(dot); - return TensorTrait::::new(result_shape.span(), result_data.span(), *self.extra); - } - - 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_shape = adjust_output_shape_after_matmul(result.shape, self_ndim, other_ndim); - - return TensorTrait::new(result_shape, result.data, *self.extra); -} - -/// Computes the dot product of two 1-dimensional FixedType tensors. -/// -/// # Arguments -/// * `vec1` - A span containing the data elements of the first vector as FixedType elements. -/// * `vec2` - A span containing the data elements of the second vector as FixedType elements. -/// -/// # Panics -/// * Panics if the lengths of the vectors do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An FixedType representing the dot product of the two vectors. -fn dot_product(mut vec1: Span, mut vec2: Span) -> FixedType { - assert(vec1.len() == vec2.len(), 'vector lengths do not match'); - - let mut result: FixedType = FixedTrait::new_unscaled(0, false); - - loop { - match vec1.pop_front() { - Option::Some(vec1_item) => { - let element_product = *vec1_item * *vec2.pop_front().unwrap(); - result += element_product; - }, - Option::None(_) => { - break; - } - }; - }; - - return result; -} - - -/// Computes the matrix multiplication of two 2-dimensional FixedType tensors. -/// -/// # Arguments -/// * `mat1` - A Span containing the data elements of the first matrix as FixedType elements. -/// * `mat1_shape` - A Span containing the shape of the first matrix as usize elements. -/// * `mat2` - A Span containing the data elements of the second matrix as FixedType elements. -/// * `mat2_shape` - A Span containing the shape of the second matrix as usize elements. -/// -/// # Panics -/// * Panics if the inner dimensions of the matrices do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * Returns the restulting FixedType tensor. -fn matrix_multiply( - mat1: Span, mat1_shape: Span, mat2: Span, mat2_shape: Span -) -> Tensor { - let m = *mat1_shape[0]; - let n = *mat1_shape[1]; - let p = *mat2_shape[1]; - - let mut result_data = ArrayTrait::new(); - let mut result_shape = ArrayTrait::new(); - result_shape.append(m); - result_shape.append(p); - - let mut i = 0_usize; - loop { - if i == m { - break (); - } - - let mut j = 0_usize; - loop { - if j == p { - break (); - } - - let mut sum: FixedType = FixedTrait::new_unscaled(0, false); - let mut k = 0_usize; - loop { - if k == n { - break (); - } - - let mat1_index = 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; - }; - - return TensorTrait::new(result_shape.span(), result_data.span(), Option::None(())); -} diff --git a/src/operators/tensor/linalg/matmul/matmul_i32.cairo b/src/operators/tensor/linalg/matmul/matmul_i32.cairo deleted file mode 100644 index f8a222f23..000000000 --- a/src/operators/tensor/linalg/matmul/matmul_i32.cairo +++ /dev/null @@ -1,135 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - - -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::core::{Tensor, ExtraParams, TensorTrait}; -use orion::operators::tensor::linalg::matmul::helpers::{ - prepare_shape_for_matmul, adjust_output_shape_after_matmul -}; - -/// Cf: TensorTrait::matmul docstring -fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - let self_shape = *self.shape; - let other_shape = *other.shape; - 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'); - - //! Case: Both tensors are 1-dimensional - if self_ndim == 1 && other_ndim == 1 { - let dot = dot_product((*self).data, (*other).data); - let mut result_shape = ArrayTrait::new(); - let mut result_data = ArrayTrait::new(); - result_shape.append(1); - result_data.append(dot); - return TensorTrait::new(result_shape.span(), result_data.span(), *self.extra); - } - - 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_shape = adjust_output_shape_after_matmul(result.shape, self_ndim, other_ndim); - - return TensorTrait::::new(result_shape, result.data, *self.extra); -} - -/// Computes the dot product of two 1-dimensional i32 tensors. -/// -/// # Arguments -/// * `vec1` - A span containing the data elements of the first vector as i32 elements. -/// * `vec2` - A span containing the data elements of the second vector as i32 elements. -/// -/// # Panics -/// * Panics if the lengths of the vectors do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An i32 representing the dot product of the two vectors. -fn dot_product(mut vec1: Span, mut vec2: Span) -> i32 { - assert(vec1.len() == vec2.len(), 'vector lengths do not match'); - - let mut result: i32 = IntegerTrait::new(0, false); - - loop { - match vec1.pop_front() { - Option::Some(vec1_item) => { - let element_product = *vec1_item * *vec2.pop_front().unwrap(); - result += element_product; - }, - Option::None(_) => { - break; - } - }; - }; - - return result; -} - - -/// Computes the matrix multiplication of two 2-dimensional i32 tensors. -/// -/// # Arguments -/// * `mat1` - A Span containing the data elements of the first matrix as i32 elements. -/// * `mat1_shape` - A Span containing the shape of the first matrix as usize elements. -/// * `mat2` - A Span containing the data elements of the second matrix as i32 elements. -/// * `mat2_shape` - A Span containing the shape of the second matrix as usize elements. -/// -/// # Panics -/// * Panics if the inner dimensions of the matrices do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * Returns the restulting i32 tensor. -fn matrix_multiply( - mat1: Span, mat1_shape: Span, mat2: Span, mat2_shape: Span -) -> Tensor { - let m = *mat1_shape[0]; - let n = *mat1_shape[1]; - let p = *mat2_shape[1]; - - let mut result_data = ArrayTrait::new(); - let mut result_shape = ArrayTrait::new(); - result_shape.append(m); - result_shape.append(p); - - let mut i = 0_usize; - loop { - if i == m { - break (); - } - - let mut j = 0_usize; - loop { - if j == p { - break (); - } - - let mut sum: i32 = IntegerTrait::new(0, false); - let mut k = 0_usize; - loop { - if k == n { - break (); - } - - let mat1_index = 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; - }; - - return TensorTrait::new(result_shape.span(), result_data.span(), Option::None(())); -} diff --git a/src/operators/tensor/linalg/matmul/matmul_i8.cairo b/src/operators/tensor/linalg/matmul/matmul_i8.cairo deleted file mode 100644 index 7a5ff68b1..000000000 --- a/src/operators/tensor/linalg/matmul/matmul_i8.cairo +++ /dev/null @@ -1,135 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - - -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::core::{Tensor, ExtraParams, TensorTrait}; -use orion::operators::tensor::linalg::matmul::helpers::{ - prepare_shape_for_matmul, adjust_output_shape_after_matmul -}; - -/// Cf: TensorTrait::matmul docstring -fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - let self_shape = *self.shape; - let other_shape = *other.shape; - 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'); - - //! Case: Both tensors are 1-dimensional - if self_ndim == 1 && other_ndim == 1 { - let dot = dot_product((*self).data, (*other).data); - let mut result_shape = ArrayTrait::new(); - let mut result_data = ArrayTrait::new(); - result_shape.append(1); - result_data.append(dot); - return TensorTrait::new(result_shape.span(), result_data.span(), *self.extra); - } - - 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_shape = adjust_output_shape_after_matmul(result.shape, self_ndim, other_ndim); - - return TensorTrait::::new(result_shape, result.data, *self.extra); -} - -/// Computes the dot product of two 1-dimensional i8 tensors. -/// -/// # Arguments -/// * `vec1` - A span containing the data elements of the first vector as i8 elements. -/// * `vec2` - A span containing the data elements of the second vector as i8 elements. -/// -/// # Panics -/// * Panics if the lengths of the vectors do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An i8 representing the dot product of the two vectors. -fn dot_product(mut vec1: Span, mut vec2: Span) -> i8 { - assert(vec1.len() == vec2.len(), 'vector lengths do not match'); - - let mut result: i8 = IntegerTrait::new(0, false); - - loop { - match vec1.pop_front() { - Option::Some(vec1_item) => { - let element_product = *vec1_item * *vec2.pop_front().unwrap(); - result += element_product; - }, - Option::None(_) => { - break; - } - }; - }; - - return result; -} - - -/// Computes the matrix multiplication of two 2-dimensional i8 tensors. -/// -/// # Arguments -/// * `mat1` - A Span containing the data elements of the first matrix as i8 elements. -/// * `mat1_shape` - A Span containing the shape of the first matrix as usize elements. -/// * `mat2` - A Span containing the data elements of the second matrix as i8 elements. -/// * `mat2_shape` - A Span containing the shape of the second matrix as usize elements. -/// -/// # Panics -/// * Panics if the inner dimensions of the matrices do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * Returns the restulting i8 tensor. -fn matrix_multiply( - mat1: Span, mat1_shape: Span, mat2: Span, mat2_shape: Span -) -> Tensor { - let m = *mat1_shape[0]; - let n = *mat1_shape[1]; - let p = *mat2_shape[1]; - - let mut result_data = ArrayTrait::new(); - let mut result_shape = ArrayTrait::new(); - result_shape.append(m); - result_shape.append(p); - - let mut i = 0_usize; - loop { - if i == m { - break (); - } - - let mut j = 0_usize; - loop { - if j == p { - break (); - } - - let mut sum: i8 = IntegerTrait::new(0, false); - let mut k = 0_usize; - loop { - if k == n { - break (); - } - - let mat1_index = 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; - }; - - return TensorTrait::new(result_shape.span(), result_data.span(), Option::None(())); -} diff --git a/src/operators/tensor/linalg/matmul/matmul_u32.cairo b/src/operators/tensor/linalg/matmul/matmul_u32.cairo deleted file mode 100644 index 2b230e91b..000000000 --- a/src/operators/tensor/linalg/matmul/matmul_u32.cairo +++ /dev/null @@ -1,134 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, ExtraParams, TensorTrait, }; -use orion::operators::tensor::linalg::matmul::helpers::{ - prepare_shape_for_matmul, adjust_output_shape_after_matmul -}; - -/// Cf: TensorTrait::matmul docstring -fn matmul(self: @Tensor, other: @Tensor) -> Tensor { - let self_shape = *self.shape; - let other_shape = *other.shape; - 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'); - - //! Case: Both tensors are 1-dimensional - if self_ndim == 1 && other_ndim == 1 { - let dot = dot_product((*self).data, (*other).data); - let mut result_shape = ArrayTrait::new(); - let mut result_data = ArrayTrait::new(); - result_shape.append(1); - result_data.append(dot); - return TensorTrait::new(result_shape.span(), result_data.span(), *self.extra); - } - - 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_shape = adjust_output_shape_after_matmul(result.shape, self_ndim, other_ndim); - - return TensorTrait::::new(result_shape, result.data, *self.extra); -} - -/// Computes the dot product of two 1-dimensional u32 tensors. -/// -/// # Arguments -/// * `vec1` - A span containing the data elements of the first vector as u32 elements. -/// * `vec2` - A span containing the data elements of the second vector as u32 elements. -/// -/// # Panics -/// * Panics if the lengths of the vectors do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An u32 representing the dot product of the two vectors. -fn dot_product(mut vec1: Span, mut vec2: Span) -> u32 { - assert(vec1.len() == vec2.len(), 'vector lengths do not match'); - - let mut result: u32 = 0; - - loop { - match vec1.pop_front() { - Option::Some(vec1_item) => { - let element_product = *vec1_item * *vec2.pop_front().unwrap(); - result += element_product; - }, - Option::None(_) => { - break; - } - }; - }; - - return result; -} - - -/// Computes the matrix multiplication of two 2-dimensional u32 tensors. -/// -/// # Arguments -/// * `mat1` - A Span containing the data elements of the first matrix as u32 elements. -/// * `mat1_shape` - A Span containing the shape of the first matrix as usize elements. -/// * `mat2` - A Span containing the data elements of the second matrix as u32 elements. -/// * `mat2_shape` - A Span containing the shape of the second matrix as usize elements. -/// -/// # Panics -/// * Panics if the inner dimensions of the matrices do not match. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * Returns the restulting u32 tensor. -fn matrix_multiply( - mat1: Span, mat1_shape: Span, mat2: Span, mat2_shape: Span -) -> Tensor { - let m = *mat1_shape[0]; - let n = *mat1_shape[1]; - let p = *mat2_shape[1]; - - let mut result_data = ArrayTrait::new(); - let mut result_shape = ArrayTrait::new(); - result_shape.append(m); - result_shape.append(p); - - let mut i = 0_usize; - loop { - if i == m { - break (); - } - - let mut j = 0_usize; - loop { - if j == p { - break (); - } - - let mut sum: u32 = 0; - let mut k = 0_usize; - loop { - if k == n { - break (); - } - - let mat1_index = 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; - }; - - return TensorTrait::new(result_shape.span(), result_data.span(), Option::None(())); -} diff --git a/src/operators/tensor/linalg/transpose.cairo b/src/operators/tensor/linalg/transpose.cairo index 15de619dc..dc972e9a3 100644 --- a/src/operators/tensor/linalg/transpose.cairo +++ b/src/operators/tensor/linalg/transpose.cairo @@ -1,4 +1,49 @@ -mod transpose_i8; -mod transpose_fp; -mod transpose_i32; -mod transpose_u32; +use array::ArrayTrait; +use array::SpanTrait; + +use orion::operators::tensor::core::{ + new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape +}; +use orion::operators::tensor::helpers::{len_from_shape, find_axis, permutation_output_shape}; +use orion::numbers::NumberTrait; + +/// Cf: TensorTrait::transpose docstring +fn transpose, impl TCopy: Copy, impl TDrop: Drop>( + self: @Tensor, axes: Span +) -> Tensor { + assert((*self.shape).len() > 1, 'cannot transpose a 1D tensor'); + assert(axes.len() == (*self.shape).len(), 'shape and axes length unequal'); + + let output_shape = permutation_output_shape(*self.shape, axes); + let output_data_len = len_from_shape(output_shape); + + let mut output_data = ArrayTrait::new(); + + let mut output_index: usize = 0; + loop { + if output_index == output_data_len { + break (); + } + + let output_indices = unravel_index(output_index, output_shape); + let mut input_indices = ArrayTrait::new(); + + let mut output_axis: usize = 0; + loop { + if output_axis == axes.len() { + break (); + } + + let input_axis = find_axis(axes, output_axis); + input_indices.append(*output_indices[input_axis]); + output_axis += 1; + }; + + let input_index = ravel_index(*self.shape, input_indices.span()); + output_data.append(*(*self.data)[input_index]); + + output_index += 1; + }; + + return TensorTrait::new(output_shape, output_data.span()); +} diff --git a/src/operators/tensor/linalg/transpose/transpose_fp.cairo b/src/operators/tensor/linalg/transpose/transpose_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/linalg/transpose/transpose_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/linalg/transpose/transpose_fp/core.cairo b/src/operators/tensor/linalg/transpose/transpose_fp/core.cairo deleted file mode 100644 index 044624247..000000000 --- a/src/operators/tensor/linalg/transpose/transpose_fp/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::Tensor; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::linalg::transpose::transpose_fp::fp8x23; -use orion::operators::tensor::linalg::transpose::transpose_fp::fp16x16; - - -/// Cf: TensorTrait::transpose docstring -fn transpose(self: @Tensor, axes: Span) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::transpose(self, axes)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::transpose(self, axes)), - }, - Option::None(_) => Option::Some(fp16x16::transpose(self, axes)), - }, - Option::None(_) => Option::Some(fp16x16::transpose(self, axes)), - } -} diff --git a/src/operators/tensor/linalg/transpose/transpose_fp/fp16x16.cairo b/src/operators/tensor/linalg/transpose/transpose_fp/fp16x16.cairo deleted file mode 100644 index 0358ce198..000000000 --- a/src/operators/tensor/linalg/transpose/transpose_fp/fp16x16.cairo +++ /dev/null @@ -1,50 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape -}; -use orion::operators::tensor::helpers::{len_from_shape, find_axis, permutation_output_shape}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::transpose docstring -fn transpose(self: @Tensor, axes: Span) -> Tensor { - assert((*self.shape).len() > 1, 'cannot transpose a 1D tensor'); - assert(axes.len() == (*self.shape).len(), 'shape and axes length unequal'); - - let output_shape = permutation_output_shape(*self.shape, axes); - let output_data_len = len_from_shape(output_shape); - - let mut output_data = ArrayTrait::new(); - - let mut output_index: usize = 0; - loop { - if output_index == output_data_len { - break (); - } - - let output_indices = unravel_index(output_index, output_shape); - let mut input_indices = ArrayTrait::new(); - - let mut output_axis: usize = 0; - loop { - if output_axis == axes.len() { - break (); - } - - let input_axis = find_axis(axes, output_axis); - input_indices.append(*output_indices[input_axis]); - output_axis += 1; - }; - - let input_index = ravel_index(*self.shape, input_indices.span()); - output_data.append(*(*self.data)[input_index]); - - output_index += 1; - }; - - return TensorTrait::new(output_shape, output_data.span(), *self.extra); -} diff --git a/src/operators/tensor/linalg/transpose/transpose_fp/fp8x23.cairo b/src/operators/tensor/linalg/transpose/transpose_fp/fp8x23.cairo deleted file mode 100644 index c84836f5c..000000000 --- a/src/operators/tensor/linalg/transpose/transpose_fp/fp8x23.cairo +++ /dev/null @@ -1,50 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape -}; -use orion::operators::tensor::helpers::{len_from_shape, find_axis, permutation_output_shape}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::transpose docstring -fn transpose(self: @Tensor, axes: Span) -> Tensor { - assert((*self.shape).len() > 1, 'cannot transpose a 1D tensor'); - assert(axes.len() == (*self.shape).len(), 'shape and axes length unequal'); - - let output_shape = permutation_output_shape(*self.shape, axes); - let output_data_len = len_from_shape(output_shape); - - let mut output_data = ArrayTrait::new(); - - let mut output_index: usize = 0; - loop { - if output_index == output_data_len { - break (); - } - - let output_indices = unravel_index(output_index, output_shape); - let mut input_indices = ArrayTrait::new(); - - let mut output_axis: usize = 0; - loop { - if output_axis == axes.len() { - break (); - } - - let input_axis = find_axis(axes, output_axis); - input_indices.append(*output_indices[input_axis]); - output_axis += 1; - }; - - let input_index = ravel_index(*self.shape, input_indices.span()); - output_data.append(*(*self.data)[input_index]); - - output_index += 1; - }; - - return TensorTrait::new(output_shape, output_data.span(), *self.extra); -} diff --git a/src/operators/tensor/linalg/transpose/transpose_i32.cairo b/src/operators/tensor/linalg/transpose/transpose_i32.cairo deleted file mode 100644 index 127f29a3a..000000000 --- a/src/operators/tensor/linalg/transpose/transpose_i32.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape -}; -use orion::operators::tensor::helpers::{len_from_shape, find_axis, permutation_output_shape}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - - -/// Cf: TensorTrait::transpose docstring -fn transpose(self: @Tensor, axes: Span) -> Tensor { - assert((*self.shape).len() > 1, 'cannot transpose a 1D tensor'); - assert(axes.len() == (*self.shape).len(), 'shape and axes length unequal'); - - let output_shape = permutation_output_shape(*self.shape, axes); - let output_data_len = len_from_shape(output_shape); - - let mut output_data = ArrayTrait::new(); - - let mut output_index: usize = 0; - loop { - if output_index == output_data_len { - break (); - } - - let output_indices = unravel_index(output_index, output_shape); - let mut input_indices = ArrayTrait::new(); - - let mut output_axis: usize = 0; - loop { - if output_axis == axes.len() { - break (); - } - - let input_axis = find_axis(axes, output_axis); - input_indices.append(*output_indices[input_axis]); - output_axis += 1; - }; - - let input_index = ravel_index(*self.shape, input_indices.span()); - output_data.append(*(*self.data)[input_index]); - - output_index += 1; - }; - - return TensorTrait::new(output_shape, output_data.span(), *self.extra); -} diff --git a/src/operators/tensor/linalg/transpose/transpose_i8.cairo b/src/operators/tensor/linalg/transpose/transpose_i8.cairo deleted file mode 100644 index 36b332c6a..000000000 --- a/src/operators/tensor/linalg/transpose/transpose_i8.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape -}; -use orion::operators::tensor::helpers::{len_from_shape, find_axis, permutation_output_shape}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - - -/// Cf: TensorTrait::transpose docstring -fn transpose(self: @Tensor, axes: Span) -> Tensor { - assert((*self.shape).len() > 1, 'cannot transpose a 1D tensor'); - assert(axes.len() == (*self.shape).len(), 'shape and axes length unequal'); - - let output_shape = permutation_output_shape(*self.shape, axes); - let output_data_len = len_from_shape(output_shape); - - let mut output_data = ArrayTrait::new(); - - let mut output_index: usize = 0; - loop { - if output_index == output_data_len { - break (); - } - - let output_indices = unravel_index(output_index, output_shape); - let mut input_indices = ArrayTrait::new(); - - let mut output_axis: usize = 0; - loop { - if output_axis == axes.len() { - break (); - } - - let input_axis = find_axis(axes, output_axis); - input_indices.append(*output_indices[input_axis]); - output_axis += 1; - }; - - let input_index = ravel_index(*self.shape, input_indices.span()); - output_data.append(*(*self.data)[input_index]); - - output_index += 1; - }; - - return TensorTrait::new(output_shape, output_data.span(), *self.extra); -} diff --git a/src/operators/tensor/linalg/transpose/transpose_u32.cairo b/src/operators/tensor/linalg/transpose/transpose_u32.cairo deleted file mode 100644 index 180a1b296..000000000 --- a/src/operators/tensor/linalg/transpose/transpose_u32.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::operators::tensor::core::{ - new_tensor, stride, Tensor, TensorTrait, ravel_index, unravel_index, reshape -}; -use orion::operators::tensor::helpers::{len_from_shape, find_axis, permutation_output_shape}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - - -/// Cf: TensorTrait::transpose docstring -fn transpose(self: @Tensor, axes: Span) -> Tensor { - assert((*self.shape).len() > 1, 'cannot transpose a 1D tensor'); - assert(axes.len() == (*self.shape).len(), 'shape and axes length unequal'); - - let output_shape = permutation_output_shape(*self.shape, axes); - let output_data_len = len_from_shape(output_shape); - - let mut output_data = ArrayTrait::new(); - - let mut output_index: usize = 0; - loop { - if output_index == output_data_len { - break (); - } - - let output_indices = unravel_index(output_index, output_shape); - let mut input_indices = ArrayTrait::new(); - - let mut output_axis: usize = 0; - loop { - if output_axis == axes.len() { - break (); - } - - let input_axis = find_axis(axes, output_axis); - input_indices.append(*output_indices[input_axis]); - output_axis += 1; - }; - - let input_index = ravel_index(*self.shape, input_indices.span()); - output_data.append(*(*self.data)[input_index]); - - output_index += 1; - }; - - return TensorTrait::new(output_shape, output_data.span(), *self.extra); -} diff --git a/src/operators/tensor/math.cairo b/src/operators/tensor/math.cairo index 4d3e4ccda..428c00880 100644 --- a/src/operators/tensor/math.cairo +++ b/src/operators/tensor/math.cairo @@ -29,3 +29,4 @@ mod or; mod acos; mod onehot; mod sqrt; +mod concat; diff --git a/src/operators/tensor/math/abs.cairo b/src/operators/tensor/math/abs.cairo index d56ebb732..56662aa6c 100644 --- a/src/operators/tensor/math/abs.cairo +++ b/src/operators/tensor/math/abs.cairo @@ -1,4 +1,32 @@ -mod abs_i8; -mod abs_i32; -mod abs_u32; -mod abs_fp; \ No newline at end of file +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait}; +use orion::numbers::NumberTrait; + +/// Cf: TensorTrait::abs docstring +fn abs< + T, + MAG, + impl TTensor: TensorTrait, + impl TNumberTrait: NumberTrait, + impl TCopy: Copy, + impl TDrop: Drop +>( + mut z: Tensor +) -> Tensor { + let mut data_result = ArrayTrait::::new(); + loop { + match z.data.pop_front() { + Option::Some(item) => { + data_result.append((*item).abs()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::::new(z.shape, data_result.span()); +} diff --git a/src/operators/tensor/math/abs/abs_fp.cairo b/src/operators/tensor/math/abs/abs_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/abs/abs_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/abs/abs_fp/core.cairo b/src/operators/tensor/math/abs/abs_fp/core.cairo deleted file mode 100644 index b30f1c412..000000000 --- a/src/operators/tensor/math/abs/abs_fp/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::math::abs::abs_fp::fp8x23; -use orion::operators::tensor::math::abs::abs_fp::fp16x16; - - -/// Cf: TensorTrait::abs docstring -fn abs(z: Tensor) -> Option> { - match z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::abs(z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::abs(z)), - }, - Option::None(_) => Option::Some(fp16x16::abs(z)), - }, - Option::None(_) => Option::Some(fp16x16::abs(z)), - } -} diff --git a/src/operators/tensor/math/abs/abs_fp/fp16x16.cairo b/src/operators/tensor/math/abs/abs_fp/fp16x16.cairo deleted file mode 100644 index 522ad6914..000000000 --- a/src/operators/tensor/math/abs/abs_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: TensorTrait::abs docstring -fn abs(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - loop { - match z.data.pop_front() { - Option::Some(item) => { - data_result.append((*item).abs()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/tensor/math/abs/abs_fp/fp8x23.cairo b/src/operators/tensor/math/abs/abs_fp/fp8x23.cairo deleted file mode 100644 index ca4cd8c60..000000000 --- a/src/operators/tensor/math/abs/abs_fp/fp8x23.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: TensorTrait::abs docstring -fn abs(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - loop { - match z.data.pop_front() { - Option::Some(item) => { - data_result.append((*item).abs()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/tensor/math/abs/abs_i32.cairo b/src/operators/tensor/math/abs/abs_i32.cairo deleted file mode 100644 index e7cf77f13..000000000 --- a/src/operators/tensor/math/abs/abs_i32.cairo +++ /dev/null @@ -1,24 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: TensorTrait::abs docstring -fn abs(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - loop { - match z.data.pop_front() { - Option::Some(item) => { - data_result.append((*item).abs()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/tensor/math/abs/abs_i8.cairo b/src/operators/tensor/math/abs/abs_i8.cairo deleted file mode 100644 index 1ab947f45..000000000 --- a/src/operators/tensor/math/abs/abs_i8.cairo +++ /dev/null @@ -1,24 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: TensorTrait::abs docstring -fn abs(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - loop { - match z.data.pop_front() { - Option::Some(item) => { - data_result.append((*item).abs()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/tensor/math/abs/abs_u32.cairo b/src/operators/tensor/math/abs/abs_u32.cairo deleted file mode 100644 index 36046410e..000000000 --- a/src/operators/tensor/math/abs/abs_u32.cairo +++ /dev/null @@ -1,6 +0,0 @@ -use orion::operators::tensor::core::Tensor; - -/// Cf: TensorTrait::abs docstring -fn abs(z: @Tensor) -> Tensor { - return *z; -} diff --git a/src/operators/tensor/math/acos.cairo b/src/operators/tensor/math/acos.cairo index 8502fa315..b394620cd 100644 --- a/src/operators/tensor/math/acos.cairo +++ b/src/operators/tensor/math/acos.cairo @@ -1 +1,33 @@ -mod acos_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: TensorTrait::acos docstring +fn acos< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).acos()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::::new(self.shape, result.span()); +} + diff --git a/src/operators/tensor/math/acos/acos_fp.cairo b/src/operators/tensor/math/acos/acos_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/acos/acos_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/acos/acos_fp/core.cairo b/src/operators/tensor/math/acos/acos_fp/core.cairo deleted file mode 100644 index d991bffe2..000000000 --- a/src/operators/tensor/math/acos/acos_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::acos::acos_fp::fp8x23; -use orion::operators::tensor::math::acos::acos_fp::fp16x16; - -/// Cf: TensorTrait::acos docstring -fn acos(self: Tensor) -> Option> { - match self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::acos(self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::acos(self)), - }, - Option::None(_) => Option::Some(fp16x16::acos(self)), - }, - Option::None(_) => Option::Some(fp16x16::acos(self)), - } -} diff --git a/src/operators/tensor/math/acos/acos_fp/fp16x16.cairo b/src/operators/tensor/math/acos/acos_fp/fp16x16.cairo deleted file mode 100644 index c2a4afa68..000000000 --- a/src/operators/tensor/math/acos/acos_fp/fp16x16.cairo +++ /dev/null @@ -1,25 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - -/// Cf: TensorTrait::acos docstring -fn acos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).acos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/acos/acos_fp/fp8x23.cairo b/src/operators/tensor/math/acos/acos_fp/fp8x23.cairo deleted file mode 100644 index 9a2c7ac84..000000000 --- a/src/operators/tensor/math/acos/acos_fp/fp8x23.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - -/// Cf: TensorTrait::acos docstring -fn acos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).acos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/acosh.cairo b/src/operators/tensor/math/acosh.cairo index cfa1a6a06..ed253063e 100644 --- a/src/operators/tensor/math/acosh.cairo +++ b/src/operators/tensor/math/acosh.cairo @@ -1,4 +1,35 @@ -mod acosh_i8; -mod acosh_i32; -mod acosh_u32; -mod acosh_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: TensorTrait::acosh docstring +fn acosh< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).acosh()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/acosh/acosh_fp.cairo b/src/operators/tensor/math/acosh/acosh_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/acosh/acosh_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/acosh/acosh_fp/core.cairo b/src/operators/tensor/math/acosh/acosh_fp/core.cairo deleted file mode 100644 index 8aebbb985..000000000 --- a/src/operators/tensor/math/acosh/acosh_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::acosh::acosh_fp::fp8x23; -use orion::operators::tensor::math::acosh::acosh_fp::fp16x16; - -/// Cf: TensorTrait::acosh docstring -fn acosh(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::acosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - } -} diff --git a/src/operators/tensor/math/acosh/acosh_fp/fp16x16.cairo b/src/operators/tensor/math/acosh/acosh_fp/fp16x16.cairo deleted file mode 100644 index 5d619ccba..000000000 --- a/src/operators/tensor/math/acosh/acosh_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/acosh/acosh_fp/fp8x23.cairo b/src/operators/tensor/math/acosh/acosh_fp/fp8x23.cairo deleted file mode 100644 index 2aaba0682..000000000 --- a/src/operators/tensor/math/acosh/acosh_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/acosh/acosh_i32.cairo b/src/operators/tensor/math/acosh/acosh_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/acosh/acosh_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/acosh/acosh_i32/core.cairo b/src/operators/tensor/math/acosh/acosh_i32/core.cairo deleted file mode 100644 index 1922952bd..000000000 --- a/src/operators/tensor/math/acosh/acosh_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::acosh::acosh_i32::fp8x23; -use orion::operators::tensor::math::acosh::acosh_i32::fp16x16; - -/// Cf: TensorTrait::acosh docstring -fn acosh_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::acosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - } -} diff --git a/src/operators/tensor/math/acosh/acosh_i32/fp16x16.cairo b/src/operators/tensor/math/acosh/acosh_i32/fp16x16.cairo deleted file mode 100644 index e13b27b16..000000000 --- a/src/operators/tensor/math/acosh/acosh_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/acosh/acosh_i32/fp8x23.cairo b/src/operators/tensor/math/acosh/acosh_i32/fp8x23.cairo deleted file mode 100644 index 0fb381607..000000000 --- a/src/operators/tensor/math/acosh/acosh_i32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/acosh/acosh_i8.cairo b/src/operators/tensor/math/acosh/acosh_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/acosh/acosh_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/acosh/acosh_i8/core.cairo b/src/operators/tensor/math/acosh/acosh_i8/core.cairo deleted file mode 100644 index b8b075a0b..000000000 --- a/src/operators/tensor/math/acosh/acosh_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::acosh::acosh_i8::fp8x23; -use orion::operators::tensor::math::acosh::acosh_i8::fp16x16; - -/// Cf: TensorTrait::acosh docstring -fn acosh_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::acosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - } -} diff --git a/src/operators/tensor/math/acosh/acosh_i8/fp16x16.cairo b/src/operators/tensor/math/acosh/acosh_i8/fp16x16.cairo deleted file mode 100644 index 282a5a1e5..000000000 --- a/src/operators/tensor/math/acosh/acosh_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/acosh/acosh_i8/fp8x23.cairo b/src/operators/tensor/math/acosh/acosh_i8/fp8x23.cairo deleted file mode 100644 index 2df839315..000000000 --- a/src/operators/tensor/math/acosh/acosh_i8/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/acosh/acosh_u32.cairo b/src/operators/tensor/math/acosh/acosh_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/acosh/acosh_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/acosh/acosh_u32/core.cairo b/src/operators/tensor/math/acosh/acosh_u32/core.cairo deleted file mode 100644 index dc8f4be36..000000000 --- a/src/operators/tensor/math/acosh/acosh_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::acosh::acosh_u32::fp8x23; -use orion::operators::tensor::math::acosh::acosh_u32::fp16x16; - -/// Cf: TensorTrait::acosh docstring -fn acosh_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::acosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::acosh(*self)), - } -} diff --git a/src/operators/tensor/math/acosh/acosh_u32/fp16x16.cairo b/src/operators/tensor/math/acosh/acosh_u32/fp16x16.cairo deleted file mode 100644 index d588aa7a2..000000000 --- a/src/operators/tensor/math/acosh/acosh_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/acosh/acosh_u32/fp8x23.cairo b/src/operators/tensor/math/acosh/acosh_u32/fp8x23.cairo deleted file mode 100644 index 9c7308d84..000000000 --- a/src/operators/tensor/math/acosh/acosh_u32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::acosh docstring -fn acosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).acosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/argmax.cairo b/src/operators/tensor/math/argmax.cairo index 4ba28d1b4..d270e0c4c 100644 --- a/src/operators/tensor/math/argmax.cairo +++ b/src/operators/tensor/math/argmax.cairo @@ -1,5 +1,186 @@ -mod argmax_i8; -mod argmax_i32; -mod argmax_u32; -mod argmax_fp; -mod helpers; +use core::debug::PrintTrait; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; +use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; +use orion::numbers::NumberTrait; + +/// Cf: TensorTrait::argmax docstring +fn argmax< + T, + MAG, + impl UsizeTensor: TensorTrait, + impl TNumber: NumberTrait, + impl TPartialOrd: PartialOrd, + impl TPartialEq: PartialEq, + impl TCopy: Copy, + impl TDrop: Drop, +>( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option +) -> Tensor { + let keepdims = match keepdims { + Option::Some(val) => val, + Option::None(_) => true, + }; + + let select_last_index = match select_last_index { + Option::Some(val) => val, + Option::None(_) => false, + }; + + assert(axis <= (*self.shape).len(), 'axis out of dimensions'); + + if (*self.shape).len() == 1 { + return find_argmax_1D::(*self, axis, true, select_last_index); + } + + let mut output_data = ArrayTrait::new(); + + let output_shape = reduce_output_shape(*self.shape, axis, false); + let output_data_len = len_from_shape(output_shape); + + let MIN = NumberTrait::min_value(); + + let mut index: usize = 0; + loop { + let output_indices = unravel_index(index, output_shape); + let current_argmax = find_argmax(self, output_indices, axis, 0, MIN, 0, select_last_index); + + output_data.append(current_argmax); + + index += 1; + if index == output_data_len { + break (); + }; + }; + + return TensorTrait::::new( + reduce_output_shape(*self.shape, axis, keepdims), output_data.span() + ); +} + +/// Helper function that finds the index of the maximum value in a flat tensor. +/// +/// # Arguments +/// * `input` - The input tensor. +/// * `axis` - The axis along which to find the maximum value. +/// * `keepdims` - Whether to keep the reduced dimension or not. +/// * `select_last_index` - Whether to selƒect last occurrence of the max value along the axis. +/// +/// # Panics +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * A usize value representing the index of the maximum value along the specified axis. +fn find_argmax_1D< + T, + impl UsizeTensor: TensorTrait, + impl TPartialOrd: PartialOrd, + impl TPartialEq: PartialEq, + impl TCopy: Copy, + impl TDrop: Drop, +>( + mut input: Tensor, axis: usize, keepdims: bool, select_last_index: bool +) -> Tensor { + let mut output_data = ArrayTrait::::new(); + + let mut max = match input.data.pop_front() { + Option::Some(item) => *item, + Option::None(_) => { + return TensorTrait::::new( + reduce_output_shape(input.shape, axis, keepdims), output_data.span() + ); + } + }; + let mut max_index = 0; + let mut count = 0; + + loop { + match input.data.pop_front() { + Option::Some(item) => { + count += 1; + + if *item > max { + max = *item; + max_index = count; + } else { + if select_last_index && item == @max { + max_index = count; + } + }; + }, + Option::None(_) => { + break; + } + }; + }; + + output_data.append(max_index); + + return TensorTrait::::new( + reduce_output_shape(input.shape, axis, keepdims), output_data.span() + ); +} + + +/// Recursive helper function that finds the index of the maximum value along a specific axis. +/// +/// # Arguments +/// * `input` - The input tensor. +/// * `output_indices` - A span of output indices. +/// * `axis` - The axis along which to find the maximum value. +/// * `axis_index` - The current index along the specified axis. +/// * `max_value` - The current maximum value found along the axis. +/// * `argmax` - The current index of the maximum value along the axis. +/// * `select_last_index` - Whether to select last occurrence of the max value along the axis. +/// +/// # Panics +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * A usize value representing the index of the maximum value along the specified axis. +fn find_argmax< + T, + impl TPartialOrd: PartialOrd, + impl TPartialEq: PartialEq, + impl TCopy: Copy, + impl TDrop: Drop, +>( + input: @Tensor, + output_indices: Span, + axis: usize, + axis_index: usize, + max_value: T, + argmax: usize, + select_last_index: bool +) -> usize { + if axis_index == *(*input.shape)[axis] { + return argmax; + } + + let input_indices = combine_indices(output_indices, axis_index, axis); + let input_index = ravel_index(*input.shape, input_indices); + let ele = *(*input.data)[input_index]; + + let (new_max_value, new_argmax) = if ele > max_value { + (ele, axis_index) + } else { + if select_last_index && ele == max_value { + (ele, axis_index) + } else { + (max_value, argmax) + } + }; + + return find_argmax( + input, + output_indices, + axis, + axis_index + 1_usize, + new_max_value, + new_argmax, + select_last_index + ); +} diff --git a/src/operators/tensor/math/argmax/argmax_fp.cairo b/src/operators/tensor/math/argmax/argmax_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/argmax/argmax_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/argmax/argmax_fp/core.cairo b/src/operators/tensor/math/argmax/argmax_fp/core.cairo deleted file mode 100644 index 32d310da8..000000000 --- a/src/operators/tensor/math/argmax/argmax_fp/core.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::argmax::argmax_fp::fp8x23; -use orion::operators::tensor::math::argmax::argmax_fp::fp16x16; - -/// Cf: TensorTrait::argmax docstring -fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some( - fp8x23::argmax(self, axis, keepdims, select_last_index) - ), - FixedImpl::FP16x16(()) => Option::Some( - fp16x16::argmax(self, axis, keepdims, select_last_index) - ), - }, - Option::None(_) => Option::Some( - fp16x16::argmax(self, axis, keepdims, select_last_index) - ), - }, - Option::None(_) => Option::Some(fp16x16::argmax(self, axis, keepdims, select_last_index)), - } -} diff --git a/src/operators/tensor/math/argmax/argmax_fp/fp16x16.cairo b/src/operators/tensor/math/argmax/argmax_fp/fp16x16.cairo deleted file mode 100644 index c2648032a..000000000 --- a/src/operators/tensor/math/argmax/argmax_fp/fp16x16.cairo +++ /dev/null @@ -1,57 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16PartialOrd, FP16x16PartialEq, MAX -}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmax::helpers::{find_argmax_1D, find_argmax}; - - -/// Cf: TensorTrait::argmax docstring -fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmax_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MIN = FixedTrait::new(MAX, true); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmax = find_argmax(self, output_indices, axis, 0, MIN, 0, select_last_index); - - output_data.append(current_argmax); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmax/argmax_fp/fp8x23.cairo b/src/operators/tensor/math/argmax/argmax_fp/fp8x23.cairo deleted file mode 100644 index d6fab9329..000000000 --- a/src/operators/tensor/math/argmax/argmax_fp/fp8x23.cairo +++ /dev/null @@ -1,57 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23PartialOrd, FP8x23PartialEq, MAX -}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmax::helpers::{find_argmax_1D, find_argmax}; - - -/// Cf: TensorTrait::argmax docstring -fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmax_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MIN = FixedTrait::new(MAX, true); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmax = find_argmax(self, output_indices, axis, 0, MIN, 0, select_last_index); - - output_data.append(current_argmax); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmax/argmax_i32.cairo b/src/operators/tensor/math/argmax/argmax_i32.cairo deleted file mode 100644 index 17b91dc73..000000000 --- a/src/operators/tensor/math/argmax/argmax_i32.cairo +++ /dev/null @@ -1,54 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::{impl_tensor_i32, impl_tensor_u32::Tensor_u32}; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmax::helpers::{find_argmax_1D, find_argmax}; - - -/// Cf: TensorTrait::argmax docstring -fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmax_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MIN = IntegerTrait::::new(2147483648, true); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmax = find_argmax(self, output_indices, axis, 0, MIN, 0, select_last_index); - - output_data.append(current_argmax); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmax/argmax_i8.cairo b/src/operators/tensor/math/argmax/argmax_i8.cairo deleted file mode 100644 index 6d1f63b37..000000000 --- a/src/operators/tensor/math/argmax/argmax_i8.cairo +++ /dev/null @@ -1,54 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::implementations::{impl_tensor_i8, impl_tensor_u32::Tensor_u32}; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmax::helpers::{find_argmax_1D, find_argmax}; - - -/// Cf: TensorTrait::argmax docstring -fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmax_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MIN = IntegerTrait::::new(128, true); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmax = find_argmax(self, output_indices, axis, 0, MIN, 0, select_last_index); - - output_data.append(current_argmax); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmax/argmax_u32.cairo b/src/operators/tensor/math/argmax/argmax_u32.cairo deleted file mode 100644 index 48d22725b..000000000 --- a/src/operators/tensor/math/argmax/argmax_u32.cairo +++ /dev/null @@ -1,51 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmax::helpers::{find_argmax_1D, find_argmax}; - - -/// Cf: TensorTrait::argmax docstring -fn argmax( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmax_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmax = find_argmax(self, output_indices, axis, 0, 0, 0, select_last_index); - - output_data.append(current_argmax); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmax/helpers.cairo b/src/operators/tensor/math/argmax/helpers.cairo deleted file mode 100644 index f13d52698..000000000 --- a/src/operators/tensor/math/argmax/helpers.cairo +++ /dev/null @@ -1,132 +0,0 @@ -use core::debug::PrintTrait; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, combine_indices}; - - -/// Helper function that finds the index of the maximum value in a flat tensor. -/// -/// # Arguments -/// * `input` - The input tensor. -/// * `axis` - The axis along which to find the maximum value. -/// * `keepdims` - Whether to keep the reduced dimension or not. -/// * `select_last_index` - Whether to select last occurrence of the max value along the axis. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A usize value representing the index of the maximum value along the specified axis. -fn find_argmax_1D< - T, - impl TPartialOrd: PartialOrd, - impl TPartialEq: PartialEq, - impl TCopy: Copy, - impl TDrop: Drop, ->( - mut input: Tensor, axis: usize, keepdims: bool, select_last_index: bool -) -> Tensor { - let mut output_data = ArrayTrait::::new(); - - let mut max = match input.data.pop_front() { - Option::Some(item) => *item, - Option::None(_) => { - return TensorTrait::::new( - reduce_output_shape(input.shape, axis, keepdims), output_data.span(), input.extra - ); - } - }; - let mut max_index = 0; - let mut count = 0; - - loop { - match input.data.pop_front() { - Option::Some(item) => { - count += 1; - - if *item > max { - max = *item; - max_index = count; - } else { - if select_last_index && item == @max { - max_index = count; - } - }; - }, - Option::None(_) => { - break; - } - }; - }; - - output_data.append(max_index); - - return TensorTrait::::new( - reduce_output_shape(input.shape, axis, keepdims), output_data.span(), input.extra - ); -} - - -/// Recursive helper function that finds the index of the maximum value along a specific axis. -/// -/// # Arguments -/// * `input` - The input tensor. -/// * `output_indices` - A span of output indices. -/// * `axis` - The axis along which to find the maximum value. -/// * `axis_index` - The current index along the specified axis. -/// * `max_value` - The current maximum value found along the axis. -/// * `argmax` - The current index of the maximum value along the axis. -/// * `select_last_index` - Whether to select last occurrence of the max value along the axis. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A usize value representing the index of the maximum value along the specified axis. -fn find_argmax< - T, - impl TPartialOrd: PartialOrd, - impl TPartialEq: PartialEq, - impl TCopy: Copy, - impl TDrop: Drop, ->( - input: @Tensor, - output_indices: Span, - axis: usize, - axis_index: usize, - max_value: T, - argmax: usize, - select_last_index: bool -) -> usize { - if axis_index == *(*input.shape)[axis] { - return argmax; - } - - let input_indices = combine_indices(output_indices, axis_index, axis); - let input_index = ravel_index(*input.shape, input_indices); - let ele = *(*input.data)[input_index]; - - let (new_max_value, new_argmax) = if ele > max_value { - (ele, axis_index) - } else { - if select_last_index && ele == max_value { - (ele, axis_index) - } else { - (max_value, argmax) - } - }; - - return find_argmax( - input, - output_indices, - axis, - axis_index + 1_usize, - new_max_value, - new_argmax, - select_last_index - ); -} diff --git a/src/operators/tensor/math/argmin.cairo b/src/operators/tensor/math/argmin.cairo index 292471efd..77217a9ab 100644 --- a/src/operators/tensor/math/argmin.cairo +++ b/src/operators/tensor/math/argmin.cairo @@ -1,5 +1,188 @@ -mod argmin_i8; -mod argmin_i32; -mod argmin_u32; -mod argmin_fp; -mod helpers; +use core::debug::PrintTrait; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; +use orion::operators::tensor::helpers::{reduce_output_shape, combine_indices, len_from_shape}; +use orion::numbers::NumberTrait; + +/// Cf: TensorTrait::argmin docstring +fn argmin< + T, + MAG, + impl UsizeTensor: TensorTrait, + impl TNumber: NumberTrait, + impl TPartialOrd: PartialOrd, + impl TPartialEq: PartialEq, + impl TCopy: Copy, + impl TDrop: Drop, +>( + self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option +) -> Tensor { + let keepdims = match keepdims { + Option::Some(val) => val, + Option::None(_) => true, + }; + + let select_last_index = match select_last_index { + Option::Some(val) => val, + Option::None(_) => false, + }; + + assert(axis <= (*self.shape).len(), 'axis out of dimensions'); + + if (*self.shape).len() == 1 { + return find_argmin_1D(*self, axis, true, select_last_index); + } + + let mut output_data = ArrayTrait::new(); + + let output_shape = reduce_output_shape(*self.shape, axis, false); + let output_data_len = len_from_shape(output_shape); + + let MAX = NumberTrait::max_value(); + + let mut index: usize = 0; + loop { + let output_indices = unravel_index(index, output_shape); + let current_argmin = find_argmin(self, output_indices, axis, 0, MAX, 0, select_last_index); + + output_data.append(current_argmin); + + index += 1; + if index == output_data_len { + break (); + }; + }; + + return TensorTrait::::new( + reduce_output_shape(*self.shape, axis, keepdims), output_data.span() + ); +} + + +/// Helper function that finds the index of the minimum value in a flat tensor. +/// +/// # Arguments +/// * `input` - The input tensor. +/// * `axis` - The axis along which to find the minimum value. +/// * `keepdims` - Whether to keep the reduced dimension or not. +/// * `select_last_index` - Whether to select last occurrence of the min value along the axis. +/// +/// # Panics +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * A usize value representing the index of the minimum value along the specified axis. +fn find_argmin_1D< + T, + impl UsizeTensor: TensorTrait, + impl TPartialOrd: PartialOrd, + impl TPartialEq: PartialEq, + impl TCopy: Copy, + impl TDrop: Drop, +>( + mut input: Tensor, axis: usize, keepdims: bool, select_last_index: bool +) -> Tensor { + let mut output_data = ArrayTrait::::new(); + + let mut min = match input.data.pop_front() { + Option::Some(item) => *item, + Option::None(_) => { + return TensorTrait::::new( + reduce_output_shape(input.shape, axis, keepdims), output_data.span() + ); + } + }; + let mut min_index = 0; + let mut count = 0; + + loop { + match input.data.pop_front() { + Option::Some(item) => { + count += 1; + + if *item < min { + min = *item; + min_index = count; + } else { + if select_last_index && item == @min { + min_index = count; + } + }; + }, + Option::None(_) => { + break; + } + }; + }; + + output_data.append(min_index); + + return TensorTrait::::new( + reduce_output_shape(input.shape, axis, keepdims), output_data.span() + ); +} + + +/// Recursive helper function that finds the index of the minimum value along a specific axis. +/// +/// # Arguments +/// * `input` - The input tensor. +/// * `output_indices` - A span of output indices. +/// * `axis` - The axis along which to find the minimum value. +/// * `axis_index` - The current index along the specified axis. +/// * `min_value` - The current minimum value found along the axis. +/// * `argmin` - The current index of the minimum value along the axis. +/// * `select_last_index` - Whether to select last occurrence of the min value along the axis. +/// +/// # Panics +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * A usize value representing the index of the minimum value along the specified axis. +fn find_argmin< + T, + impl TPartialOrd: PartialOrd, + impl TPartialEq: PartialEq, + impl TCopy: Copy, + impl TDrop: Drop, +>( + input: @Tensor, + output_indices: Span, + axis: usize, + axis_index: usize, + min_value: T, + argmin: usize, + select_last_index: bool +) -> usize { + if axis_index == *(*input.shape)[axis] { + return argmin; + } + + let input_indices = combine_indices(output_indices, axis_index, axis); + let input_index = ravel_index(*input.shape, input_indices); + let ele = *(*input.data)[input_index]; + + let (new_min_value, new_argmin) = if ele < min_value { + (ele, axis_index) + } else { + if select_last_index && ele == min_value { + (ele, axis_index) + } else { + (min_value, argmin) + } + }; + + return find_argmin( + input, + output_indices, + axis, + axis_index + 1_usize, + new_min_value, + new_argmin, + select_last_index + ); +} + diff --git a/src/operators/tensor/math/argmin/argmin_fp.cairo b/src/operators/tensor/math/argmin/argmin_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/argmin/argmin_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/argmin/argmin_fp/core.cairo b/src/operators/tensor/math/argmin/argmin_fp/core.cairo deleted file mode 100644 index 282758b5c..000000000 --- a/src/operators/tensor/math/argmin/argmin_fp/core.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::argmin::argmin_fp::fp8x23; -use orion::operators::tensor::math::argmin::argmin_fp::fp16x16; - -/// Cf: TensorTrait::argmin docstring -fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some( - fp8x23::argmin(self, axis, keepdims, select_last_index) - ), - FixedImpl::FP16x16(()) => Option::Some( - fp16x16::argmin(self, axis, keepdims, select_last_index) - ), - }, - Option::None(_) => Option::Some( - fp16x16::argmin(self, axis, keepdims, select_last_index) - ), - }, - Option::None(_) => Option::Some(fp16x16::argmin(self, axis, keepdims, select_last_index)), - } -} diff --git a/src/operators/tensor/math/argmin/argmin_fp/fp16x16.cairo b/src/operators/tensor/math/argmin/argmin_fp/fp16x16.cairo deleted file mode 100644 index 0f620aa6a..000000000 --- a/src/operators/tensor/math/argmin/argmin_fp/fp16x16.cairo +++ /dev/null @@ -1,58 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16PartialOrd, FP16x16PartialEq, MAX -}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmin::helpers::{find_argmin_1D, find_argmin}; - - -/// Cf: TensorTrait::argmin docstring -fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmin_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MAX = FixedTrait::new(MAX, false); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmin = find_argmin(self, output_indices, axis, 0, MAX, 0, select_last_index); - - output_data.append(current_argmin); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} - diff --git a/src/operators/tensor/math/argmin/argmin_fp/fp8x23.cairo b/src/operators/tensor/math/argmin/argmin_fp/fp8x23.cairo deleted file mode 100644 index ff567cec3..000000000 --- a/src/operators/tensor/math/argmin/argmin_fp/fp8x23.cairo +++ /dev/null @@ -1,56 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23PartialOrd, FP8x23PartialEq, MAX -}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmin::helpers::{find_argmin_1D, find_argmin}; - - -/// Cf: TensorTrait::argmin docstring -fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmin_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MAX = FixedTrait::new(MAX, false); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmin = find_argmin(self, output_indices, axis, 0, MAX, 0, select_last_index); - - output_data.append(current_argmin); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmin/argmin_i32.cairo b/src/operators/tensor/math/argmin/argmin_i32.cairo deleted file mode 100644 index 60448455b..000000000 --- a/src/operators/tensor/math/argmin/argmin_i32.cairo +++ /dev/null @@ -1,54 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::{impl_tensor_i32, impl_tensor_u32::Tensor_u32}; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmin::helpers::{find_argmin_1D, find_argmin}; - - -/// Cf: TensorTrait::argmin docstring -fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmin_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MAX = IntegerTrait::::new(2147483647, false); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmin = find_argmin(self, output_indices, axis, 0, MAX, 0, select_last_index); - - output_data.append(current_argmin); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmin/argmin_i8.cairo b/src/operators/tensor/math/argmin/argmin_i8.cairo deleted file mode 100644 index fc4585b6b..000000000 --- a/src/operators/tensor/math/argmin/argmin_i8.cairo +++ /dev/null @@ -1,54 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::implementations::{impl_tensor_i8, impl_tensor_u32::Tensor_u32}; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmin::helpers::{find_argmin_1D, find_argmin}; - - -/// Cf: TensorTrait::argmin docstring -fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmin_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MAX = IntegerTrait::::new(127, false); - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmin = find_argmin(self, output_indices, axis, 0, MAX, 0, select_last_index); - - output_data.append(current_argmin); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmin/argmin_u32.cairo b/src/operators/tensor/math/argmin/argmin_u32.cairo deleted file mode 100644 index 0ef4e9a13..000000000 --- a/src/operators/tensor/math/argmin/argmin_u32.cairo +++ /dev/null @@ -1,53 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; -use orion::operators::tensor::math::argmin::helpers::{find_argmin_1D, find_argmin}; - - -/// Cf: TensorTrait::argmin docstring -fn argmin( - self: @Tensor, axis: usize, keepdims: Option, select_last_index: Option -) -> Tensor { - let keepdims = match keepdims { - Option::Some(val) => val, - Option::None(_) => true, - }; - - let select_last_index = match select_last_index { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - - if (*self.shape).len() == 1 { - return find_argmin_1D(*self, axis, true, select_last_index); - } - - let mut output_data = ArrayTrait::new(); - - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - - let MAX = 4294967295; // 2 ** 32 - 1 - - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_argmin = find_argmin(self, output_indices, axis, 0, MAX, 0, select_last_index); - - output_data.append(current_argmin); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - return TensorTrait::::new( - reduce_output_shape(*self.shape, axis, keepdims), output_data.span(), *self.extra - ); -} diff --git a/src/operators/tensor/math/argmin/helpers.cairo b/src/operators/tensor/math/argmin/helpers.cairo deleted file mode 100644 index 895213d5c..000000000 --- a/src/operators/tensor/math/argmin/helpers.cairo +++ /dev/null @@ -1,135 +0,0 @@ -use core::debug::PrintTrait; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, combine_indices}; - - -/// Helper function that finds the index of the minimum value in a flat tensor. -/// -/// # Arguments -/// * `input` - The input tensor. -/// * `axis` - The axis along which to find the minimum value. -/// * `keepdims` - Whether to keep the reduced dimension or not. -/// * `select_last_index` - Whether to select last occurrence of the min value along the axis. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A usize value representing the index of the minimum value along the specified axis. -fn find_argmin_1D< - T, - impl TPartialOrd: PartialOrd, - impl TPartialEq: PartialEq, - impl TCopy: Copy, - impl TDrop: Drop, ->( - mut input: Tensor, axis: usize, keepdims: bool, select_last_index: bool -) -> Tensor { - let mut output_data = ArrayTrait::::new(); - - let mut min = match input.data.pop_front() { - Option::Some(item) => *item, - Option::None(_) => { - return TensorTrait::::new( - reduce_output_shape(input.shape, axis, keepdims), output_data.span(), input.extra - ); - } - }; - let mut min_index = 0; - let mut count = 0; - - loop { - match input.data.pop_front() { - Option::Some(item) => { - count += 1; - - if *item < min { - min = *item; - min_index = count; - } else { - if select_last_index && item == @min { - min_index = count; - } - }; - }, - Option::None(_) => { - break; - } - }; - }; - - - - output_data.append(min_index); - - return TensorTrait::::new( - reduce_output_shape(input.shape, axis, keepdims), output_data.span(), input.extra - ); -} - - -/// Recursive helper function that finds the index of the minimum value along a specific axis. -/// -/// # Arguments -/// * `input` - The input tensor. -/// * `output_indices` - A span of output indices. -/// * `axis` - The axis along which to find the minimum value. -/// * `axis_index` - The current index along the specified axis. -/// * `min_value` - The current minimum value found along the axis. -/// * `argmin` - The current index of the minimum value along the axis. -/// * `select_last_index` - Whether to select last occurrence of the min value along the axis. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A usize value representing the index of the minimum value along the specified axis. -fn find_argmin< - T, - impl TPartialOrd: PartialOrd, - impl TPartialEq: PartialEq, - impl TCopy: Copy, - impl TDrop: Drop, ->( - input: @Tensor, - output_indices: Span, - axis: usize, - axis_index: usize, - min_value: T, - argmin: usize, - select_last_index: bool -) -> usize { - if axis_index == *(*input.shape)[axis] { - return argmin; - } - - let input_indices = combine_indices(output_indices, axis_index, axis); - let input_index = ravel_index(*input.shape, input_indices); - let ele = *(*input.data)[input_index]; - - let (new_min_value, new_argmin) = if ele < min_value { - (ele, axis_index) - } else { - if select_last_index && ele == min_value { - (ele, axis_index) - } else { - (min_value, argmin) - } - }; - - return find_argmin( - input, - output_indices, - axis, - axis_index + 1_usize, - new_min_value, - new_argmin, - select_last_index - ); -} - diff --git a/src/operators/tensor/math/arithmetic.cairo b/src/operators/tensor/math/arithmetic.cairo index 9432de7da..075f565b8 100644 --- a/src/operators/tensor/math/arithmetic.cairo +++ b/src/operators/tensor/math/arithmetic.cairo @@ -1,4 +1,306 @@ -mod arithmetic_i8; -mod arithmetic_fp; -mod arithmetic_i32; -mod arithmetic_u32; +use core::option::OptionTrait; +use core::traits::TryInto; +use array::ArrayTrait; +use array::SpanTrait; + +use orion::operators::tensor::helpers::broadcast_shape; + +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index,}; +use orion::operators::tensor::helpers::{broadcast_index_mapping, len_from_shape,}; +use orion::utils::saturate; + +fn add< + T, impl TTensor: TensorTrait, impl TAdd: Add, impl TCopy: Copy, impl TDrop: Drop +>( + self: @Tensor, other: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result.append(*(*self.data)[indices_self] + *(*other.data)[indices_other]); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} + +fn saturated_add< + T, + Q, + impl TTensor: TensorTrait, + impl QTensor: TensorTrait, + impl TAdd: Add, + impl TPartialOrd: PartialOrd, + impl TTryInto: TryInto, + impl TCopy: Copy, + impl TDrop: Drop, + impl QDrop: Drop, +>( + self: @Tensor, other: @Tensor, min_saturation: T, max_saturation: T +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result + .append( + saturate( + min_saturation, + max_saturation, + *(*self.data)[indices_self] + *(*other.data)[indices_other] + ) + .try_into() + .unwrap() + ); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} + +fn sub< + T, impl TTensor: TensorTrait, impl TSub: Sub, impl TCopy: Copy, impl TDrop: Drop +>( + self: @Tensor, other: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result.append(*(*self.data)[indices_self] - *(*other.data)[indices_other]); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} + +fn saturated_sub< + T, + Q, + impl TTensor: TensorTrait, + impl QTensor: TensorTrait, + impl TSub: Sub, + impl TPartialOrd: PartialOrd, + impl TTryInto: TryInto, + impl TCopy: Copy, + impl TDrop: Drop, + impl QDrop: Drop, +>( + self: @Tensor, other: @Tensor, min_saturation: T, max_saturation: T +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result + .append( + saturate( + min_saturation, + max_saturation, + *(*self.data)[indices_self] - *(*other.data)[indices_other] + ) + .try_into() + .unwrap() + ); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} + +fn mul< + T, impl TTensor: TensorTrait, impl TMul: Mul, impl TCopy: Copy, impl TDrop: Drop +>( + self: @Tensor, other: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result.append(*(*self.data)[indices_self] * *(*other.data)[indices_other]); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} + +fn saturated_mul< + T, + Q, + impl TTensor: TensorTrait, + impl QTensor: TensorTrait, + impl TMul: Mul, + impl TPartialOrd: PartialOrd, + impl TTryInto: TryInto, + impl TCopy: Copy, + impl TDrop: Drop, + impl QDrop: Drop, +>( + self: @Tensor, other: @Tensor, min_saturation: T, max_saturation: T +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result + .append( + saturate( + min_saturation, + max_saturation, + *(*self.data)[indices_self] * *(*other.data)[indices_other] + ) + .try_into() + .unwrap() + ); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} + +fn div< + T, impl TTensor: TensorTrait, impl TMul: Div, impl TCopy: Copy, impl TDrop: Drop +>( + self: @Tensor, other: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result.append(*(*self.data)[indices_self] / *(*other.data)[indices_other]); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} + +fn saturated_div< + T, + Q, + impl TTensor: TensorTrait, + impl QTensor: TensorTrait, + impl TDiv: Div, + impl TPartialOrd: PartialOrd, + impl TTryInto: TryInto, + impl TCopy: Copy, + impl TDrop: Drop, + impl QDrop: Drop, +>( + self: @Tensor, other: @Tensor, min_saturation: T, max_saturation: T +) -> Tensor { + let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); + let mut result = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); + + result + .append( + saturate( + min_saturation, + max_saturation, + *(*self.data)[indices_self] / *(*other.data)[indices_other] + ) + .try_into() + .unwrap() + ); + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/arithmetic/arithmetic_fp.cairo b/src/operators/tensor/math/arithmetic/arithmetic_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/arithmetic/arithmetic_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/arithmetic/arithmetic_fp/core.cairo b/src/operators/tensor/math/arithmetic/arithmetic_fp/core.cairo deleted file mode 100644 index a14b0b046..000000000 --- a/src/operators/tensor/math/arithmetic/arithmetic_fp/core.cairo +++ /dev/null @@ -1,56 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::arithmetic::arithmetic_fp::fp8x23; -use orion::operators::tensor::math::arithmetic::arithmetic_fp::fp16x16; - -fn add(self: @Tensor, other: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::add(self, other)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::add(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::add(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::add(self, other)), - } -} - -fn sub(self: @Tensor, other: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sub(self, other)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sub(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::sub(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::sub(self, other)), - } -} - -fn mul(self: @Tensor, other: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::mul(self, other)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::mul(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::mul(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::mul(self, other)), - } -} - -fn div(self: @Tensor, other: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::div(self, other)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::div(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::div(self, other)), - }, - Option::None(_) => Option::Some(fp16x16::div(self, other)), - } -} diff --git a/src/operators/tensor/math/arithmetic/arithmetic_fp/fp16x16.cairo b/src/operators/tensor/math/arithmetic/arithmetic_fp/fp16x16.cairo deleted file mode 100644 index 7b2cbe425..000000000 --- a/src/operators/tensor/math/arithmetic/arithmetic_fp/fp16x16.cairo +++ /dev/null @@ -1,386 +0,0 @@ -use core::traits::Into; -use core::option::OptionTrait; -use array::ArrayTrait; -use array::SpanTrait; -use traits::{TryInto}; - -use orion::numbers::signed_integer::i8::i8; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Sub, FP16x16Mul, FP16x16Div, FP16x16PartialOrd, FP16x16TryIntoI8 -}; -use orion::operators::tensor::helpers::broadcast_shape; -use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; -use orion::operators::tensor::helpers::{broadcast_index_mapping, len_from_shape, }; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - -use orion::utils::saturate; - -/// Adds two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting. -fn add(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] + *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise addition of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting and saturation. -fn saturated_add_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] + *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Subtracts two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise subtraction with broadcasting. -fn sub(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] - *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise substraction of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise substraction with broadcasting and saturation. -fn saturated_sub_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] - *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - - -/// Multiplies two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting. -fn mul(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] * *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise multiplication of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting and saturation. -fn saturated_mul_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] * *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Divides two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting. -fn div(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] / *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise division of two `Tensor` instances with broadcasting and saturation. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// * `min` - The minimum value for saturation. -/// * `max` - The maximum value for saturation. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting and saturation. -fn saturated_div( - self: @Tensor, other: @Tensor, min: FixedType, max: FixedType -) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate(min, max, *(*self.data)[indices_self] / *(*other.data)[indices_other]) - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise division of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting and saturation. -fn saturated_div_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] / *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} diff --git a/src/operators/tensor/math/arithmetic/arithmetic_fp/fp8x23.cairo b/src/operators/tensor/math/arithmetic/arithmetic_fp/fp8x23.cairo deleted file mode 100644 index 322f899ba..000000000 --- a/src/operators/tensor/math/arithmetic/arithmetic_fp/fp8x23.cairo +++ /dev/null @@ -1,386 +0,0 @@ -use core::traits::Into; -use core::option::OptionTrait; -use array::ArrayTrait; -use array::SpanTrait; -use traits::{TryInto}; - -use orion::numbers::signed_integer::i8::i8; -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23Add, FP8x23Sub, FP8x23Mul, FP8x23Div, FP8x23PartialOrd, FP8x23TryIntoI8 -}; -use orion::operators::tensor::helpers::broadcast_shape; -use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; -use orion::operators::tensor::helpers::{broadcast_index_mapping, len_from_shape, }; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - -use orion::utils::saturate; - -/// Adds two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting. -fn add(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] + *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise addition of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting and saturation. -fn saturated_add_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] + *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Subtracts two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise subtraction with broadcasting. -fn sub(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] - *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise substraction of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise substraction with broadcasting and saturation. -fn saturated_sub_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] - *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - - -/// Multiplies two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting. -fn mul(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] * *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise multiplication of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting and saturation. -fn saturated_mul_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] * *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Divides two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting. -fn div(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] / *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise division of two `Tensor` instances with broadcasting and saturation. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// * `min` - The minimum value for saturation. -/// * `max` - The maximum value for saturation. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting and saturation. -fn saturated_div( - self: @Tensor, other: @Tensor, min: FixedType, max: FixedType -) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate(min, max, *(*self.data)[indices_self] / *(*other.data)[indices_other]) - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise division of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting and saturation. -fn saturated_div_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - *(*self.data)[indices_self] / *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} diff --git a/src/operators/tensor/math/arithmetic/arithmetic_i32.cairo b/src/operators/tensor/math/arithmetic/arithmetic_i32.cairo deleted file mode 100644 index 71f531b0b..000000000 --- a/src/operators/tensor/math/arithmetic/arithmetic_i32.cairo +++ /dev/null @@ -1,338 +0,0 @@ -use core::option::OptionTrait; -use core::traits::TryInto; -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::{i32::i32, i8::i8}; -use orion::operators::tensor::helpers::broadcast_shape; - -use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index, }; -use orion::operators::tensor::helpers::{broadcast_index_mapping, len_from_shape, }; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - -use orion::utils::saturate; - -/// Adds two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting. -fn add(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] + *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise addition of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting and saturation. -fn saturated_add_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - i32 { mag: 128, sign: true }, - i32 { mag: 127, sign: false }, - *(*self.data)[indices_self] + *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Subtracts two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise subtraction with broadcasting. -fn sub(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] - *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise subtraction of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise subtraction with broadcasting and saturation. -fn saturated_sub_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - i32 { mag: 128, sign: true }, - i32 { mag: 127, sign: false }, - *(*self.data)[indices_self] - *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Multiplies two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting. -fn mul(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] * *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise multriplication of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting and saturation. -fn saturated_mul_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - i32 { mag: 128, sign: true }, - i32 { mag: 127, sign: false }, - *(*self.data)[indices_self] * *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Divides two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting. -fn div(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] / *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise division of two `Tensor` instances with broadcasting and saturation [-128;127]. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting and saturation. -fn saturated_div_i8(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate( - i32 { mag: 128, sign: true }, - i32 { mag: 127, sign: false }, - *(*self.data)[indices_self] / *(*other.data)[indices_other] - ) - .try_into() - .unwrap() - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} diff --git a/src/operators/tensor/math/arithmetic/arithmetic_i8.cairo b/src/operators/tensor/math/arithmetic/arithmetic_i8.cairo deleted file mode 100644 index 9ec01202c..000000000 --- a/src/operators/tensor/math/arithmetic/arithmetic_i8.cairo +++ /dev/null @@ -1,319 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::helpers::broadcast_shape; - -use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index, }; -use orion::operators::tensor::helpers::{broadcast_index_mapping, len_from_shape, }; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - -use orion::utils::saturate; - -/// Adds two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting. -fn add(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] + *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise addition of two `Tensor` instances with broadcasting and saturation. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// * `min` - The minimum value for saturation. -/// * `max` - The maximum value for saturation. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting and saturation. -fn saturated_add(self: @Tensor, other: @Tensor, min: i8, max: i8) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate(min, max, *(*self.data)[indices_self] + *(*other.data)[indices_other]) - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Subtracts two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise subtraction with broadcasting. -fn sub(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] - *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise substraction of two `Tensor` instances with broadcasting and saturation. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// * `min` - The minimum value for saturation. -/// * `max` - The maximum value for saturation. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise substraction with broadcasting and saturation. -fn saturated_sub(self: @Tensor, other: @Tensor, min: i8, max: i8) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate(min, max, *(*self.data)[indices_self] - *(*other.data)[indices_other]) - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Multiplies two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting. -fn mul(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] * *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise multiplication of two `Tensor` instances with broadcasting and saturation. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// * `min` - The minimum value for saturation. -/// * `max` - The maximum value for saturation. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting and saturation. -fn saturated_mul(self: @Tensor, other: @Tensor, min: i8, max: i8) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate(min, max, *(*self.data)[indices_self] * *(*other.data)[indices_other]) - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Divides two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting. -fn div(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] / *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Performs element-wise division of two `Tensor` instances with broadcasting and saturation. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// * `min` - The minimum value for saturation. -/// * `max` - The maximum value for saturation. -/// -/// # Panics -/// * Panics if the shapes of the tensors are not compatible. -/// * Panics if the gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting and saturation. -fn saturated_div(self: @Tensor, other: @Tensor, min: i8, max: i8) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result - .append( - saturate(min, max, *(*self.data)[indices_self] / *(*other.data)[indices_other]) - ); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} diff --git a/src/operators/tensor/math/arithmetic/arithmetic_u32.cairo b/src/operators/tensor/math/arithmetic/arithmetic_u32.cairo deleted file mode 100644 index cb3435be2..000000000 --- a/src/operators/tensor/math/arithmetic/arithmetic_u32.cairo +++ /dev/null @@ -1,158 +0,0 @@ -use core::option::OptionTrait; -use array::ArrayTrait; -use array::SpanTrait; -use core::traits::TryInto; - -use orion::operators::tensor::helpers::broadcast_shape; -use orion::numbers::signed_integer::{i32::i32, i8::i8}; -use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index, }; -use orion::operators::tensor::helpers::{broadcast_index_mapping, len_from_shape, }; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - -use orion::utils::saturate; - - -/// Adds two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise addition with broadcasting. -fn add(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] + *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Subtracts two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise subtraction with broadcasting. -fn sub(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] - *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Multiplies two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise multiplication with broadcasting. -fn mul(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] * *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} - -/// Divides two `Tensor` instances element-wise with broadcasting. -/// -/// # Arguments -/// * `self` - The first tensor. -/// * `other` - The second tensor. -/// -/// # Panics -/// * Panics if the shape of tensors are not compatible. -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * A `Tensor` instance representing the result of the element-wise division with broadcasting. -fn div(self: @Tensor, other: @Tensor) -> Tensor { - let broadcasted_shape = broadcast_shape(*self.shape, *other.shape); - let mut result = ArrayTrait::new(); - - let num_elements = len_from_shape(broadcasted_shape); - - let mut n: usize = 0; - loop { - let indices_broadcasted = unravel_index(n, broadcasted_shape); - - let indices_self = broadcast_index_mapping(*self.shape, indices_broadcasted); - let indices_other = broadcast_index_mapping(*other.shape, indices_broadcasted); - - result.append(*(*self.data)[indices_self] / *(*other.data)[indices_other]); - - n += 1; - if n == num_elements { - break (); - }; - }; - - return TensorTrait::::new(broadcasted_shape, result.span(), *self.extra); -} diff --git a/src/operators/tensor/math/asin.cairo b/src/operators/tensor/math/asin.cairo index 0bbe2037c..712c34575 100644 --- a/src/operators/tensor/math/asin.cairo +++ b/src/operators/tensor/math/asin.cairo @@ -1 +1,33 @@ -mod asin_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: TensorTrait::asin docstring +fn asin< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).asin()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/asin/asin_fp.cairo b/src/operators/tensor/math/asin/asin_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/asin/asin_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/asin/asin_fp/core.cairo b/src/operators/tensor/math/asin/asin_fp/core.cairo deleted file mode 100644 index 89767e9bc..000000000 --- a/src/operators/tensor/math/asin/asin_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::asin::asin_fp::fp8x23; -use orion::operators::tensor::math::asin::asin_fp::fp16x16; - -/// Cf: TensorTrait::asin docstring -fn asin(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::asin(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::asin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asin(*self)), - } -} diff --git a/src/operators/tensor/math/asin/asin_fp/fp16x16.cairo b/src/operators/tensor/math/asin/asin_fp/fp16x16.cairo deleted file mode 100644 index f7cce7502..000000000 --- a/src/operators/tensor/math/asin/asin_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::asin docstring -fn asin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).asin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/asin/asin_fp/fp8x23.cairo b/src/operators/tensor/math/asin/asin_fp/fp8x23.cairo deleted file mode 100644 index 80db7fbd6..000000000 --- a/src/operators/tensor/math/asin/asin_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::asin docstring -fn asin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).asin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/asinh.cairo b/src/operators/tensor/math/asinh.cairo index 05e6aea0d..4fe92bc16 100644 --- a/src/operators/tensor/math/asinh.cairo +++ b/src/operators/tensor/math/asinh.cairo @@ -1,4 +1,37 @@ -mod asinh_i8; -mod asinh_i32; -mod asinh_u32; -mod asinh_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::asinh docstring +fn asinh< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).asinh()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} + diff --git a/src/operators/tensor/math/asinh/asinh_fp.cairo b/src/operators/tensor/math/asinh/asinh_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/asinh/asinh_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/asinh/asinh_fp/core.cairo b/src/operators/tensor/math/asinh/asinh_fp/core.cairo deleted file mode 100644 index 31bd8ae0d..000000000 --- a/src/operators/tensor/math/asinh/asinh_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::asinh::asinh_fp::fp8x23; -use orion::operators::tensor::math::asinh::asinh_fp::fp16x16; - -/// Cf: TensorTrait::asinh docstring -fn asinh(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::asinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - } -} diff --git a/src/operators/tensor/math/asinh/asinh_fp/fp16x16.cairo b/src/operators/tensor/math/asinh/asinh_fp/fp16x16.cairo deleted file mode 100644 index a040ced67..000000000 --- a/src/operators/tensor/math/asinh/asinh_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/asinh/asinh_fp/fp8x23.cairo b/src/operators/tensor/math/asinh/asinh_fp/fp8x23.cairo deleted file mode 100644 index 0c72347f3..000000000 --- a/src/operators/tensor/math/asinh/asinh_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/asinh/asinh_i32.cairo b/src/operators/tensor/math/asinh/asinh_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/asinh/asinh_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/asinh/asinh_i32/core.cairo b/src/operators/tensor/math/asinh/asinh_i32/core.cairo deleted file mode 100644 index db7728ee7..000000000 --- a/src/operators/tensor/math/asinh/asinh_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::asinh::asinh_i32::fp8x23; -use orion::operators::tensor::math::asinh::asinh_i32::fp16x16; - -/// Cf: TensorTrait:asinh docstring -fn asinh_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::asinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - } -} diff --git a/src/operators/tensor/math/asinh/asinh_i32/fp16x16.cairo b/src/operators/tensor/math/asinh/asinh_i32/fp16x16.cairo deleted file mode 100644 index a79e0f3d1..000000000 --- a/src/operators/tensor/math/asinh/asinh_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/asinh/asinh_i32/fp8x23.cairo b/src/operators/tensor/math/asinh/asinh_i32/fp8x23.cairo deleted file mode 100644 index da47d5205..000000000 --- a/src/operators/tensor/math/asinh/asinh_i32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/asinh/asinh_i8.cairo b/src/operators/tensor/math/asinh/asinh_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/asinh/asinh_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/asinh/asinh_i8/core.cairo b/src/operators/tensor/math/asinh/asinh_i8/core.cairo deleted file mode 100644 index 0215e9a86..000000000 --- a/src/operators/tensor/math/asinh/asinh_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::asinh::asinh_i8::fp8x23; -use orion::operators::tensor::math::asinh::asinh_i8::fp16x16; - -/// Cf: TensorTrait:asinh docstring -fn asinh_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::asinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - } -} diff --git a/src/operators/tensor/math/asinh/asinh_i8/fp16x16.cairo b/src/operators/tensor/math/asinh/asinh_i8/fp16x16.cairo deleted file mode 100644 index 7a95383ae..000000000 --- a/src/operators/tensor/math/asinh/asinh_i8/fp16x16.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/asinh/asinh_i8/fp8x23.cairo b/src/operators/tensor/math/asinh/asinh_i8/fp8x23.cairo deleted file mode 100644 index 6ee4de9de..000000000 --- a/src/operators/tensor/math/asinh/asinh_i8/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/asinh/asinh_u32.cairo b/src/operators/tensor/math/asinh/asinh_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/asinh/asinh_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/asinh/asinh_u32/core.cairo b/src/operators/tensor/math/asinh/asinh_u32/core.cairo deleted file mode 100644 index 5afc2550f..000000000 --- a/src/operators/tensor/math/asinh/asinh_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::asinh::asinh_u32::fp8x23; -use orion::operators::tensor::math::asinh::asinh_u32::fp16x16; - -/// Cf: TensorTrait::asinh docstring -fn asinh_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::asinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::asinh(*self)), - } -} diff --git a/src/operators/tensor/math/asinh/asinh_u32/fp16x16.cairo b/src/operators/tensor/math/asinh/asinh_u32/fp16x16.cairo deleted file mode 100644 index 7d73ec207..000000000 --- a/src/operators/tensor/math/asinh/asinh_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/asinh/asinh_u32/fp8x23.cairo b/src/operators/tensor/math/asinh/asinh_u32/fp8x23.cairo deleted file mode 100644 index 91fcad656..000000000 --- a/src/operators/tensor/math/asinh/asinh_u32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::asinh docstring -fn asinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).asinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/atan.cairo b/src/operators/tensor/math/atan.cairo index 8d111caee..d1a0ab3b3 100644 --- a/src/operators/tensor/math/atan.cairo +++ b/src/operators/tensor/math/atan.cairo @@ -1,4 +1,35 @@ -mod atan_i8; -mod atan_i32; -mod atan_u32; -mod atan_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +fn atan< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).atan()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/atan/atan_fp.cairo b/src/operators/tensor/math/atan/atan_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/atan/atan_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/atan/atan_fp/core.cairo b/src/operators/tensor/math/atan/atan_fp/core.cairo deleted file mode 100644 index 3d06bab6f..000000000 --- a/src/operators/tensor/math/atan/atan_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::atan::atan_fp::fp8x23; -use orion::operators::tensor::math::atan::atan_fp::fp16x16; - -/// Cf: TensorTrait::atan docstring -fn atan(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::atan(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - } -} diff --git a/src/operators/tensor/math/atan/atan_fp/fp16x16.cairo b/src/operators/tensor/math/atan/atan_fp/fp16x16.cairo deleted file mode 100644 index c4235c39a..000000000 --- a/src/operators/tensor/math/atan/atan_fp/fp16x16.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/atan/atan_fp/fp8x23.cairo b/src/operators/tensor/math/atan/atan_fp/fp8x23.cairo deleted file mode 100644 index b1bd2f050..000000000 --- a/src/operators/tensor/math/atan/atan_fp/fp8x23.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/atan/atan_i32.cairo b/src/operators/tensor/math/atan/atan_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/atan/atan_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/atan/atan_i32/core.cairo b/src/operators/tensor/math/atan/atan_i32/core.cairo deleted file mode 100644 index 57bb7d649..000000000 --- a/src/operators/tensor/math/atan/atan_i32/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::atan::atan_i32::fp8x23; -use orion::operators::tensor::math::atan::atan_i32::fp16x16; - -fn atan_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::atan(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - } -} diff --git a/src/operators/tensor/math/atan/atan_i32/fp16x16.cairo b/src/operators/tensor/math/atan/atan_i32/fp16x16.cairo deleted file mode 100644 index 600c9a57d..000000000 --- a/src/operators/tensor/math/atan/atan_i32/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item).mag, *item.sign).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/atan/atan_i32/fp8x23.cairo b/src/operators/tensor/math/atan/atan_i32/fp8x23.cairo deleted file mode 100644 index 49bb0b660..000000000 --- a/src/operators/tensor/math/atan/atan_i32/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item).mag, *item.sign).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/atan/atan_i8.cairo b/src/operators/tensor/math/atan/atan_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/atan/atan_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/atan/atan_i8/core.cairo b/src/operators/tensor/math/atan/atan_i8/core.cairo deleted file mode 100644 index e552560d1..000000000 --- a/src/operators/tensor/math/atan/atan_i8/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::atan::atan_i8::fp8x23; -use orion::operators::tensor::math::atan::atan_i8::fp16x16; - -fn atan_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::atan(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - } -} diff --git a/src/operators/tensor/math/atan/atan_i8/fp16x16.cairo b/src/operators/tensor/math/atan/atan_i8/fp16x16.cairo deleted file mode 100644 index 4b75090dd..000000000 --- a/src/operators/tensor/math/atan/atan_i8/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item).mag.into(), *item.sign).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/atan/atan_i8/fp8x23.cairo b/src/operators/tensor/math/atan/atan_i8/fp8x23.cairo deleted file mode 100644 index fcfd18a25..000000000 --- a/src/operators/tensor/math/atan/atan_i8/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item).mag.into(), *item.sign).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/atan/atan_u32.cairo b/src/operators/tensor/math/atan/atan_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/atan/atan_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/atan/atan_u32/core.cairo b/src/operators/tensor/math/atan/atan_u32/core.cairo deleted file mode 100644 index 400b9fa07..000000000 --- a/src/operators/tensor/math/atan/atan_u32/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::atan::atan_u32::fp8x23; -use orion::operators::tensor::math::atan::atan_u32::fp16x16; - -fn atan_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::atan(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - }, - Option::None(_) => Option::Some(fp16x16::atan(*self)), - } -} diff --git a/src/operators/tensor/math/atan/atan_u32/fp16x16.cairo b/src/operators/tensor/math/atan/atan_u32/fp16x16.cairo deleted file mode 100644 index c3ea1677c..000000000 --- a/src/operators/tensor/math/atan/atan_u32/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/atan/atan_u32/fp8x23.cairo b/src/operators/tensor/math/atan/atan_u32/fp8x23.cairo deleted file mode 100644 index f523e3cdc..000000000 --- a/src/operators/tensor/math/atan/atan_u32/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn atan(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).atan()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/ceil.cairo b/src/operators/tensor/math/ceil.cairo index 2aff6ecb7..6b8e68d4b 100644 --- a/src/operators/tensor/math/ceil.cairo +++ b/src/operators/tensor/math/ceil.cairo @@ -1 +1,34 @@ -mod ceil_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + +/// Cf: TensorTrait::ceil docstring +fn ceil< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop +>( + mut z: Tensor +) -> Tensor { + let mut data_result = ArrayTrait::::new(); + + loop { + match z.data.pop_front() { + Option::Some(item) => { + data_result.append((*item).ceil()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(z.shape, data_result.span()); +} + diff --git a/src/operators/tensor/math/ceil/ceil_fp.cairo b/src/operators/tensor/math/ceil/ceil_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/ceil/ceil_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/ceil/ceil_fp/core.cairo b/src/operators/tensor/math/ceil/ceil_fp/core.cairo deleted file mode 100644 index 8b40cc10c..000000000 --- a/src/operators/tensor/math/ceil/ceil_fp/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::math::ceil::ceil_fp::fp8x23; -use orion::operators::tensor::math::ceil::ceil_fp::fp16x16; - - -/// Cf: TensorTrait::ceil docstring -fn ceil(z: @Tensor) -> Option> { - match *z.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::ceil(*z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::ceil(*z)), - }, - Option::None(_) => Option::Some(fp16x16::ceil(*z)), - }, - Option::None(_) => Option::Some(fp16x16::ceil(*z)), - } -} diff --git a/src/operators/tensor/math/ceil/ceil_fp/fp16x16.cairo b/src/operators/tensor/math/ceil/ceil_fp/fp16x16.cairo deleted file mode 100644 index ea3ce845c..000000000 --- a/src/operators/tensor/math/ceil/ceil_fp/fp16x16.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: TensorTrait::ceil docstring -fn ceil(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - data_result.append((*item).ceil()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} diff --git a/src/operators/tensor/math/ceil/ceil_fp/fp8x23.cairo b/src/operators/tensor/math/ceil/ceil_fp/fp8x23.cairo deleted file mode 100644 index 814618b1e..000000000 --- a/src/operators/tensor/math/ceil/ceil_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: TensorTrait::ceil docstring -fn ceil(mut z: Tensor) -> Tensor { - let mut data_result = ArrayTrait::::new(); - - loop { - match z.data.pop_front() { - Option::Some(item) => { - data_result.append((*item).ceil()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(z.shape, data_result.span(), z.extra); -} - diff --git a/src/operators/tensor/math/concat.cairo b/src/operators/tensor/math/concat.cairo new file mode 100644 index 000000000..e4baf6c91 --- /dev/null +++ b/src/operators/tensor/math/concat.cairo @@ -0,0 +1,146 @@ +use core::clone::Clone; +use array::{ArrayTrait, SpanTrait}; +use option::OptionTrait; +use debug::PrintTrait; +use core::traits::Into; + +use orion::operators::tensor::helpers::replace_index; +use orion::operators::tensor::{TensorTrait, Tensor}; + + +fn concat, impl TCopy: Copy, impl TDrop: Drop,>( + mut tensors: Span>, axis: usize +) -> Tensor { + assert(tensors.len() >= 2, 'Input tensors must be > 1'); + let base_tensor = *tensors.at(0); + let base_shape = base_tensor.shape; + let dimension = base_shape.len(); + assert(dimension > axis, 'Out of bounds for dimension'); + + // Validate shapes of tensors + validate_shapes(tensors, base_shape, axis); + + // Calculate output size + let output_size = compute_output_size(base_shape, tensors, axis); + + // Concatenate tensor data + let output_data: Array = concatenate_data(tensors, axis, base_shape); + + TensorTrait::::new(output_size.span(), output_data.span()) +} + +fn validate_shapes(mut tensors: Span>, mut base_shape: Span, axis: usize) { + loop { + match tensors.pop_front() { + Option::Some(tensor) => { + assert(base_shape.len() == (*tensor.shape).len(), 'Dimension not the same'); + + let mut axis_index = 0; + loop { + if axis_index == base_shape.len() { + break; + } + if axis_index != axis { + assert( + base_shape.at(axis_index) == (*tensor.shape).at(axis_index), + 'Shape is not the same' + ); + } + axis_index += 1; + }; + }, + Option::None(_) => { + break; + } + }; + }; +} + +fn compute_output_size( + mut base_shape: Span, mut tensors: Span>, axis: usize +) -> Array { + let mut output_size = ArrayTrait::::new(); + + let mut axis_size = 0; + loop { + match tensors.pop_front() { + Option::Some(tensor) => { + axis_size += *(*tensor.shape).at(axis); + }, + Option::None(_) => { + break; + } + }; + }; + + let mut shape_index = 0; + loop { + match base_shape.pop_front() { + Option::Some(item) => { + if shape_index == axis { + output_size.append(axis_size); + } else { + output_size.append(*item); + } + shape_index += 1; + }, + Option::None(_) => { + break; + } + }; + }; + + output_size +} + +fn concatenate_data, impl TDrop: Drop,>( + mut tensors: Span>, axis: usize, base_shape: Span +) -> Array { + let mut output_data = ArrayTrait::::new(); + + let total_loops = product_upto(base_shape, axis); + + let mut outer_loop_index = 0; + loop { + if outer_loop_index == total_loops { + break; + } + + let mut tensor_index = 0; + loop { + if tensor_index == tensors.len() { + break; + } + let tensor = tensors.at(tensor_index); + let slice_len = (*tensor.data).len() / total_loops; + + let mut inner_index = 0; + loop { + if inner_index == slice_len { + break; + } + + output_data.append(*(*tensor.data).at(slice_len * outer_loop_index + inner_index)); + inner_index += 1; + }; + tensor_index += 1; + }; + outer_loop_index += 1; + }; + + output_data +} + +fn product_upto(mut shape: Span, upto: usize) -> usize { + let mut total = 1; + let mut index = 0; + + loop { + if index == upto { + break; + } + total *= *shape.at(index); + index += 1; + }; + total +} diff --git a/src/operators/tensor/math/cos.cairo b/src/operators/tensor/math/cos.cairo index 6184ac825..e27ad5c1d 100644 --- a/src/operators/tensor/math/cos.cairo +++ b/src/operators/tensor/math/cos.cairo @@ -1,4 +1,36 @@ -mod cos_i8; -mod cos_i32; -mod cos_u32; -mod cos_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::cos docstring +fn cos< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).cos()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/cos/cos_fp.cairo b/src/operators/tensor/math/cos/cos_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cos/cos_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cos/cos_fp/core.cairo b/src/operators/tensor/math/cos/cos_fp/core.cairo deleted file mode 100644 index cae21faf3..000000000 --- a/src/operators/tensor/math/cos/cos_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::cos::cos_fp::fp8x23; -use orion::operators::tensor::math::cos::cos_fp::fp16x16; - -/// Cf: TensorTrait::cos docstring -fn cos(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cos(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - } -} diff --git a/src/operators/tensor/math/cos/cos_fp/fp16x16.cairo b/src/operators/tensor/math/cos/cos_fp/fp16x16.cairo deleted file mode 100644 index 747638960..000000000 --- a/src/operators/tensor/math/cos/cos_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cos/cos_fp/fp8x23.cairo b/src/operators/tensor/math/cos/cos_fp/fp8x23.cairo deleted file mode 100644 index 88878ac8f..000000000 --- a/src/operators/tensor/math/cos/cos_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cos/cos_i32.cairo b/src/operators/tensor/math/cos/cos_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cos/cos_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cos/cos_i32/core.cairo b/src/operators/tensor/math/cos/cos_i32/core.cairo deleted file mode 100644 index baf106dd2..000000000 --- a/src/operators/tensor/math/cos/cos_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::cos::cos_i32::fp8x23; -use orion::operators::tensor::math::cos::cos_i32::fp16x16; - -/// Cf: TensorTrait::cos docstring -fn cos_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cos(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - } -} diff --git a/src/operators/tensor/math/cos/cos_i32/fp16x16.cairo b/src/operators/tensor/math/cos/cos_i32/fp16x16.cairo deleted file mode 100644 index a3f9a67aa..000000000 --- a/src/operators/tensor/math/cos/cos_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cos/cos_i32/fp8x23.cairo b/src/operators/tensor/math/cos/cos_i32/fp8x23.cairo deleted file mode 100644 index 794c6ccaa..000000000 --- a/src/operators/tensor/math/cos/cos_i32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cos/cos_i8.cairo b/src/operators/tensor/math/cos/cos_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cos/cos_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cos/cos_i8/core.cairo b/src/operators/tensor/math/cos/cos_i8/core.cairo deleted file mode 100644 index 7b66ebf58..000000000 --- a/src/operators/tensor/math/cos/cos_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::cos::cos_i8::fp8x23; -use orion::operators::tensor::math::cos::cos_i8::fp16x16; - -/// Cf: TensorTrait::cos docstring -fn cos_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cos(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - } -} diff --git a/src/operators/tensor/math/cos/cos_i8/fp16x16.cairo b/src/operators/tensor/math/cos/cos_i8/fp16x16.cairo deleted file mode 100644 index c6e3e03be..000000000 --- a/src/operators/tensor/math/cos/cos_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cos/cos_i8/fp8x23.cairo b/src/operators/tensor/math/cos/cos_i8/fp8x23.cairo deleted file mode 100644 index 8be684847..000000000 --- a/src/operators/tensor/math/cos/cos_i8/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cos/cos_u32.cairo b/src/operators/tensor/math/cos/cos_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cos/cos_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cos/cos_u32/core.cairo b/src/operators/tensor/math/cos/cos_u32/core.cairo deleted file mode 100644 index 322b1010f..000000000 --- a/src/operators/tensor/math/cos/cos_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::cos::cos_u32::fp8x23; -use orion::operators::tensor::math::cos::cos_u32::fp16x16; - -/// Cf: TensorTrait::cos docstring -fn cos_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cos(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cos(*self)), - } -} diff --git a/src/operators/tensor/math/cos/cos_u32/fp16x16.cairo b/src/operators/tensor/math/cos/cos_u32/fp16x16.cairo deleted file mode 100644 index b7450b8e4..000000000 --- a/src/operators/tensor/math/cos/cos_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cos/cos_u32/fp8x23.cairo b/src/operators/tensor/math/cos/cos_u32/fp8x23.cairo deleted file mode 100644 index 4b7f9cb79..000000000 --- a/src/operators/tensor/math/cos/cos_u32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cos docstring -fn cos(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).cos()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cosh.cairo b/src/operators/tensor/math/cosh.cairo index 6131c2780..d0c2d8515 100644 --- a/src/operators/tensor/math/cosh.cairo +++ b/src/operators/tensor/math/cosh.cairo @@ -1,4 +1,36 @@ -mod cosh_i8; -mod cosh_i32; -mod cosh_u32; -mod cosh_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::cosh docstring +fn cosh< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).cosh()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/cosh/cosh_fp.cairo b/src/operators/tensor/math/cosh/cosh_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cosh/cosh_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cosh/cosh_fp/core.cairo b/src/operators/tensor/math/cosh/cosh_fp/core.cairo deleted file mode 100644 index 0ff8378bc..000000000 --- a/src/operators/tensor/math/cosh/cosh_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::cosh::cosh_fp::fp8x23; -use orion::operators::tensor::math::cosh::cosh_fp::fp16x16; - -/// Cf: TensorTrait::cosh docstring -fn cosh(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - } -} diff --git a/src/operators/tensor/math/cosh/cosh_fp/fp16x16.cairo b/src/operators/tensor/math/cosh/cosh_fp/fp16x16.cairo deleted file mode 100644 index 17d6a4bb5..000000000 --- a/src/operators/tensor/math/cosh/cosh_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/cosh/cosh_fp/fp8x23.cairo b/src/operators/tensor/math/cosh/cosh_fp/fp8x23.cairo deleted file mode 100644 index d8ec5ad1d..000000000 --- a/src/operators/tensor/math/cosh/cosh_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cosh/cosh_i32.cairo b/src/operators/tensor/math/cosh/cosh_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cosh/cosh_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cosh/cosh_i32/core.cairo b/src/operators/tensor/math/cosh/cosh_i32/core.cairo deleted file mode 100644 index ed557dfdf..000000000 --- a/src/operators/tensor/math/cosh/cosh_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::cosh::cosh_i32::fp8x23; -use orion::operators::tensor::math::cosh::cosh_i32::fp16x16; - -/// Cf: TensorTrait::cosh docstring -fn cosh_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - } -} diff --git a/src/operators/tensor/math/cosh/cosh_i32/fp16x16.cairo b/src/operators/tensor/math/cosh/cosh_i32/fp16x16.cairo deleted file mode 100644 index d4f381d0b..000000000 --- a/src/operators/tensor/math/cosh/cosh_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cosh/cosh_i32/fp8x23.cairo b/src/operators/tensor/math/cosh/cosh_i32/fp8x23.cairo deleted file mode 100644 index 395214d5f..000000000 --- a/src/operators/tensor/math/cosh/cosh_i32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/cosh/cosh_i8.cairo b/src/operators/tensor/math/cosh/cosh_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cosh/cosh_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cosh/cosh_i8/core.cairo b/src/operators/tensor/math/cosh/cosh_i8/core.cairo deleted file mode 100644 index cf1b18d50..000000000 --- a/src/operators/tensor/math/cosh/cosh_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::cosh::cosh_i8::fp8x23; -use orion::operators::tensor::math::cosh::cosh_i8::fp16x16; - -/// Cf: TensorTrait::cosh docstring -fn cosh_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - } -} diff --git a/src/operators/tensor/math/cosh/cosh_i8/fp16x16.cairo b/src/operators/tensor/math/cosh/cosh_i8/fp16x16.cairo deleted file mode 100644 index 7ab17385d..000000000 --- a/src/operators/tensor/math/cosh/cosh_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cosh/cosh_i8/fp8x23.cairo b/src/operators/tensor/math/cosh/cosh_i8/fp8x23.cairo deleted file mode 100644 index 61fdbdee2..000000000 --- a/src/operators/tensor/math/cosh/cosh_i8/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/cosh/cosh_u32.cairo b/src/operators/tensor/math/cosh/cosh_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cosh/cosh_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cosh/cosh_u32/core.cairo b/src/operators/tensor/math/cosh/cosh_u32/core.cairo deleted file mode 100644 index 8017aa912..000000000 --- a/src/operators/tensor/math/cosh/cosh_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::cosh::cosh_u32::fp8x23; -use orion::operators::tensor::math::cosh::cosh_u32::fp16x16; - -/// Cf: TensorTrait::cosh docstring -fn cosh_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::cosh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::cosh(*self)), - } -} diff --git a/src/operators/tensor/math/cosh/cosh_u32/fp16x16.cairo b/src/operators/tensor/math/cosh/cosh_u32/fp16x16.cairo deleted file mode 100644 index c360a9d7b..000000000 --- a/src/operators/tensor/math/cosh/cosh_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/cosh/cosh_u32/fp8x23.cairo b/src/operators/tensor/math/cosh/cosh_u32/fp8x23.cairo deleted file mode 100644 index 69e00eba4..000000000 --- a/src/operators/tensor/math/cosh/cosh_u32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::cosh docstring -fn cosh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).cosh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/cumsum.cairo b/src/operators/tensor/math/cumsum.cairo index b6863d403..97a755874 100644 --- a/src/operators/tensor/math/cumsum.cairo +++ b/src/operators/tensor/math/cumsum.cairo @@ -1,6 +1,173 @@ -mod cumsum_i8; -mod cumsum_i32; -mod cumsum_u32; -mod cumsum_fp; -mod helpers; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use debug::PrintTrait; +use orion::operators::tensor::helpers::replace_index; +use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; +use orion::numbers::NumberTrait; + +/// Cf: TensorTrait::cumsum docstring +fn cumsum< + T, + MAG, + impl TTensorTrait: TensorTrait, + impl TNumber: NumberTrait, + impl TAddEq: AddEq, + impl TAdd: Add, + impl TSub: Sub, + impl TCopy: Copy, + impl TDrop: Drop, +>( + self: @Tensor, axis: usize, exclusive: Option, reverse: Option +) -> Tensor { + let reverse = match reverse { + Option::Some(val) => val, + Option::None(_) => false + }; + + if reverse { + cumsum_reverse::(self, axis, exclusive, NumberTrait::zero()) + } else { + cumsum_forward::(self, axis, exclusive, NumberTrait::zero()) + } +} + +/// Cf: TensorTrait::cumsum docstring +fn cumsum_forward< + T, + impl TTensorTrait: TensorTrait, + impl TAdd: Add, + impl TCopy: Copy, + impl TDrop: Drop, +>( + self: @Tensor, axis: usize, exclusive: Option, zero: T, +) -> Tensor { + let exclusive = match exclusive { + Option::Some(val) => val, + Option::None(_) => false, + }; + + assert(axis < (*self.shape).len(), 'axis out of dimensions'); + + let data = *self.data; + + let mut output_data = ArrayTrait::new(); + + let mut index: usize = 0; + + loop { + if index == data.len() { + break (); + }; + + let current_indices = unravel_index(index, *self.shape); + let axis_value = *current_indices[axis]; + if axis_value == 0 { + if exclusive { + output_data.append(zero); + } else { + output_data.append(*(data)[index]); + } + } else { + let previous_axis_element_indices = replace_index( + current_indices, axis, axis_value - 1 + ); + let previous_axis_element_index = ravel_index( + *self.shape, previous_axis_element_indices + ); + + if exclusive { + output_data + .append( + *output_data[previous_axis_element_index] + + *(data)[previous_axis_element_index] + ); + } else { + output_data.append(*output_data[previous_axis_element_index] + *(data)[index]); + }; + } + + index += 1; + }; + + return TensorTrait::::new(*self.shape, output_data.span()); +} + + +/// Cf: TensorTrait::cumsum docstring +fn cumsum_reverse< + T, + impl TTensorTrait: TensorTrait, + impl TAddEq: AddEq, + impl TSub: Sub, + impl TCopy: Copy, + impl TDrop: Drop, +>( + self: @Tensor, axis: usize, exclusive: Option, zero: T, +) -> Tensor { + let exclusive = match exclusive { + Option::Some(val) => val, + Option::None(_) => false, + }; + + assert(axis < (*self.shape).len(), 'axis out of dimensions'); + let data = *self.data; + let mut output_data = ArrayTrait::new(); + let mut index: usize = 0; + loop { + if index == data.len() { + break (); + }; + + let current_indices = unravel_index(index, *self.shape); + let mut axis_value = *current_indices[axis]; + + if axis_value == 0 { + // If the axis value is 0, we need to sum all the elements + // in the axis. + + let mut sum = *(data)[index]; + if exclusive { + sum = zero; + } + + let end_index = *(*self.shape)[axis] - 1; + + loop { + axis_value += 1; + if axis_value > end_index { + break (); + } + + let next_axis_element_indices = replace_index(current_indices, axis, axis_value); + let next_axis_element_index = ravel_index(*self.shape, next_axis_element_indices); + sum += *data[next_axis_element_index]; + }; + output_data.append(sum); + } else { + // If the axis value is not 0, we only need to do a subtraction + let previous_axis_element_indices = replace_index( + current_indices, axis, axis_value - 1 + ); + let previous_axis_element_index = ravel_index( + *self.shape, previous_axis_element_indices + ); + let mut z = *(data)[previous_axis_element_index]; + + if exclusive { + output_data.append(*output_data[previous_axis_element_index] - *(data)[index]); + } else { + output_data + .append( + *output_data[previous_axis_element_index] + - *(data)[previous_axis_element_index] + ); + } + } + + index += 1; + }; + + return TensorTrait::::new(*self.shape, output_data.span()); +} diff --git a/src/operators/tensor/math/cumsum/cumsum_fp.cairo b/src/operators/tensor/math/cumsum/cumsum_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/cumsum/cumsum_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/cumsum/cumsum_fp/core.cairo b/src/operators/tensor/math/cumsum/cumsum_fp/core.cairo deleted file mode 100644 index 9906299ab..000000000 --- a/src/operators/tensor/math/cumsum/cumsum_fp/core.cairo +++ /dev/null @@ -1,24 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::cumsum::cumsum_fp::fp8x23; -use orion::operators::tensor::math::cumsum::cumsum_fp::fp16x16; - -/// Cf: TensorTrait::cumsum docstring -fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option -) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some( - fp8x23::cumsum(self, axis, exclusive, reverse) - ), - FixedImpl::FP16x16(()) => Option::Some( - fp16x16::cumsum(self, axis, exclusive, reverse) - ), - }, - Option::None(_) => Option::Some(fp16x16::cumsum(self, axis, exclusive, reverse)), - }, - Option::None(_) => Option::Some(fp16x16::cumsum(self, axis, exclusive, reverse)), - } -} diff --git a/src/operators/tensor/math/cumsum/cumsum_fp/fp16x16.cairo b/src/operators/tensor/math/cumsum/cumsum_fp/fp16x16.cairo deleted file mode 100644 index d8303db36..000000000 --- a/src/operators/tensor/math/cumsum/cumsum_fp/fp16x16.cairo +++ /dev/null @@ -1,24 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Sub, FP16x16AddEq -}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::cumsum::helpers::{cumsum_forward, cumsum_reverse}; - - -/// Cf: TensorTrait::cumsum docstring -fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option -) -> Tensor { - let reverse = match reverse { - Option::Some(val) => val, - Option::None(_) => false - }; - - if reverse { - cumsum_reverse(self, axis, exclusive, FixedTrait::new(0, false)) - } else { - cumsum_forward(self, axis, exclusive, FixedTrait::new(0, false)) - } -} diff --git a/src/operators/tensor/math/cumsum/cumsum_fp/fp8x23.cairo b/src/operators/tensor/math/cumsum/cumsum_fp/fp8x23.cairo deleted file mode 100644 index 3ee7544b5..000000000 --- a/src/operators/tensor/math/cumsum/cumsum_fp/fp8x23.cairo +++ /dev/null @@ -1,24 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23Add, FP8x23Sub, FP8x23AddEq -}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::cumsum::helpers::{cumsum_forward, cumsum_reverse}; - - -/// Cf: TensorTrait::cumsum docstring -fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option -) -> Tensor { - let reverse = match reverse { - Option::Some(val) => val, - Option::None(_) => false - }; - - if reverse { - cumsum_reverse(self, axis, exclusive, FixedTrait::new(0, false)) - } else { - cumsum_forward(self, axis, exclusive, FixedTrait::new(0, false)) - } -} diff --git a/src/operators/tensor/math/cumsum/cumsum_i32.cairo b/src/operators/tensor/math/cumsum/cumsum_i32.cairo deleted file mode 100644 index ba401f713..000000000 --- a/src/operators/tensor/math/cumsum/cumsum_i32.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::cumsum::helpers::{cumsum_forward, cumsum_reverse}; - -/// Cf: TensorTrait::cumsum docstring -fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option -) -> Tensor { - let reverse = match reverse { - Option::Some(val) => val, - Option::None(_) => false - }; - - if reverse { - cumsum_reverse(self, axis, exclusive, IntegerTrait::new(0, false)) - } else { - cumsum_forward(self, axis, exclusive, IntegerTrait::new(0, false)) - } -} diff --git a/src/operators/tensor/math/cumsum/cumsum_i8.cairo b/src/operators/tensor/math/cumsum/cumsum_i8.cairo deleted file mode 100644 index a5d3ae93c..000000000 --- a/src/operators/tensor/math/cumsum/cumsum_i8.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::cumsum::helpers::{cumsum_forward, cumsum_reverse}; - -/// Cf: TensorTrait::cumsum docstring -fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option -) -> Tensor { - let reverse = match reverse { - Option::Some(val) => val, - Option::None(_) => false - }; - - if reverse { - cumsum_reverse(self, axis, exclusive, IntegerTrait::new(0, false)) - } else { - cumsum_forward(self, axis, exclusive, IntegerTrait::new(0, false)) - } -} diff --git a/src/operators/tensor/math/cumsum/cumsum_u32.cairo b/src/operators/tensor/math/cumsum/cumsum_u32.cairo deleted file mode 100644 index 84a3492ad..000000000 --- a/src/operators/tensor/math/cumsum/cumsum_u32.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::cumsum::helpers::{cumsum_forward, cumsum_reverse}; - -/// Cf: TensorTrait::cumsum docstring -fn cumsum( - self: @Tensor, axis: usize, exclusive: Option, reverse: Option, -) -> Tensor { - let reverse = match reverse { - Option::Some(val) => val, - Option::None(_) => false - }; - - if reverse { - cumsum_reverse(self, axis, exclusive, 0) - } else { - cumsum_forward(self, axis, exclusive, 0) - } -} diff --git a/src/operators/tensor/math/cumsum/helpers.cairo b/src/operators/tensor/math/cumsum/helpers.cairo deleted file mode 100644 index 7953cc3e6..000000000 --- a/src/operators/tensor/math/cumsum/helpers.cairo +++ /dev/null @@ -1,149 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use debug::PrintTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::{impl_tensor_i32, impl_tensor_u32}; -use orion::operators::tensor::helpers::replace_index; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; - - -/// Cf: TensorTrait::cumsum docstring -fn cumsum_forward< - T, - impl TTensorTrait: TensorTrait, - impl TAdd: Add, - impl TCopy: Copy, - impl TDrop: Drop, ->( - self: @Tensor, axis: usize, exclusive: Option, zero: T, -) -> Tensor { - let exclusive = match exclusive { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis < (*self.shape).len(), 'axis out of dimensions'); - - let data = *self.data; - - let mut output_data = ArrayTrait::new(); - - let mut index: usize = 0; - - loop { - if index == data.len() { - break (); - }; - - let current_indices = unravel_index(index, *self.shape); - let axis_value = *current_indices[axis]; - if axis_value == 0 { - if exclusive { - output_data.append(zero); - } else { - output_data.append(*(data)[index]); - } - } else { - let previous_axis_element_indices = replace_index( - current_indices, axis, axis_value - 1 - ); - let previous_axis_element_index = ravel_index( - *self.shape, previous_axis_element_indices - ); - - if exclusive { - output_data - .append( - *output_data[previous_axis_element_index] - + *(data)[previous_axis_element_index] - ); - } else { - output_data.append(*output_data[previous_axis_element_index] + *(data)[index]); - }; - } - - index += 1; - }; - - return TensorTrait::::new(*self.shape, output_data.span(), *self.extra); -} - - -/// Cf: TensorTrait::cumsum docstring -fn cumsum_reverse< - T, - impl TTensorTrait: TensorTrait, - impl TAddEq: AddEq, - impl TSub: Sub, - impl TCopy: Copy, - impl TDrop: Drop, ->( - self: @Tensor, axis: usize, exclusive: Option, zero: T, -) -> Tensor { - let exclusive = match exclusive { - Option::Some(val) => val, - Option::None(_) => false, - }; - - assert(axis < (*self.shape).len(), 'axis out of dimensions'); - let data = *self.data; - let mut output_data = ArrayTrait::new(); - let mut index: usize = 0; - loop { - if index == data.len() { - break (); - }; - - let current_indices = unravel_index(index, *self.shape); - let mut axis_value = *current_indices[axis]; - - if axis_value == 0 { - // If the axis value is 0, we need to sum all the elements - // in the axis. - - let mut sum = *(data)[index]; - if exclusive { - sum = zero; - } - - let end_index = *(*self.shape)[axis] - 1; - - loop { - axis_value += 1; - if axis_value > end_index { - break (); - } - - let next_axis_element_indices = replace_index(current_indices, axis, axis_value); - let next_axis_element_index = ravel_index(*self.shape, next_axis_element_indices); - sum += *data[next_axis_element_index]; - }; - output_data.append(sum); - } else { - // If the axis value is not 0, we only need to do a subtraction - let previous_axis_element_indices = replace_index( - current_indices, axis, axis_value - 1 - ); - let previous_axis_element_index = ravel_index( - *self.shape, previous_axis_element_indices - ); - let mut z = *(data)[previous_axis_element_index]; - - if exclusive { - output_data.append(*output_data[previous_axis_element_index] - *(data)[index]); - } else { - output_data - .append( - *output_data[previous_axis_element_index] - - *(data)[previous_axis_element_index] - ); - } - } - - index += 1; - }; - - return TensorTrait::::new(*self.shape, output_data.span(), *self.extra); -} diff --git a/src/operators/tensor/math/equal.cairo b/src/operators/tensor/math/equal.cairo index e3dbe48a0..9de0c9fe4 100644 --- a/src/operators/tensor/math/equal.cairo +++ b/src/operators/tensor/math/equal.cairo @@ -1,4 +1,45 @@ -mod equal_i8; -mod equal_i32; -mod equal_u32; -mod equal_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::helpers::{ + broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility +}; + +/// Cf: TensorTrait::equal docstring +fn equal< + T, + impl UsizeFTensor: TensorTrait, + impl TPartialEq: PartialEq, + impl TCopy: Copy, + impl TDrop: Drop +>( + y: @Tensor, z: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); + let mut result: Array = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); + + if *(*y.data)[indices_self] == *(*z.data)[indices_other] { + result.append(1); + } else { + result.append(0); + } + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/equal/equal_fp.cairo b/src/operators/tensor/math/equal/equal_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/equal/equal_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/equal/equal_fp/core.cairo b/src/operators/tensor/math/equal/equal_fp/core.cairo deleted file mode 100644 index aba2e6e73..000000000 --- a/src/operators/tensor/math/equal/equal_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::equal::equal_fp::fp8x23; -use orion::operators::tensor::math::equal::equal_fp::fp16x16; - -/// Cf: TensorTrait::equal docstring -fn equal(y: @Tensor, z: @Tensor) -> Option> { - match *y.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::equal(y, z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::equal(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::equal(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::equal(y, z)), - } -} diff --git a/src/operators/tensor/math/equal/equal_fp/fp16x16.cairo b/src/operators/tensor/math/equal/equal_fp/fp16x16.cairo deleted file mode 100644 index 4ed415c10..000000000 --- a/src/operators/tensor/math/equal/equal_fp/fp16x16.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialEq; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::equal docstring -fn equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger) = if (*y.data).len() < (*z.data).len() { - (y, z) - } else { - (z, y) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - if bigger_current_index == smaller_current_index { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/equal/equal_fp/fp8x23.cairo b/src/operators/tensor/math/equal/equal_fp/fp8x23.cairo deleted file mode 100644 index f1acc3f75..000000000 --- a/src/operators/tensor/math/equal/equal_fp/fp8x23.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23PartialEq; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::equal docstring -fn equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger) = if (*y.data).len() < (*z.data).len() { - (y, z) - } else { - (z, y) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - if bigger_current_index == smaller_current_index { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/equal/equal_i32.cairo b/src/operators/tensor/math/equal/equal_i32.cairo deleted file mode 100644 index 43e1071db..000000000 --- a/src/operators/tensor/math/equal/equal_i32.cairo +++ /dev/null @@ -1,43 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::equal docstring -fn equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger) = if (*y.data).len() < (*z.data).len() { - (y, z) - } else { - (z, y) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - if bigger_current_index == smaller_current_index { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/equal/equal_i8.cairo b/src/operators/tensor/math/equal/equal_i8.cairo deleted file mode 100644 index 4509aa253..000000000 --- a/src/operators/tensor/math/equal/equal_i8.cairo +++ /dev/null @@ -1,43 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::equal docstring -fn equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger) = if (*y.data).len() < (*z.data).len() { - (y, z) - } else { - (z, y) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - if bigger_current_index == smaller_current_index { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/equal/equal_u32.cairo b/src/operators/tensor/math/equal/equal_u32.cairo deleted file mode 100644 index dfc678a30..000000000 --- a/src/operators/tensor/math/equal/equal_u32.cairo +++ /dev/null @@ -1,42 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::equal docstring -fn equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger) = if (*y.data).len() < (*z.data).len() { - (y, z) - } else { - (z, y) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - if bigger_current_index == smaller_current_index { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/exp.cairo b/src/operators/tensor/math/exp.cairo index 4872b572c..3ba1e97d7 100644 --- a/src/operators/tensor/math/exp.cairo +++ b/src/operators/tensor/math/exp.cairo @@ -1,4 +1,36 @@ -mod exp_i8; -mod exp_u32; -mod exp_i32; -mod exp_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::{Into, TryInto}; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::exp docstring +fn exp< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).exp()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/exp/exp_fp.cairo b/src/operators/tensor/math/exp/exp_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/exp/exp_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/exp/exp_fp/core.cairo b/src/operators/tensor/math/exp/exp_fp/core.cairo deleted file mode 100644 index b26551f69..000000000 --- a/src/operators/tensor/math/exp/exp_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::exp::exp_fp::fp8x23; -use orion::operators::tensor::math::exp::exp_fp::fp16x16; - -/// Cf: TensorTrait::exp docstring -fn exp(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::exp(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - } -} diff --git a/src/operators/tensor/math/exp/exp_fp/fp16x16.cairo b/src/operators/tensor/math/exp/exp_fp/fp16x16.cairo deleted file mode 100644 index a94ffe263..000000000 --- a/src/operators/tensor/math/exp/exp_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/exp/exp_fp/fp8x23.cairo b/src/operators/tensor/math/exp/exp_fp/fp8x23.cairo deleted file mode 100644 index 6366f025f..000000000 --- a/src/operators/tensor/math/exp/exp_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/exp/exp_i32.cairo b/src/operators/tensor/math/exp/exp_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/exp/exp_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/exp/exp_i32/core.cairo b/src/operators/tensor/math/exp/exp_i32/core.cairo deleted file mode 100644 index b856f0f14..000000000 --- a/src/operators/tensor/math/exp/exp_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::exp::exp_i32::fp8x23; -use orion::operators::tensor::math::exp::exp_i32::fp16x16; - -/// Cf: TensorTrait::exp docstring -fn exp_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::exp(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - } -} diff --git a/src/operators/tensor/math/exp/exp_i32/fp16x16.cairo b/src/operators/tensor/math/exp/exp_i32/fp16x16.cairo deleted file mode 100644 index 10a6dce0e..000000000 --- a/src/operators/tensor/math/exp/exp_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/exp/exp_i32/fp8x23.cairo b/src/operators/tensor/math/exp/exp_i32/fp8x23.cairo deleted file mode 100644 index e8bc126f1..000000000 --- a/src/operators/tensor/math/exp/exp_i32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/exp/exp_i8.cairo b/src/operators/tensor/math/exp/exp_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/exp/exp_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/exp/exp_i8/core.cairo b/src/operators/tensor/math/exp/exp_i8/core.cairo deleted file mode 100644 index d8b2a129b..000000000 --- a/src/operators/tensor/math/exp/exp_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::exp::exp_i8::fp8x23; -use orion::operators::tensor::math::exp::exp_i8::fp16x16; - -/// Cf: TensorTrait::exp docstring -fn exp_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::exp(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - } -} diff --git a/src/operators/tensor/math/exp/exp_i8/fp16x16.cairo b/src/operators/tensor/math/exp/exp_i8/fp16x16.cairo deleted file mode 100644 index bcb904813..000000000 --- a/src/operators/tensor/math/exp/exp_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/exp/exp_i8/fp8x23.cairo b/src/operators/tensor/math/exp/exp_i8/fp8x23.cairo deleted file mode 100644 index c0cf4588d..000000000 --- a/src/operators/tensor/math/exp/exp_i8/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/exp/exp_u32.cairo b/src/operators/tensor/math/exp/exp_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/exp/exp_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/exp/exp_u32/core.cairo b/src/operators/tensor/math/exp/exp_u32/core.cairo deleted file mode 100644 index 9761775d0..000000000 --- a/src/operators/tensor/math/exp/exp_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::exp::exp_u32::fp8x23; -use orion::operators::tensor::math::exp::exp_u32::fp16x16; - -/// Cf: TensorTrait::exp docstring -fn exp_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::exp(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - }, - Option::None(_) => Option::Some(fp16x16::exp(*self)), - } -} diff --git a/src/operators/tensor/math/exp/exp_u32/fp16x16.cairo b/src/operators/tensor/math/exp/exp_u32/fp16x16.cairo deleted file mode 100644 index ec5c87381..000000000 --- a/src/operators/tensor/math/exp/exp_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/exp/exp_u32/fp8x23.cairo b/src/operators/tensor/math/exp/exp_u32/fp8x23.cairo deleted file mode 100644 index ab9d8cd68..000000000 --- a/src/operators/tensor/math/exp/exp_u32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::exp docstring -fn exp(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).exp()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/flatten.cairo b/src/operators/tensor/math/flatten.cairo index 011187607..a15bb13ef 100644 --- a/src/operators/tensor/math/flatten.cairo +++ b/src/operators/tensor/math/flatten.cairo @@ -1,6 +1,31 @@ -mod flatten_i8; -mod flatten_i32; -mod flatten_u32; -mod flatten_fp; -mod helpers; +use array::ArrayTrait; +use array::SpanTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::flatten docstring +fn flatten>(self: @Tensor, axis: usize) -> Tensor { + let current_shape = *self.shape; + assert(axis < current_shape.len(), 'axis out of dimensions'); + + let mut new_shape_first_axis = 1; + let mut index = 0; + loop { + if index == axis { + break; + } + + new_shape_first_axis *= *current_shape[index]; + + index += 1; + }; + + let new_shape_second_axis = (*self.data).len() / new_shape_first_axis; + + let mut new_shape = ArrayTrait::::new(); + new_shape.append(new_shape_first_axis); + new_shape.append(new_shape_second_axis); + + return self.reshape(new_shape.span()); +} diff --git a/src/operators/tensor/math/flatten/flatten_fp.cairo b/src/operators/tensor/math/flatten/flatten_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/flatten/flatten_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/flatten/flatten_fp/core.cairo b/src/operators/tensor/math/flatten/flatten_fp/core.cairo deleted file mode 100644 index a1b0e3bc2..000000000 --- a/src/operators/tensor/math/flatten/flatten_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::flatten::flatten_fp::fp8x23; -use orion::operators::tensor::math::flatten::flatten_fp::fp16x16; - -/// Cf: TensorTrait::flatten docstring -fn flatten(self: @Tensor, axis: usize) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::flatten(self, axis)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::flatten(self, axis)), - }, - Option::None(_) => Option::Some(fp16x16::flatten(self, axis)), - }, - Option::None(_) => Option::Some(fp16x16::flatten(self, axis)), - } -} diff --git a/src/operators/tensor/math/flatten/flatten_fp/fp16x16.cairo b/src/operators/tensor/math/flatten/flatten_fp/fp16x16.cairo deleted file mode 100644 index 6b32cbd27..000000000 --- a/src/operators/tensor/math/flatten/flatten_fp/fp16x16.cairo +++ /dev/null @@ -1,9 +0,0 @@ -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::flatten::helpers::_flatten; - -/// Cf: TensorTrait::flatten docstring -fn flatten(self: @Tensor, axis: usize) -> Tensor { - _flatten(self, axis) -} diff --git a/src/operators/tensor/math/flatten/flatten_fp/fp8x23.cairo b/src/operators/tensor/math/flatten/flatten_fp/fp8x23.cairo deleted file mode 100644 index 6b32cbd27..000000000 --- a/src/operators/tensor/math/flatten/flatten_fp/fp8x23.cairo +++ /dev/null @@ -1,9 +0,0 @@ -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::flatten::helpers::_flatten; - -/// Cf: TensorTrait::flatten docstring -fn flatten(self: @Tensor, axis: usize) -> Tensor { - _flatten(self, axis) -} diff --git a/src/operators/tensor/math/flatten/flatten_i32.cairo b/src/operators/tensor/math/flatten/flatten_i32.cairo deleted file mode 100644 index e2c2718ff..000000000 --- a/src/operators/tensor/math/flatten/flatten_i32.cairo +++ /dev/null @@ -1,9 +0,0 @@ -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::flatten::helpers::_flatten; - -/// Cf: TensorTrait::flatten docstring -fn flatten(self: @Tensor, axis: usize) -> Tensor { - _flatten(self, axis) -} diff --git a/src/operators/tensor/math/flatten/flatten_i8.cairo b/src/operators/tensor/math/flatten/flatten_i8.cairo deleted file mode 100644 index cc9ca7a42..000000000 --- a/src/operators/tensor/math/flatten/flatten_i8.cairo +++ /dev/null @@ -1,9 +0,0 @@ -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::flatten::helpers::_flatten; - -/// Cf: TensorTrait::flatten docstring -fn flatten(self: @Tensor, axis: usize) -> Tensor { - _flatten(self, axis) -} diff --git a/src/operators/tensor/math/flatten/flatten_u32.cairo b/src/operators/tensor/math/flatten/flatten_u32.cairo deleted file mode 100644 index 1a8015cf3..000000000 --- a/src/operators/tensor/math/flatten/flatten_u32.cairo +++ /dev/null @@ -1,8 +0,0 @@ -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::flatten::helpers::_flatten; - -/// Cf: TensorTrait::flatten docstring -fn flatten(self: @Tensor, axis: usize) -> Tensor { - _flatten(self, axis) -} diff --git a/src/operators/tensor/math/flatten/helpers.cairo b/src/operators/tensor/math/flatten/helpers.cairo deleted file mode 100644 index 5706c9b89..000000000 --- a/src/operators/tensor/math/flatten/helpers.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -/// Cf: TensorTrait::flatten docstring -fn _flatten>(self: @Tensor, axis: usize) -> Tensor { - let current_shape = *self.shape; - assert(axis < current_shape.len(), 'axis out of dimensions'); - - let mut new_shape_first_axis = 1; - let mut index = 0; - loop { - if index == axis { - break; - } - - new_shape_first_axis *= *current_shape[index]; - - index += 1; - }; - - let new_shape_second_axis = (*self.data).len() / new_shape_first_axis; - - let mut new_shape = ArrayTrait::::new(); - new_shape.append(new_shape_first_axis); - new_shape.append(new_shape_second_axis); - - return self.reshape(new_shape.span()); -} diff --git a/src/operators/tensor/math/greater.cairo b/src/operators/tensor/math/greater.cairo index e6e48bb70..7d4825b12 100644 --- a/src/operators/tensor/math/greater.cairo +++ b/src/operators/tensor/math/greater.cairo @@ -1,4 +1,45 @@ -mod greater_i8; -mod greater_i32; -mod greater_u32; -mod greater_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::helpers::{ + broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility +}; + +/// Cf: TensorTrait::greater docstring +fn greater< + T, + impl UsizeFTensor: TensorTrait, + impl TPartialOrd: PartialOrd, + impl TCopy: Copy, + impl TDrop: Drop +>( + y: @Tensor, z: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); + let mut result: Array = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); + + if *(*y.data)[indices_self] > *(*z.data)[indices_other] { + result.append(1); + } else { + result.append(0); + } + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/greater/greater_fp.cairo b/src/operators/tensor/math/greater/greater_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/greater/greater_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/greater/greater_fp/core.cairo b/src/operators/tensor/math/greater/greater_fp/core.cairo deleted file mode 100644 index f58a10621..000000000 --- a/src/operators/tensor/math/greater/greater_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::greater::greater_fp::fp8x23; -use orion::operators::tensor::math::greater::greater_fp::fp16x16; - -/// Cf: TensorTrait::greater docstring -fn greater(y: @Tensor, z: @Tensor) -> Option> { - match *y.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::greater(y, z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::greater(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::greater(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::greater(y, z)), - } -} diff --git a/src/operators/tensor/math/greater/greater_fp/fp16x16.cairo b/src/operators/tensor/math/greater/greater_fp/fp16x16.cairo deleted file mode 100644 index 50b522436..000000000 --- a/src/operators/tensor/math/greater/greater_fp/fp16x16.cairo +++ /dev/null @@ -1,52 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; - -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::greater docstring -fn greater(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value > z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater/greater_fp/fp8x23.cairo b/src/operators/tensor/math/greater/greater_fp/fp8x23.cairo deleted file mode 100644 index d80fd8049..000000000 --- a/src/operators/tensor/math/greater/greater_fp/fp8x23.cairo +++ /dev/null @@ -1,52 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; - -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::greater docstring -fn greater(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value > z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater/greater_i32.cairo b/src/operators/tensor/math/greater/greater_i32.cairo deleted file mode 100644 index d4767a329..000000000 --- a/src/operators/tensor/math/greater/greater_i32.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::greater docstring -fn greater(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value > z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater/greater_i8.cairo b/src/operators/tensor/math/greater/greater_i8.cairo deleted file mode 100644 index d10a4e139..000000000 --- a/src/operators/tensor/math/greater/greater_i8.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::greater docstring -fn greater(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value > z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater/greater_u32.cairo b/src/operators/tensor/math/greater/greater_u32.cairo deleted file mode 100644 index 0918d3110..000000000 --- a/src/operators/tensor/math/greater/greater_u32.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::greater docstring -fn greater(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value > z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater_equal.cairo b/src/operators/tensor/math/greater_equal.cairo index 5c2aeb345..9edb87373 100644 --- a/src/operators/tensor/math/greater_equal.cairo +++ b/src/operators/tensor/math/greater_equal.cairo @@ -1,4 +1,45 @@ -mod greater_equal_i8; -mod greater_equal_i32; -mod greater_equal_u32; -mod greater_equal_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::helpers::{ + broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility +}; + +/// Cf: TensorTrait::greater_equal docstring +fn greater_equal< + T, + impl UsizeFTensor: TensorTrait, + impl TPartialOrd: PartialOrd, + impl TCopy: Copy, + impl TDrop: Drop +>( + y: @Tensor, z: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); + let mut result: Array = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); + + if *(*y.data)[indices_self] >= *(*z.data)[indices_other] { + result.append(1); + } else { + result.append(0); + } + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/greater_equal/greater_equal_fp.cairo b/src/operators/tensor/math/greater_equal/greater_equal_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/greater_equal/greater_equal_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/greater_equal/greater_equal_fp/core.cairo b/src/operators/tensor/math/greater_equal/greater_equal_fp/core.cairo deleted file mode 100644 index e15b2bb3e..000000000 --- a/src/operators/tensor/math/greater_equal/greater_equal_fp/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::greater_equal::greater_equal_fp::fp8x23; -use orion::operators::tensor::math::greater_equal::greater_equal_fp::fp16x16; - - -/// Cf: TensorTrait::greater_equal docstring -fn greater_equal(y: @Tensor, z: @Tensor) -> Option> { - match *y.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::greater_equal(y, z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::greater_equal(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::greater_equal(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::greater_equal(y, z)), - } -} diff --git a/src/operators/tensor/math/greater_equal/greater_equal_fp/fp16x16.cairo b/src/operators/tensor/math/greater_equal/greater_equal_fp/fp16x16.cairo deleted file mode 100644 index eced1f429..000000000 --- a/src/operators/tensor/math/greater_equal/greater_equal_fp/fp16x16.cairo +++ /dev/null @@ -1,51 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; - -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::greater_equal docstring -fn greater_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value >= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater_equal/greater_equal_fp/fp8x23.cairo b/src/operators/tensor/math/greater_equal/greater_equal_fp/fp8x23.cairo deleted file mode 100644 index f2a773cf1..000000000 --- a/src/operators/tensor/math/greater_equal/greater_equal_fp/fp8x23.cairo +++ /dev/null @@ -1,52 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; - -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::greater_equal docstring -fn greater_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value >= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater_equal/greater_equal_i32.cairo b/src/operators/tensor/math/greater_equal/greater_equal_i32.cairo deleted file mode 100644 index dab6500c5..000000000 --- a/src/operators/tensor/math/greater_equal/greater_equal_i32.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::greater_equal docstring -fn greater_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value >= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater_equal/greater_equal_i8.cairo b/src/operators/tensor/math/greater_equal/greater_equal_i8.cairo deleted file mode 100644 index 69427ffbf..000000000 --- a/src/operators/tensor/math/greater_equal/greater_equal_i8.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::greater_equal docstring -fn greater_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value >= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/greater_equal/greater_equal_u32.cairo b/src/operators/tensor/math/greater_equal/greater_equal_u32.cairo deleted file mode 100644 index f49383ba1..000000000 --- a/src/operators/tensor/math/greater_equal/greater_equal_u32.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::greater_equal docstring -fn greater_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value >= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less.cairo b/src/operators/tensor/math/less.cairo index db7c80491..e578ec426 100644 --- a/src/operators/tensor/math/less.cairo +++ b/src/operators/tensor/math/less.cairo @@ -1,4 +1,45 @@ -mod less_i8; -mod less_i32; -mod less_u32; -mod less_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::helpers::{ + broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility +}; + +/// Cf: TensorTrait::less docstring +fn less< + T, + impl UsizeFTensor: TensorTrait, + impl TPartialOrd: PartialOrd, + impl TCopy: Copy, + impl TDrop: Drop +>( + y: @Tensor, z: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); + let mut result: Array = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); + + if *(*y.data)[indices_self] < *(*z.data)[indices_other] { + result.append(1); + } else { + result.append(0); + } + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/less/less_fp.cairo b/src/operators/tensor/math/less/less_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/less/less_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/less/less_fp/core.cairo b/src/operators/tensor/math/less/less_fp/core.cairo deleted file mode 100644 index a38b961fa..000000000 --- a/src/operators/tensor/math/less/less_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::less::less_fp::fp8x23; -use orion::operators::tensor::math::less::less_fp::fp16x16; - -/// Cf: TensorTrait::less docstring -fn less(y: @Tensor, z: @Tensor) -> Option> { - match *y.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::less(y, z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::less(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::less(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::less(y, z)), - } -} diff --git a/src/operators/tensor/math/less/less_fp/fp16x16.cairo b/src/operators/tensor/math/less/less_fp/fp16x16.cairo deleted file mode 100644 index 1f8cd8cf6..000000000 --- a/src/operators/tensor/math/less/less_fp/fp16x16.cairo +++ /dev/null @@ -1,52 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less docstring -fn less(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value < z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less/less_fp/fp8x23.cairo b/src/operators/tensor/math/less/less_fp/fp8x23.cairo deleted file mode 100644 index 79b5fbf81..000000000 --- a/src/operators/tensor/math/less/less_fp/fp8x23.cairo +++ /dev/null @@ -1,52 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less docstring -fn less(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value < z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less/less_i32.cairo b/src/operators/tensor/math/less/less_i32.cairo deleted file mode 100644 index 7f35cd8b6..000000000 --- a/src/operators/tensor/math/less/less_i32.cairo +++ /dev/null @@ -1,50 +0,0 @@ -use core::debug::PrintTrait; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less docstring -fn less(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value < z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less/less_i8.cairo b/src/operators/tensor/math/less/less_i8.cairo deleted file mode 100644 index 19c387235..000000000 --- a/src/operators/tensor/math/less/less_i8.cairo +++ /dev/null @@ -1,50 +0,0 @@ -use core::debug::PrintTrait; -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less docstring -fn less(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value < z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less/less_u32.cairo b/src/operators/tensor/math/less/less_u32.cairo deleted file mode 100644 index 230852809..000000000 --- a/src/operators/tensor/math/less/less_u32.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less docstring -fn less(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value < z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less_equal.cairo b/src/operators/tensor/math/less_equal.cairo index 7f0937936..9b970a999 100644 --- a/src/operators/tensor/math/less_equal.cairo +++ b/src/operators/tensor/math/less_equal.cairo @@ -1,4 +1,45 @@ -mod less_equal_i8; -mod less_equal_i32; -mod less_equal_u32; -mod less_equal_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::helpers::{ + broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility +}; + +/// Cf: TensorTrait::less_equal docstring +fn less_equal< + T, + impl UsizeFTensor: TensorTrait, + impl TPartialOrd: PartialOrd, + impl TCopy: Copy, + impl TDrop: Drop +>( + y: @Tensor, z: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); + let mut result: Array = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); + + if *(*y.data)[indices_self] <= *(*z.data)[indices_other] { + result.append(1); + } else { + result.append(0); + } + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/less_equal/less_equal_fp.cairo b/src/operators/tensor/math/less_equal/less_equal_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/less_equal/less_equal_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/less_equal/less_equal_fp/core.cairo b/src/operators/tensor/math/less_equal/less_equal_fp/core.cairo deleted file mode 100644 index e15f69199..000000000 --- a/src/operators/tensor/math/less_equal/less_equal_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::less_equal::less_equal_fp::fp8x23; -use orion::operators::tensor::math::less_equal::less_equal_fp::fp16x16; - -/// Cf: TensorTrait::less_equal docstring -fn less_equal(y: @Tensor, z: @Tensor) -> Option> { - match *y.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::less_equal(y, z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::less_equal(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::less_equal(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::less_equal(y, z)), - } -} diff --git a/src/operators/tensor/math/less_equal/less_equal_fp/fp16x16.cairo b/src/operators/tensor/math/less_equal/less_equal_fp/fp16x16.cairo deleted file mode 100644 index f1f432b4f..000000000 --- a/src/operators/tensor/math/less_equal/less_equal_fp/fp16x16.cairo +++ /dev/null @@ -1,51 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::less_equal docstring -fn less_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value <= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less_equal/less_equal_fp/fp8x23.cairo b/src/operators/tensor/math/less_equal/less_equal_fp/fp8x23.cairo deleted file mode 100644 index 7ed0f3862..000000000 --- a/src/operators/tensor/math/less_equal/less_equal_fp/fp8x23.cairo +++ /dev/null @@ -1,51 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::less_equal docstring -fn less_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value <= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less_equal/less_equal_i32.cairo b/src/operators/tensor/math/less_equal/less_equal_i32.cairo deleted file mode 100644 index c00b2a2bc..000000000 --- a/src/operators/tensor/math/less_equal/less_equal_i32.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less_equal docstring -fn less_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value <= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less_equal/less_equal_i8.cairo b/src/operators/tensor/math/less_equal/less_equal_i8.cairo deleted file mode 100644 index 6bc455c66..000000000 --- a/src/operators/tensor/math/less_equal/less_equal_i8.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less_equal docstring -fn less_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value <= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/less_equal/less_equal_u32.cairo b/src/operators/tensor/math/less_equal/less_equal_u32.cairo deleted file mode 100644 index 2fb861bc8..000000000 --- a/src/operators/tensor/math/less_equal/less_equal_u32.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::less_equal docstring -fn less_equal(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value <= z_value { - data_result.append(1); - } else { - data_result.append(0); - }; - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/log.cairo b/src/operators/tensor/math/log.cairo index 650d93998..1b9413e57 100644 --- a/src/operators/tensor/math/log.cairo +++ b/src/operators/tensor/math/log.cairo @@ -1,4 +1,36 @@ -mod log_i8; -mod log_u32; -mod log_i32; -mod log_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::log docstring +fn log< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).ln()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/log/log_fp.cairo b/src/operators/tensor/math/log/log_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/log/log_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/log/log_fp/core.cairo b/src/operators/tensor/math/log/log_fp/core.cairo deleted file mode 100644 index f92f64827..000000000 --- a/src/operators/tensor/math/log/log_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::log::log_fp::fp8x23; -use orion::operators::tensor::math::log::log_fp::fp16x16; - -/// Cf: TensorTrait::log docstring -fn log(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::log(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - } -} diff --git a/src/operators/tensor/math/log/log_fp/fp16x16.cairo b/src/operators/tensor/math/log/log_fp/fp16x16.cairo deleted file mode 100644 index 3c88dc152..000000000 --- a/src/operators/tensor/math/log/log_fp/fp16x16.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/log/log_fp/fp8x23.cairo b/src/operators/tensor/math/log/log_fp/fp8x23.cairo deleted file mode 100644 index 96eb88d0b..000000000 --- a/src/operators/tensor/math/log/log_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/log/log_i32.cairo b/src/operators/tensor/math/log/log_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/log/log_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/log/log_i32/core.cairo b/src/operators/tensor/math/log/log_i32/core.cairo deleted file mode 100644 index aadd63f47..000000000 --- a/src/operators/tensor/math/log/log_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::log::log_i32::fp8x23; -use orion::operators::tensor::math::log::log_i32::fp16x16; - -/// Cf: TensorTrait::log docstring -fn log_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::log(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - } -} diff --git a/src/operators/tensor/math/log/log_i32/fp16x16.cairo b/src/operators/tensor/math/log/log_i32/fp16x16.cairo deleted file mode 100644 index de356ccef..000000000 --- a/src/operators/tensor/math/log/log_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/log/log_i32/fp8x23.cairo b/src/operators/tensor/math/log/log_i32/fp8x23.cairo deleted file mode 100644 index a761b48de..000000000 --- a/src/operators/tensor/math/log/log_i32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/log/log_i8.cairo b/src/operators/tensor/math/log/log_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/log/log_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/log/log_i8/core.cairo b/src/operators/tensor/math/log/log_i8/core.cairo deleted file mode 100644 index 0b63f263f..000000000 --- a/src/operators/tensor/math/log/log_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::log::log_i8::fp8x23; -use orion::operators::tensor::math::log::log_i8::fp16x16; - -/// Cf: TensorTrait::log docstring -fn log_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::log(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - } -} diff --git a/src/operators/tensor/math/log/log_i8/fp16x16.cairo b/src/operators/tensor/math/log/log_i8/fp16x16.cairo deleted file mode 100644 index f3a06364b..000000000 --- a/src/operators/tensor/math/log/log_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/log/log_i8/fp8x23.cairo b/src/operators/tensor/math/log/log_i8/fp8x23.cairo deleted file mode 100644 index 14cbe2349..000000000 --- a/src/operators/tensor/math/log/log_i8/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/log/log_u32.cairo b/src/operators/tensor/math/log/log_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/log/log_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/log/log_u32/core.cairo b/src/operators/tensor/math/log/log_u32/core.cairo deleted file mode 100644 index c77f0c408..000000000 --- a/src/operators/tensor/math/log/log_u32/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::log::log_u32::fp8x23; -use orion::operators::tensor::math::log::log_u32::fp16x16; - -/// Cf: TensorTrait::log docstring -fn log_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::log(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - }, - Option::None(_) => Option::Some(fp16x16::log(*self)), - } -} diff --git a/src/operators/tensor/math/log/log_u32/fp16x16.cairo b/src/operators/tensor/math/log/log_u32/fp16x16.cairo deleted file mode 100644 index 152c95a6f..000000000 --- a/src/operators/tensor/math/log/log_u32/fp16x16.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/log/log_u32/fp8x23.cairo b/src/operators/tensor/math/log/log_u32/fp8x23.cairo deleted file mode 100644 index 28b90e001..000000000 --- a/src/operators/tensor/math/log/log_u32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::log docstring -fn log(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).ln()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/max.cairo b/src/operators/tensor/math/max.cairo index 9d3205543..854ef9613 100644 --- a/src/operators/tensor/math/max.cairo +++ b/src/operators/tensor/math/max.cairo @@ -1,4 +1,34 @@ -mod max_i8; -mod max_i32; -mod max_u32; -mod max_fp; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::NumberTrait; + +/// Cf: TensorTrait::max docstring +fn max_in_tensor< + T, + MAG, + impl TNumber: NumberTrait, + impl TPartialOrd: PartialOrd, + impl TCopy: Copy, + impl TDrop: Drop +>( + mut vec: Span:: +) -> T { + let mut max_value: T = NumberTrait::min_value(); + + loop { + match vec.pop_front() { + Option::Some(item) => { + let check_max = max_value.max(*item); + if (max_value < check_max) { + max_value = check_max; + } + }, + Option::None(_) => { + break; + } + }; + }; + + return max_value; +} diff --git a/src/operators/tensor/math/max/max_fp.cairo b/src/operators/tensor/math/max/max_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/max/max_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/max/max_fp/core.cairo b/src/operators/tensor/math/max/max_fp/core.cairo deleted file mode 100644 index e98b0038a..000000000 --- a/src/operators/tensor/math/max/max_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::ExtraParams; -use orion::operators::tensor::math::max::max_fp::fp8x23; -use orion::operators::tensor::math::max::max_fp::fp16x16; - -/// Cf: TensorTrait::max docstring -fn max_in_tensor(mut vec: Span::, extra: Option) -> Option { - match extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::max_in_tensor(vec)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::max_in_tensor(vec)), - }, - Option::None(_) => Option::Some(fp16x16::max_in_tensor(vec)), - }, - Option::None(_) => Option::Some(fp16x16::max_in_tensor(vec)), - } -} diff --git a/src/operators/tensor/math/max/max_fp/fp16x16.cairo b/src/operators/tensor/math/max/max_fp/fp16x16.cairo deleted file mode 100644 index 74c5c4b20..000000000 --- a/src/operators/tensor/math/max/max_fp/fp16x16.cairo +++ /dev/null @@ -1,31 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, MAX, FP16x16PartialOrd -}; -use orion::numbers::fixed_point::implementations::fp16x16::math::comp::max; - -/// Cf: TensorTrait::max docstring -fn max_in_tensor(mut vec: Span::) -> FixedType { - let mut max_value: FixedType = FixedTrait::new(MAX, true); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_max = max(max_value, *item); - if (max_value < check_max) { - max_value = check_max; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return max_value; -} - - diff --git a/src/operators/tensor/math/max/max_fp/fp8x23.cairo b/src/operators/tensor/math/max/max_fp/fp8x23.cairo deleted file mode 100644 index 937fce55b..000000000 --- a/src/operators/tensor/math/max/max_fp/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, MAX, FP8x23PartialOrd}; -use orion::numbers::fixed_point::implementations::fp8x23::math::comp::max; - - -/// Cf: TensorTrait::max docstring -fn max_in_tensor(mut vec: Span::) -> FixedType { - let mut max_value: FixedType = FixedTrait::new(MAX, true); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_max = max(max_value, *item); - if (max_value < check_max) { - max_value = check_max; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return max_value; -} diff --git a/src/operators/tensor/math/max/max_i32.cairo b/src/operators/tensor/math/max/max_i32.cairo deleted file mode 100644 index 0812544c6..000000000 --- a/src/operators/tensor/math/max/max_i32.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; - - -/// Cf: TensorTrait::max docstring -fn max_in_tensor(mut vec: Span::) -> i32 { - let mut max_value: i32 = IntegerTrait::new(2147483647, true); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_max = max_value.max(*item); - if (max_value < check_max) { - max_value = check_max; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return max_value; -} diff --git a/src/operators/tensor/math/max/max_i8.cairo b/src/operators/tensor/math/max/max_i8.cairo deleted file mode 100644 index 2bf17c935..000000000 --- a/src/operators/tensor/math/max/max_i8.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; - - -/// Cf: TensorTrait::max docstring -fn max_in_tensor(mut vec: Span::) -> i8 { - let mut max_value: i8 = IntegerTrait::new(128, true); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_max = max_value.max(*item); - if (max_value < check_max) { - max_value = check_max; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return max_value; -} diff --git a/src/operators/tensor/math/max/max_u32.cairo b/src/operators/tensor/math/max/max_u32.cairo deleted file mode 100644 index 994c5fb13..000000000 --- a/src/operators/tensor/math/max/max_u32.cairo +++ /dev/null @@ -1,23 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - - -/// Cf: TensorTrait::max docstring -fn max_in_tensor(mut vec: Span::) -> u32 { - let mut max_value = 0; - - loop { - match vec.pop_front() { - Option::Some(item) => { - if (max_value < *item) { - max_value = *item; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return max_value; -} diff --git a/src/operators/tensor/math/min.cairo b/src/operators/tensor/math/min.cairo index c21a59f76..518e0eb69 100644 --- a/src/operators/tensor/math/min.cairo +++ b/src/operators/tensor/math/min.cairo @@ -1,4 +1,34 @@ -mod min_i8; -mod min_i32; -mod min_u32; -mod min_fp; +use array::SpanTrait; +use option::OptionTrait; + +use orion::numbers::NumberTrait; + +/// Cf: TensorTrait::min docstring +fn min_in_tensor< + T, + MAG, + impl TNumber: NumberTrait, + impl TPartialOrd: PartialOrd, + impl TCopy: Copy, + impl TDrop: Drop +>( + mut vec: Span:: +) -> T { + let mut min_value: T = NumberTrait::max_value(); + + loop { + match vec.pop_front() { + Option::Some(item) => { + let check_min = min_value.min(*item); + if (min_value > check_min) { + min_value = check_min; + } + }, + Option::None(_) => { + break; + } + }; + }; + + return min_value; +} diff --git a/src/operators/tensor/math/min/min_fp.cairo b/src/operators/tensor/math/min/min_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/min/min_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/min/min_fp/core.cairo b/src/operators/tensor/math/min/min_fp/core.cairo deleted file mode 100644 index ef7873ed0..000000000 --- a/src/operators/tensor/math/min/min_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::ExtraParams; -use orion::operators::tensor::math::min::min_fp::fp8x23; -use orion::operators::tensor::math::min::min_fp::fp16x16; - -/// Cf: TensorTrait::min docstring -fn min_in_tensor(mut vec: Span::, extra: Option) -> Option { - match extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::min_in_tensor(vec)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::min_in_tensor(vec)), - }, - Option::None(_) => Option::Some(fp16x16::min_in_tensor(vec)), - }, - Option::None(_) => Option::Some(fp16x16::min_in_tensor(vec)), - } -} diff --git a/src/operators/tensor/math/min/min_fp/fp16x16.cairo b/src/operators/tensor/math/min/min_fp/fp16x16.cairo deleted file mode 100644 index 3b3e43c62..000000000 --- a/src/operators/tensor/math/min/min_fp/fp16x16.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, MAX, FP16x16PartialOrd -}; -use orion::numbers::fixed_point::implementations::fp16x16::math::comp::min; - -/// Cf: TensorTrait::min docstring -fn min_in_tensor(mut vec: Span::) -> FixedType { - let mut min_value: FixedType = FixedTrait::new(MAX - 1, false); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_min = min(min_value, *item); - if (min_value > check_min) { - min_value = check_min; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return min_value; -} - diff --git a/src/operators/tensor/math/min/min_fp/fp8x23.cairo b/src/operators/tensor/math/min/min_fp/fp8x23.cairo deleted file mode 100644 index 4bdb2d887..000000000 --- a/src/operators/tensor/math/min/min_fp/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, MAX, FP8x23PartialOrd}; -use orion::numbers::fixed_point::implementations::fp8x23::math::comp::min; - - -/// Cf: TensorTrait::min docstring -fn min_in_tensor(mut vec: Span::) -> FixedType { - let mut min_value: FixedType = FixedTrait::new(MAX - 1, false); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_min = min(min_value, *item); - if (min_value > check_min) { - min_value = check_min; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return min_value; -} diff --git a/src/operators/tensor/math/min/min_i32.cairo b/src/operators/tensor/math/min/min_i32.cairo deleted file mode 100644 index 730c96e13..000000000 --- a/src/operators/tensor/math/min/min_i32.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; - - -/// Cf: TensorTrait::min docstring -fn min_in_tensor(mut vec: Span::) -> i32 { - let mut min_value: i32 = IntegerTrait::new(2147483647, false); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_min = min_value.min(*item); - if (min_value > check_min) { - min_value = check_min; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return min_value; -} - diff --git a/src/operators/tensor/math/min/min_i8.cairo b/src/operators/tensor/math/min/min_i8.cairo deleted file mode 100644 index 14534a167..000000000 --- a/src/operators/tensor/math/min/min_i8.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; - - -/// Cf: TensorTrait::min docstring -fn min_in_tensor(mut vec: Span::) -> i8 { - let mut min_value: i8 = IntegerTrait::new(127, false); - - loop { - match vec.pop_front() { - Option::Some(item) => { - let check_min = min_value.min(*item); - if (min_value > check_min) { - min_value = check_min; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return min_value; -} diff --git a/src/operators/tensor/math/min/min_u32.cairo b/src/operators/tensor/math/min/min_u32.cairo deleted file mode 100644 index e842111f3..000000000 --- a/src/operators/tensor/math/min/min_u32.cairo +++ /dev/null @@ -1,25 +0,0 @@ -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - - -/// Cf: TensorTrait::min docstring -fn min_in_tensor(mut vec: Span::) -> u32 { - let mut min_value = 4294967295; - - loop { - match vec.pop_front() { - Option::Some(item) => { - if (min_value > *item) { - min_value = *item; - } - }, - Option::None(_) => { - break; - } - }; - }; - - return min_value; -} diff --git a/src/operators/tensor/math/onehot.cairo b/src/operators/tensor/math/onehot.cairo index f547b02f2..56f465e0b 100644 --- a/src/operators/tensor/math/onehot.cairo +++ b/src/operators/tensor/math/onehot.cairo @@ -1,4 +1,147 @@ -mod onehot_i8; -mod onehot_i32; -mod onehot_u32; -mod onehot_fp; +use array::ArrayTrait; +use array::SpanTrait; + +use core::traits::Into; +use debug::PrintTrait; +use core::traits::TryInto; +use core::serde::Serde; +use core::traits::Destruct; +use option::OptionTrait; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::{TensorTrait, Tensor}; + + +/// Cf: TensorTrait::onehot docstring +fn onehot_encode< + T, + MAG, + impl FFixed: FixedTrait, + impl FTensorTrait: TensorTrait, + impl FNumber: NumberTrait, + impl U32TryIntoMAG: TryInto, + impl FPartialEq: PartialEq, + impl FAdd: Add, + impl FCopy: Copy, + impl FDrop: Drop, +>( + self: @Tensor, depth: usize, axis: Option, values: Tensor +) -> Tensor { + let data = *self.data; + let shape = *self.shape; + let rank = shape.len(); + + // using 999 to denote -1, innermost dimension + let axis = match axis { + Option::Some(val) => val, + Option::None(_) => 999 + }; + + assert(((axis == 999) | (axis.into() <= rank)), 'axis out of dimensions'); + + let tensor_len: usize = data.len(); + + let mut output_data = ArrayTrait::new(); + let mut output_size = ArrayTrait::::new(); + + // New shape for output data + let mut index: usize = 0; + loop { + if index == shape.len() { + break (); + }; + let size: usize = *shape.at(index); + output_size.append(size); + index += 1; + }; + output_size.append(depth.into()); + + // OneHot enocde loop + let mut outer_index: usize = 0; + loop { + if outer_index == tensor_len { + break (); + }; + + let mut inner_index = 0; + let mut fixed_number = *(*self.data).at(outer_index); + + if fixed_number.is_neg() { + fixed_number = FixedTrait::::new_unscaled(depth.try_into().unwrap(), false) + + fixed_number + } + + loop { + if inner_index == depth { + break (); + }; + let ind = FixedTrait::::new_unscaled(inner_index.try_into().unwrap(), false); + + if fixed_number == ind { + output_data.append(*values.data.at(1)); + } else { + output_data.append(*values.data.at(0)); + }; + + inner_index += 1; + }; + + outer_index += 1; + }; + + let mut output_tensor = TensorTrait::new(output_size.span(), output_data.span()); + let mut tranpose_axes = ArrayTrait::new(); + // Get New shape is axis is not last dimension + if (axis != 999) & (axis.into() != rank) { + let mut index: usize = 0; + loop { + let max_dim = output_size.len() - 1; + if index.into() == max_dim { + break (); + }; + + if axis == index { + tranpose_axes.append(max_dim.into()) + } + tranpose_axes.append(index.into()); + index += 1; + }; + + let mut index: usize = 0; + + output_tensor = output_tensor.transpose(tranpose_axes.span()); + } + + return output_tensor; +} + +fn onehot< + T, + MAG, + impl FFixed: FixedTrait, + impl FTensorTrait: TensorTrait, + impl FNumber: NumberTrait, + impl U32TryIntoMAG: TryInto, + impl FPartialEq: PartialEq, + impl FAdd: Add, + impl FCopy: Copy, + impl FDrop: Drop, +>( + self: @Tensor, depth: usize, axis: Option, mut values: Span, +) -> Tensor { + assert(values.len() == 2, 'Wrong values dimensions'); + + let mut sizes = ArrayTrait::new(); + sizes.append(2); + + let mut first = *values.pop_front().unwrap(); + let mut second = *values.pop_front().unwrap(); + + let mut data = ArrayTrait::new(); + data.append(FixedTrait::::new_unscaled(first.try_into().unwrap(), false)); + data.append(FixedTrait::::new_unscaled(second.try_into().unwrap(), false)); + + let values = TensorTrait::new(sizes.span(), data.span()); + onehot_encode(self, depth, axis, values) +} diff --git a/src/operators/tensor/math/onehot/onehot_fp.cairo b/src/operators/tensor/math/onehot/onehot_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/onehot/onehot_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/onehot/onehot_fp/core.cairo b/src/operators/tensor/math/onehot/onehot_fp/core.cairo deleted file mode 100644 index 42a1f989e..000000000 --- a/src/operators/tensor/math/onehot/onehot_fp/core.cairo +++ /dev/null @@ -1,22 +0,0 @@ -use core::option::OptionTrait; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::Tensor; -use orion::operators::tensor::math::onehot::onehot_fp::fp8x23; -use orion::operators::tensor::math::onehot::onehot_fp::fp16x16; -use debug::PrintTrait; - -/// Cf: TensorTrait::cumsum docstring -fn onehot( - self: @Tensor, depth: usize, axis: Option, values: Span -) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::onehot(self, depth, axis, values)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::onehot(self, depth, axis, values)), - }, - Option::None(_) => Option::Some(fp16x16::onehot(self, depth, axis, values)), - }, - Option::None(_) => Option::Some(fp16x16::onehot(self, depth, axis, values)), - } -} diff --git a/src/operators/tensor/math/onehot/onehot_fp/fp16x16.cairo b/src/operators/tensor/math/onehot/onehot_fp/fp16x16.cairo deleted file mode 100644 index 08f0e9620..000000000 --- a/src/operators/tensor/math/onehot/onehot_fp/fp16x16.cairo +++ /dev/null @@ -1,136 +0,0 @@ -use core::traits::Into; -use debug::PrintTrait; -use core::traits::TryInto; -use core::serde::Serde; -use core::traits::Destruct; -use core::clone::Clone; -use option::OptionTrait; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16Add, FP16x16Sub, FP16x16AddEq, FP16x16PartialEq -}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use array::{ArrayTrait, SpanTrait}; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::{impl_tensor_i32, impl_tensor_u32}; -use orion::operators::tensor::helpers::replace_index; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - - -/// Cf: TensorTrait::onehot docstring -fn onehot_encode( - self: @Tensor, depth: usize, axis: Option, values: Tensor -) -> Tensor { - let data = *self.data; - let shape = *self.shape; - let rank = shape.len(); - - // using 999 to denote -1, innermost dimension - let axis = match axis { - Option::Some(val) => val, - Option::None(_) => 999 - }; - - assert(((axis == 999) | (axis <= rank)), 'axis out of dimensions'); - - let mut tensor_data = self.data.clone(); - let tensor_len: usize = data.len(); - - let mut output_data = ArrayTrait::new(); - let mut output_size = ArrayTrait::::new(); - let extra = Option::::None(()); - - // New shape for output data - let mut index: usize = 0; - loop { - if index == shape.len() { - break (); - }; - let size: usize = *shape.at(index); - output_size.append(size); - index += 1; - }; - output_size.append(depth); - - // OneHot enocde loop - let mut outer_index: usize = 0; - loop { - if outer_index == tensor_len { - break (); - }; - - let mut inner_index: usize = 0; - - let mut fixed_number = *tensor_data.at(outer_index); - if fixed_number.sign == true { - fixed_number = - FP16x16Add::add(FixedTrait::new_unscaled(depth.into(), false), fixed_number) - } - - loop { - if inner_index == depth { - break (); - }; - let ind = FixedTrait::new_unscaled(inner_index.into(), false); - - if fixed_number == ind { - output_data.append(*values.data.at(1)); - } else { - output_data.append(*values.data.at(0)); - }; - - inner_index += 1; - }; - - outer_index += 1; - }; - - let mut output_tensor = TensorTrait::::new( - output_size.span(), output_data.span(), extra - ); - let mut tranpose_axes = ArrayTrait::::new(); - // Get New shape is axis is not last dimension - if (axis != 999) & (axis != rank) { - let mut index: usize = 0; - loop { - let max_dim = output_size.len() - 1; - if index == max_dim { - break (); - }; - - if axis == index { - tranpose_axes.append(max_dim) - } - tranpose_axes.append(index); - index += 1; - }; - - let mut index: usize = 0; - - output_tensor = output_tensor.transpose(tranpose_axes.span()); - } - - return output_tensor; -} - -/// Cf: TensorTrait::onehot docstring -fn onehot( - self: @Tensor, depth: usize, axis: Option, mut values: Span, -) -> Tensor { - assert(values.len() == 2, 'Wrong values dimensions'); - - let mut sizes = ArrayTrait::new(); - sizes.append(2); - - let mut first = *values.pop_front().unwrap(); - let mut second = *values.pop_front().unwrap(); - - let mut data = ArrayTrait::new(); - data.append(FixedTrait::new_unscaled(first.into(), false)); - data.append(FixedTrait::new_unscaled(second.into(), false)); - let extra = Option::::None(()); - - let values = TensorTrait::::new(sizes.span(), data.span(), extra); - onehot_encode(self, depth, axis, values) -} diff --git a/src/operators/tensor/math/onehot/onehot_fp/fp8x23.cairo b/src/operators/tensor/math/onehot/onehot_fp/fp8x23.cairo deleted file mode 100644 index 89b07d9e3..000000000 --- a/src/operators/tensor/math/onehot/onehot_fp/fp8x23.cairo +++ /dev/null @@ -1,132 +0,0 @@ -use core::traits::Into; -use debug::PrintTrait; -use core::traits::TryInto; -use core::serde::Serde; -use core::traits::Destruct; -use core::clone::Clone; -use option::OptionTrait; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23Add, FP8x23Sub, FP8x23AddEq, FP8x23PartialEq -}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use array::{ArrayTrait, SpanTrait}; - - -/// Cf: TensorTrait::onehot docstring -fn onehot_encode( - self: @Tensor, depth: usize, axis: Option, values: Tensor -) -> Tensor { - let data = *self.data; - let shape = *self.shape; - let rank = shape.len(); - - // using 999 to denote -1, innermost dimension - let axis = match axis { - Option::Some(val) => val, - Option::None(_) => 999 - }; - - assert(((axis == 999) | (axis <= rank)), 'axis out of dimensions'); - - let mut tensor_data = self.data.clone(); - let tensor_len: usize = data.len(); - - let mut output_data = ArrayTrait::new(); - let mut output_size = ArrayTrait::::new(); - let extra = Option::::None(()); - - // New shape for output data - let mut index: usize = 0; - loop { - if index == shape.len() { - break (); - }; - let size: usize = *shape.at(index); - output_size.append(size); - index += 1; - }; - output_size.append(depth); - - // OneHot enocde loop - let mut outer_index: usize = 0; - loop { - if outer_index == tensor_len { - break (); - }; - - let mut inner_index: usize = 0; - - let mut fixed_number = *tensor_data.at(outer_index); - if fixed_number.sign == true { - fixed_number = - FP8x23Add::add(FixedTrait::new_unscaled(depth.into(), false), fixed_number) - } - - loop { - if inner_index == depth { - break (); - }; - let ind = FixedTrait::new_unscaled(inner_index.into(), false); - - if fixed_number == ind { - output_data.append(*values.data.at(1)); - } else { - output_data.append(*values.data.at(0)); - }; - - inner_index += 1; - }; - - outer_index += 1; - }; - - let mut output_tensor = TensorTrait::::new( - output_size.span(), output_data.span(), extra - ); - let mut tranpose_axes = ArrayTrait::::new(); - // Get New shape is axis is not last dimension - if (axis != 999) & (axis != rank) { - let mut index: usize = 0; - loop { - let max_dim = output_size.len() - 1; - if index == max_dim { - break (); - }; - - if axis == index { - tranpose_axes.append(max_dim) - } - tranpose_axes.append(index); - index += 1; - }; - - let mut index: usize = 0; - - output_tensor = output_tensor.transpose(tranpose_axes.span()); - } - - return output_tensor; -} - -/// Cf: TensorTrait::onehot docstring -fn onehot( - self: @Tensor, depth: usize, axis: Option, mut values: Span, -) -> Tensor { - assert(values.len() == 2, 'Wrong values dimensions'); - - let mut sizes = ArrayTrait::new(); - sizes.append(2); - - let mut first = *values.pop_front().unwrap(); - let mut second = *values.pop_front().unwrap(); - - let mut data = ArrayTrait::new(); - data.append(FixedTrait::new_unscaled(first.into(), false)); - data.append(FixedTrait::new_unscaled(second.into(), false)); - let extra = Option::::None(()); - - let values = TensorTrait::::new(sizes.span(), data.span(), extra); - onehot_encode(self, depth, axis, values) -} diff --git a/src/operators/tensor/math/onehot/onehot_i32.cairo b/src/operators/tensor/math/onehot/onehot_i32.cairo deleted file mode 100644 index cfbaef8a9..000000000 --- a/src/operators/tensor/math/onehot/onehot_i32.cairo +++ /dev/null @@ -1,132 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; - -use core::traits::Into; -use debug::PrintTrait; -use core::traits::TryInto; -use core::serde::Serde; -use core::traits::Destruct; -use core::clone::Clone; -use option::OptionTrait; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::signed_integer::i32::{ - i32Add, i32AddEq, i32PartialEq, i32PartialOrd, i32_new, i32Into -}; - - -/// Cf: TensorTrait::onehot docstring -fn onehot_encode( - self: @Tensor, depth: usize, axis: Option, values: Tensor -) -> Tensor { - let data = *self.data; - let shape = *self.shape; - let rank = shape.len(); - - // using 255 to denote -1, innermost dimension - let axis = match axis { - Option::Some(val) => val, - Option::None(_) => 255 - }; - - assert(((axis == 255) | (axis.into() <= rank)), 'axis out of dimensions'); - - let mut tensor_data = self.data.clone(); - let tensor_len: usize = data.len(); - - let mut output_data = ArrayTrait::new(); - let mut output_size = ArrayTrait::::new(); - let extra = Option::::None(()); - - // New shape for output data - let mut index: usize = 0; - loop { - if index == shape.len() { - break (); - }; - let size: usize = *shape.at(index); - output_size.append(size); - index += 1; - }; - output_size.append(depth.into()); - - // OneHot enocde loop - let mut outer_index: usize = 0; - loop { - if outer_index == tensor_len { - break (); - }; - - let mut inner_index = 0; - let mut fixed_number = *tensor_data.at(outer_index); - - if fixed_number.sign == true { - fixed_number = i32Add::add(i32_new(depth, false), fixed_number) - } - - loop { - if inner_index == depth { - break (); - }; - let ind = IntegerTrait::::new(inner_index, false); - - if fixed_number == ind { - output_data.append(*values.data.at(1)); - } else { - output_data.append(*values.data.at(0)); - }; - - inner_index += 1; - }; - - outer_index += 1; - }; - - let mut output_tensor = TensorTrait::::new(output_size.span(), output_data.span(), extra); - let mut tranpose_axes = ArrayTrait::new(); - // Get New shape is axis is not last dimension - if (axis != 255) & (axis.into() != rank) { - let mut index: usize = 0; - loop { - let max_dim = output_size.len() - 1; - if index.into() == max_dim { - break (); - }; - - if axis == index { - tranpose_axes.append(max_dim.into()) - } - tranpose_axes.append(index.into()); - index += 1; - }; - - let mut index: usize = 0; - - output_tensor = output_tensor.transpose(tranpose_axes.span()); - } - - return output_tensor; -} - - -fn onehot( - self: @Tensor, depth: usize, axis: Option, mut values: Span, -) -> Tensor { - assert(values.len() == 2, 'Wrong values dimensions'); - - let mut sizes = ArrayTrait::new(); - sizes.append(2); - - let mut first = *values.pop_front().unwrap(); - let mut second = *values.pop_front().unwrap(); - - let mut data = ArrayTrait::new(); - data.append(IntegerTrait::::new(first, false)); - data.append(IntegerTrait::::new(second, false)); - let extra = Option::::None(()); - - let values = TensorTrait::::new(sizes.span(), data.span(), extra); - onehot_encode(self, depth, axis, values) -} diff --git a/src/operators/tensor/math/onehot/onehot_i8.cairo b/src/operators/tensor/math/onehot/onehot_i8.cairo deleted file mode 100644 index 668013242..000000000 --- a/src/operators/tensor/math/onehot/onehot_i8.cairo +++ /dev/null @@ -1,136 +0,0 @@ -use core::traits::Into; -use debug::PrintTrait; -use core::traits::TryInto; -use core::serde::Serde; -use core::traits::Destruct; -use core::clone::Clone; -use option::OptionTrait; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use array::{ArrayTrait, SpanTrait}; -use orion::numbers::signed_integer::i8::{ - i8Add, i8AddEq, i8PartialEq, i8PartialOrd, i8_new, i8Into, -}; - - -/// Cf: TensorTrait::onehot docstring -fn onehot_encode( - self: @Tensor, depth: usize, axis: Option, values: Tensor -) -> Tensor { - let data = *self.data; - let shape = *self.shape; - let rank = shape.len(); - - // using 255 to denote -1, innermost dimension - let axis = match axis { - Option::Some(val) => val, - Option::None(_) => 255 - }; - - assert(((axis == 255) | (axis.into() <= rank)), 'axis out of dimensions'); - - let mut tensor_data = self.data.clone(); - let tensor_len: usize = data.len(); - - let mut output_data = ArrayTrait::new(); - let mut output_size = ArrayTrait::::new(); - let extra = Option::::None(()); - - // New shape for output data - let mut index: usize = 0; - loop { - if index == shape.len() { - break (); - }; - let size: usize = *shape.at(index); - output_size.append(size); - index += 1; - }; - output_size.append(depth.into()); - - // OneHot enocde loop - let mut outer_index: usize = 0; - loop { - if outer_index == tensor_len { - break (); - }; - - let mut inner_index: u8 = 0; - let mut fixed_number = *tensor_data.at(outer_index); - let depth: u8 = integer::u8_try_from_felt252(integer::u32_to_felt252(depth)).unwrap(); - - if fixed_number.sign == true { - fixed_number = i8Add::add(i8_new(depth, false), fixed_number) - } - - loop { - if inner_index == depth { - break (); - }; - let ind = IntegerTrait::::new(inner_index, false); - - if fixed_number == ind { - output_data.append(*values.data.at(1)); - } else { - output_data.append(*values.data.at(0)); - }; - - inner_index += 1; - }; - - outer_index += 1; - }; - - let mut output_tensor = TensorTrait::::new(output_size.span(), output_data.span(), extra); - let mut tranpose_axes = ArrayTrait::new(); - // Get New shape is axis is not last dimension - if (axis != 255) & (axis.into() != rank) { - let mut index: usize = 0; - loop { - let max_dim = output_size.len() - 1; - if index.into() == max_dim { - break (); - }; - - if axis == index { - tranpose_axes.append(max_dim.into()) - } - tranpose_axes.append(index.into()); - index += 1; - }; - - let mut index: usize = 0; - - output_tensor = output_tensor.transpose(tranpose_axes.span()); - } - - return output_tensor; -} - - -fn onehot( - self: @Tensor, depth: usize, axis: Option, mut values: Span, -) -> Tensor { - assert(values.len() == 2, 'Wrong values dimensions'); - - let mut sizes = ArrayTrait::new(); - sizes.append(2); - - let mut first = *values.pop_front().unwrap(); - let mut second = *values.pop_front().unwrap(); - - let first = integer::u32_to_felt252(first); - let second = integer::u32_to_felt252(second); - let first: u8 = integer::u8_try_from_felt252(first).unwrap(); - let second: u8 = integer::u8_try_from_felt252(second).unwrap(); - - let mut data = ArrayTrait::new(); - data.append(IntegerTrait::::new(first, false)); - data.append(IntegerTrait::::new(second, false)); - let extra = Option::::None(()); - - let values = TensorTrait::::new(sizes.span(), data.span(), extra); - onehot_encode(self, depth, axis, values) -} diff --git a/src/operators/tensor/math/onehot/onehot_u32.cairo b/src/operators/tensor/math/onehot/onehot_u32.cairo deleted file mode 100644 index 7ec15c50a..000000000 --- a/src/operators/tensor/math/onehot/onehot_u32.cairo +++ /dev/null @@ -1,124 +0,0 @@ -use core::traits::Into; -use debug::PrintTrait; -use core::traits::TryInto; -use core::serde::Serde; -use core::traits::Destruct; -use core::clone::Clone; -use option::OptionTrait; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use array::{ArrayTrait, SpanTrait}; - - -/// Cf: TensorTrait::onehot docstring -fn onehot_encode( - self: @Tensor, depth: usize, axis: Option, values: Tensor -) -> Tensor { - let data = *self.data; - let shape = *self.shape; - let rank = shape.len(); - - // using 999 to denote -1, innermost dimension - let axis = match axis { - Option::Some(val) => val, - Option::None(_) => 999 - }; - - assert(((axis == 999) | (axis.into() <= rank)), 'axis out of dimensions'); - - let mut tensor_data = self.data.clone(); - let tensor_len: usize = data.len(); - - let mut output_data = ArrayTrait::new(); - let mut output_size = ArrayTrait::::new(); - let extra = Option::::None(()); - - // New shape for output data - let mut index: usize = 0; - loop { - if index == shape.len() { - break (); - }; - let size: usize = *shape.at(index); - output_size.append(size); - index += 1; - }; - output_size.append(depth.into()); - - // OneHot enocde loop - let mut outer_index: usize = 0; - loop { - if outer_index == tensor_len { - break (); - }; - - let mut inner_index: usize = 0; - let mut fixed_number = *tensor_data.at(outer_index); - loop { - if inner_index == depth { - break (); - }; - let ind = inner_index; - - if fixed_number == ind { - output_data.append(*values.data.at(1)); - } else { - output_data.append(*values.data.at(0)); - }; - - inner_index += 1; - }; - - outer_index += 1; - }; - - let mut output_tensor = TensorTrait::::new(output_size.span(), output_data.span(), extra); - let mut tranpose_axes = ArrayTrait::new(); - // Get New shape is axis is not last dimension - if (axis != 999) & (axis.into() != rank) { - let mut index: usize = 0; - loop { - let max_dim = output_size.len() - 1; - if index.into() == max_dim { - break (); - }; - - if axis == index { - tranpose_axes.append(max_dim.into()) - } - tranpose_axes.append(index.into()); - index += 1; - }; - - let mut index: usize = 0; - - output_tensor = output_tensor.transpose(tranpose_axes.span()); - } - - return output_tensor; -} - - -fn onehot( - self: @Tensor, depth: usize, axis: Option, mut values: Span, -) -> Tensor { - assert(values.len() == 2, 'Wrong values dimensions'); - - let mut sizes = ArrayTrait::new(); - sizes.append(2); - - let mut first: u32 = *values.pop_front().unwrap(); - let mut second: u32 = *values.pop_front().unwrap(); - - let mut data = ArrayTrait::new(); - data.append(first); - data.append(second); - - let extra = Option::::None(()); - - let values = TensorTrait::::new(sizes.span(), data.span(), extra); - - onehot_encode(self, depth, axis, values) -} diff --git a/src/operators/tensor/math/or.cairo b/src/operators/tensor/math/or.cairo index 6317506f3..95f3f9fab 100644 --- a/src/operators/tensor/math/or.cairo +++ b/src/operators/tensor/math/or.cairo @@ -1,4 +1,47 @@ -mod or_i8; -mod or_u32; -mod or_i32; -mod or_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::numbers::NumberTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::helpers::{ + broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility +}; + +/// Cf: TensorTrait::or docstring +fn or< + T, + MAG, + impl TNumber: NumberTrait, + impl UsizeFTensor: TensorTrait, + impl TCopy: Copy, + impl TDrop: Drop +>( + y: @Tensor, z: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); + let mut result: Array = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); + + if NumberTrait::or(*(*y.data)[indices_self], *(*z.data)[indices_other]) { + result.append(1); + } else { + result.append(0); + } + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/or/or_fp.cairo b/src/operators/tensor/math/or/or_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/or/or_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/or/or_fp/core.cairo b/src/operators/tensor/math/or/or_fp/core.cairo deleted file mode 100644 index 60ef043fb..000000000 --- a/src/operators/tensor/math/or/or_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::or::or_fp::fp8x23; -use orion::operators::tensor::math::or::or_fp::fp16x16; - -/// Cf: TensorTrait::or docstring -fn or(y: @Tensor, z: @Tensor) -> Option> { - match *y.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::or(y, z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::or(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::or(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::or(y, z)), - } -} diff --git a/src/operators/tensor/math/or/or_fp/fp16x16.cairo b/src/operators/tensor/math/or/or_fp/fp16x16.cairo deleted file mode 100644 index 2440b2352..000000000 --- a/src/operators/tensor/math/or/or_fp/fp16x16.cairo +++ /dev/null @@ -1,52 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialOrd; -use orion::numbers::fixed_point::implementations::fp16x16::math::comp::or as or_16x16; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::or docstring -fn or(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if or_16x16(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/or/or_fp/fp8x23.cairo b/src/operators/tensor/math/or/or_fp/fp8x23.cairo deleted file mode 100644 index ffdb229dc..000000000 --- a/src/operators/tensor/math/or/or_fp/fp8x23.cairo +++ /dev/null @@ -1,52 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedType, FixedTrait}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23PartialOrd, FP8x23Impl}; -use orion::numbers::fixed_point::implementations::fp8x23::math::comp::or as or_8x23; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::or docstring -fn or(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if or_8x23(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/or/or_i32.cairo b/src/operators/tensor/math/or/or_i32.cairo deleted file mode 100644 index 2f442245f..000000000 --- a/src/operators/tensor/math/or/or_i32.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::i32::{i32, i32_or}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::or docstring -fn or(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if i32_or(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/or/or_i8.cairo b/src/operators/tensor/math/or/or_i8.cairo deleted file mode 100644 index 475fa4ee9..000000000 --- a/src/operators/tensor/math/or/or_i8.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::i8::{i8, i8_or}; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::or docstring -fn or(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if i8_or(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/or/or_u32.cairo b/src/operators/tensor/math/or/or_u32.cairo deleted file mode 100644 index ef05070ac..000000000 --- a/src/operators/tensor/math/or/or_u32.cairo +++ /dev/null @@ -1,48 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::or docstring -fn or(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if y_value == 0 && z_value == 0 { - data_result.append(0); - } else { - data_result.append(1); - } - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/reduce_sum.cairo b/src/operators/tensor/math/reduce_sum.cairo index 8f23622a5..fb27c9c26 100644 --- a/src/operators/tensor/math/reduce_sum.cairo +++ b/src/operators/tensor/math/reduce_sum.cairo @@ -1,4 +1,114 @@ -mod reduce_sum_i8; -mod reduce_sum_i32; -mod reduce_sum_u32; -mod reduce_sum_fp; +use core::option::OptionTrait; +use array::ArrayTrait; +use array::SpanTrait; + +use orion::numbers::NumberTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; +use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; + + +/// Cf: TensorTrait::reduce_sum docstring +fn reduce_sum< + T, + MAG, + impl TTensor: TensorTrait, + impl TNumber: NumberTrait, + impl TAddEq: AddEq, + impl TCopy: Copy, + impl TDrop: Drop +>( + self: @Tensor, axis: usize, keepdims: bool +) -> Tensor { + let mut output_data = ArrayTrait::new(); + + if (*self.shape).len() == 1 { + assert(axis == 0, 'axis out of dimensions'); + let current_sum = accumulate_sum::(*self.data, *self.shape, *self.shape, axis); + output_data.append(current_sum); + + let mut output_shape = ArrayTrait::new(); + output_shape.append(1); + + return TensorTrait::new(output_shape.span(), output_data.span()); + } else { + assert(axis <= (*self.shape).len(), 'axis out of dimensions'); + let output_shape = reduce_output_shape(*self.shape, axis, false); + let output_data_len = len_from_shape(output_shape); + let mut index: usize = 0; + loop { + let output_indices = unravel_index(index, output_shape); + let current_sum = accumulate_sum::(*self.data, *self.shape, output_indices, axis); + + output_data.append(current_sum); + + index += 1; + if index == output_data_len { + break (); + }; + }; + + if keepdims { + let output_shape = reduce_output_shape(*self.shape, axis, true); + return TensorTrait::::new(output_shape, output_data.span()); + } else { + return TensorTrait::::new(output_shape, output_data.span()); + } + } +} + + +/// Helper function that accumulates the sum of elements along a specific axis. +/// +/// # Arguments +/// * `input_data` - The input's data. +/// * `input_shape` - The input's shape. +/// * `output_indices` - A span of output indices. +/// * `axis` - The axis along which to accumulate the sum. +/// +/// # Panics +/// * Panics if gas limit is exceeded during execution. +/// +/// # Returns +/// * An i32 value representing the accumulated sum along the specified axis. +fn accumulate_sum< + T, + MAG, + impl TNumber: NumberTrait, + impl TAddEq: AddEq, + impl TCopy: Copy, + impl TDrop: Drop +>( + mut input_data: Span, input_shape: Span, output_indices: Span, axis: usize +) -> T { + let axis_len = *(input_shape)[axis]; + let mut acc: T = NumberTrait::zero(); + + let mut axis_index: usize = 0; + + if (input_shape).len() > 1 { + loop { + if axis_index == axis_len { + break (); + } + + let input_indices = combine_indices(output_indices, axis_index, axis); + let input_index = ravel_index(input_shape, input_indices); + let ele = *(input_data)[input_index]; + acc += ele; + axis_index += 1; + }; + } else { + loop { + match input_data.pop_front() { + Option::Some(item) => { + acc += *item; + }, + Option::None(_) => { + break; + } + }; + }; + } + + return acc; +} diff --git a/src/operators/tensor/math/reduce_sum/reduce_sum_fp.cairo b/src/operators/tensor/math/reduce_sum/reduce_sum_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/reduce_sum/reduce_sum_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/reduce_sum/reduce_sum_fp/core.cairo b/src/operators/tensor/math/reduce_sum/reduce_sum_fp/core.cairo deleted file mode 100644 index 752eefff7..000000000 --- a/src/operators/tensor/math/reduce_sum/reduce_sum_fp/core.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::reduce_sum::reduce_sum_fp::fp8x23; -use orion::operators::tensor::math::reduce_sum::reduce_sum_fp::fp16x16; - - -/// Cf: TensorTrait::reduce_sum docstring -fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::reduce_sum(self, axis, keepdims)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::reduce_sum(self, axis, keepdims)), - }, - Option::None(_) => Option::Some(fp16x16::reduce_sum(self, axis, keepdims)), - }, - Option::None(_) => Option::Some(fp16x16::reduce_sum(self, axis, keepdims)), - } -} - diff --git a/src/operators/tensor/math/reduce_sum/reduce_sum_fp/fp16x16.cairo b/src/operators/tensor/math/reduce_sum/reduce_sum_fp/fp16x16.cairo deleted file mode 100644 index 91b11a853..000000000 --- a/src/operators/tensor/math/reduce_sum/reduce_sum_fp/fp16x16.cairo +++ /dev/null @@ -1,103 +0,0 @@ -use core::option::OptionTrait; -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16AddEq}; - -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; - - -/// Cf: TensorTrait::reduce_sum docstring -fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - let mut output_data = ArrayTrait::new(); - - if (*self.shape).len() == 1 { - assert(axis == 0, 'axis out of dimensions'); - let current_sum = accumulate_sum(*self.data, *self.shape, *self.shape, axis); - output_data.append(current_sum); - - let mut output_shape = ArrayTrait::new(); - output_shape.append(1); - - return TensorTrait::::new(output_shape.span(), output_data.span(), *self.extra); - } else { - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_sum = accumulate_sum(*self.data, *self.shape, output_indices, axis); - - output_data.append(current_sum); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - if keepdims { - let output_shape = reduce_output_shape(*self.shape, axis, true); - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } else { - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } - } -} - - -/// Helper function that accumulates the sum of elements along a specific axis. -/// -/// # Arguments -/// * `input_data` - The input's data. -/// * `input_shape` - The input's shape. -/// * `output_indices` - A span of output indices. -/// * `axis` - The axis along which to accumulate the sum. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An FixedType value representing the accumulated sum along the specified axis. -fn accumulate_sum( - mut input_data: Span, - input_shape: Span, - output_indices: Span, - axis: usize -) -> FixedType { - let axis_len = *(input_shape)[axis]; - let mut acc = FixedTrait::new(0, false); - - let mut axis_index: usize = 0; - - if (input_shape).len() > 1 { - loop { - if axis_index == axis_len { - break (); - } - - let input_indices = combine_indices(output_indices, axis_index, axis); - let input_index = ravel_index(input_shape, input_indices); - let ele = *(input_data)[input_index]; - acc += ele; - axis_index += 1; - }; - } else { - loop { - match input_data.pop_front() { - Option::Some(item) => { - acc += *item; - }, - Option::None(_) => { - break; - } - }; - }; - } - - return acc; -} diff --git a/src/operators/tensor/math/reduce_sum/reduce_sum_fp/fp8x23.cairo b/src/operators/tensor/math/reduce_sum/reduce_sum_fp/fp8x23.cairo deleted file mode 100644 index 869805fe1..000000000 --- a/src/operators/tensor/math/reduce_sum/reduce_sum_fp/fp8x23.cairo +++ /dev/null @@ -1,103 +0,0 @@ -use core::option::OptionTrait; -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23AddEq}; - -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; - - -/// Cf: TensorTrait::reduce_sum docstring -fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - let mut output_data = ArrayTrait::new(); - - if (*self.shape).len() == 1 { - assert(axis == 0, 'axis out of dimensions'); - let current_sum = accumulate_sum(*self.data, *self.shape, *self.shape, axis); - output_data.append(current_sum); - - let mut output_shape = ArrayTrait::new(); - output_shape.append(1); - - return TensorTrait::::new(output_shape.span(), output_data.span(), *self.extra); - } else { - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_sum = accumulate_sum(*self.data, *self.shape, output_indices, axis); - - output_data.append(current_sum); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - if keepdims { - let output_shape = reduce_output_shape(*self.shape, axis, true); - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } else { - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } - } -} - - -/// Helper function that accumulates the sum of elements along a specific axis. -/// -/// # Arguments -/// * `input_data` - The input's data. -/// * `input_shape` - The input's shape. -/// * `output_indices` - A span of output indices. -/// * `axis` - The axis along which to accumulate the sum. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An FixedType value representing the accumulated sum along the specified axis. -fn accumulate_sum( - mut input_data: Span, - input_shape: Span, - output_indices: Span, - axis: usize -) -> FixedType { - let axis_len = *(input_shape)[axis]; - let mut acc = FixedTrait::new(0, false); - - let mut axis_index: usize = 0; - - if (input_shape).len() > 1 { - loop { - if axis_index == axis_len { - break (); - } - - let input_indices = combine_indices(output_indices, axis_index, axis); - let input_index = ravel_index(input_shape, input_indices); - let ele = *(input_data)[input_index]; - acc += ele; - axis_index += 1; - }; - } else { - loop { - match input_data.pop_front() { - Option::Some(item) => { - acc += *item; - }, - Option::None(_) => { - break; - } - }; - }; - } - - return acc; -} diff --git a/src/operators/tensor/math/reduce_sum/reduce_sum_i32.cairo b/src/operators/tensor/math/reduce_sum/reduce_sum_i32.cairo deleted file mode 100644 index 8ce5922f6..000000000 --- a/src/operators/tensor/math/reduce_sum/reduce_sum_i32.cairo +++ /dev/null @@ -1,98 +0,0 @@ -use core::option::OptionTrait; -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; - - -/// Cf: TensorTrait::reduce_sum docstring -fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - let mut output_data = ArrayTrait::new(); - - if (*self.shape).len() == 1 { - assert(axis == 0, 'axis out of dimensions'); - let current_sum = accumulate_sum(*self.data, *self.shape, *self.shape, axis); - output_data.append(current_sum); - - let mut output_shape = ArrayTrait::new(); - output_shape.append(1); - - return TensorTrait::::new(output_shape.span(), output_data.span(), *self.extra); - } else { - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_sum = accumulate_sum(*self.data, *self.shape, output_indices, axis); - - output_data.append(current_sum); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - if keepdims { - let output_shape = reduce_output_shape(*self.shape, axis, true); - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } else { - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } - } -} - - -/// Helper function that accumulates the sum of elements along a specific axis. -/// -/// # Arguments -/// * `input_data` - The input's data. -/// * `input_shape` - The input's shape. -/// * `output_indices` - A span of output indices. -/// * `axis` - The axis along which to accumulate the sum. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An i32 value representing the accumulated sum along the specified axis. -fn accumulate_sum( - mut input_data: Span, input_shape: Span, output_indices: Span, axis: usize -) -> i32 { - let axis_len = *(input_shape)[axis]; - let mut acc = IntegerTrait::new(0, false); - - let mut axis_index: usize = 0; - - if (input_shape).len() > 1 { - loop { - if axis_index == axis_len { - break (); - } - - let input_indices = combine_indices(output_indices, axis_index, axis); - let input_index = ravel_index(input_shape, input_indices); - let ele = *(input_data)[input_index]; - acc += ele; - axis_index += 1; - }; - } else { - loop { - match input_data.pop_front() { - Option::Some(item) => { - acc += *item; - }, - Option::None(_) => { - break; - } - }; - }; - } - - return acc; -} diff --git a/src/operators/tensor/math/reduce_sum/reduce_sum_i8.cairo b/src/operators/tensor/math/reduce_sum/reduce_sum_i8.cairo deleted file mode 100644 index d5e51fdcf..000000000 --- a/src/operators/tensor/math/reduce_sum/reduce_sum_i8.cairo +++ /dev/null @@ -1,98 +0,0 @@ -use core::option::OptionTrait; -use array::ArrayTrait; -use array::SpanTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; - - -/// Cf: TensorTrait::reduce_sum docstring -fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - let mut output_data = ArrayTrait::new(); - - if (*self.shape).len() == 1 { - assert(axis == 0, 'axis out of dimensions'); - let current_sum = accumulate_sum(*self.data, *self.shape, *self.shape, axis); - output_data.append(current_sum); - - let mut output_shape = ArrayTrait::new(); - output_shape.append(1); - - return TensorTrait::::new(output_shape.span(), output_data.span(), *self.extra); - } else { - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_sum = accumulate_sum(*self.data, *self.shape, output_indices, axis); - - output_data.append(current_sum); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - if keepdims { - let output_shape = reduce_output_shape(*self.shape, axis, true); - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } else { - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } - } -} - - -/// Helper function that accumulates the sum of elements along a specific axis. -/// -/// # Arguments -/// * `input_data` - The input's data. -/// * `input_shape` - The input's shape. -/// * `output_indices` - A span of output indices. -/// * `axis` - The axis along which to accumulate the sum. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An i8 value representing the accumulated sum along the specified axis. -fn accumulate_sum( - mut input_data: Span, input_shape: Span, output_indices: Span, axis: usize -) -> i8 { - let axis_len = *(input_shape)[axis]; - let mut acc = IntegerTrait::new(0, false); - - let mut axis_index: usize = 0; - - if (input_shape).len() > 1 { - loop { - if axis_index == axis_len { - break (); - } - - let input_indices = combine_indices(output_indices, axis_index, axis); - let input_index = ravel_index(input_shape, input_indices); - let ele = *(input_data)[input_index]; - acc += ele; - axis_index += 1; - }; - } else { - loop { - match input_data.pop_front() { - Option::Some(item) => { - acc += *item; - }, - Option::None(_) => { - break; - } - }; - }; - } - - return acc; -} diff --git a/src/operators/tensor/math/reduce_sum/reduce_sum_u32.cairo b/src/operators/tensor/math/reduce_sum/reduce_sum_u32.cairo deleted file mode 100644 index acad569fc..000000000 --- a/src/operators/tensor/math/reduce_sum/reduce_sum_u32.cairo +++ /dev/null @@ -1,97 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait, ravel_index, unravel_index}; -use orion::operators::tensor::helpers::{reduce_output_shape, len_from_shape, combine_indices}; - - -/// Cf: TensorTrait::reduce_sum docstring -fn reduce_sum(self: @Tensor, axis: usize, keepdims: bool) -> Tensor { - let mut output_data = ArrayTrait::new(); - - if (*self.shape).len() == 1 { - assert(axis == 0, 'axis out of dimensions'); - let current_sum = accumulate_sum(*self.data, *self.shape, *self.shape, axis); - output_data.append(current_sum); - - let mut output_shape = ArrayTrait::new(); - output_shape.append(1); - - return TensorTrait::::new(output_shape.span(), output_data.span(), *self.extra); - } else { - assert(axis <= (*self.shape).len(), 'axis out of dimensions'); - let output_shape = reduce_output_shape(*self.shape, axis, false); - let output_data_len = len_from_shape(output_shape); - let mut index: usize = 0; - loop { - let output_indices = unravel_index(index, output_shape); - let current_sum = accumulate_sum(*self.data, *self.shape, output_indices, axis); - - output_data.append(current_sum); - - index += 1; - if index == output_data_len { - break (); - }; - }; - - if keepdims { - let output_shape = reduce_output_shape(*self.shape, axis, true); - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } else { - return TensorTrait::::new(output_shape, output_data.span(), *self.extra); - } - } -} - - -/// Helper function that accumulates the sum of elements along a specific axis. -/// -/// # Arguments -/// * `input_data` - The input's data. -/// * `input_shape` - The input's shape. -/// * `output_indices` - A span of output indices. -/// * `axis` - The axis along which to accumulate the sum. -/// -/// # Panics -/// * Panics if gas limit is exceeded during execution. -/// -/// # Returns -/// * An u32 value representing the accumulated sum along the specified axis. -fn accumulate_sum( - mut input_data: Span, input_shape: Span, output_indices: Span, axis: usize -) -> u32 { - let axis_len = *(input_shape)[axis]; - let mut acc = 0; - - let mut axis_index: usize = 0; - - if (input_shape).len() > 1 { - loop { - if axis_index == axis_len { - break (); - } - - let input_indices = combine_indices(output_indices, axis_index, axis); - let input_index = ravel_index(input_shape, input_indices); - let ele = *(input_data)[input_index]; - acc += ele; - axis_index += 1; - }; - } else { - loop { - match input_data.pop_front() { - Option::Some(item) => { - acc += *item; - }, - Option::None(_) => { - break; - } - }; - }; - } - - return acc; -} diff --git a/src/operators/tensor/math/sin.cairo b/src/operators/tensor/math/sin.cairo index 7d26fe617..fb8212a77 100644 --- a/src/operators/tensor/math/sin.cairo +++ b/src/operators/tensor/math/sin.cairo @@ -1,4 +1,37 @@ -mod sin_i8; -mod sin_i32; -mod sin_u32; -mod sin_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::sin docstring +fn sin< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).sin()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} + diff --git a/src/operators/tensor/math/sin/sin_fp.cairo b/src/operators/tensor/math/sin/sin_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sin/sin_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sin/sin_fp/core.cairo b/src/operators/tensor/math/sin/sin_fp/core.cairo deleted file mode 100644 index f761707af..000000000 --- a/src/operators/tensor/math/sin/sin_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::sin::sin_fp::fp8x23; -use orion::operators::tensor::math::sin::sin_fp::fp16x16; - -/// Cf: TensorTrait::sin docstring -fn sin(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sin(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - } -} diff --git a/src/operators/tensor/math/sin/sin_fp/fp16x16.cairo b/src/operators/tensor/math/sin/sin_fp/fp16x16.cairo deleted file mode 100644 index 296eeed09..000000000 --- a/src/operators/tensor/math/sin/sin_fp/fp16x16.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sin/sin_fp/fp8x23.cairo b/src/operators/tensor/math/sin/sin_fp/fp8x23.cairo deleted file mode 100644 index 31a39449b..000000000 --- a/src/operators/tensor/math/sin/sin_fp/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/sin/sin_i32.cairo b/src/operators/tensor/math/sin/sin_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sin/sin_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sin/sin_i32/core.cairo b/src/operators/tensor/math/sin/sin_i32/core.cairo deleted file mode 100644 index 4bcbd118e..000000000 --- a/src/operators/tensor/math/sin/sin_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::sin::sin_i32::fp8x23; -use orion::operators::tensor::math::sin::sin_i32::fp16x16; - -/// Cf: TensorTrait::sin docstring -fn sin_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sin(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - } -} diff --git a/src/operators/tensor/math/sin/sin_i32/fp16x16.cairo b/src/operators/tensor/math/sin/sin_i32/fp16x16.cairo deleted file mode 100644 index b9b4032ad..000000000 --- a/src/operators/tensor/math/sin/sin_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/sin/sin_i32/fp8x23.cairo b/src/operators/tensor/math/sin/sin_i32/fp8x23.cairo deleted file mode 100644 index 5510fd5d7..000000000 --- a/src/operators/tensor/math/sin/sin_i32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/sin/sin_i8.cairo b/src/operators/tensor/math/sin/sin_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sin/sin_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sin/sin_i8/core.cairo b/src/operators/tensor/math/sin/sin_i8/core.cairo deleted file mode 100644 index f16fcea69..000000000 --- a/src/operators/tensor/math/sin/sin_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::sin::sin_i8::fp8x23; -use orion::operators::tensor::math::sin::sin_i8::fp16x16; - -/// Cf: TensorTrait::sin docstring -fn sin_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sin(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - } -} diff --git a/src/operators/tensor/math/sin/sin_i8/fp16x16.cairo b/src/operators/tensor/math/sin/sin_i8/fp16x16.cairo deleted file mode 100644 index c04d639a1..000000000 --- a/src/operators/tensor/math/sin/sin_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/sin/sin_i8/fp8x23.cairo b/src/operators/tensor/math/sin/sin_i8/fp8x23.cairo deleted file mode 100644 index badd8b4ee..000000000 --- a/src/operators/tensor/math/sin/sin_i8/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sin/sin_u32.cairo b/src/operators/tensor/math/sin/sin_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sin/sin_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sin/sin_u32/core.cairo b/src/operators/tensor/math/sin/sin_u32/core.cairo deleted file mode 100644 index c3cb26fa1..000000000 --- a/src/operators/tensor/math/sin/sin_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::sin::sin_u32::fp8x23; -use orion::operators::tensor::math::sin::sin_u32::fp16x16; - -/// Cf: TensorTrait::sin docstring -fn sin_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sin(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sin(*self)), - } -} diff --git a/src/operators/tensor/math/sin/sin_u32/fp16x16.cairo b/src/operators/tensor/math/sin/sin_u32/fp16x16.cairo deleted file mode 100644 index c784e5721..000000000 --- a/src/operators/tensor/math/sin/sin_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sin/sin_u32/fp8x23.cairo b/src/operators/tensor/math/sin/sin_u32/fp8x23.cairo deleted file mode 100644 index 0a70bd8dc..000000000 --- a/src/operators/tensor/math/sin/sin_u32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sin docstring -fn sin(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).sin()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sinh.cairo b/src/operators/tensor/math/sinh.cairo index e141690a7..f728bf966 100644 --- a/src/operators/tensor/math/sinh.cairo +++ b/src/operators/tensor/math/sinh.cairo @@ -1,4 +1,36 @@ -mod sinh_i8; -mod sinh_i32; -mod sinh_u32; -mod sinh_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::sinh docstring +fn sinh< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).sinh()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/sinh/sinh_fp.cairo b/src/operators/tensor/math/sinh/sinh_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sinh/sinh_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sinh/sinh_fp/core.cairo b/src/operators/tensor/math/sinh/sinh_fp/core.cairo deleted file mode 100644 index affbc65f9..000000000 --- a/src/operators/tensor/math/sinh/sinh_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::sinh::sinh_fp::fp8x23; -use orion::operators::tensor::math::sinh::sinh_fp::fp16x16; - -/// Cf: TensorTrait::sinh docstring -fn sinh(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - } -} diff --git a/src/operators/tensor/math/sinh/sinh_fp/fp16x16.cairo b/src/operators/tensor/math/sinh/sinh_fp/fp16x16.cairo deleted file mode 100644 index 9cfbc4219..000000000 --- a/src/operators/tensor/math/sinh/sinh_fp/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/sinh/sinh_fp/fp8x23.cairo b/src/operators/tensor/math/sinh/sinh_fp/fp8x23.cairo deleted file mode 100644 index c4dc93141..000000000 --- a/src/operators/tensor/math/sinh/sinh_fp/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/sinh/sinh_i32.cairo b/src/operators/tensor/math/sinh/sinh_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sinh/sinh_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sinh/sinh_i32/core.cairo b/src/operators/tensor/math/sinh/sinh_i32/core.cairo deleted file mode 100644 index bfe7dd0a4..000000000 --- a/src/operators/tensor/math/sinh/sinh_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::sinh::sinh_i32::fp8x23; -use orion::operators::tensor::math::sinh::sinh_i32::fp16x16; - -/// Cf: TensorTrait::sinh docstring -fn sinh_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - } -} diff --git a/src/operators/tensor/math/sinh/sinh_i32/fp16x16.cairo b/src/operators/tensor/math/sinh/sinh_i32/fp16x16.cairo deleted file mode 100644 index 0a7899a61..000000000 --- a/src/operators/tensor/math/sinh/sinh_i32/fp16x16.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/sinh/sinh_i32/fp8x23.cairo b/src/operators/tensor/math/sinh/sinh_i32/fp8x23.cairo deleted file mode 100644 index 1af870b89..000000000 --- a/src/operators/tensor/math/sinh/sinh_i32/fp8x23.cairo +++ /dev/null @@ -1,30 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/sinh/sinh_i8.cairo b/src/operators/tensor/math/sinh/sinh_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sinh/sinh_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sinh/sinh_i8/core.cairo b/src/operators/tensor/math/sinh/sinh_i8/core.cairo deleted file mode 100644 index a77278c6d..000000000 --- a/src/operators/tensor/math/sinh/sinh_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::sinh::sinh_i8::fp8x23; -use orion::operators::tensor::math::sinh::sinh_i8::fp16x16; - -/// Cf: TensorTrait::sinh docstring -fn sinh_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - } -} diff --git a/src/operators/tensor/math/sinh/sinh_i8/fp16x16.cairo b/src/operators/tensor/math/sinh/sinh_i8/fp16x16.cairo deleted file mode 100644 index c37bbcb16..000000000 --- a/src/operators/tensor/math/sinh/sinh_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sinh/sinh_i8/fp8x23.cairo b/src/operators/tensor/math/sinh/sinh_i8/fp8x23.cairo deleted file mode 100644 index af3e8caea..000000000 --- a/src/operators/tensor/math/sinh/sinh_i8/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/sinh/sinh_u32.cairo b/src/operators/tensor/math/sinh/sinh_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/sinh/sinh_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/sinh/sinh_u32/core.cairo b/src/operators/tensor/math/sinh/sinh_u32/core.cairo deleted file mode 100644 index 2fa9b82d1..000000000 --- a/src/operators/tensor/math/sinh/sinh_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::sinh::sinh_u32::fp8x23; -use orion::operators::tensor::math::sinh::sinh_u32::fp16x16; - -/// Cf: TensorTrait::sinh docstring -fn sinh_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sinh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sinh(*self)), - } -} diff --git a/src/operators/tensor/math/sinh/sinh_u32/fp16x16.cairo b/src/operators/tensor/math/sinh/sinh_u32/fp16x16.cairo deleted file mode 100644 index 3e406a877..000000000 --- a/src/operators/tensor/math/sinh/sinh_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sinh/sinh_u32/fp8x23.cairo b/src/operators/tensor/math/sinh/sinh_u32/fp8x23.cairo deleted file mode 100644 index fb3c8e42c..000000000 --- a/src/operators/tensor/math/sinh/sinh_u32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::sinh docstring -fn sinh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).sinh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt.cairo b/src/operators/tensor/math/sqrt.cairo index a91eb385f..39cae98a4 100644 --- a/src/operators/tensor/math/sqrt.cairo +++ b/src/operators/tensor/math/sqrt.cairo @@ -1,4 +1,35 @@ -mod sqrt_i8; -mod sqrt_i32; -mod sqrt_u32; -mod sqrt_fp; \ No newline at end of file +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +fn sqrt< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).sqrt()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/sqrt/sqrt_fp.cairo b/src/operators/tensor/math/sqrt/sqrt_fp.cairo deleted file mode 100644 index 1a2b31adf..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_fp/core.cairo b/src/operators/tensor/math/sqrt/sqrt_fp/core.cairo deleted file mode 100644 index 676d07a3a..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::sqrt::sqrt_fp::fp8x23; -use orion::operators::tensor::math::sqrt::sqrt_fp::fp16x16; - -/// Cf: TensorTrait::sqrt docstring -fn sqrt(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sqrt(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - } -} diff --git a/src/operators/tensor/math/sqrt/sqrt_fp/fp16x16.cairo b/src/operators/tensor/math/sqrt/sqrt_fp/fp16x16.cairo deleted file mode 100644 index 136f4ddfa..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_fp/fp16x16.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sqrt/sqrt_fp/fp8x23.cairo b/src/operators/tensor/math/sqrt/sqrt_fp/fp8x23.cairo deleted file mode 100644 index 50125089f..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_fp/fp8x23.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i32.cairo b/src/operators/tensor/math/sqrt/sqrt_i32.cairo deleted file mode 100644 index 1a2b31adf..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i32/core.cairo b/src/operators/tensor/math/sqrt/sqrt_i32/core.cairo deleted file mode 100644 index f13d02904..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i32/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::sqrt::sqrt_i32::fp8x23; -use orion::operators::tensor::math::sqrt::sqrt_i32::fp16x16; - -fn sqrt_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sqrt(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - } -} \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i32/fp16x16.cairo b/src/operators/tensor/math/sqrt/sqrt_i32/fp16x16.cairo deleted file mode 100644 index 46c71dc8f..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i32/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i32/fp8x23.cairo b/src/operators/tensor/math/sqrt/sqrt_i32/fp8x23.cairo deleted file mode 100644 index ee47fe173..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i32/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i8.cairo b/src/operators/tensor/math/sqrt/sqrt_i8.cairo deleted file mode 100644 index 1a2b31adf..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i8/core.cairo b/src/operators/tensor/math/sqrt/sqrt_i8/core.cairo deleted file mode 100644 index 55a7f4141..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i8/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::sqrt::sqrt_i8::fp8x23; -use orion::operators::tensor::math::sqrt::sqrt_i8::fp16x16; - -fn sqrt_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sqrt(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - } -} \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i8/fp16x16.cairo b/src/operators/tensor/math/sqrt/sqrt_i8/fp16x16.cairo deleted file mode 100644 index 0d69b27b9..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i8/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_i8/fp8x23.cairo b/src/operators/tensor/math/sqrt/sqrt_i8/fp8x23.cairo deleted file mode 100644 index c37f548f9..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_i8/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sqrt/sqrt_u32.cairo b/src/operators/tensor/math/sqrt/sqrt_u32.cairo deleted file mode 100644 index 1a2b31adf..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; \ No newline at end of file diff --git a/src/operators/tensor/math/sqrt/sqrt_u32/core.cairo b/src/operators/tensor/math/sqrt/sqrt_u32/core.cairo deleted file mode 100644 index 619ec3459..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_u32/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::sqrt::sqrt_u32::fp8x23; -use orion::operators::tensor::math::sqrt::sqrt_u32::fp16x16; - -fn sqrt_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::sqrt(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - }, - Option::None(_) => Option::Some(fp16x16::sqrt(*self)), - } -} diff --git a/src/operators/tensor/math/sqrt/sqrt_u32/fp16x16.cairo b/src/operators/tensor/math/sqrt/sqrt_u32/fp16x16.cairo deleted file mode 100644 index 8ab07e5ad..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_u32/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/sqrt/sqrt_u32/fp8x23.cairo b/src/operators/tensor/math/sqrt/sqrt_u32/fp8x23.cairo deleted file mode 100644 index f37773768..000000000 --- a/src/operators/tensor/math/sqrt/sqrt_u32/fp8x23.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -fn sqrt(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).sqrt()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/tanh.cairo b/src/operators/tensor/math/tanh.cairo index 9edd60e20..cb12690c5 100644 --- a/src/operators/tensor/math/tanh.cairo +++ b/src/operators/tensor/math/tanh.cairo @@ -1,4 +1,36 @@ -mod tanh_i8; -mod tanh_i32; -mod tanh_u32; -mod tanh_fp; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::Into; + +use orion::numbers::NumberTrait; +use orion::numbers::fixed_point::core::FixedTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait}; + + +/// Cf: TensorTrait::tanh docstring +fn tanh< + T, + MAG, + impl FFixedTrait: FixedTrait, + impl FTensor: TensorTrait, + impl FCopy: Copy, + impl FDrop: Drop, +>( + mut self: Tensor +) -> Tensor { + let mut result = ArrayTrait::new(); + + loop { + match self.data.pop_front() { + Option::Some(item) => { + result.append((*item).tanh()); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(self.shape, result.span()); +} diff --git a/src/operators/tensor/math/tanh/tanh_fp.cairo b/src/operators/tensor/math/tanh/tanh_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/tanh/tanh_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/tanh/tanh_fp/core.cairo b/src/operators/tensor/math/tanh/tanh_fp/core.cairo deleted file mode 100644 index d3cef366b..000000000 --- a/src/operators/tensor/math/tanh/tanh_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::tanh::tanh_fp::fp8x23; -use orion::operators::tensor::math::tanh::tanh_fp::fp16x16; - -/// Cf: TensorTrait::tanh docstring -fn tanh(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::tanh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - } -} diff --git a/src/operators/tensor/math/tanh/tanh_fp/fp16x16.cairo b/src/operators/tensor/math/tanh/tanh_fp/fp16x16.cairo deleted file mode 100644 index 443d726f7..000000000 --- a/src/operators/tensor/math/tanh/tanh_fp/fp16x16.cairo +++ /dev/null @@ -1,28 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} - diff --git a/src/operators/tensor/math/tanh/tanh_fp/fp8x23.cairo b/src/operators/tensor/math/tanh/tanh_fp/fp8x23.cairo deleted file mode 100644 index 0ed37fe99..000000000 --- a/src/operators/tensor/math/tanh/tanh_fp/fp8x23.cairo +++ /dev/null @@ -1,27 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append((*item).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/tanh/tanh_i32.cairo b/src/operators/tensor/math/tanh/tanh_i32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/tanh/tanh_i32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/tanh/tanh_i32/core.cairo b/src/operators/tensor/math/tanh/tanh_i32/core.cairo deleted file mode 100644 index 600c99386..000000000 --- a/src/operators/tensor/math/tanh/tanh_i32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::tanh::tanh_i32::fp8x23; -use orion::operators::tensor::math::tanh::tanh_i32::fp16x16; - -/// Cf: TensorTrait::tanh docstring -fn tanh_i32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::tanh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - } -} diff --git a/src/operators/tensor/math/tanh/tanh_i32/fp16x16.cairo b/src/operators/tensor/math/tanh/tanh_i32/fp16x16.cairo deleted file mode 100644 index cc6b03b40..000000000 --- a/src/operators/tensor/math/tanh/tanh_i32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} \ No newline at end of file diff --git a/src/operators/tensor/math/tanh/tanh_i32/fp8x23.cairo b/src/operators/tensor/math/tanh/tanh_i32/fp8x23.cairo deleted file mode 100644 index a2891fa74..000000000 --- a/src/operators/tensor/math/tanh/tanh_i32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item.mag, *item.sign).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/tanh/tanh_i8.cairo b/src/operators/tensor/math/tanh/tanh_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/tanh/tanh_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/tanh/tanh_i8/core.cairo b/src/operators/tensor/math/tanh/tanh_i8/core.cairo deleted file mode 100644 index b4ce797ff..000000000 --- a/src/operators/tensor/math/tanh/tanh_i8/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::math::tanh::tanh_i8::fp8x23; -use orion::operators::tensor::math::tanh::tanh_i8::fp16x16; - -/// Cf: TensorTrait::tanh docstring -fn tanh_i8(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::tanh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - } -} diff --git a/src/operators/tensor/math/tanh/tanh_i8/fp16x16.cairo b/src/operators/tensor/math/tanh/tanh_i8/fp16x16.cairo deleted file mode 100644 index 668de1f85..000000000 --- a/src/operators/tensor/math/tanh/tanh_i8/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/tanh/tanh_i8/fp8x23.cairo b/src/operators/tensor/math/tanh/tanh_i8/fp8x23.cairo deleted file mode 100644 index f60adb4e7..000000000 --- a/src/operators/tensor/math/tanh/tanh_i8/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled((*item.mag).into(), *item.sign).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/tanh/tanh_u32.cairo b/src/operators/tensor/math/tanh/tanh_u32.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/tanh/tanh_u32.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/tanh/tanh_u32/core.cairo b/src/operators/tensor/math/tanh/tanh_u32/core.cairo deleted file mode 100644 index 03b0655f1..000000000 --- a/src/operators/tensor/math/tanh/tanh_u32/core.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::math::tanh::tanh_u32::fp8x23; -use orion::operators::tensor::math::tanh::tanh_u32::fp16x16; - -/// Cf: TensorTrait::tanh docstring -fn tanh_u32(self: @Tensor) -> Option> { - match *self.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::tanh(*self)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - }, - Option::None(_) => Option::Some(fp16x16::tanh(*self)), - } -} diff --git a/src/operators/tensor/math/tanh/tanh_u32/fp16x16.cairo b/src/operators/tensor/math/tanh/tanh_u32/fp16x16.cairo deleted file mode 100644 index 500ab9db8..000000000 --- a/src/operators/tensor/math/tanh/tanh_u32/fp16x16.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/tanh/tanh_u32/fp8x23.cairo b/src/operators/tensor/math/tanh/tanh_u32/fp8x23.cairo deleted file mode 100644 index cfd29bfe4..000000000 --- a/src/operators/tensor/math/tanh/tanh_u32/fp8x23.cairo +++ /dev/null @@ -1,29 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::Into; - -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - - -/// Cf: TensorTrait::tanh docstring -fn tanh(mut self: Tensor) -> Tensor { - let mut result = ArrayTrait::new(); - - loop { - match self.data.pop_front() { - Option::Some(item) => { - result.append(FixedTrait::new_unscaled(*item, false).tanh()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::::new(self.shape, result.span(), self.extra); -} diff --git a/src/operators/tensor/math/xor.cairo b/src/operators/tensor/math/xor.cairo index f3de7b256..690a768d7 100644 --- a/src/operators/tensor/math/xor.cairo +++ b/src/operators/tensor/math/xor.cairo @@ -1,4 +1,47 @@ -mod xor_i8; -mod xor_u32; -mod xor_i32; -mod xor_fp; +use array::ArrayTrait; +use option::OptionTrait; +use array::SpanTrait; + +use orion::numbers::NumberTrait; +use orion::operators::tensor::core::{Tensor, TensorTrait, unravel_index}; +use orion::operators::tensor::helpers::{ + broadcast_shape, broadcast_index_mapping, len_from_shape, check_compatibility +}; + +/// Cf: TensorTrait::xor docstring +fn xor< + T, + MAG, + impl TNumber: NumberTrait, + impl UsizeFTensor: TensorTrait, + impl TCopy: Copy, + impl TDrop: Drop +>( + y: @Tensor, z: @Tensor +) -> Tensor { + let broadcasted_shape = broadcast_shape(*y.shape, *z.shape); + let mut result: Array = ArrayTrait::new(); + + let num_elements = len_from_shape(broadcasted_shape); + + let mut n: usize = 0; + loop { + let indices_broadcasted = unravel_index(n, broadcasted_shape); + + let indices_self = broadcast_index_mapping(*y.shape, indices_broadcasted); + let indices_other = broadcast_index_mapping(*z.shape, indices_broadcasted); + + if NumberTrait::xor(*(*y.data)[indices_self], *(*z.data)[indices_other]) { + result.append(1); + } else { + result.append(0); + } + + n += 1; + if n == num_elements { + break (); + }; + }; + + return TensorTrait::new(broadcasted_shape, result.span()); +} diff --git a/src/operators/tensor/math/xor/xor_fp.cairo b/src/operators/tensor/math/xor/xor_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/operators/tensor/math/xor/xor_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/operators/tensor/math/xor/xor_fp/core.cairo b/src/operators/tensor/math/xor/xor_fp/core.cairo deleted file mode 100644 index 09a92b57d..000000000 --- a/src/operators/tensor/math/xor/xor_fp/core.cairo +++ /dev/null @@ -1,18 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::operators::tensor::math::xor::xor_fp::fp8x23; -use orion::operators::tensor::math::xor::xor_fp::fp16x16; - -/// Cf: TensorTrait::logical_or docstring -fn xor(y: @Tensor, z: @Tensor) -> Option> { - match *y.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some(fp8x23::xor(y, z)), - FixedImpl::FP16x16(()) => Option::Some(fp16x16::xor(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::xor(y, z)), - }, - Option::None(_) => Option::Some(fp16x16::xor(y, z)), - } -} \ No newline at end of file diff --git a/src/operators/tensor/math/xor/xor_fp/fp16x16.cairo b/src/operators/tensor/math/xor/xor_fp/fp16x16.cairo deleted file mode 100644 index 4172db858..000000000 --- a/src/operators/tensor/math/xor/xor_fp/fp16x16.cairo +++ /dev/null @@ -1,53 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp16x16::math::comp::xor as xor_fp16x16; - -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::xor docstring -fn xor(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if xor_fp16x16(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/xor/xor_fp/fp8x23.cairo b/src/operators/tensor/math/xor/xor_fp/fp8x23.cairo deleted file mode 100644 index 685c9e7bb..000000000 --- a/src/operators/tensor/math/xor/xor_fp/fp8x23.cairo +++ /dev/null @@ -1,53 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::fixed_point::core::FixedType; -use orion::numbers::fixed_point::implementations::fp8x23::math::comp::xor as xor_fp8x23; - -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23PartialOrd; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - - -/// Cf: TensorTrait::xor docstring -fn xor(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if xor_fp8x23(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/xor/xor_i32.cairo b/src/operators/tensor/math/xor/xor_i32.cairo deleted file mode 100644 index 2844ff357..000000000 --- a/src/operators/tensor/math/xor/xor_i32.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i32::i32_xor; -use orion::numbers::signed_integer::i32::i32; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::xor docstring -fn xor(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if i32_xor(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/xor/xor_i8.cairo b/src/operators/tensor/math/xor/xor_i8.cairo deleted file mode 100644 index a2d9f011e..000000000 --- a/src/operators/tensor/math/xor/xor_i8.cairo +++ /dev/null @@ -1,49 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::numbers::signed_integer::i8::i8_xor; -use orion::numbers::signed_integer::i8::i8; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::xor docstring -fn xor(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if i8_xor(y_value, z_value) { - data_result.append(1); - } else { - data_result.append(0); - } - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/math/xor/xor_u32.cairo b/src/operators/tensor/math/xor/xor_u32.cairo deleted file mode 100644 index fd93c6f0a..000000000 --- a/src/operators/tensor/math/xor/xor_u32.cairo +++ /dev/null @@ -1,47 +0,0 @@ -use array::ArrayTrait; -use option::OptionTrait; -use array::SpanTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{Tensor, TensorTrait}; - -use orion::operators::tensor::helpers::check_compatibility; - -/// Cf: TensorTrait::xor docstring -fn xor(y: @Tensor, z: @Tensor) -> Tensor { - check_compatibility(*y.shape, *z.shape); - - let mut data_result = ArrayTrait::::new(); - let (mut smaller, mut bigger, retains_input_order) = if (*y.data).len() < (*z.data).len() { - (y, z, true) - } else { - (z, y, false) - }; - - let mut bigger_data = *bigger.data; - let mut smaller_data = *smaller.data; - let mut smaller_index = 0; - - loop { - if bigger_data.len() == 0 { - break (); - }; - - let bigger_current_index = *bigger_data.pop_front().unwrap(); - let smaller_current_index = *smaller_data[smaller_index]; - - let (y_value, z_value) = if retains_input_order { - (smaller_current_index, bigger_current_index) - } else { - (bigger_current_index, smaller_current_index) - }; - - if (y_value == 0 || z_value == 0) && y_value != z_value { - data_result.append(1); - } else { - data_result.append(0); - } - smaller_index = (1 + smaller_index) % smaller_data.len(); - }; - - return TensorTrait::::new(*bigger.shape, data_result.span(), *y.extra); -} diff --git a/src/operators/tensor/quantization.cairo b/src/operators/tensor/quantization.cairo new file mode 100644 index 000000000..31ee00711 --- /dev/null +++ b/src/operators/tensor/quantization.cairo @@ -0,0 +1,2 @@ +mod quantize_linear; +mod dequantize_linear; \ No newline at end of file diff --git a/src/operators/tensor/quantization/dequantize_linear.cairo b/src/operators/tensor/quantization/dequantize_linear.cairo new file mode 100644 index 000000000..1ca4bf8d5 --- /dev/null +++ b/src/operators/tensor/quantization/dequantize_linear.cairo @@ -0,0 +1,90 @@ +use core::traits::Into; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; + +use orion::operators::tensor::core::{Tensor, TensorTrait}; +use orion::operators::tensor::helpers::check_compatibility; +use orion::utils::saturate; + +/// Cf: PerfomanceTrait::dequantize_linear docstring +fn dequantize_linear< + Q, + T, + impl TTensor: TensorTrait, + impl QIntoT: Into, + impl TSub: Sub, + impl TMul: Mul, + impl TTensorSub: Sub>, + impl TTensorMul: Mul>, + impl QTensorIntoTTensor: Into, Tensor>, + impl TDrop: Drop, + impl TCopy: Copy, + impl QCopy: Copy, + impl QDrop: Drop +>( + x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor +) -> Tensor:: { + if (*x_scale.data).len() == 1 && (*x_zero_point.data).len() == 1 { + dequantize_element_wise(*x, *x_scale.data[0], *x_zero_point.data[0]) + } else { + check_compatibility(*x.shape, *x_scale.shape); + check_compatibility(*x.shape, *x_zero_point.shape); + check_compatibility(*x_scale.shape, *x_zero_point.shape); + dequantize_per_axis(@(*x).into(), x_scale, x_zero_point) + } +} + +fn dequantize_per_axis< + T, + impl TTensor: TensorTrait, + impl TTensorSub: Sub>, + impl TTensorMul: Mul>, + impl TCopy: Copy, + impl TDrop: Drop +>( + x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor +) -> Tensor:: { + let mut result_data = ArrayTrait::::new(); + + (*x - *x_zero_point) * *x_scale +} + +fn dequantize_element_wise< + Q, + T, + impl TTensor: TensorTrait, + impl QIntoT: Into, + impl TSub: Sub, + impl TMul: Mul, + impl TDrop: Drop, + impl TCopy: Copy, + impl QCopy: Copy, + impl QDrop: Drop +>( + mut x: Tensor::, x_scale: T, x_zero_point: T +) -> Tensor:: { + let mut result_data = ArrayTrait::::new(); + + loop { + match x.data.pop_front() { + Option::Some(item) => { + let dequantized = dequantize(*item, x_scale, x_zero_point); + result_data.append(dequantized); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(x.shape, result_data.span()); +} + +fn dequantize< + Q, T, impl QIntoT: Into, impl TSub: Sub, impl TMul: Mul, impl TDrop: Drop +>( + x: Q, x_scale: T, x_zero_point: T +) -> T { + (x.into() - x_zero_point) * x_scale +} diff --git a/src/operators/tensor/quantization/quantize_linear.cairo b/src/operators/tensor/quantization/quantize_linear.cairo new file mode 100644 index 000000000..4c68edfe4 --- /dev/null +++ b/src/operators/tensor/quantization/quantize_linear.cairo @@ -0,0 +1,103 @@ +use core::debug::PrintTrait; +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use traits::TryInto; + +use orion::operators::tensor::core::{Tensor, TensorTrait}; +use orion::operators::tensor::helpers::check_compatibility; +use orion::operators::tensor::math::arithmetic::saturated_add; +use orion::utils::saturate; + +/// Cf: TensorTrait::quantize_linear docstring +fn quantize_linear< + T, + Q, + impl TTensor: TensorTrait, + impl QTensor: TensorTrait, + impl TAdd: Add, + impl TDiv: Div, + impl TTensorDiv: Div>, + impl TPartialOrd: PartialOrd, + impl TTryInto: TryInto, + impl TCopy: Copy, + impl TDrop: Drop, + impl QCopy: Copy, + impl QDrop: Drop, +>( + x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor, min: T, max: T +) -> Tensor:: { + if (*y_scale.data).len() == 1 && (*y_zero_point.data).len() == 1 { + quantize_element_wise(*x, *y_scale.data[0], *y_zero_point.data[0], min, max) + } else { + check_compatibility(*x.shape, *y_scale.shape); + check_compatibility(*x.shape, *y_zero_point.shape); + check_compatibility(*y_scale.shape, *y_zero_point.shape); + quantize_per_axis(x, y_scale, y_zero_point, min, max) + } +} + +fn quantize_per_axis< + T, + Q, + impl TTensor: TensorTrait, + impl QTensor: TensorTrait, + impl TAdd: Add, + impl TTensorDiv: Div>, + impl TPartialOrd: PartialOrd, + impl TTryInto: TryInto, + impl TCopy: Copy, + impl TDrop: Drop, + impl QDrop: Drop, +>( + x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor, min: T, max: T +) -> Tensor:: { + saturated_add(@(*x / *y_scale), y_zero_point, min, max) +} + +fn quantize_element_wise< + T, + Q, + impl TCopy: Copy, + impl TDrop: Drop, + impl QCopy: Copy, + impl QDrop: Drop, + impl TPartialOrd: PartialOrd, + impl TDiv: Div, + impl TAdd: Add, + impl TTryIntoQ: TryInto, + impl QTensor: TensorTrait +>( + mut x: Tensor::, y_scale: T, y_zero_point: T, min: T, max: T +) -> Tensor:: { + let mut result_data = ArrayTrait::::new(); + + loop { + match x.data.pop_front() { + Option::Some(item) => { + let quantized = quantize(*item, y_scale, y_zero_point, min, max); + result_data.append(quantized); + }, + Option::None(_) => { + break; + } + }; + }; + + return TensorTrait::new(x.shape, result_data.span()); +} + +fn quantize< + T, + Q, + impl TCopy: Copy, + impl TDrop: Drop, + impl TPartialOrd: PartialOrd, + impl TDiv: Div, + impl TAdd: Add, + impl TTryIntoQ: TryInto +>( + x: T, y_scale: T, y_zero_point: T, min: T, max: T +) -> Q { + saturate(min, max, ((x / y_scale) + y_zero_point)).try_into().unwrap() +} diff --git a/src/performance.cairo b/src/performance.cairo deleted file mode 100644 index f8caa9fac..000000000 --- a/src/performance.cairo +++ /dev/null @@ -1,4 +0,0 @@ -mod functional; -mod implementations; -mod core; - diff --git a/src/performance/core.cairo b/src/performance/core.cairo deleted file mode 100644 index 29273b1d0..000000000 --- a/src/performance/core.cairo +++ /dev/null @@ -1,154 +0,0 @@ -use orion::operators::tensor::core::Tensor; -use orion::numbers::fixed_point::core::FixedType; - -/// Trait -/// -/// quantize_linear - Quantizes a Tensor using linear quantization. -/// dequantize_linear - Dequantizes a Tensor using linear dequantization. -trait PerfomanceTrait { - /// # performance.quantize_linear - /// - /// ```rust - /// fn quantize_linear(self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor) -> Tensor::; - /// ``` - /// - /// Quantizes a Tensor using linear quantization. - /// - /// The linear quantization operator. It consumes a high precision tensor, a scale, and a zero point - /// to compute the low precision / quantized tensor. The scale factor and zero point must have same shape, - /// and can be either a scalar for per-tensor / per layer quantization, or a 1-D tensor for per-axis quantization. - /// The quantization formula is `y = saturate ((x / y_scale) + y_zero_point)`. For saturation, it saturates to `[-128, 127]`. - /// For (x / y_scale), it's rounding to the nearest even. - /// - /// ## Args - /// - /// * `self`(`@Tensor`) - The input tensor. - /// * `y_scale`(`@Tensor`) - Scale for doing quantization to get `y`. - /// * `y_zero_point`(`@Tensor`) - Zero point for doing quantization to get `y`. - /// - /// ## Returns - /// - /// A new `Tensor` with the same shape as the input tensor, containing the quantized values. - /// - /// ## Examples - /// - /// ```rust - /// use array::{ArrayTrait, SpanTrait}; - /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor}; - /// use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - /// use orion::numbers::signed_integer::i32::{i32, IntegerTrait}; - /// use orion::numbers::signed_integer::i8::i8; - /// use orion::performance::core::PerfomanceTrait; - /// use orion::performance::implementations::impl_performance_i32::Performance_i32_i8; - /// - /// fn quantize_linear_example() -> Tensor { - /// // We instantiate a 1D Tensor here. - /// let x = TensorTrait::::new( - /// shape: array![6].span(), - /// data: array![ - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(2, false), - /// IntegerTrait::new(3, false), - /// IntegerTrait::new(1000, false), - /// IntegerTrait::new(254, true), - /// IntegerTrait::new(1000, true), - /// ] - /// .span(), - /// extra: Option::None(()) - /// ); - /// - /// // We instantiate the y_scale here. - /// let y_scale = TensorTrait::::new( - /// shape: array![1].span(), - /// data: array![IntegerTrait::new(2, false)].span(), - /// extra: Option::None(()) - /// ); - /// - /// // We instantiate the y_zero_point here. - /// let y_zero_point = TensorTrait::::new( - /// shape: array![1].span(), - /// data: array![IntegerTrait::new(1, false)].span(), - /// extra: Option::None(()) - /// ); - /// - /// return x.quantize_linear(@y_scale, @y_zero_point); - /// } - /// >>> [1, 2, 2, 127, -126, -128] - /// ``` - /// - fn quantize_linear( - self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor - ) -> Tensor::; - /// # performance.dequantize_linear - /// - /// ```rust - /// fn dequantize_linear(self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor) -> Tensor::; - /// ``` - /// - /// Dequantizes a Tensor using linear dequantization. - /// - /// The linear dequantization operator. It consumes a quantized tensor, a scale, and a zero point to compute - /// the full precision tensor. The dequantization formula is y = (x - x_zero_point) * x_scale. x_scale and - /// x_zero_point must have same shape, and can be either a scalar for per-tensor / per layer quantization, - /// or a 1-D tensor for per-axis quantization. - /// - /// ## Args - /// - /// * `self`(`@Tensor`) - The input tensor. - /// * `x_scale`(`@Tensor`) - Scale for input `x`. - /// * `x_zero_point`(`@Tensor`) - Zero point for input `x`. - /// - /// ## Returns - /// - /// A new `Tensor` with the same shape as the input tensor, containing the dequantized values. - /// - /// ## Examples - /// - /// ```rust - /// use array::{ArrayTrait, SpanTrait}; - /// - /// use orion::operators::tensor::core::{TensorTrait, Tensor}; - /// use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - /// use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - /// use orion::numbers::signed_integer::i32::i32; - /// use orion::numbers::signed_integer::i8::{i8, IntegerTrait}; - /// use orion::performance::core::PerfomanceTrait; - /// use orion::performance::implementations::impl_performance_i32::Performance_i32_i8; - /// - /// fn dequantize_linear_example() -> Tensor { - /// // We instantiate a 1D Tensor here. - /// let x = TensorTrait::::new( - /// shape: array![4].span(), - /// data: array![ - /// IntegerTrait::new(0, false), - /// IntegerTrait::new(3, false), - /// IntegerTrait::new(125, false), - /// IntegerTrait::new(127, false), - /// ].span(), - /// extra: Option::None(()) - /// ); - /// - /// // We instantiate the x_scale here. - /// let x_scale = TensorTrait::::new( - /// shape: array![1].span(), - /// data: array![IntegerTrait::new(2, false)].span(), - /// extra: Option::None(()) - /// ); - /// - /// // We instantiate the x_zero_point here. - /// let x_zero_point = TensorTrait::::new( - /// shape: array![1].span(), - /// data: array![IntegerTrait::new(0, false)].span(), - /// extra: Option::None(()) - /// ); - /// - /// return x.dequantize_linear(@x_scale, @x_zero_point); - /// } - /// >>> [0, 6, 250, 254] - /// ``` - /// - fn dequantize_linear( - self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor - ) -> Tensor::; -} diff --git a/src/performance/functional.cairo b/src/performance/functional.cairo deleted file mode 100644 index 0ed0c12d8..000000000 --- a/src/performance/functional.cairo +++ /dev/null @@ -1,2 +0,0 @@ -mod quantize_linear; -mod dequantize_linear; diff --git a/src/performance/functional/dequantize_linear.cairo b/src/performance/functional/dequantize_linear.cairo deleted file mode 100644 index 5225b8b79..000000000 --- a/src/performance/functional/dequantize_linear.cairo +++ /dev/null @@ -1,2 +0,0 @@ -mod dequantize_linear_i32; -mod dequantize_linear_fp; diff --git a/src/performance/functional/dequantize_linear/dequantize_linear_fp.cairo b/src/performance/functional/dequantize_linear/dequantize_linear_fp.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/performance/functional/dequantize_linear/dequantize_linear_fp.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/performance/functional/dequantize_linear/dequantize_linear_fp/core.cairo b/src/performance/functional/dequantize_linear/dequantize_linear_fp/core.cairo deleted file mode 100644 index 15ff0a4ad..000000000 --- a/src/performance/functional/dequantize_linear/dequantize_linear_fp/core.cairo +++ /dev/null @@ -1,25 +0,0 @@ -use orion::numbers::signed_integer::i8::i8; -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor}; -use orion::performance::functional::dequantize_linear::dequantize_linear_fp::fp8x23; -use orion::performance::functional::dequantize_linear::dequantize_linear_fp::fp16x16; - -/// Cf: PerfomanceTrait::dequantize_linear docstring -fn dequantize_linear( - x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor -) -> Option> { - match *x.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some( - fp8x23::dequantize_linear(x, x_scale, x_zero_point) - ), - FixedImpl::FP16x16(()) => Option::Some( - fp16x16::dequantize_linear(x, x_scale, x_zero_point) - ), - }, - Option::None(_) => Option::Some(fp16x16::dequantize_linear(x, x_scale, x_zero_point)), - }, - Option::None(_) => Option::Some(fp16x16::dequantize_linear(x, x_scale, x_zero_point)), - } -} diff --git a/src/performance/functional/dequantize_linear/dequantize_linear_fp/fp16x16.cairo b/src/performance/functional/dequantize_linear/dequantize_linear_fp/fp16x16.cairo deleted file mode 100644 index 292e7114f..000000000 --- a/src/performance/functional/dequantize_linear/dequantize_linear_fp/fp16x16.cairo +++ /dev/null @@ -1,61 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i8::{i8, i8_to_fp16x16}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Sub, FP16x16Mul}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::core::FixedType; -use orion::operators::tensor::implementations::impl_tensor_fp::{ - Tensor_fp, FixedTypeTensorSub, FixedTypeTensorMul -}; -use orion::operators::tensor::implementations::impl_tensor_i8::TensorI8IntoTensorFP; -use orion::operators::tensor::helpers::check_compatibility; -use orion::utils::saturate; - -/// Cf: PerfomanceTrait::dequantize_linear docstring -fn dequantize_linear( - x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor -) -> Tensor:: { - if (*x_scale.data).len() == 1 && (*x_zero_point.data).len() == 1 { - dequantize_element_wise(*x, *x_scale.data[0], *x_zero_point.data[0]) - } else { - check_compatibility(*x.shape, *x_scale.shape); - check_compatibility(*x.shape, *x_zero_point.shape); - check_compatibility(*x_scale.shape, *x_zero_point.shape); - dequantize_per_axis(@(*x).into(), x_scale, x_zero_point) - } -} - -fn dequantize_per_axis( - x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor -) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - (*x - *x_zero_point) * *x_scale -} - -fn dequantize_element_wise( - mut x: Tensor::, x_scale: FixedType, x_zero_point: FixedType -) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - loop { - match x.data.pop_front() { - Option::Some(item) => { - let dequantized = dequantize(*item, x_scale, x_zero_point); - result_data.append(dequantized); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(x.shape, result_data.span(), x.extra); -} - -fn dequantize(x: i8, x_scale: FixedType, x_zero_point: FixedType) -> FixedType { - (i8_to_fp16x16(x) - x_zero_point) * x_scale -} diff --git a/src/performance/functional/dequantize_linear/dequantize_linear_fp/fp8x23.cairo b/src/performance/functional/dequantize_linear/dequantize_linear_fp/fp8x23.cairo deleted file mode 100644 index 1ffa2a3e8..000000000 --- a/src/performance/functional/dequantize_linear/dequantize_linear_fp/fp8x23.cairo +++ /dev/null @@ -1,61 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::i8::{i8, i8_to_fp8x23}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Sub, FP8x23Mul}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::core::FixedType; -use orion::operators::tensor::implementations::impl_tensor_fp::{ - Tensor_fp, FixedTypeTensorSub, FixedTypeTensorMul -}; -use orion::operators::tensor::implementations::impl_tensor_i8::TensorI8IntoTensorFP; -use orion::operators::tensor::helpers::check_compatibility; -use orion::utils::saturate; - -/// Cf: PerfomanceTrait::dequantize_linear docstring -fn dequantize_linear( - x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor -) -> Tensor:: { - if (*x_scale.data).len() == 1 && (*x_zero_point.data).len() == 1 { - dequantize_element_wise(*x, *x_scale.data[0], *x_zero_point.data[0]) - } else { - check_compatibility(*x.shape, *x_scale.shape); - check_compatibility(*x.shape, *x_zero_point.shape); - check_compatibility(*x_scale.shape, *x_zero_point.shape); - dequantize_per_axis(@(*x).into(), x_scale, x_zero_point) - } -} - -fn dequantize_per_axis( - x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor -) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - (*x - *x_zero_point) * *x_scale -} - -fn dequantize_element_wise( - mut x: Tensor::, x_scale: FixedType, x_zero_point: FixedType -) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - loop { - match x.data.pop_front() { - Option::Some(item) => { - let dequantized = dequantize(*item, x_scale, x_zero_point); - result_data.append(dequantized); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(x.shape, result_data.span(), x.extra); -} - -fn dequantize(x: i8, x_scale: FixedType, x_zero_point: FixedType) -> FixedType { - (i8_to_fp8x23(x) - x_zero_point) * x_scale -} diff --git a/src/performance/functional/dequantize_linear/dequantize_linear_i32.cairo b/src/performance/functional/dequantize_linear/dequantize_linear_i32.cairo deleted file mode 100644 index 8d289c2c7..000000000 --- a/src/performance/functional/dequantize_linear/dequantize_linear_i32.cairo +++ /dev/null @@ -1,58 +0,0 @@ -use core::traits::Into; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32, i8::i8}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_i32::{ - Tensor_i32, i32TensorSub, i32TensorMul -}; -use orion::operators::tensor::implementations::impl_tensor_i8::TensorI8IntoTensorI32; -use orion::operators::tensor::helpers::check_compatibility; -use orion::utils::saturate; - -/// Cf: PerfomanceTrait::dequantize_linear docstring -fn dequantize_linear( - x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor -) -> Tensor:: { - if (*x_scale.data).len() == 1 && (*x_zero_point.data).len() == 1 { - dequantize_element_wise(*x, *x_scale.data[0], *x_zero_point.data[0]) - } else { - check_compatibility(*x.shape, *x_scale.shape); - check_compatibility(*x.shape, *x_zero_point.shape); - check_compatibility(*x_scale.shape, *x_zero_point.shape); - dequantize_per_axis(@(*x).into(), x_scale, x_zero_point) - } -} - -fn dequantize_per_axis( - x: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor -) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - (*x - *x_zero_point) * *x_scale -} - -fn dequantize_element_wise(mut x: Tensor::, x_scale: i32, x_zero_point: i32) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - loop { - match x.data.pop_front() { - Option::Some(item) => { - let dequantized = dequantize(*item, x_scale, x_zero_point); - result_data.append(dequantized); - }, - Option::None(_) => { - break; - } - }; - }; - - - return TensorTrait::new(x.shape, result_data.span(), x.extra); -} - -fn dequantize(x: i8, x_scale: i32, x_zero_point: i32) -> i32 { - (x.into() - x_zero_point) * x_scale -} diff --git a/src/performance/functional/quantize_linear.cairo b/src/performance/functional/quantize_linear.cairo deleted file mode 100644 index 6bb995ec9..000000000 --- a/src/performance/functional/quantize_linear.cairo +++ /dev/null @@ -1,2 +0,0 @@ -mod quantize_linear_i32; -mod quantize_linear_fp; diff --git a/src/performance/functional/quantize_linear/quantize_linear_fp.cairo b/src/performance/functional/quantize_linear/quantize_linear_fp.cairo deleted file mode 100644 index 339155638..000000000 --- a/src/performance/functional/quantize_linear/quantize_linear_fp.cairo +++ /dev/null @@ -1 +0,0 @@ -mod fp_i8; diff --git a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8.cairo b/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8.cairo deleted file mode 100644 index 50d44d68c..000000000 --- a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod core; -mod fp8x23; -mod fp16x16; diff --git a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/core.cairo b/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/core.cairo deleted file mode 100644 index 58890ed2f..000000000 --- a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/core.cairo +++ /dev/null @@ -1,26 +0,0 @@ -use orion::numbers::fixed_point::core::{FixedType, FixedImpl}; -use orion::operators::tensor::core::{Tensor, ExtraParams}; -use orion::numbers::signed_integer::i8::i8; -use orion::performance::functional::quantize_linear::quantize_linear_fp::fp_i8::fp8x23; -use orion::performance::functional::quantize_linear::quantize_linear_fp::fp_i8::fp16x16; -use orion::numbers::signed_integer::i32::i32; - -/// Cf: PerfomanceTrait::quantize_linear docstring -fn quantize_linear( - x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor -) -> Option> { - match *x.extra { - Option::Some(extra_params) => match extra_params.fixed_point { - Option::Some(fixed_point) => match fixed_point { - FixedImpl::FP8x23(()) => Option::Some( - fp8x23::quantize_linear(x, y_scale, y_zero_point) - ), - FixedImpl::FP16x16(()) => Option::Some( - fp16x16::quantize_linear(x, y_scale, y_zero_point) - ), - }, - Option::None(_) => Option::Some(fp16x16::quantize_linear(x, y_scale, y_zero_point)), - }, - Option::None(_) => Option::Some(fp16x16::quantize_linear(x, y_scale, y_zero_point)), - } -} diff --git a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/fp16x16.cairo b/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/fp16x16.cairo deleted file mode 100644 index 85cf16238..000000000 --- a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/fp16x16.cairo +++ /dev/null @@ -1,66 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::TryInto; - -use orion::numbers::signed_integer::i8::i8; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16PartialOrd, FP16x16Div, FP16x16Add, FP16x16TryIntoI8 -}; -use orion::operators::tensor::math::arithmetic::arithmetic_fp::fp16x16::{ - saturated_add_i8, saturated_div -}; -use orion::operators::tensor::helpers::check_compatibility; -use orion::utils::{saturate}; - -/// Cf: PerfomanceTrait::quantize_linear docstring -fn quantize_linear( - x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor -) -> Tensor:: { - if (*y_scale.data).len() == 1 && (*y_zero_point.data).len() == 1 { - quantize_element_wise(*x, *y_scale.data[0], *y_zero_point.data[0]) - } else { - check_compatibility(*x.shape, *y_scale.shape); - check_compatibility(*x.shape, *y_zero_point.shape); - check_compatibility(*y_scale.shape, *y_zero_point.shape); - quantize_per_axis(x, y_scale, y_zero_point) - } -} - -fn quantize_per_axis( - x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor -) -> Tensor:: { - saturated_add_i8(@(*x / *y_scale), y_zero_point) -} - -fn quantize_element_wise( - mut x: Tensor::, y_scale: FixedType, y_zero_point: FixedType -) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - loop { - match x.data.pop_front() { - Option::Some(item) => { - let quantized = quantize(*item, y_scale, y_zero_point); - result_data.append(quantized.try_into().unwrap()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(x.shape, result_data.span(), x.extra); -} - -fn quantize(x: FixedType, y_scale: FixedType, y_zero_point: FixedType) -> FixedType { - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - ((x / y_scale) + y_zero_point) - ) -} diff --git a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/fp8x23.cairo b/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/fp8x23.cairo deleted file mode 100644 index 8995acd6a..000000000 --- a/src/performance/functional/quantize_linear/quantize_linear_fp/fp_i8/fp8x23.cairo +++ /dev/null @@ -1,67 +0,0 @@ -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::TryInto; - -use orion::numbers::signed_integer::i8::i8; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23PartialOrd, FP8x23Div, FP8x23Add, FP8x23TryIntoI8 -}; -use orion::operators::tensor::math::arithmetic::arithmetic_fp::fp8x23::{ - saturated_add_i8, saturated_div -}; -use orion::operators::tensor::helpers::check_compatibility; -use orion::utils::{saturate}; - -/// Cf: PerfomanceTrait::quantize_linear docstring -fn quantize_linear( - x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor -) -> Tensor:: { - if (*y_scale.data).len() == 1 && (*y_zero_point.data).len() == 1 { - quantize_element_wise(*x, *y_scale.data[0], *y_zero_point.data[0]) - } else { - check_compatibility(*x.shape, *y_scale.shape); - check_compatibility(*x.shape, *y_zero_point.shape); - check_compatibility(*y_scale.shape, *y_zero_point.shape); - quantize_per_axis(x, y_scale, y_zero_point) - } -} - -fn quantize_per_axis( - x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor -) -> Tensor:: { - saturated_add_i8(@(*x / *y_scale), y_zero_point) -} - -fn quantize_element_wise( - mut x: Tensor::, y_scale: FixedType, y_zero_point: FixedType -) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - loop { - match x.data.pop_front() { - Option::Some(item) => { - let quantized = quantize(*item, y_scale, y_zero_point); - result_data.append(quantized.try_into().unwrap()); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(x.shape, result_data.span(), x.extra); -} - - -fn quantize(x: FixedType, y_scale: FixedType, y_zero_point: FixedType) -> FixedType { - saturate( - FixedTrait::new_unscaled(128, true), - FixedTrait::new_unscaled(127, false), - ((x / y_scale) + y_zero_point) - ) -} diff --git a/src/performance/functional/quantize_linear/quantize_linear_i32.cairo b/src/performance/functional/quantize_linear/quantize_linear_i32.cairo deleted file mode 100644 index f98be60a2..000000000 --- a/src/performance/functional/quantize_linear/quantize_linear_i32.cairo +++ /dev/null @@ -1,59 +0,0 @@ -use core::debug::PrintTrait; -use array::ArrayTrait; -use array::SpanTrait; -use option::OptionTrait; -use traits::TryInto; - -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32, i8::i8}; -use orion::operators::tensor::core::{Tensor, TensorTrait}; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorDiv, }; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorDiv, }; -use orion::operators::tensor::math::arithmetic::arithmetic_i32::{saturated_add_i8}; -use orion::operators::tensor::helpers::check_compatibility; -use orion::utils::saturate; - -/// Cf: PerfomanceTrait::quantize_linear docstring -fn quantize_linear( - x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor -) -> Tensor:: { - if (*y_scale.data).len() == 1 && (*y_zero_point.data).len() == 1 { - quantize_element_wise(*x, *y_scale.data[0], *y_zero_point.data[0]) - } else { - check_compatibility(*x.shape, *y_scale.shape); - check_compatibility(*x.shape, *y_zero_point.shape); - check_compatibility(*y_scale.shape, *y_zero_point.shape); - quantize_per_axis(x, y_scale, y_zero_point) - } -} - -fn quantize_per_axis( - x: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor -) -> Tensor:: { - saturated_add_i8(@(*x / *y_scale), y_zero_point) -} - -fn quantize_element_wise(mut x: Tensor::, y_scale: i32, y_zero_point: i32) -> Tensor:: { - let mut result_data = ArrayTrait::::new(); - - loop { - match x.data.pop_front() { - Option::Some(item) => { - let quantized = quantize(*item, y_scale, y_zero_point); - result_data.append(quantized); - }, - Option::None(_) => { - break; - } - }; - }; - - return TensorTrait::new(x.shape, result_data.span(), x.extra); -} - -fn quantize(x: i32, y_scale: i32, y_zero_point: i32) -> i8 { - saturate( - IntegerTrait::new(128, true), IntegerTrait::new(127, false), ((x / y_scale) + y_zero_point) - ) - .try_into() - .unwrap() -} diff --git a/src/performance/implementations.cairo b/src/performance/implementations.cairo deleted file mode 100644 index aa3f889d8..000000000 --- a/src/performance/implementations.cairo +++ /dev/null @@ -1,2 +0,0 @@ -mod impl_performance_i32; -mod impl_performance_fp; diff --git a/src/performance/implementations/impl_performance_fp.cairo b/src/performance/implementations/impl_performance_fp.cairo deleted file mode 100644 index 7b653d4f4..000000000 --- a/src/performance/implementations/impl_performance_fp.cairo +++ /dev/null @@ -1,24 +0,0 @@ -use array::ArrayTrait; -use core::option::OptionTrait; - -use orion::numbers::signed_integer::i8::i8; -use orion::numbers::fixed_point::core::FixedType; -use orion::operators::tensor::core::Tensor; -use orion::performance::core::PerfomanceTrait; -use orion::performance::functional::quantize_linear::quantize_linear_fp::fp_i8::core::quantize_linear; -use orion::performance::functional::dequantize_linear::dequantize_linear_fp::core::dequantize_linear; - - -impl Performance_fp_i8 of PerfomanceTrait { - fn quantize_linear( - self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor - ) -> Tensor { - quantize_linear(self, y_scale, y_zero_point).unwrap() - } - - fn dequantize_linear( - self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor - ) -> Tensor { - dequantize_linear(self, x_scale, x_zero_point).unwrap() - } -} diff --git a/src/performance/implementations/impl_performance_i32.cairo b/src/performance/implementations/impl_performance_i32.cairo deleted file mode 100644 index a04f56a07..000000000 --- a/src/performance/implementations/impl_performance_i32.cairo +++ /dev/null @@ -1,22 +0,0 @@ -use orion::numbers::signed_integer::{i32::i32, i8::i8}; -use orion::numbers::fixed_point::core::FixedType; - -use orion::operators::tensor::core::Tensor; -use orion::performance::core::PerfomanceTrait; -use orion::performance::functional::quantize_linear::quantize_linear_i32::quantize_linear; -use orion::performance::functional::dequantize_linear::dequantize_linear_i32::dequantize_linear; - - -impl Performance_i32_i8 of PerfomanceTrait { - fn quantize_linear( - self: @Tensor, y_scale: @Tensor, y_zero_point: @Tensor - ) -> Tensor { - quantize_linear(self, y_scale, y_zero_point) - } - - fn dequantize_linear( - self: @Tensor, x_scale: @Tensor, x_zero_point: @Tensor - ) -> Tensor { - dequantize_linear(self, x_scale, x_zero_point) - } -} diff --git a/src/tests.cairo b/src/tests.cairo index 8463adb0a..ca676bffd 100644 --- a/src/tests.cairo +++ b/src/tests.cairo @@ -3,3 +3,4 @@ mod performance; mod tensor_core; mod nodes; mod helpers; + diff --git a/src/tests/helpers/tensor.cairo b/src/tests/helpers/tensor.cairo index c1cfb1deb..a87d2ad1b 100644 --- a/src/tests/helpers/tensor.cairo +++ b/src/tests/helpers/tensor.cairo @@ -1,3 +1,4 @@ mod fixed_point; mod i32; +mod i8; mod u32; diff --git a/src/tests/helpers/tensor/fixed_point/fp16x16.cairo b/src/tests/helpers/tensor/fixed_point/fp16x16.cairo index 9b52b162f..8ec365032 100644 --- a/src/tests/helpers/tensor/fixed_point/fp16x16.cairo +++ b/src/tests/helpers/tensor/fixed_point/fp16x16.cairo @@ -1,12 +1,12 @@ use array::ArrayTrait; use array::SpanTrait; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; +use orion::numbers::fixed_point::core::{FixedTrait}; +use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16; +use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; +use orion::operators::tensor::{TensorTrait, Tensor}; // 1D -fn fp_tensor_1x3_helper() -> Tensor { +fn fp_tensor_1x3_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); @@ -14,14 +14,14 @@ fn fp_tensor_1x3_helper() -> Tensor { data.append(FixedTrait::new_unscaled(0, false)); data.append(FixedTrait::new_unscaled(1, false)); data.append(FixedTrait::new_unscaled(2, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_1x3_neg_helper() -> Tensor { +fn fp_tensor_1x3_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); @@ -29,16 +29,16 @@ fn fp_tensor_1x3_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(0, false)); data.append(FixedTrait::new_unscaled(1, true)); data.append(FixedTrait::new_unscaled(2, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } // 2D -fn fp_tensor_2x2_helper() -> Tensor { +fn fp_tensor_2x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -48,14 +48,14 @@ fn fp_tensor_2x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, false)); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(3, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x2_neg_helper() -> Tensor { +fn fp_tensor_2x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -65,14 +65,14 @@ fn fp_tensor_2x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, true)); data.append(FixedTrait::new_unscaled(2, true)); data.append(FixedTrait::new_unscaled(3, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x3_helper() -> Tensor { +fn fp_tensor_3x3_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(3); @@ -88,14 +88,14 @@ fn fp_tensor_3x3_helper() -> Tensor { data.append(FixedTrait::new_unscaled(7, false)); data.append(FixedTrait::new_unscaled(8, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x3_neg_helper() -> Tensor { +fn fp_tensor_3x3_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(3); @@ -111,14 +111,14 @@ fn fp_tensor_3x3_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(7, true)); data.append(FixedTrait::new_unscaled(8, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2_helper() -> Tensor { +fn fp_tensor_3x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -131,14 +131,14 @@ fn fp_tensor_3x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, false)); data.append(FixedTrait::new_unscaled(5, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2_neg_helper() -> Tensor { +fn fp_tensor_3x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -151,14 +151,14 @@ fn fp_tensor_3x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, true)); data.append(FixedTrait::new_unscaled(5, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x1_helper() -> Tensor { +fn fp_tensor_3x1_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(1); @@ -168,14 +168,14 @@ fn fp_tensor_3x1_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, false)); data.append(FixedTrait::new_unscaled(2, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x1_neg_helper() -> Tensor { +fn fp_tensor_3x1_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(1); @@ -185,14 +185,14 @@ fn fp_tensor_3x1_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, true)); data.append(FixedTrait::new_unscaled(2, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x3_helper() -> Tensor { +fn fp_tensor_2x3_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(3); @@ -205,14 +205,14 @@ fn fp_tensor_2x3_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, false)); data.append(FixedTrait::new_unscaled(5, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x3_neg_helper() -> Tensor { +fn fp_tensor_2x3_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(3); @@ -225,16 +225,16 @@ fn fp_tensor_2x3_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, true)); data.append(FixedTrait::new_unscaled(5, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } // 3D -fn fp_tensor_2x2x2_helper() -> Tensor { +fn fp_tensor_2x2x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -250,14 +250,14 @@ fn fp_tensor_2x2x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(6, false)); data.append(FixedTrait::new_unscaled(7, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x2x2_neg_helper() -> Tensor { +fn fp_tensor_2x2x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -273,14 +273,14 @@ fn fp_tensor_2x2x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(6, true)); data.append(FixedTrait::new_unscaled(7, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2x2_helper() -> Tensor { +fn fp_tensor_3x2x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -300,14 +300,14 @@ fn fp_tensor_3x2x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(10, false)); data.append(FixedTrait::new_unscaled(11, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2x2_neg_helper() -> Tensor { +fn fp_tensor_3x2x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -327,9 +327,93 @@ fn fp_tensor_3x2x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(10, true)); data.append(FixedTrait::new_unscaled(11, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); + + return tensor; +} + +fn fp_tensor_3x3x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(FixedTrait::new_unscaled(0, false)); + data.append(FixedTrait::new_unscaled(1, false)); + data.append(FixedTrait::new_unscaled(2, false)); + data.append(FixedTrait::new_unscaled(3, false)); + data.append(FixedTrait::new_unscaled(4, false)); + data.append(FixedTrait::new_unscaled(5, false)); + data.append(FixedTrait::new_unscaled(6, false)); + data.append(FixedTrait::new_unscaled(7, false)); + data.append(FixedTrait::new_unscaled(8, false)); + data.append(FixedTrait::new_unscaled(9, false)); + data.append(FixedTrait::new_unscaled(10, false)); + data.append(FixedTrait::new_unscaled(11, false)); + data.append(FixedTrait::new_unscaled(12, false)); + data.append(FixedTrait::new_unscaled(13, false)); + data.append(FixedTrait::new_unscaled(14, false)); + data.append(FixedTrait::new_unscaled(15, false)); + data.append(FixedTrait::new_unscaled(16, false)); + data.append(FixedTrait::new_unscaled(17, false)); + data.append(FixedTrait::new_unscaled(18, false)); + data.append(FixedTrait::new_unscaled(19, false)); + data.append(FixedTrait::new_unscaled(20, false)); + data.append(FixedTrait::new_unscaled(21, false)); + data.append(FixedTrait::new_unscaled(22, false)); + data.append(FixedTrait::new_unscaled(23, false)); + data.append(FixedTrait::new_unscaled(24, false)); + data.append(FixedTrait::new_unscaled(25, false)); + data.append(FixedTrait::new_unscaled(26, false)); + + + + let tensor = TensorTrait::::new(sizes.span(), data.span()); + + return tensor; +} + +fn fp_tensor_3x3x3_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(FixedTrait::new_unscaled(0, false)); + data.append(FixedTrait::new_unscaled(1, true)); + data.append(FixedTrait::new_unscaled(2, true)); + data.append(FixedTrait::new_unscaled(3, true)); + data.append(FixedTrait::new_unscaled(4, true)); + data.append(FixedTrait::new_unscaled(5, true)); + data.append(FixedTrait::new_unscaled(6, true)); + data.append(FixedTrait::new_unscaled(7, true)); + data.append(FixedTrait::new_unscaled(8, true)); + data.append(FixedTrait::new_unscaled(9, true)); + data.append(FixedTrait::new_unscaled(10, true)); + data.append(FixedTrait::new_unscaled(11, true)); + data.append(FixedTrait::new_unscaled(12, true)); + data.append(FixedTrait::new_unscaled(13, true)); + data.append(FixedTrait::new_unscaled(14, true)); + data.append(FixedTrait::new_unscaled(15, true)); + data.append(FixedTrait::new_unscaled(16, true)); + data.append(FixedTrait::new_unscaled(17, true)); + data.append(FixedTrait::new_unscaled(18, true)); + data.append(FixedTrait::new_unscaled(19, true)); + data.append(FixedTrait::new_unscaled(20, true)); + data.append(FixedTrait::new_unscaled(21, true)); + data.append(FixedTrait::new_unscaled(22, true)); + data.append(FixedTrait::new_unscaled(23, true)); + data.append(FixedTrait::new_unscaled(24, true)); + data.append(FixedTrait::new_unscaled(25, true)); + data.append(FixedTrait::new_unscaled(26, true)); + + + + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } diff --git a/src/tests/helpers/tensor/fixed_point/fp8x23.cairo b/src/tests/helpers/tensor/fixed_point/fp8x23.cairo index db4440f6b..57f4475b7 100644 --- a/src/tests/helpers/tensor/fixed_point/fp8x23.cairo +++ b/src/tests/helpers/tensor/fixed_point/fp8x23.cairo @@ -1,12 +1,12 @@ use array::ArrayTrait; use array::SpanTrait; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; +use orion::numbers::fixed_point::core::{FixedTrait}; +use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23; +use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; +use orion::operators::tensor::{TensorTrait, Tensor}; // 1D -fn fp_tensor_1x3_helper() -> Tensor { +fn fp_tensor_1x3_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); @@ -14,14 +14,14 @@ fn fp_tensor_1x3_helper() -> Tensor { data.append(FixedTrait::new_unscaled(0, false)); data.append(FixedTrait::new_unscaled(1, false)); data.append(FixedTrait::new_unscaled(2, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_1x3_neg_helper() -> Tensor { +fn fp_tensor_1x3_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); @@ -29,16 +29,16 @@ fn fp_tensor_1x3_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(0, false)); data.append(FixedTrait::new_unscaled(1, true)); data.append(FixedTrait::new_unscaled(2, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } // 2D -fn fp_tensor_2x2_helper() -> Tensor { +fn fp_tensor_2x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -48,14 +48,14 @@ fn fp_tensor_2x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, false)); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(3, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x2_neg_helper() -> Tensor { +fn fp_tensor_2x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -65,14 +65,14 @@ fn fp_tensor_2x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, true)); data.append(FixedTrait::new_unscaled(2, true)); data.append(FixedTrait::new_unscaled(3, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x3_helper() -> Tensor { +fn fp_tensor_3x3_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(3); @@ -88,14 +88,14 @@ fn fp_tensor_3x3_helper() -> Tensor { data.append(FixedTrait::new_unscaled(7, false)); data.append(FixedTrait::new_unscaled(8, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x3_neg_helper() -> Tensor { +fn fp_tensor_3x3_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(3); @@ -111,14 +111,14 @@ fn fp_tensor_3x3_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(7, true)); data.append(FixedTrait::new_unscaled(8, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2_helper() -> Tensor { +fn fp_tensor_3x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -131,14 +131,14 @@ fn fp_tensor_3x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, false)); data.append(FixedTrait::new_unscaled(5, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2_neg_helper() -> Tensor { +fn fp_tensor_3x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -151,14 +151,14 @@ fn fp_tensor_3x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, true)); data.append(FixedTrait::new_unscaled(5, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x1_helper() -> Tensor { +fn fp_tensor_3x1_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(1); @@ -168,14 +168,14 @@ fn fp_tensor_3x1_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, false)); data.append(FixedTrait::new_unscaled(2, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x1_neg_helper() -> Tensor { +fn fp_tensor_3x1_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(1); @@ -185,14 +185,14 @@ fn fp_tensor_3x1_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(1, true)); data.append(FixedTrait::new_unscaled(2, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x3_helper() -> Tensor { +fn fp_tensor_2x3_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(3); @@ -205,14 +205,14 @@ fn fp_tensor_2x3_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, false)); data.append(FixedTrait::new_unscaled(5, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x3_neg_helper() -> Tensor { +fn fp_tensor_2x3_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(3); @@ -225,16 +225,16 @@ fn fp_tensor_2x3_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(4, true)); data.append(FixedTrait::new_unscaled(5, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } // 3D -fn fp_tensor_2x2x2_helper() -> Tensor { +fn fp_tensor_2x2x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -250,14 +250,14 @@ fn fp_tensor_2x2x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(6, false)); data.append(FixedTrait::new_unscaled(7, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_2x2x2_neg_helper() -> Tensor { +fn fp_tensor_2x2x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -273,14 +273,14 @@ fn fp_tensor_2x2x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(6, true)); data.append(FixedTrait::new_unscaled(7, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2x2_helper() -> Tensor { +fn fp_tensor_3x2x2_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -300,14 +300,14 @@ fn fp_tensor_3x2x2_helper() -> Tensor { data.append(FixedTrait::new_unscaled(10, false)); data.append(FixedTrait::new_unscaled(11, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } -fn fp_tensor_3x2x2_neg_helper() -> Tensor { +fn fp_tensor_3x2x2_neg_helper() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -327,9 +327,94 @@ fn fp_tensor_3x2x2_neg_helper() -> Tensor { data.append(FixedTrait::new_unscaled(10, true)); data.append(FixedTrait::new_unscaled(11, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; + - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + let tensor = TensorTrait::::new(sizes.span(), data.span()); + + return tensor; +} + + +fn fp_tensor_3x3x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(FixedTrait::new_unscaled(0, false)); + data.append(FixedTrait::new_unscaled(1, false)); + data.append(FixedTrait::new_unscaled(2, false)); + data.append(FixedTrait::new_unscaled(3, false)); + data.append(FixedTrait::new_unscaled(4, false)); + data.append(FixedTrait::new_unscaled(5, false)); + data.append(FixedTrait::new_unscaled(6, false)); + data.append(FixedTrait::new_unscaled(7, false)); + data.append(FixedTrait::new_unscaled(8, false)); + data.append(FixedTrait::new_unscaled(9, false)); + data.append(FixedTrait::new_unscaled(10, false)); + data.append(FixedTrait::new_unscaled(11, false)); + data.append(FixedTrait::new_unscaled(12, false)); + data.append(FixedTrait::new_unscaled(13, false)); + data.append(FixedTrait::new_unscaled(14, false)); + data.append(FixedTrait::new_unscaled(15, false)); + data.append(FixedTrait::new_unscaled(16, false)); + data.append(FixedTrait::new_unscaled(17, false)); + data.append(FixedTrait::new_unscaled(18, false)); + data.append(FixedTrait::new_unscaled(19, false)); + data.append(FixedTrait::new_unscaled(20, false)); + data.append(FixedTrait::new_unscaled(21, false)); + data.append(FixedTrait::new_unscaled(22, false)); + data.append(FixedTrait::new_unscaled(23, false)); + data.append(FixedTrait::new_unscaled(24, false)); + data.append(FixedTrait::new_unscaled(25, false)); + data.append(FixedTrait::new_unscaled(26, false)); + + + + let tensor = TensorTrait::::new(sizes.span(), data.span()); + + return tensor; +} + +fn fp_tensor_3x3x3_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(FixedTrait::new_unscaled(0, false)); + data.append(FixedTrait::new_unscaled(1, true)); + data.append(FixedTrait::new_unscaled(2, true)); + data.append(FixedTrait::new_unscaled(3, true)); + data.append(FixedTrait::new_unscaled(4, true)); + data.append(FixedTrait::new_unscaled(5, true)); + data.append(FixedTrait::new_unscaled(6, true)); + data.append(FixedTrait::new_unscaled(7, true)); + data.append(FixedTrait::new_unscaled(8, true)); + data.append(FixedTrait::new_unscaled(9, true)); + data.append(FixedTrait::new_unscaled(10, true)); + data.append(FixedTrait::new_unscaled(11, true)); + data.append(FixedTrait::new_unscaled(12, true)); + data.append(FixedTrait::new_unscaled(13, true)); + data.append(FixedTrait::new_unscaled(14, true)); + data.append(FixedTrait::new_unscaled(15, true)); + data.append(FixedTrait::new_unscaled(16, true)); + data.append(FixedTrait::new_unscaled(17, true)); + data.append(FixedTrait::new_unscaled(18, true)); + data.append(FixedTrait::new_unscaled(19, true)); + data.append(FixedTrait::new_unscaled(20, true)); + data.append(FixedTrait::new_unscaled(21, true)); + data.append(FixedTrait::new_unscaled(22, true)); + data.append(FixedTrait::new_unscaled(23, true)); + data.append(FixedTrait::new_unscaled(24, true)); + data.append(FixedTrait::new_unscaled(25, true)); + data.append(FixedTrait::new_unscaled(26, true)); + + + + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } diff --git a/src/tests/helpers/tensor/i32.cairo b/src/tests/helpers/tensor/i32.cairo index 4f29cbf4f..5de4889ff 100644 --- a/src/tests/helpers/tensor/i32.cairo +++ b/src/tests/helpers/tensor/i32.cairo @@ -3,8 +3,8 @@ use array::SpanTrait; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::{TensorTrait, Tensor}; // 1D fn i32_tensor_1x3_helper() -> Tensor { @@ -15,9 +15,9 @@ fn i32_tensor_1x3_helper() -> Tensor { data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -30,9 +30,9 @@ fn i32_tensor_1x3_neg_helper() -> Tensor { data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -49,9 +49,9 @@ fn i32_tensor_2x2_helper() -> Tensor { data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 3, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -66,9 +66,9 @@ fn i32_tensor_2x2_neg_helper() -> Tensor { data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -89,9 +89,9 @@ fn i32_tensor_3x3_helper() -> Tensor { data.append(i32 { mag: 7, sign: false }); data.append(i32 { mag: 8, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -112,9 +112,9 @@ fn i32_tensor_3x3_neg_helper() -> Tensor { data.append(i32 { mag: 7_u32, sign: true }); data.append(i32 { mag: 8_u32, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -132,9 +132,9 @@ fn i32_tensor_3x2_helper() -> Tensor { data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -152,9 +152,9 @@ fn i32_tensor_3x2_neg_helper() -> Tensor { data.append(i32 { mag: 4, sign: true }); data.append(i32 { mag: 5, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -169,9 +169,9 @@ fn i32_tensor_3x1_helper() -> Tensor { data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -186,9 +186,9 @@ fn i32_tensor_3x1_neg_helper() -> Tensor { data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -206,9 +206,9 @@ fn i32_tensor_2x3_helper() -> Tensor { data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -226,9 +226,9 @@ fn i32_tensor_2x3_neg_helper() -> Tensor { data.append(i32 { mag: 4, sign: true }); data.append(i32 { mag: 5, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -251,9 +251,9 @@ fn i32_tensor_2x2x2_helper() -> Tensor { data.append(i32 { mag: 6, sign: false }); data.append(i32 { mag: 7, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -274,9 +274,9 @@ fn i32_tensor_2x2x2_neg_helper() -> Tensor { data.append(i32 { mag: 6_u32, sign: true }); data.append(i32 { mag: 7_u32, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -301,9 +301,9 @@ fn i32_tensor_3x2x2_helper() -> Tensor { data.append(i32 { mag: 10, sign: false }); data.append(i32 { mag: 11, sign: false }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -328,9 +328,93 @@ fn i32_tensor_3x2x2_neg_helper() -> Tensor { data.append(i32 { mag: 10, sign: true }); data.append(i32 { mag: 11, sign: true }); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); + + return tensor; +} + +fn i32_tensor_3x3x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + 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: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + + + + let tensor = TensorTrait::::new(sizes.span(), data.span()); + + return tensor; +} + +fn i32_tensor_3x3x3_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 6, sign: true }); + data.append(i32 { mag: 7, sign: true }); + data.append(i32 { mag: 8, sign: true }); + data.append(i32 { mag: 9, sign: true }); + data.append(i32 { mag: 10, sign: true }); + data.append(i32 { mag: 11, sign: true }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 13, sign: true }); + data.append(i32 { mag: 14, sign: true }); + data.append(i32 { mag: 15, sign: true }); + data.append(i32 { mag: 16, sign: true }); + data.append(i32 { mag: 17, sign: true }); + data.append(i32 { mag: 18, sign: true }); + data.append(i32 { mag: 19, sign: true }); + data.append(i32 { mag: 20, sign: true }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 22, sign: true }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 24, sign: true }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 26, sign: true }); + + + + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } diff --git a/src/tests/helpers/tensor/i8.cairo b/src/tests/helpers/tensor/i8.cairo new file mode 100644 index 000000000..27274dcc4 --- /dev/null +++ b/src/tests/helpers/tensor/i8.cairo @@ -0,0 +1,385 @@ +use array::ArrayTrait; +use array::SpanTrait; + + +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; + + +// 1D +fn i8_tensor_1x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + return tensor; +} + +fn i8_tensor_1x3_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + return tensor; +} + +// 2D + +fn i8_tensor_2x2_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(2); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_2x2_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(2); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 8, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x3_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 8, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x2_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 5, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x2_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 5, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x1_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(1); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x1_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(1); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_2x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(2); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 5, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_2x3_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(2); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 5, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +// 3D + +fn i8_tensor_2x2x2_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(2); + sizes.append(2); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 7, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_2x2x2_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(2); + sizes.append(2); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 7, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x2x2_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(2); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 8, sign: false }); + data.append(i8 { mag: 9, sign: false }); + data.append(i8 { mag: 10, sign: false }); + data.append(i8 { mag: 11, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x2x2_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(2); + sizes.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 8, sign: true }); + data.append(i8 { mag: 9, sign: true }); + data.append(i8 { mag: 10, sign: true }); + data.append(i8 { mag: 11, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x3x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 8, sign: false }); + data.append(i8 { mag: 9, sign: false }); + data.append(i8 { mag: 10, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 12, sign: false }); + data.append(i8 { mag: 13, sign: false }); + data.append(i8 { mag: 14, sign: false }); + data.append(i8 { mag: 15, sign: false }); + data.append(i8 { mag: 16, sign: false }); + data.append(i8 { mag: 17, sign: false }); + data.append(i8 { mag: 18, sign: false }); + data.append(i8 { mag: 19, sign: false }); + data.append(i8 { mag: 20, sign: false }); + data.append(i8 { mag: 21, sign: false }); + data.append(i8 { mag: 22, sign: false }); + data.append(i8 { mag: 23, sign: false }); + data.append(i8 { mag: 24, sign: false }); + data.append(i8 { mag: 25, sign: false }); + data.append(i8 { mag: 26, sign: false }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} + +fn i8_tensor_3x3x3_neg_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 8, sign: true }); + data.append(i8 { mag: 9, sign: true }); + data.append(i8 { mag: 10, sign: true }); + data.append(i8 { mag: 11, sign: true }); + data.append(i8 { mag: 12, sign: true }); + data.append(i8 { mag: 13, sign: true }); + data.append(i8 { mag: 14, sign: true }); + data.append(i8 { mag: 15, sign: true }); + data.append(i8 { mag: 16, sign: true }); + data.append(i8 { mag: 17, sign: true }); + data.append(i8 { mag: 18, sign: true }); + data.append(i8 { mag: 19, sign: true }); + data.append(i8 { mag: 20, sign: true }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 22, sign: true }); + data.append(i8 { mag: 23, sign: true }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 25, sign: true }); + data.append(i8 { mag: 26, sign: true }); + + let tensor = TensorTrait::new(sizes.span(), data.span()); + + return tensor; +} diff --git a/src/tests/helpers/tensor/u32.cairo b/src/tests/helpers/tensor/u32.cairo index dcde6470e..4395faffc 100644 --- a/src/tests/helpers/tensor/u32.cairo +++ b/src/tests/helpers/tensor/u32.cairo @@ -1,7 +1,7 @@ use array::ArrayTrait; use array::SpanTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::{TensorTrait, Tensor}; // 1D fn u32_tensor_1x3_helper() -> Tensor { @@ -12,9 +12,9 @@ fn u32_tensor_1x3_helper() -> Tensor { data.append(0); data.append(1); data.append(2); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -31,9 +31,9 @@ fn u32_tensor_2x2_helper() -> Tensor { data.append(1); data.append(2); data.append(3); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -54,9 +54,9 @@ fn u32_tensor_3x3_helper() -> Tensor { data.append(7); data.append(8); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -74,9 +74,9 @@ fn u32_tensor_3x2_helper() -> Tensor { data.append(4); data.append(5); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -91,9 +91,9 @@ fn u32_tensor_3x1_helper() -> Tensor { data.append(1); data.append(2); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -111,9 +111,9 @@ fn u32_tensor_2x3_helper() -> Tensor { data.append(4); data.append(5); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -136,9 +136,9 @@ fn u32_tensor_2x2x2_helper() -> Tensor { data.append(6); data.append(7); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } @@ -163,9 +163,51 @@ fn u32_tensor_3x2x2_helper() -> Tensor { data.append(10); data.append(11); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); + + return tensor; +} + +fn u32_tensor_3x3x3_helper() -> Tensor { + let mut sizes = ArrayTrait::new(); + sizes.append(3); + sizes.append(3); + sizes.append(3); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + + + + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } diff --git a/src/tests/nodes.cairo b/src/tests/nodes.cairo index e819cfd40..0c8f6f114 100644 --- a/src/tests/nodes.cairo +++ b/src/tests/nodes.cairo @@ -1,219 +1,198 @@ -mod abs_fp16x16; -mod abs_fp8x23; -mod abs_i32; -mod abs_i8; -mod acos_fp8x23; -mod acos_fp16x16; -mod argmax_fp16x16_1D_default; -mod argmax_fp16x16_1D_keepdims_false; -mod argmax_fp16x16_1D_last_index; -mod argmax_fp16x16_2D_default; -mod argmax_fp16x16_2D_keepdims_false; -mod argmax_fp16x16_2D_last_index; -mod argmax_fp16x16_3D_default; -mod argmax_fp16x16_3D_keepdims_false; -mod argmax_fp16x16_3D_last_index; -mod argmax_fp8x23_1D_default; -mod argmax_fp8x23_1D_keepdims_false; -mod argmax_fp8x23_1D_last_index; -mod argmax_fp8x23_2D_default; -mod argmax_fp8x23_2D_keepdims_false; -mod argmax_fp8x23_2D_last_index; -mod argmax_fp8x23_3D_default; -mod argmax_fp8x23_3D_keepdims_false; -mod argmax_fp8x23_3D_last_index; -mod argmax_i32_1D_default; -mod argmax_i32_1D_keepdims_false; -mod argmax_i32_1D_last_index; -mod argmax_i32_2D_default; -mod argmax_i32_2D_keepdims_false; -mod argmax_i32_2D_last_index; -mod argmax_i32_3D_default; -mod argmax_i32_3D_keepdims_false; -mod argmax_i32_3D_last_index; -mod argmax_i8_1D_default; -mod argmax_i8_1D_keepdims_false; -mod argmax_i8_1D_last_index; -mod argmax_i8_2D_default; -mod argmax_i8_2D_keepdims_false; -mod argmax_i8_2D_last_index; -mod argmax_i8_3D_default; -mod argmax_i8_3D_keepdims_false; -mod argmax_i8_3D_last_index; -mod argmax_u32_1D_default; -mod argmax_u32_1D_keepdims_false; -mod argmax_u32_1D_last_index; -mod argmax_u32_2D_default; -mod argmax_u32_2D_keepdims_false; -mod argmax_u32_2D_last_index; -mod argmax_u32_3D_default; -mod argmax_u32_3D_keepdims_false; -mod argmax_u32_3D_last_index; -mod argmin_fp16x16_1D_default; -mod argmin_fp16x16_1D_keepdims_false; -mod argmin_fp16x16_1D_last_index; -mod argmin_fp16x16_2D_default; -mod argmin_fp16x16_2D_keepdims_false; -mod argmin_fp16x16_2D_last_index; -mod argmin_fp16x16_3D_default; -mod argmin_fp16x16_3D_keepdims_false; -mod argmin_fp16x16_3D_last_index; -mod argmin_fp8x23_1D_default; -mod argmin_fp8x23_1D_keepdims_false; -mod argmin_fp8x23_1D_last_index; -mod argmin_fp8x23_2D_default; -mod argmin_fp8x23_2D_keepdims_false; -mod argmin_fp8x23_2D_last_index; -mod argmin_fp8x23_3D_default; -mod argmin_fp8x23_3D_keepdims_false; -mod argmin_fp8x23_3D_last_index; -mod argmin_i32_1D_default; -mod argmin_i32_1D_keepdims_false; -mod argmin_i32_1D_last_index; -mod argmin_i32_2D_default; -mod argmin_i32_2D_keepdims_false; -mod argmin_i32_2D_last_index; -mod argmin_i32_3D_default; -mod argmin_i32_3D_keepdims_false; -mod argmin_i32_3D_last_index; -mod argmin_i8_1D_default; -mod argmin_i8_1D_keepdims_false; -mod argmin_i8_1D_last_index; -mod argmin_i8_2D_default; -mod argmin_i8_2D_keepdims_false; -mod argmin_i8_2D_last_index; -mod argmin_i8_3D_default; -mod argmin_i8_3D_keepdims_false; -mod argmin_i8_3D_last_index; -mod argmin_u32_1D_default; -mod argmin_u32_1D_keepdims_false; -mod argmin_u32_1D_last_index; -mod argmin_u32_2D_default; -mod argmin_u32_2D_keepdims_false; -mod argmin_u32_2D_last_index; -mod argmin_u32_3D_default; -mod argmin_u32_3D_keepdims_false; -mod argmin_u32_3D_last_index; -mod transpose_fp16x16_2d; -mod transpose_fp16x16_3d; -mod transpose_fp8x23_2d; -mod transpose_fp8x23_3d; -mod transpose_i32_2d; -mod transpose_i32_3d; -mod transpose_i8_2d; -mod transpose_i8_3d; -mod transpose_u32_2d; -mod transpose_u32_3d; -mod asin_fp16x16; -mod asin_fp8x23; -mod atan_fp16x16; -mod atan_fp8x23; -mod atan_i32_fp8x23; -mod atan_i32_fp16x16; -mod atan_i8_fp8x23; -mod atan_i8_fp16x16; -mod atan_u32_fp8x23; -mod atan_u32_fp16x16; -mod ceil_fp16x16; -mod ceil_fp8x23; -mod cos_fp16x16; -mod cos_fp8x23; -mod cos_i32_fp8x23; -mod cos_i32_fp16x16; -mod cos_i8_fp8x23; -mod cos_i8_fp16x16; -mod cos_u32_fp8x23; -mod cos_u32_fp16x16; -mod cumsum_fp16x16_1d_default; -mod cumsum_fp16x16_1d_exclusive; -mod cumsum_fp16x16_1d_reverse; -mod cumsum_fp16x16_1d_reverse_exclusive; -mod cumsum_fp16x16_2d_axis_0; -mod cumsum_fp16x16_2d_axis_1; -mod cumsum_fp8x23_1d_default; -mod cumsum_fp8x23_1d_exclusive; -mod cumsum_fp8x23_1d_reverse; -mod cumsum_fp8x23_1d_reverse_exclusive; -mod cumsum_fp8x23_2d_axis_0; -mod cumsum_fp8x23_2d_axis_1; -mod cumsum_i32_1d_default; -mod cumsum_i32_1d_exclusive; -mod cumsum_i32_1d_reverse; -mod cumsum_i32_1d_reverse_exclusive; -mod cumsum_i32_2d_axis_0; -mod cumsum_i32_2d_axis_1; -mod cumsum_i8_1d_default; -mod cumsum_i8_1d_exclusive; -mod cumsum_i8_1d_reverse; -mod cumsum_i8_1d_reverse_exclusive; -mod cumsum_i8_2d_axis_0; -mod cumsum_i8_2d_axis_1; -mod cumsum_u32_1d_default; -mod cumsum_u32_1d_exclusive; -mod cumsum_u32_1d_reverse; -mod cumsum_u32_1d_reverse_exclusive; -mod cumsum_u32_2d_axis_0; -mod cumsum_u32_2d_axis_1; -mod cosh_fp16x16; -mod cosh_fp8x23; -mod cosh_i32_fp8x23; -mod cosh_i32_fp16x16; -mod cosh_i8_fp8x23; -mod cosh_i8_fp16x16; -mod cosh_u32_fp8x23; -mod cosh_u32_fp16x16; -mod sinh_fp16x16; -mod sinh_fp8x23; -mod sinh_i32_fp8x23; -mod sinh_i32_fp16x16; -mod sinh_i8_fp8x23; -mod sinh_i8_fp16x16; -mod sinh_u32_fp8x23; -mod sinh_u32_fp16x16; -mod tanh_fp16x16; -mod tanh_fp8x23; -mod tanh_i32_fp8x23; -mod tanh_i32_fp16x16; -mod tanh_i8_fp8x23; -mod tanh_i8_fp16x16; -mod tanh_u32_fp8x23; -mod tanh_u32_fp16x16; -mod log_fp16x16; -mod log_fp8x23; -mod log_i32_fp8x23; -mod log_i32_fp16x16; -mod log_i8_fp8x23; -mod log_i8_fp16x16; -mod log_u32_fp8x23; -mod log_u32_fp16x16; -mod reduce_sum_fp16x16_1D; -mod reduce_sum_fp16x16_2D_default; -mod reduce_sum_fp16x16_2D_keepdims; -mod reduce_sum_fp16x16_2D_axis_1; -mod reduce_sum_fp8x23_1D; -mod reduce_sum_fp8x23_2D_default; -mod reduce_sum_fp8x23_2D_keepdims; -mod reduce_sum_fp8x23_2D_axis_1; -mod reduce_sum_i32_1D; -mod reduce_sum_i32_2D_default; -mod reduce_sum_i32_2D_keepdims; -mod reduce_sum_i32_2D_axis_1; -mod reduce_sum_i8_1D; -mod reduce_sum_i8_2D_default; -mod reduce_sum_i8_2D_keepdims; -mod reduce_sum_i8_2D_axis_1; -mod reduce_sum_u32_1D; -mod reduce_sum_u32_2D_default; -mod reduce_sum_u32_2D_keepdims; -mod reduce_sum_u32_2D_axis_1; -mod exp_fp16x16; -mod exp_fp8x23; -mod exp_i32_fp8x23; -mod exp_i32_fp16x16; -mod exp_i8_fp8x23; -mod exp_i8_fp16x16; -mod exp_u32_fp8x23; -mod exp_u32_fp16x16; +mod abs_fp16x16; +mod abs_fp8x23; +mod abs_i32; +mod abs_i8; +mod acos_fp16x16; +mod acos_fp8x23; +mod acosh_fp16x16; +mod acosh_fp8x23; +mod add_fp16x16; +mod add_fp16x16_broadcast; +mod add_fp8x23; +mod add_fp8x23_broadcast; +mod add_i32; +mod add_i32_broadcast; +mod add_i8; +mod add_i8_broadcast; +mod add_u32; +mod add_u32_broadcast; +mod argmax_fp16x16_1D_default; +mod argmax_fp16x16_1D_keepdims_false; +mod argmax_fp16x16_1D_last_index; +mod argmax_fp16x16_2D_default; +mod argmax_fp16x16_2D_keepdims_false; +mod argmax_fp16x16_2D_last_index; +mod argmax_fp16x16_3D_default; +mod argmax_fp16x16_3D_keepdims_false; +mod argmax_fp16x16_3D_last_index; +mod argmax_fp8x23_1D_default; +mod argmax_fp8x23_1D_keepdims_false; +mod argmax_fp8x23_1D_last_index; +mod argmax_fp8x23_2D_default; +mod argmax_fp8x23_2D_keepdims_false; +mod argmax_fp8x23_2D_last_index; +mod argmax_fp8x23_3D_default; +mod argmax_fp8x23_3D_keepdims_false; +mod argmax_fp8x23_3D_last_index; +mod argmax_i32_1D_default; +mod argmax_i32_1D_keepdims_false; +mod argmax_i32_1D_last_index; +mod argmax_i32_2D_default; +mod argmax_i32_2D_keepdims_false; +mod argmax_i32_2D_last_index; +mod argmax_i32_3D_default; +mod argmax_i32_3D_keepdims_false; +mod argmax_i32_3D_last_index; +mod argmax_i8_1D_default; +mod argmax_i8_1D_keepdims_false; +mod argmax_i8_1D_last_index; +mod argmax_i8_2D_default; +mod argmax_i8_2D_keepdims_false; +mod argmax_i8_2D_last_index; +mod argmax_i8_3D_default; +mod argmax_i8_3D_keepdims_false; +mod argmax_i8_3D_last_index; +mod argmax_u32_1D_default; +mod argmax_u32_1D_keepdims_false; +mod argmax_u32_1D_last_index; +mod argmax_u32_2D_default; +mod argmax_u32_2D_keepdims_false; +mod argmax_u32_2D_last_index; +mod argmax_u32_3D_default; +mod argmax_u32_3D_keepdims_false; +mod argmax_u32_3D_last_index; +mod argmin_fp16x16_1D_default; +mod argmin_fp16x16_1D_keepdims_false; +mod argmin_fp16x16_1D_last_index; +mod argmin_fp16x16_2D_default; +mod argmin_fp16x16_2D_keepdims_false; +mod argmin_fp16x16_2D_last_index; +mod argmin_fp16x16_3D_default; +mod argmin_fp16x16_3D_keepdims_false; +mod argmin_fp16x16_3D_last_index; +mod argmin_fp8x23_1D_default; +mod argmin_fp8x23_1D_keepdims_false; +mod argmin_fp8x23_1D_last_index; +mod argmin_fp8x23_2D_default; +mod argmin_fp8x23_2D_keepdims_false; +mod argmin_fp8x23_2D_last_index; +mod argmin_fp8x23_3D_default; +mod argmin_fp8x23_3D_keepdims_false; +mod argmin_fp8x23_3D_last_index; +mod argmin_i32_1D_default; +mod argmin_i32_1D_keepdims_false; +mod argmin_i32_1D_last_index; +mod argmin_i32_2D_default; +mod argmin_i32_2D_keepdims_false; +mod argmin_i32_2D_last_index; +mod argmin_i32_3D_default; +mod argmin_i32_3D_keepdims_false; +mod argmin_i32_3D_last_index; +mod argmin_i8_1D_default; +mod argmin_i8_1D_keepdims_false; +mod argmin_i8_1D_last_index; +mod argmin_i8_2D_default; +mod argmin_i8_2D_keepdims_false; +mod argmin_i8_2D_last_index; +mod argmin_i8_3D_default; +mod argmin_i8_3D_keepdims_false; +mod argmin_i8_3D_last_index; +mod argmin_u32_1D_default; +mod argmin_u32_1D_keepdims_false; +mod argmin_u32_1D_last_index; +mod argmin_u32_2D_default; +mod argmin_u32_2D_keepdims_false; +mod argmin_u32_2D_last_index; +mod argmin_u32_3D_default; +mod argmin_u32_3D_keepdims_false; +mod argmin_u32_3D_last_index; +mod asin_fp16x16; +mod asin_fp8x23; +mod asinh_fp16x16; +mod asinh_fp8x23; +mod atan_fp16x16; +mod atan_fp8x23; +mod ceil_fp16x16; +mod ceil_fp8x23; +mod concat_fp16x16_1d; +mod concat_fp16x16_2d; +mod concat_fp16x16_3d_default; +mod concat_fp16x16_3d_axis_1; +mod concat_fp16x16_3d_axis_2; +mod concat_fp16x16_3d_three_tensors_axis_1; +mod concat_fp16x16_3d_three_tensors_axis_2; +mod concat_fp8x23_1d; +mod concat_fp8x23_2d; +mod concat_fp8x23_3d_default; +mod concat_fp8x23_3d_axis_1; +mod concat_fp8x23_3d_axis_2; +mod concat_fp8x23_3d_three_tensors_axis_1; +mod concat_fp8x23_3d_three_tensors_axis_2; +mod concat_i32_1d; +mod concat_i32_2d; +mod concat_i32_3d_default; +mod concat_i32_3d_axis_1; +mod concat_i32_3d_axis_2; +mod concat_i32_3d_three_tensors_axis_1; +mod concat_i32_3d_three_tensors_axis_2; +mod concat_i8_1d; +mod concat_i8_2d; +mod concat_i8_3d_default; +mod concat_i8_3d_axis_1; +mod concat_i8_3d_axis_2; +mod concat_i8_3d_three_tensors_axis_1; +mod concat_i8_3d_three_tensors_axis_2; +mod concat_u32_1d; +mod concat_u32_2d; +mod concat_u32_3d_default; +mod concat_u32_3d_axis_1; +mod concat_u32_3d_axis_2; +mod concat_u32_3d_three_tensors_axis_1; +mod concat_u32_3d_three_tensors_axis_2; +mod cos_fp16x16; +mod cos_fp8x23; +mod cosh_fp16x16; +mod cosh_fp8x23; +mod cumsum_fp16x16_1d_default; +mod cumsum_fp16x16_1d_exclusive; +mod cumsum_fp16x16_1d_reverse; +mod cumsum_fp16x16_1d_reverse_exclusive; +mod cumsum_fp16x16_2d_axis_0; +mod cumsum_fp16x16_2d_axis_1; +mod cumsum_fp8x23_1d_default; +mod cumsum_fp8x23_1d_exclusive; +mod cumsum_fp8x23_1d_reverse; +mod cumsum_fp8x23_1d_reverse_exclusive; +mod cumsum_fp8x23_2d_axis_0; +mod cumsum_fp8x23_2d_axis_1; +mod cumsum_i32_1d_default; +mod cumsum_i32_1d_exclusive; +mod cumsum_i32_1d_reverse; +mod cumsum_i32_1d_reverse_exclusive; +mod cumsum_i32_2d_axis_0; +mod cumsum_i32_2d_axis_1; +mod cumsum_i8_1d_default; +mod cumsum_i8_1d_exclusive; +mod cumsum_i8_1d_reverse; +mod cumsum_i8_1d_reverse_exclusive; +mod cumsum_i8_2d_axis_0; +mod cumsum_i8_2d_axis_1; +mod cumsum_u32_1d_default; +mod cumsum_u32_1d_exclusive; +mod cumsum_u32_1d_reverse; +mod cumsum_u32_1d_reverse_exclusive; +mod cumsum_u32_2d_axis_0; +mod cumsum_u32_2d_axis_1; +mod div_fp16x16; +mod div_fp16x16_broadcast; +mod div_fp8x23; +mod div_fp8x23_broadcast; +mod div_i32; +mod div_i32_broadcast; +mod div_i8; +mod div_i8_broadcast; +mod div_u32; +mod div_u32_broadcast; mod equal_fp16x16; mod equal_fp16x16_broadcast; mod equal_fp8x23; @@ -224,16 +203,8 @@ mod equal_i8; mod equal_i8_broadcast; mod equal_u32; mod equal_u32_broadcast; -mod greater_fp16x16; -mod greater_fp16x16_broadcast; -mod greater_fp8x23; -mod greater_fp8x23_broadcast; -mod greater_i32; -mod greater_i32_broadcast; -mod greater_i8; -mod greater_i8_broadcast; -mod greater_u32; -mod greater_u32_broadcast; +mod exp_fp16x16; +mod exp_fp8x23; mod less_equal_fp16x16; mod less_equal_fp16x16_broadcast; mod less_equal_fp8x23; @@ -244,34 +215,29 @@ mod less_equal_i8; mod less_equal_i8_broadcast; mod less_equal_u32; mod less_equal_u32_broadcast; -mod sqrt_fp16x16; -mod sqrt_fp8x23; -mod sqrt_i32_fp8x23; -mod sqrt_i32_fp16x16; -mod sqrt_i8_fp8x23; -mod sqrt_i8_fp16x16; -mod sqrt_u32_fp8x23; -mod sqrt_u32_fp16x16; -mod or_fp16x16; -mod or_fp16x16_broadcast; -mod or_fp8x23; -mod or_fp8x23_broadcast; -mod or_i32; -mod or_i32_broadcast; -mod or_i8; -mod or_i8_broadcast; -mod or_u32; -mod or_u32_broadcast; -mod xor_fp16x16; -mod xor_fp16x16_broadcast; -mod xor_fp8x23; -mod xor_fp8x23_broadcast; -mod xor_i32; -mod xor_i32_broadcast; -mod xor_i8; -mod xor_i8_broadcast; -mod xor_u32; -mod xor_u32_broadcast; +mod greater_fp16x16; +mod greater_fp16x16_broadcast; +mod greater_fp8x23; +mod greater_fp8x23_broadcast; +mod greater_i32; +mod greater_i32_broadcast; +mod greater_i8; +mod greater_i8_broadcast; +mod greater_u32; +mod greater_u32_broadcast; +mod leaky_relu_fp16x16; +mod leaky_relu_fp8x23; +mod linear_fp16x16; +mod linear_fp8x23; +mod linear_i32; +mod linear_i8; +mod linear_u32; +mod log_fp16x16; +mod log_fp8x23; +mod logsoftmax_fp16x16_axis_0; +mod logsoftmax_fp16x16_axis_1; +mod logsoftmax_fp8x23_axis_0; +mod logsoftmax_fp8x23_axis_1; mod matmul_fp16x16_1d; mod matmul_fp16x16_2x2; mod matmul_fp16x16_2x1; @@ -292,42 +258,6 @@ mod matmul_u32_1d; mod matmul_u32_2x2; mod matmul_u32_2x1; mod matmul_u32_1x2; -mod acosh_fp16x16; -mod acosh_fp8x23; -mod acosh_i32_fp8x23; -mod acosh_i32_fp16x16; -mod acosh_i8_fp8x23; -mod acosh_i8_fp16x16; -mod acosh_u32_fp8x23; -mod acosh_u32_fp16x16; -mod asinh_fp16x16; -mod asinh_fp8x23; -mod asinh_i32_fp8x23; -mod asinh_i32_fp16x16; -mod asinh_i8_fp8x23; -mod asinh_i8_fp16x16; -mod asinh_u32_fp8x23; -mod asinh_u32_fp16x16; -mod add_fp16x16; -mod add_fp16x16_broadcast; -mod add_fp8x23; -mod add_fp8x23_broadcast; -mod add_i32; -mod add_i32_broadcast; -mod add_i8; -mod add_i8_broadcast; -mod add_u32; -mod add_u32_broadcast; -mod sub_fp16x16; -mod sub_fp16x16_broadcast; -mod sub_fp8x23; -mod sub_fp8x23_broadcast; -mod sub_i32; -mod sub_i32_broadcast; -mod sub_i8; -mod sub_i8_broadcast; -mod sub_u32; -mod sub_u32_broadcast; mod mul_fp16x16; mod mul_fp16x16_broadcast; mod mul_fp8x23; @@ -338,84 +268,113 @@ mod mul_i8; mod mul_i8_broadcast; mod mul_u32; mod mul_u32_broadcast; -mod div_fp16x16; -mod div_fp16x16_broadcast; -mod div_fp8x23; -mod div_fp8x23_broadcast; -mod div_i32; -mod div_i32_broadcast; -mod div_i8; -mod div_i8_broadcast; -mod div_u32; -mod div_u32_broadcast; -mod leaky_relu_fp16x16; -mod leaky_relu_fp8x23; -mod leaky_relu_i32_fp8x23; -mod leaky_relu_i32_fp16x16; -mod leaky_relu_i8_fp8x23; -mod leaky_relu_i8_fp16x16; -mod linear_fp16x16; -mod linear_fp8x23; -mod linear_i32; -mod linear_i8; -mod linear_u32; -mod logsoftmax_fp16x16_axis_0; -mod logsoftmax_fp16x16_axis_1; -mod logsoftmax_fp8x23_axis_0; -mod logsoftmax_fp8x23_axis_1; -mod logsoftmax_i32_fp8x23_axis_0; -mod logsoftmax_i32_fp8x23_axis_1; -mod logsoftmax_i32_fp16x16_axis_0; -mod logsoftmax_i32_fp16x16_axis_1; -mod logsoftmax_i8_fp8x23_axis_0; -mod logsoftmax_i8_fp8x23_axis_1; -mod logsoftmax_i8_fp16x16_axis_0; -mod logsoftmax_i8_fp16x16_axis_1; -mod logsoftmax_u32_fp8x23_axis_0; -mod logsoftmax_u32_fp8x23_axis_1; -mod logsoftmax_u32_fp16x16_axis_0; -mod logsoftmax_u32_fp16x16_axis_1; +mod or_fp16x16; +mod or_fp16x16_broadcast; +mod or_fp8x23; +mod or_fp8x23_broadcast; +mod or_i32; +mod or_i32_broadcast; +mod or_i8; +mod or_i8_broadcast; +mod or_u32; +mod or_u32_broadcast; +mod reduce_sum_fp16x16_1D; +mod reduce_sum_fp16x16_2D_default; +mod reduce_sum_fp16x16_2D_keepdims; +mod reduce_sum_fp16x16_2D_axis_1; +mod reduce_sum_fp8x23_1D; +mod reduce_sum_fp8x23_2D_default; +mod reduce_sum_fp8x23_2D_keepdims; +mod reduce_sum_fp8x23_2D_axis_1; +mod reduce_sum_i32_1D; +mod reduce_sum_i32_2D_default; +mod reduce_sum_i32_2D_keepdims; +mod reduce_sum_i32_2D_axis_1; +mod reduce_sum_i8_1D; +mod reduce_sum_i8_2D_default; +mod reduce_sum_i8_2D_keepdims; +mod reduce_sum_i8_2D_axis_1; +mod reduce_sum_u32_1D; +mod reduce_sum_u32_2D_default; +mod reduce_sum_u32_2D_keepdims; +mod reduce_sum_u32_2D_axis_1; mod relu_fp16x16; mod relu_fp8x23; mod relu_i32; mod relu_i8; -mod sigmoid_fp8x23; mod sigmoid_fp16x16; -mod sigmoid_i32_fp8x23; -mod sigmoid_i32_fp16x16; -mod sigmoid_i8_fp8x23; -mod sigmoid_i8_fp16x16; -mod sigmoid_u32_fp8x23; -mod sigmoid_u32_fp16x16; -mod softmax_fp8x23; +mod sigmoid_fp8x23; +mod sin_fp16x16; +mod sin_fp8x23; +mod sinh_fp16x16; +mod sinh_fp8x23; mod softmax_fp16x16; -mod softmax_i32_fp8x23; -mod softmax_i32_fp16x16; -mod softmax_i8_fp8x23; -mod softmax_i8_fp16x16; -mod softmax_u32_fp8x23; -mod softmax_u32_fp16x16; +mod softmax_fp8x23; mod softplus_fp8x23; mod softplus_fp16x16; -mod softplus_i32_fp8x23; -mod softplus_i32_fp16x16; -mod softplus_i8_fp8x23; -mod softplus_i8_fp16x16; -mod softplus_u32_fp8x23; -mod softplus_u32_fp16x16; mod softsign_fp8x23; mod softsign_fp16x16; -mod softsign_i32_fp8x23; -mod softsign_i32_fp16x16; -mod softsign_i8_fp8x23; -mod softsign_i8_fp16x16; -mod softsign_u32_fp8x23; -mod softsign_u32_fp16x16; -mod sin_fp16x16; -mod sin_fp8x23; -mod sin_i32_fp8x23; -mod sin_i32_fp16x16; -mod sin_i8_fp8x23; -mod sin_i8_fp16x16; -mod sin_u32_fp8x23; -mod sin_u32_fp16x16; +mod sqrt_fp16x16; +mod sqrt_fp8x23; +mod sub_fp16x16; +mod sub_fp16x16_broadcast; +mod sub_fp8x23; +mod sub_fp8x23_broadcast; +mod sub_i32; +mod sub_i32_broadcast; +mod sub_i8; +mod sub_i8_broadcast; +mod sub_u32; +mod sub_u32_broadcast; +mod tanh_fp16x16; +mod tanh_fp8x23; +mod transpose_fp16x16_2d; +mod transpose_fp16x16_3d; +mod transpose_fp8x23_2d; +mod transpose_fp8x23_3d; +mod transpose_i32_2d; +mod transpose_i32_3d; +mod transpose_i8_2d; +mod transpose_i8_3d; +mod transpose_u32_2d; +mod transpose_u32_3d; +mod xor_fp16x16; +mod xor_fp16x16_broadcast; +mod xor_fp8x23; +mod xor_fp8x23_broadcast; +mod xor_i32; +mod xor_i32_broadcast; +mod xor_i8; +mod xor_i8_broadcast; +mod xor_u32; +mod xor_u32_broadcast; +mod less_fp16x16; +mod less_fp16x16_broadcast; +mod less_fp8x23; +mod less_fp8x23_broadcast; +mod less_i32; +mod less_i32_broadcast; +mod less_i8; +mod less_i8_broadcast; +mod less_u32; +mod less_u32_broadcast; +mod greater_equal_fp16x16; +mod greater_equal_fp16x16_broadcast; +mod greater_equal_fp8x23; +mod greater_equal_fp8x23_broadcast; +mod greater_equal_i32; +mod greater_equal_i32_broadcast; +mod greater_equal_i8; +mod greater_equal_i8_broadcast; +mod greater_equal_u32; +mod greater_equal_u32_broadcast; +mod slice_fp16x16_2d; +mod slice_fp16x16_3d; +mod slice_fp8x23_2d; +mod slice_fp8x23_3d; +mod slice_i32_2d; +mod slice_i32_3d; +mod slice_i8_2d; +mod slice_i8_3d; +mod slice_u32_2d; +mod slice_u32_3d; diff --git a/src/tests/nodes/abs_fp16x16.cairo b/src/tests/nodes/abs_fp16x16.cairo index 8af5dcee5..70d99c0bd 100644 --- a/src/tests/nodes/abs_fp16x16.cairo +++ b/src/tests/nodes/abs_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/abs_fp16x16/input_0.cairo b/src/tests/nodes/abs_fp16x16/input_0.cairo index 786dd3d68..b7b95b898 100644 --- a/src/tests/nodes/abs_fp16x16/input_0.cairo +++ b/src/tests/nodes/abs_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2424832, sign: true }); - data.append(FixedType { mag: 7405568, sign: false }); - data.append(FixedType { mag: 7536640, sign: true }); - data.append(FixedType { mag: 7929856, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 8192000, sign: true }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: true }); + data.append(FP16x16 { mag: 3604480, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/abs_fp16x16/output_0.cairo b/src/tests/nodes/abs_fp16x16/output_0.cairo index 957f60884..d48f57bdd 100644 --- a/src/tests/nodes/abs_fp16x16/output_0.cairo +++ b/src/tests/nodes/abs_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2424832, sign: false }); - data.append(FixedType { mag: 7405568, sign: false }); - data.append(FixedType { mag: 7536640, sign: false }); - data.append(FixedType { mag: 7929856, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 8192000, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/abs_fp8x23.cairo b/src/tests/nodes/abs_fp8x23.cairo index bea33535f..cd8851f74 100644 --- a/src/tests/nodes/abs_fp8x23.cairo +++ b/src/tests/nodes/abs_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/abs_fp8x23/input_0.cairo b/src/tests/nodes/abs_fp8x23/input_0.cairo index 3a0c86191..399e80f63 100644 --- a/src/tests/nodes/abs_fp8x23/input_0.cairo +++ b/src/tests/nodes/abs_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 788529152, sign: false }); - data.append(FixedType { mag: 150994944, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 612368384, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 402653184, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/abs_fp8x23/output_0.cairo b/src/tests/nodes/abs_fp8x23/output_0.cairo index 97f823a8c..060e575b3 100644 --- a/src/tests/nodes/abs_fp8x23/output_0.cairo +++ b/src/tests/nodes/abs_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 788529152, sign: false }); - data.append(FixedType { mag: 150994944, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 612368384, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/abs_i32.cairo b/src/tests/nodes/abs_i32.cairo index bd358e4ed..8a9e21e62 100644 --- a/src/tests/nodes/abs_i32.cairo +++ b/src/tests/nodes/abs_i32.cairo @@ -1,11 +1,11 @@ -mod input_0; -mod output_0; +mod input_0; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -17,4 +17,4 @@ fn test_abs_i32() { let y = input_0.abs(); assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/abs_i32/input_0.cairo b/src/tests/nodes/abs_i32/input_0.cairo index 69a5c106b..38b5eacd5 100644 --- a/src/tests/nodes/abs_i32/input_0.cairo +++ b/src/tests/nodes/abs_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 102, sign: false }); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 81, sign: false }); - data.append(i32 { mag: 101, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 81, sign: true }); + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 67, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/abs_i32/output_0.cairo b/src/tests/nodes/abs_i32/output_0.cairo index 677e44037..043732383 100644 --- a/src/tests/nodes/abs_i32/output_0.cairo +++ b/src/tests/nodes/abs_i32/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 102, sign: false }); - data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 69, sign: false }); data.append(i32 { mag: 81, sign: false }); - data.append(i32 { mag: 101, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 67, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/abs_i8.cairo b/src/tests/nodes/abs_i8.cairo index 52ab8f4e3..60ddd91ec 100644 --- a/src/tests/nodes/abs_i8.cairo +++ b/src/tests/nodes/abs_i8.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/abs_i8/input_0.cairo b/src/tests/nodes/abs_i8/input_0.cairo index 3f06252c1..b746a1d05 100644 --- a/src/tests/nodes/abs_i8/input_0.cairo +++ b/src/tests/nodes/abs_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 78, sign: false }); - data.append(i8 { mag: 6, sign: false }); - data.append(i8 { mag: 67, sign: false }); - data.append(i8 { mag: 41, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 59, sign: true }); + data.append(i8 { mag: 103, sign: true }); + data.append(i8 { mag: 41, sign: false }); + data.append(i8 { mag: 24, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/abs_i8/output_0.cairo b/src/tests/nodes/abs_i8/output_0.cairo index 60b03dafb..447c92e0c 100644 --- a/src/tests/nodes/abs_i8/output_0.cairo +++ b/src/tests/nodes/abs_i8/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 78, sign: false }); - data.append(i8 { mag: 6, sign: false }); - data.append(i8 { mag: 67, sign: false }); + data.append(i8 { mag: 59, sign: false }); + data.append(i8 { mag: 103, sign: false }); data.append(i8 { mag: 41, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 24, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acos_fp16x16.cairo b/src/tests/nodes/acos_fp16x16.cairo index 414ce02fa..51d2ba037 100644 --- a/src/tests/nodes/acos_fp16x16.cairo +++ b/src/tests/nodes/acos_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/acos_fp16x16/input_0.cairo b/src/tests/nodes/acos_fp16x16/input_0.cairo index 030687cd5..d8cfb2281 100644 --- a/src/tests/nodes/acos_fp16x16/input_0.cairo +++ b/src/tests/nodes/acos_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 57673, sign: false }); - data.append(FixedType { mag: 46735, sign: false }); - data.append(FixedType { mag: 47892, sign: false }); - data.append(FixedType { mag: 52526, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 47767, sign: false }); + data.append(FP16x16 { mag: 33238, sign: true }); + data.append(FP16x16 { mag: 47744, sign: false }); + data.append(FP16x16 { mag: 21178, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acos_fp16x16/output_0.cairo b/src/tests/nodes/acos_fp16x16/output_0.cairo index 53772f58b..3b9cb8230 100644 --- a/src/tests/nodes/acos_fp16x16/output_0.cairo +++ b/src/tests/nodes/acos_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 32432, sign: false }); - data.append(FixedType { mag: 50911, sign: false }); - data.append(FixedType { mag: 49239, sign: false }); - data.append(FixedType { mag: 42008, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 49421, sign: false }); + data.append(FP16x16 { mag: 137802, sign: false }); + data.append(FP16x16 { mag: 49455, sign: false }); + data.append(FP16x16 { mag: 124509, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acos_fp8x23.cairo b/src/tests/nodes/acos_fp8x23.cairo index b15d2a59d..3efe7353a 100644 --- a/src/tests/nodes/acos_fp8x23.cairo +++ b/src/tests/nodes/acos_fp8x23.cairo @@ -1,14 +1,11 @@ -use core::traits::Into; -use core::array::SpanTrait; -use debug::PrintTrait; mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/acos_fp8x23/input_0.cairo b/src/tests/nodes/acos_fp8x23/input_0.cairo index af2939887..b948c697b 100644 --- a/src/tests/nodes/acos_fp8x23/input_0.cairo +++ b/src/tests/nodes/acos_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 3385979, sign: true }); - data.append(FixedType { mag: 6224397, sign: false }); - data.append(FixedType { mag: 190013, sign: true }); - data.append(FixedType { mag: 8257919, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 3985911, sign: false }); + data.append(FP8x23 { mag: 4254306, sign: true }); + data.append(FP8x23 { mag: 5997528, sign: true }); + data.append(FP8x23 { mag: 3494756, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acos_fp8x23/output_0.cairo b/src/tests/nodes/acos_fp8x23/output_0.cairo index bcbfe60ca..41234983f 100644 --- a/src/tests/nodes/acos_fp8x23/output_0.cairo +++ b/src/tests/nodes/acos_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16662195, sign: false }); - data.append(FixedType { mag: 6163433, sign: false }); - data.append(FixedType { mag: 13366824, sign: false }); - data.append(FixedType { mag: 24870922, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 9023232, sign: false }); + data.append(FP8x23 { mag: 17638511, sign: false }); + data.append(FP8x23 { mag: 19858895, sign: false }); + data.append(FP8x23 { mag: 16781466, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acosh_fp16x16.cairo b/src/tests/nodes/acosh_fp16x16.cairo index 1e3f3e6ec..b72263a43 100644 --- a/src/tests/nodes/acosh_fp16x16.cairo +++ b/src/tests/nodes/acosh_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/acosh_fp16x16/input_0.cairo b/src/tests/nodes/acosh_fp16x16/input_0.cairo index 2ac325a99..bcc909846 100644 --- a/src/tests/nodes/acosh_fp16x16/input_0.cairo +++ b/src/tests/nodes/acosh_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 141514, sign: false }); - data.append(FixedType { mag: 155360, sign: false }); - data.append(FixedType { mag: 119042, sign: false }); - data.append(FixedType { mag: 312767, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 257246, sign: false }); + data.append(FP16x16 { mag: 273870, sign: false }); + data.append(FP16x16 { mag: 185580, sign: false }); + data.append(FP16x16 { mag: 308003, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acosh_fp16x16/output_0.cairo b/src/tests/nodes/acosh_fp16x16/output_0.cairo index 9cfe7e34f..a6be6f408 100644 --- a/src/tests/nodes/acosh_fp16x16/output_0.cairo +++ b/src/tests/nodes/acosh_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 92040, sign: false }); - data.append(FixedType { mag: 98861, sign: false }); - data.append(FixedType { mag: 78893, sign: false }); - data.append(FixedType { mag: 147118, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 133952, sign: false }); + data.append(FP16x16 { mag: 138187, sign: false }); + data.append(FP16x16 { mag: 111495, sign: false }); + data.append(FP16x16 { mag: 146089, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acosh_fp8x23.cairo b/src/tests/nodes/acosh_fp8x23.cairo index 111a9b881..d416a1ca8 100644 --- a/src/tests/nodes/acosh_fp8x23.cairo +++ b/src/tests/nodes/acosh_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/acosh_fp8x23/input_0.cairo b/src/tests/nodes/acosh_fp8x23/input_0.cairo index bbf740ee2..66b687af8 100644 --- a/src/tests/nodes/acosh_fp8x23/input_0.cairo +++ b/src/tests/nodes/acosh_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 9774601, sign: false }); - data.append(FixedType { mag: 29725534, sign: false }); - data.append(FixedType { mag: 20607627, sign: false }); - data.append(FixedType { mag: 39982645, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 26479692, sign: false }); + data.append(FP8x23 { mag: 34552514, sign: false }); + data.append(FP8x23 { mag: 21028116, sign: false }); + data.append(FP8x23 { mag: 39741582, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acosh_fp8x23/output_0.cairo b/src/tests/nodes/acosh_fp8x23/output_0.cairo index f51b83b01..34ed86b13 100644 --- a/src/tests/nodes/acosh_fp8x23/output_0.cairo +++ b/src/tests/nodes/acosh_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 4758107, sign: false }); - data.append(FixedType { mag: 16255001, sign: false }); - data.append(FixedType { mag: 12982783, sign: false }); - data.append(FixedType { mag: 18820070, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 15238413, sign: false }); + data.append(FP8x23 { mag: 17563067, sign: false }); + data.append(FP8x23 { mag: 13167925, sign: false }); + data.append(FP8x23 { mag: 18768178, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/acosh_i32_fp16x16.cairo b/src/tests/nodes/acosh_i32_fp16x16.cairo deleted file mode 100644 index c763ddc6c..000000000 --- a/src/tests/nodes/acosh_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_acosh_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.acosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i32_fp16x16/input_0.cairo b/src/tests/nodes/acosh_i32_fp16x16/input_0.cairo deleted file mode 100644 index 8ed65eca9..000000000 --- a/src/tests/nodes/acosh_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 4, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i32_fp16x16/output_0.cairo b/src/tests/nodes/acosh_i32_fp16x16/output_0.cairo deleted file mode 100644 index a1c985716..000000000 --- a/src/tests/nodes/acosh_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 135229, sign: false }); - data.append(FixedType { mag: 86308, sign: false }); - data.append(FixedType { mag: 86308, sign: false }); - data.append(FixedType { mag: 86308, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i32_fp8x23.cairo b/src/tests/nodes/acosh_i32_fp8x23.cairo deleted file mode 100644 index fbcf63d06..000000000 --- a/src/tests/nodes/acosh_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_acosh_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.acosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i32_fp8x23/input_0.cairo b/src/tests/nodes/acosh_i32_fp8x23/input_0.cairo deleted file mode 100644 index 5404b904b..000000000 --- a/src/tests/nodes/acosh_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 3, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i32_fp8x23/output_0.cairo b/src/tests/nodes/acosh_i32_fp8x23/output_0.cairo deleted file mode 100644 index 17f2815ee..000000000 --- a/src/tests/nodes/acosh_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 14786995, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 14786995, sign: false }); - data.append(FixedType { mag: 14786995, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i8_fp16x16.cairo b/src/tests/nodes/acosh_i8_fp16x16.cairo deleted file mode 100644 index 4d15637ff..000000000 --- a/src/tests/nodes/acosh_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_acosh_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.acosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i8_fp16x16/input_0.cairo b/src/tests/nodes/acosh_i8_fp16x16/input_0.cairo deleted file mode 100644 index 33483a44f..000000000 --- a/src/tests/nodes/acosh_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: false }); - data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i8_fp16x16/output_0.cairo b/src/tests/nodes/acosh_i8_fp16x16/output_0.cairo deleted file mode 100644 index 336e9d623..000000000 --- a/src/tests/nodes/acosh_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 86308, sign: false }); - data.append(FixedType { mag: 86308, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 86308, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i8_fp8x23.cairo b/src/tests/nodes/acosh_i8_fp8x23.cairo deleted file mode 100644 index c28ca4ba1..000000000 --- a/src/tests/nodes/acosh_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_acosh_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.acosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i8_fp8x23/input_0.cairo b/src/tests/nodes/acosh_i8_fp8x23/input_0.cairo deleted file mode 100644 index 51b510820..000000000 --- a/src/tests/nodes/acosh_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 3, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_i8_fp8x23/output_0.cairo b/src/tests/nodes/acosh_i8_fp8x23/output_0.cairo deleted file mode 100644 index b3ad39dff..000000000 --- a/src/tests/nodes/acosh_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 14786560, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 17301504, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_u32_fp16x16.cairo b/src/tests/nodes/acosh_u32_fp16x16.cairo deleted file mode 100644 index 965520e85..000000000 --- a/src/tests/nodes/acosh_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_acosh_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.acosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_u32_fp16x16/input_0.cairo b/src/tests/nodes/acosh_u32_fp16x16/input_0.cairo deleted file mode 100644 index f701b75a9..000000000 --- a/src/tests/nodes/acosh_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(4); - data.append(1); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_u32_fp16x16/output_0.cairo b/src/tests/nodes/acosh_u32_fp16x16/output_0.cairo deleted file mode 100644 index c02ac139a..000000000 --- a/src/tests/nodes/acosh_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 135229, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_u32_fp8x23.cairo b/src/tests/nodes/acosh_u32_fp8x23.cairo deleted file mode 100644 index 39e51d0eb..000000000 --- a/src/tests/nodes/acosh_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_acosh_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.acosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_u32_fp8x23/input_0.cairo b/src/tests/nodes/acosh_u32_fp8x23/input_0.cairo deleted file mode 100644 index f2aa58ff3..000000000 --- a/src/tests/nodes/acosh_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(3); - data.append(2); - data.append(2); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/acosh_u32_fp8x23/output_0.cairo b/src/tests/nodes/acosh_u32_fp8x23/output_0.cairo deleted file mode 100644 index df0a869ae..000000000 --- a/src/tests/nodes/acosh_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 14786995, sign: false }); - data.append(FixedType { mag: 11047443, sign: false }); - data.append(FixedType { mag: 11047443, sign: false }); - data.append(FixedType { mag: 11047443, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/add_fp16x16.cairo b/src/tests/nodes/add_fp16x16.cairo index 8f981a797..e9b665573 100644 --- a/src/tests/nodes/add_fp16x16.cairo +++ b/src/tests/nodes/add_fp16x16.cairo @@ -1,12 +1,12 @@ -mod input_0; -mod input_1; -mod output_0; +mod input_0; +mod input_1; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_add_fp16x16() { let y = input_0 + input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/add_fp16x16/input_0.cairo b/src/tests/nodes/add_fp16x16/input_0.cairo index f865e39fa..f8a4ff052 100644 --- a/src/tests/nodes/add_fp16x16/input_0.cairo +++ b/src/tests/nodes/add_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + 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: true }); + 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: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp16x16/input_1.cairo b/src/tests/nodes/add_fp16x16/input_1.cairo index 6d244ab35..74ed543f4 100644 --- a/src/tests/nodes/add_fp16x16/input_1.cairo +++ b/src/tests/nodes/add_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, 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: 131072, sign: false }); + data.append(FP16x16 { mag: 0, 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()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp16x16/output_0.cairo b/src/tests/nodes/add_fp16x16/output_0.cairo index ccee743a1..564b17a50 100644 --- a/src/tests/nodes/add_fp16x16/output_0.cairo +++ b/src/tests/nodes/add_fp16x16/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 327680, sign: true }); - data.append(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 327680, sign: true }); - data.append(FixedType { mag: 327680, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 327680, sign: true }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 327680, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 196608, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 327680, sign: true }); + data.append(FP16x16 { mag: 262144, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp16x16_broadcast.cairo b/src/tests/nodes/add_fp16x16_broadcast.cairo index fe6e171be..8e5aa2265 100644 --- a/src/tests/nodes/add_fp16x16_broadcast.cairo +++ b/src/tests/nodes/add_fp16x16_broadcast.cairo @@ -1,12 +1,12 @@ -mod input_0; -mod input_1; -mod output_0; +mod input_0; +mod input_1; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorAdd}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/add_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/add_fp16x16_broadcast/input_0.cairo index 775295c8f..da0ed021d 100644 --- a/src/tests/nodes/add_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/add_fp16x16_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/add_fp16x16_broadcast/input_1.cairo index 2ccd49cad..c9f1cf735 100644 --- a/src/tests/nodes/add_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/add_fp16x16_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/add_fp16x16_broadcast/output_0.cairo index 74c8a5a33..7b3c06bad 100644 --- a/src/tests/nodes/add_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/add_fp16x16_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: true }); + 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: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, 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: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp8x23.cairo b/src/tests/nodes/add_fp8x23.cairo index fb73ae977..036664ec7 100644 --- a/src/tests/nodes/add_fp8x23.cairo +++ b/src/tests/nodes/add_fp8x23.cairo @@ -1,12 +1,12 @@ -mod input_0; -mod input_1; -mod output_0; +mod input_0; +mod input_1; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/add_fp8x23/input_0.cairo b/src/tests/nodes/add_fp8x23/input_0.cairo index 7c4ea71a3..bebbe1f55 100644 --- a/src/tests/nodes/add_fp8x23/input_0.cairo +++ b/src/tests/nodes/add_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + 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: 25165824, 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, 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: 8388608, sign: true }); + 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: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp8x23/input_1.cairo b/src/tests/nodes/add_fp8x23/input_1.cairo index 41684e408..f931fac67 100644 --- a/src/tests/nodes/add_fp8x23/input_1.cairo +++ b/src/tests/nodes/add_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + 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: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + 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: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, 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: 8388608, 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: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp8x23/output_0.cairo b/src/tests/nodes/add_fp8x23/output_0.cairo index e2d119dd6..b19076e39 100644 --- a/src/tests/nodes/add_fp8x23/output_0.cairo +++ b/src/tests/nodes/add_fp8x23/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 50331648, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 41943040, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 50331648, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 41943040, 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp8x23_broadcast.cairo b/src/tests/nodes/add_fp8x23_broadcast.cairo index 575847779..be1d3f286 100644 --- a/src/tests/nodes/add_fp8x23_broadcast.cairo +++ b/src/tests/nodes/add_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorAdd}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/add_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/add_fp8x23_broadcast/input_0.cairo index e17abb6f7..4ed90ce0f 100644 --- a/src/tests/nodes/add_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/add_fp8x23_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, 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: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/add_fp8x23_broadcast/input_1.cairo index 2b624c14a..cf8066ef2 100644 --- a/src/tests/nodes/add_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/add_fp8x23_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/add_fp8x23_broadcast/output_0.cairo index 29c9141b0..daf198e84 100644 --- a/src/tests/nodes/add_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/add_fp8x23_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 50331648, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 41943040, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, 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: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, 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: 8388608, sign: false }); + 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: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i32.cairo b/src/tests/nodes/add_i32.cairo index ca1a261ec..cd7821e3b 100644 --- a/src/tests/nodes/add_i32.cairo +++ b/src/tests/nodes/add_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_add_i32() { let y = input_0 + input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/add_i32/input_0.cairo b/src/tests/nodes/add_i32/input_0.cairo index 602a76c22..c61672795 100644 --- a/src/tests/nodes/add_i32/input_0.cairo +++ b/src/tests/nodes/add_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - 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: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); 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: 2, sign: false }); + data.append(i32 { mag: 1, sign: false }); + 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: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: true }); 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: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, 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: 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: 1, sign: true }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i32/input_1.cairo b/src/tests/nodes/add_i32/input_1.cairo index b5000b71c..3a48a3bab 100644 --- a/src/tests/nodes/add_i32/input_1.cairo +++ b/src/tests/nodes/add_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: true }); 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: false }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i32/output_0.cairo b/src/tests/nodes/add_i32/output_0.cairo index cb1687973..7ba2f56ba 100644 --- a/src/tests/nodes/add_i32/output_0.cairo +++ b/src/tests/nodes/add_i32/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 6, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 5, 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: 4, sign: true }); - data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 6, sign: true }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i32_broadcast.cairo b/src/tests/nodes/add_i32_broadcast.cairo index a458985b0..73678c376 100644 --- a/src/tests/nodes/add_i32_broadcast.cairo +++ b/src/tests/nodes/add_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorAdd}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_add_i32_broadcast() { let y = input_0 + input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/add_i32_broadcast/input_0.cairo b/src/tests/nodes/add_i32_broadcast/input_0.cairo index f08c83abe..33350ec16 100644 --- a/src/tests/nodes/add_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/add_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 2, sign: false }); - 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: 0, sign: false }); - data.append(i32 { mag: 3, sign: true }); - 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: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i32_broadcast/input_1.cairo b/src/tests/nodes/add_i32_broadcast/input_1.cairo index 35b6df79f..190e0eb30 100644 --- a/src/tests/nodes/add_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/add_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i32_broadcast/output_0.cairo b/src/tests/nodes/add_i32_broadcast/output_0.cairo index 4956e9e2e..b30c8eddc 100644 --- a/src/tests/nodes/add_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/add_i32_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 6, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 4, sign: true }); data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 6, sign: true }); - data.append(i32 { mag: 6, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i8.cairo b/src/tests/nodes/add_i8.cairo index eace999a5..64c8eb2ae 100644 --- a/src/tests/nodes/add_i8.cairo +++ b/src/tests/nodes/add_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_add_i8() { let y = input_0 + input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/add_i8/input_0.cairo b/src/tests/nodes/add_i8/input_0.cairo index 8ad7f880f..bc2d2b810 100644 --- a/src/tests/nodes/add_i8/input_0.cairo +++ b/src/tests/nodes/add_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - 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: 1, sign: true }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 3, 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: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i8/input_1.cairo b/src/tests/nodes/add_i8/input_1.cairo index e34106166..f135bdbbf 100644 --- a/src/tests/nodes/add_i8/input_1.cairo +++ b/src/tests/nodes/add_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -12,33 +11,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, 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: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: false }); 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: 1, sign: true }); + data.append(i8 { mag: 2, 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: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: true }); + 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: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i8/output_0.cairo b/src/tests/nodes/add_i8/output_0.cairo index d7c2df80a..c46103db2 100644 --- a/src/tests/nodes/add_i8/output_0.cairo +++ b/src/tests/nodes/add_i8/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - 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: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 4, sign: false }); - 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: 1, sign: false }); data.append(i8 { mag: 4, sign: true }); - data.append(i8 { mag: 1, 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: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, 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: 0, 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: true }); - data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i8_broadcast.cairo b/src/tests/nodes/add_i8_broadcast.cairo index f448e5612..83644ae26 100644 --- a/src/tests/nodes/add_i8_broadcast.cairo +++ b/src/tests/nodes/add_i8_broadcast.cairo @@ -1,12 +1,12 @@ -mod input_0; -mod input_1; -mod output_0; +mod input_0; +mod input_1; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorAdd}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,5 +19,4 @@ fn test_add_i8_broadcast() { let y = input_0 + input_1; assert_eq(y, z); -} - +} \ No newline at end of file diff --git a/src/tests/nodes/add_i8_broadcast/input_0.cairo b/src/tests/nodes/add_i8_broadcast/input_0.cairo index f1e87bcf2..8d4d4d989 100644 --- a/src/tests/nodes/add_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/add_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); + 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: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, 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: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 0, sign: false }); 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: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i8_broadcast/input_1.cairo b/src/tests/nodes/add_i8_broadcast/input_1.cairo index c8ee6cf0a..4df125dec 100644 --- a/src/tests/nodes/add_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/add_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - 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 }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_i8_broadcast/output_0.cairo b/src/tests/nodes/add_i8_broadcast/output_0.cairo index d9daef08a..49e3377a1 100644 --- a/src/tests/nodes/add_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/add_i8_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 6, sign: true }); - data.append(i8 { mag: 6, sign: true }); - data.append(i8 { mag: 2, sign: true }); + 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: 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: 4, sign: true }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 4, sign: true }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, 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: 3, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 6, sign: true }); - data.append(i8 { mag: 5, sign: true }); - data.append(i8 { mag: 0, sign: false }); - 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: 3, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_u32.cairo b/src/tests/nodes/add_u32.cairo index c84223cf3..8aa827616 100644 --- a/src/tests/nodes/add_u32.cairo +++ b/src/tests/nodes/add_u32.cairo @@ -1,12 +1,12 @@ -mod input_0; -mod input_1; -mod output_0; +mod input_0; +mod input_1; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_add_u32() { let y = input_0 + input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/add_u32/input_0.cairo b/src/tests/nodes/add_u32/input_0.cairo index 45faa343a..00c1a646a 100644 --- a/src/tests/nodes/add_u32/input_0.cairo +++ b/src/tests/nodes/add_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); - data.append(2); - data.append(1); - data.append(1); - data.append(2); - data.append(2); data.append(1); - data.append(2); data.append(1); data.append(1); data.append(2); - data.append(2); data.append(0); + data.append(1); data.append(0); data.append(2); - data.append(2); - data.append(2); + data.append(0); data.append(1); data.append(2); data.append(2); - data.append(2); data.append(0); + data.append(1); + data.append(1); data.append(2); data.append(0); + data.append(1); data.append(2); + data.append(1); data.append(2); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_u32/input_1.cairo b/src/tests/nodes/add_u32/input_1.cairo index 63126cba0..7b3139dc5 100644 --- a/src/tests/nodes/add_u32/input_1.cairo +++ b/src/tests/nodes/add_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(2); - data.append(2); - data.append(1); - data.append(1); data.append(0); data.append(1); - data.append(2); + data.append(0); data.append(1); data.append(1); data.append(1); data.append(1); data.append(2); data.append(0); - data.append(0); - data.append(0); - data.append(0); + data.append(2); data.append(1); data.append(1); data.append(0); data.append(1); data.append(1); + data.append(2); + data.append(1); data.append(0); + data.append(2); data.append(1); + data.append(2); data.append(1); + data.append(2); + data.append(2); + data.append(2); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_u32/output_0.cairo b/src/tests/nodes/add_u32/output_0.cairo index 8dbd98688..d85c4172f 100644 --- a/src/tests/nodes/add_u32/output_0.cairo +++ b/src/tests/nodes/add_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(3); - data.append(4); - data.append(3); + data.append(1); data.append(2); + data.append(1); data.append(3); + data.append(1); data.append(2); - data.append(2); + data.append(1); data.append(4); - data.append(2); - data.append(2); + data.append(0); + data.append(3); data.append(3); data.append(3); - data.append(2); data.append(0); data.append(2); data.append(2); + data.append(4); + data.append(1); + data.append(1); + data.append(4); data.append(2); - data.append(2); + data.append(4); data.append(3); data.append(2); - data.append(3); - data.append(1); data.append(2); - data.append(1); - data.append(3); data.append(2); - data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_u32_broadcast.cairo b/src/tests/nodes/add_u32_broadcast.cairo index 5db2c7af1..447dba22f 100644 --- a/src/tests/nodes/add_u32_broadcast.cairo +++ b/src/tests/nodes/add_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorAdd}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorAdd}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/add_u32_broadcast/input_0.cairo b/src/tests/nodes/add_u32_broadcast/input_0.cairo index a0258444f..95f2dd5bf 100644 --- a/src/tests/nodes/add_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/add_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(1); - data.append(2); data.append(0); - data.append(1); data.append(2); - data.append(1); data.append(0); - data.append(2); - data.append(2); - data.append(1); - data.append(1); - data.append(2); - data.append(1); data.append(0); data.append(0); data.append(1); data.append(1); data.append(0); data.append(1); + data.append(2); + data.append(0); + data.append(0); data.append(1); data.append(0); data.append(2); + data.append(0); data.append(2); data.append(0); data.append(0); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(0); + data.append(0); + data.append(0); + data.append(0); + data.append(1); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_u32_broadcast/input_1.cairo b/src/tests/nodes/add_u32_broadcast/input_1.cairo index f88126e9d..79e305aa6 100644 --- a/src/tests/nodes/add_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/add_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,9 +10,7 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(2); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/add_u32_broadcast/output_0.cairo b/src/tests/nodes/add_u32_broadcast/output_0.cairo index b5f9c2aee..ed0af4825 100644 --- a/src/tests/nodes/add_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/add_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); - data.append(2); - data.append(3); - data.append(2); - data.append(3); - data.append(4); + data.append(1); data.append(3); + data.append(0); + data.append(0); + data.append(0); data.append(2); - data.append(4); - data.append(3); data.append(2); + data.append(1); data.append(2); - data.append(4); data.append(3); - data.append(2); - data.append(2); + data.append(1); + data.append(0); + data.append(1); + data.append(0); data.append(3); + data.append(1); data.append(3); data.append(1); + data.append(1); data.append(2); + data.append(0); + data.append(0); + data.append(0); + data.append(1); data.append(2); - data.append(2); - data.append(4); - data.append(4); - data.append(2); - data.append(2); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_1D_default.cairo b/src/tests/nodes/argmax_fp16x16_1D_default.cairo index c22f87f99..58b6a68a3 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_default.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_1D_default/input_0.cairo b/src/tests/nodes/argmax_fp16x16_1D_default/input_0.cairo index ccf5463b0..f23d32b16 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_default/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_default/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8257536, sign: false }); - data.append(FixedType { mag: 4128768, sign: false }); - data.append(FixedType { mag: 3997696, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 5832704, sign: true }); + data.append(FP16x16 { mag: 8323072, sign: true }); + data.append(FP16x16 { mag: 983040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_1D_default/output_0.cairo b/src/tests/nodes/argmax_fp16x16_1D_default/output_0.cairo index 01dca80e5..56f9cff0f 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_default/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_default/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_1D_keepdims_false.cairo b/src/tests/nodes/argmax_fp16x16_1D_keepdims_false.cairo index 592884d49..a315caa9b 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/input_0.cairo index 9a8a139d0..f514f7acb 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 6684672, sign: true }); - data.append(FixedType { mag: 7733248, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/output_0.cairo index 01dca80e5..1565560fe 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_keepdims_false/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_1D_last_index.cairo b/src/tests/nodes/argmax_fp16x16_1D_last_index.cairo index 376d9cfdd..c12d59b17 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_last_index.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_1D_last_index/input_0.cairo b/src/tests/nodes/argmax_fp16x16_1D_last_index/input_0.cairo index 7fedeeef6..1ee7073b4 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_last_index/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1310720, sign: false }); - data.append(FixedType { mag: 2293760, sign: false }); - data.append(FixedType { mag: 1245184, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 6094848, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_1D_last_index/output_0.cairo b/src/tests/nodes/argmax_fp16x16_1D_last_index/output_0.cairo index b0d7ca254..1565560fe 100644 --- a/src/tests/nodes/argmax_fp16x16_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_1D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_2D_default.cairo b/src/tests/nodes/argmax_fp16x16_2D_default.cairo index 11f5f32a8..4ce5de2e6 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_default.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_2D_default/input_0.cairo b/src/tests/nodes/argmax_fp16x16_2D_default/input_0.cairo index f3f8a6b0d..cd8f41c61 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_default/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6422528, sign: true }); - data.append(FixedType { mag: 5373952, sign: true }); - data.append(FixedType { mag: 3473408, sign: true }); - data.append(FixedType { mag: 5505024, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 6094848, sign: true }); + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 5767168, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_2D_default/output_0.cairo b/src/tests/nodes/argmax_fp16x16_2D_default/output_0.cairo index 66bf81a47..18c2bb3fe 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_default/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_2D_keepdims_false.cairo b/src/tests/nodes/argmax_fp16x16_2D_keepdims_false.cairo index 302676301..8bbde673a 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/input_0.cairo index 365028b63..f1f9169ed 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2424832, sign: true }); - data.append(FixedType { mag: 458752, sign: false }); - data.append(FixedType { mag: 7405568, sign: true }); - data.append(FixedType { mag: 7340032, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 7143424, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 7471104, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/output_0.cairo index 6cb485b7a..af0e54527 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_2D_last_index.cairo b/src/tests/nodes/argmax_fp16x16_2D_last_index.cairo index 10d18f8c7..f91b15c85 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_last_index.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_2D_last_index/input_0.cairo b/src/tests/nodes/argmax_fp16x16_2D_last_index/input_0.cairo index 66e89c01b..1243376fe 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_last_index/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8126464, sign: true }); - data.append(FixedType { mag: 1114112, sign: false }); - data.append(FixedType { mag: 6619136, sign: false }); - data.append(FixedType { mag: 6488064, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 5373952, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: true }); + data.append(FP16x16 { mag: 4784128, sign: true }); + data.append(FP16x16 { mag: 4587520, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_2D_last_index/output_0.cairo b/src/tests/nodes/argmax_fp16x16_2D_last_index/output_0.cairo index 66bf81a47..4fb656f2a 100644 --- a/src/tests/nodes/argmax_fp16x16_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_3D_default.cairo b/src/tests/nodes/argmax_fp16x16_3D_default.cairo index caea55612..f8c7c1589 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_default.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_3D_default/input_0.cairo b/src/tests/nodes/argmax_fp16x16_3D_default/input_0.cairo index 36c3b1d9c..cacca75ec 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_default/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_default/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7143424, sign: false }); - data.append(FixedType { mag: 7471104, sign: true }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 1835008, sign: false }); - data.append(FixedType { mag: 2883584, sign: false }); - data.append(FixedType { mag: 3014656, sign: true }); - data.append(FixedType { mag: 3145728, sign: true }); - data.append(FixedType { mag: 4521984, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: true }); + data.append(FP16x16 { mag: 8126464, sign: true }); + data.append(FP16x16 { mag: 4194304, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 7340032, sign: true }); + data.append(FP16x16 { mag: 5242880, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_3D_default/output_0.cairo b/src/tests/nodes/argmax_fp16x16_3D_default/output_0.cairo index f8ee9d526..b5312855b 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_default/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_3D_keepdims_false.cairo b/src/tests/nodes/argmax_fp16x16_3D_keepdims_false.cairo index c7eaff0ee..54243bd59 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/input_0.cairo index c4308627f..540435864 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 4128768, sign: false }); - data.append(FixedType { mag: 4390912, sign: true }); - data.append(FixedType { mag: 7274496, sign: true }); - data.append(FixedType { mag: 5111808, sign: true }); - data.append(FixedType { mag: 6684672, sign: true }); - data.append(FixedType { mag: 2818048, sign: true }); - data.append(FixedType { mag: 6553600, sign: true }); - data.append(FixedType { mag: 3407872, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 4063232, sign: true }); + data.append(FP16x16 { mag: 6946816, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: true }); + data.append(FP16x16 { mag: 7340032, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: true }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 6750208, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/output_0.cairo index fec9e9f5b..fdae52d6a 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_3D_last_index.cairo b/src/tests/nodes/argmax_fp16x16_3D_last_index.cairo index 565e757d9..4d633778d 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_last_index.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp16x16_3D_last_index/input_0.cairo b/src/tests/nodes/argmax_fp16x16_3D_last_index/input_0.cairo index 8cca84bf3..57d1f9c07 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_last_index/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 4128768, sign: false }); - data.append(FixedType { mag: 4653056, sign: false }); - data.append(FixedType { mag: 6750208, sign: true }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 6160384, sign: true }); - data.append(FixedType { mag: 4063232, sign: true }); - data.append(FixedType { mag: 3932160, sign: true }); - data.append(FixedType { mag: 8257536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 7340032, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 4980736, sign: false }); + data.append(FP16x16 { mag: 5636096, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: true }); + data.append(FP16x16 { mag: 1310720, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp16x16_3D_last_index/output_0.cairo b/src/tests/nodes/argmax_fp16x16_3D_last_index/output_0.cairo index 11ea0410a..0a783bab9 100644 --- a/src/tests/nodes/argmax_fp16x16_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_fp16x16_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,9 +11,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_1D_default.cairo b/src/tests/nodes/argmax_fp8x23_1D_default.cairo index 86e69fe87..173032fc3 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_default.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_1D_default/input_0.cairo b/src/tests/nodes/argmax_fp8x23_1D_default/input_0.cairo index 3ce6cda7b..f456b6a3e 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_default/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_default/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 754974720, sign: true }); - data.append(FixedType { mag: 763363328, sign: false }); - data.append(FixedType { mag: 427819008, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 578813952, sign: false }); + data.append(FP8x23 { mag: 771751936, sign: true }); + data.append(FP8x23 { mag: 394264576, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_1D_default/output_0.cairo b/src/tests/nodes/argmax_fp8x23_1D_default/output_0.cairo index b0d7ca254..eda6965eb 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_default/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_default/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_1D_keepdims_false.cairo b/src/tests/nodes/argmax_fp8x23_1D_keepdims_false.cairo index b3163eeb1..1dde67779 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/input_0.cairo index 5bd23effc..690040b55 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 629145600, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 989855744, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/output_0.cairo index 01dca80e5..1565560fe 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_keepdims_false/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_1D_last_index.cairo b/src/tests/nodes/argmax_fp8x23_1D_last_index.cairo index 5a3e04851..9b2094325 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_last_index.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_1D_last_index/input_0.cairo b/src/tests/nodes/argmax_fp8x23_1D_last_index/input_0.cairo index 454b17b44..530bfdf08 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_last_index/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 746586112, sign: true }); - data.append(FixedType { mag: 1056964608, sign: true }); - data.append(FixedType { mag: 109051904, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 452984832, sign: true }); + data.append(FP8x23 { mag: 360710144, sign: true }); + data.append(FP8x23 { mag: 192937984, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_1D_last_index/output_0.cairo b/src/tests/nodes/argmax_fp8x23_1D_last_index/output_0.cairo index d2248bdc0..56f9cff0f 100644 --- a/src/tests/nodes/argmax_fp8x23_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_1D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_2D_default.cairo b/src/tests/nodes/argmax_fp8x23_2D_default.cairo index 2c8b3005b..b5e22f49d 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_default.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_2D_default/input_0.cairo b/src/tests/nodes/argmax_fp8x23_2D_default/input_0.cairo index 92b397ae5..1075d4252 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_default/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 142606336, sign: false }); - data.append(FixedType { mag: 411041792, sign: false }); - data.append(FixedType { mag: 956301312, sign: false }); - data.append(FixedType { mag: 385875968, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: true }); + data.append(FP8x23 { mag: 721420288, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_2D_default/output_0.cairo b/src/tests/nodes/argmax_fp8x23_2D_default/output_0.cairo index 66bf81a47..6e8934615 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_default/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_2D_keepdims_false.cairo b/src/tests/nodes/argmax_fp8x23_2D_keepdims_false.cairo index 9183c2472..c8e819a0a 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/input_0.cairo index 932ca9518..15b48a8d1 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 780140544, sign: true }); - data.append(FixedType { mag: 897581056, sign: false }); - data.append(FixedType { mag: 201326592, sign: true }); - data.append(FixedType { mag: 662700032, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 301989888, sign: true }); + data.append(FP8x23 { mag: 595591168, sign: true }); + data.append(FP8x23 { mag: 805306368, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/output_0.cairo index 23fddb1e1..d895ba817 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,8 +8,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_2D_last_index.cairo b/src/tests/nodes/argmax_fp8x23_2D_last_index.cairo index 495f161e8..871ba2be0 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_last_index.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_2D_last_index/input_0.cairo b/src/tests/nodes/argmax_fp8x23_2D_last_index/input_0.cairo index b6e5361d5..d7f58ab66 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_last_index/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 503316480, sign: true }); - data.append(FixedType { mag: 914358272, sign: false }); - data.append(FixedType { mag: 754974720, sign: true }); - data.append(FixedType { mag: 696254464, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 905969664, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_2D_last_index/output_0.cairo b/src/tests/nodes/argmax_fp8x23_2D_last_index/output_0.cairo index 63fe1399a..4fb656f2a 100644 --- a/src/tests/nodes/argmax_fp8x23_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_3D_default.cairo b/src/tests/nodes/argmax_fp8x23_3D_default.cairo index 315624db5..478037446 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_default.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_3D_default/input_0.cairo b/src/tests/nodes/argmax_fp8x23_3D_default/input_0.cairo index 5374e9f63..6d7523e62 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_default/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_default/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1031798784, sign: false }); - data.append(FixedType { mag: 687865856, sign: true }); - data.append(FixedType { mag: 612368384, sign: false }); - data.append(FixedType { mag: 822083584, sign: true }); - data.append(FixedType { mag: 746586112, sign: false }); - data.append(FixedType { mag: 226492416, sign: false }); - data.append(FixedType { mag: 268435456, sign: false }); - data.append(FixedType { mag: 553648128, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: true }); + data.append(FP8x23 { mag: 310378496, sign: true }); + data.append(FP8x23 { mag: 394264576, sign: true }); + data.append(FP8x23 { mag: 75497472, sign: true }); + data.append(FP8x23 { mag: 285212672, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_3D_default/output_0.cairo b/src/tests/nodes/argmax_fp8x23_3D_default/output_0.cairo index db3256051..9763d507f 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_default/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,9 +11,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(1); - data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_3D_keepdims_false.cairo b/src/tests/nodes/argmax_fp8x23_3D_keepdims_false.cairo index 865bb1db8..23414b00c 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/input_0.cairo index 15d2ca47b..af97ff18f 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 746586112, sign: true }); - data.append(FixedType { mag: 721420288, sign: true }); - data.append(FixedType { mag: 796917760, sign: false }); - data.append(FixedType { mag: 1040187392, sign: true }); - data.append(FixedType { mag: 109051904, sign: true }); - data.append(FixedType { mag: 1056964608, sign: false }); - data.append(FixedType { mag: 50331648, sign: false }); - data.append(FixedType { mag: 360710144, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 822083584, sign: true }); + data.append(FP8x23 { mag: 603979776, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: true }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/output_0.cairo index a7ee4b7f0..2094003c4 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(1); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_3D_last_index.cairo b/src/tests/nodes/argmax_fp8x23_3D_last_index.cairo index 13221fecb..940bc9669 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_last_index.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_fp8x23_3D_last_index/input_0.cairo b/src/tests/nodes/argmax_fp8x23_3D_last_index/input_0.cairo index c791c470b..1fe0ce7fe 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_last_index/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 268435456, sign: true }); - data.append(FixedType { mag: 939524096, sign: false }); - data.append(FixedType { mag: 100663296, sign: false }); - data.append(FixedType { mag: 721420288, sign: false }); - data.append(FixedType { mag: 301989888, sign: true }); - data.append(FixedType { mag: 964689920, sign: false }); - data.append(FixedType { mag: 377487360, sign: false }); - data.append(FixedType { mag: 897581056, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 889192448, sign: false }); + data.append(FP8x23 { mag: 813694976, sign: true }); + data.append(FP8x23 { mag: 92274688, sign: true }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 536870912, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_fp8x23_3D_last_index/output_0.cairo b/src/tests/nodes/argmax_fp8x23_3D_last_index/output_0.cairo index 70d6bf379..1cb8809eb 100644 --- a/src/tests/nodes/argmax_fp8x23_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_fp8x23_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,9 +11,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(1); + data.append(0); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_1D_default.cairo b/src/tests/nodes/argmax_i32_1D_default.cairo index 13664eb06..8a5a5d5b5 100644 --- a/src/tests/nodes/argmax_i32_1D_default.cairo +++ b/src/tests/nodes/argmax_i32_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_1D_default/input_0.cairo b/src/tests/nodes/argmax_i32_1D_default/input_0.cairo index 2402b0a39..c12dae57e 100644 --- a/src/tests/nodes/argmax_i32_1D_default/input_0.cairo +++ b/src/tests/nodes/argmax_i32_1D_default/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 37, sign: false }); - data.append(i32 { mag: 56, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 74, sign: true }); + data.append(i32 { mag: 122, sign: false }); + data.append(i32 { mag: 108, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_1D_default/output_0.cairo b/src/tests/nodes/argmax_i32_1D_default/output_0.cairo index b0d7ca254..1565560fe 100644 --- a/src/tests/nodes/argmax_i32_1D_default/output_0.cairo +++ b/src/tests/nodes/argmax_i32_1D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_1D_keepdims_false.cairo b/src/tests/nodes/argmax_i32_1D_keepdims_false.cairo index f7b9bfce1..13dbb21a4 100644 --- a/src/tests/nodes/argmax_i32_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_i32_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_i32_1D_keepdims_false/input_0.cairo index 69022ff99..a465f823f 100644 --- a/src/tests/nodes/argmax_i32_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_i32_1D_keepdims_false/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 8, sign: true }); - data.append(i32 { mag: 26, sign: true }); - data.append(i32 { mag: 62, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 33, sign: true }); + data.append(i32 { mag: 92, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_i32_1D_keepdims_false/output_0.cairo index 01dca80e5..eda6965eb 100644 --- a/src/tests/nodes/argmax_i32_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_i32_1D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_1D_last_index.cairo b/src/tests/nodes/argmax_i32_1D_last_index.cairo index 1e558b4b6..1a1e84a2e 100644 --- a/src/tests/nodes/argmax_i32_1D_last_index.cairo +++ b/src/tests/nodes/argmax_i32_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_1D_last_index/input_0.cairo b/src/tests/nodes/argmax_i32_1D_last_index/input_0.cairo index b2b90e702..76e714b0d 100644 --- a/src/tests/nodes/argmax_i32_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_i32_1D_last_index/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 25, sign: false }); - data.append(i32 { mag: 243, sign: false }); - data.append(i32 { mag: 101, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 232, sign: false }); + data.append(i32 { mag: 204, sign: false }); + data.append(i32 { mag: 189, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_1D_last_index/output_0.cairo b/src/tests/nodes/argmax_i32_1D_last_index/output_0.cairo index b0d7ca254..eda6965eb 100644 --- a/src/tests/nodes/argmax_i32_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_i32_1D_last_index/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_2D_default.cairo b/src/tests/nodes/argmax_i32_2D_default.cairo index 26cfa2017..b2638c25e 100644 --- a/src/tests/nodes/argmax_i32_2D_default.cairo +++ b/src/tests/nodes/argmax_i32_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_2D_default/input_0.cairo b/src/tests/nodes/argmax_i32_2D_default/input_0.cairo index c99652544..4f06af5d9 100644 --- a/src/tests/nodes/argmax_i32_2D_default/input_0.cairo +++ b/src/tests/nodes/argmax_i32_2D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 127, sign: true }); - data.append(i32 { mag: 25, sign: false }); - data.append(i32 { mag: 124, sign: true }); - data.append(i32 { mag: 84, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 103, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_2D_default/output_0.cairo b/src/tests/nodes/argmax_i32_2D_default/output_0.cairo index 66bf81a47..4fb656f2a 100644 --- a/src/tests/nodes/argmax_i32_2D_default/output_0.cairo +++ b/src/tests/nodes/argmax_i32_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_2D_keepdims_false.cairo b/src/tests/nodes/argmax_i32_2D_keepdims_false.cairo index b2621eaf2..c4dd18979 100644 --- a/src/tests/nodes/argmax_i32_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_i32_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_i32_2D_keepdims_false/input_0.cairo index a787ab134..4a58a036d 100644 --- a/src/tests/nodes/argmax_i32_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_i32_2D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 65, sign: true }); - data.append(i32 { mag: 14, sign: true }); - data.append(i32 { mag: 28, sign: true }); - data.append(i32 { mag: 119, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 80, sign: false }); + data.append(i32 { mag: 108, sign: false }); + data.append(i32 { mag: 108, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_i32_2D_keepdims_false/output_0.cairo index 166f1bf27..d895ba817 100644 --- a/src/tests/nodes/argmax_i32_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_i32_2D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_2D_last_index.cairo b/src/tests/nodes/argmax_i32_2D_last_index.cairo index a0ed205c0..93143b8e3 100644 --- a/src/tests/nodes/argmax_i32_2D_last_index.cairo +++ b/src/tests/nodes/argmax_i32_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_2D_last_index/input_0.cairo b/src/tests/nodes/argmax_i32_2D_last_index/input_0.cairo index bc9b7f9f2..0199493ad 100644 --- a/src/tests/nodes/argmax_i32_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_i32_2D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 12, sign: false }); - data.append(i32 { mag: 15, sign: false }); - data.append(i32 { mag: 82, sign: false }); - data.append(i32 { mag: 25, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 127, sign: true }); + data.append(i32 { mag: 43, sign: true }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 127, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_2D_last_index/output_0.cairo b/src/tests/nodes/argmax_i32_2D_last_index/output_0.cairo index 66bf81a47..5541876d4 100644 --- a/src/tests/nodes/argmax_i32_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_i32_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_3D_default.cairo b/src/tests/nodes/argmax_i32_3D_default.cairo index 070092976..669db2212 100644 --- a/src/tests/nodes/argmax_i32_3D_default.cairo +++ b/src/tests/nodes/argmax_i32_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_3D_default/input_0.cairo b/src/tests/nodes/argmax_i32_3D_default/input_0.cairo index 4c9828375..f534aa0f0 100644 --- a/src/tests/nodes/argmax_i32_3D_default/input_0.cairo +++ b/src/tests/nodes/argmax_i32_3D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 39, sign: true }); - data.append(i32 { mag: 30, sign: false }); - data.append(i32 { mag: 65, sign: false }); - data.append(i32 { mag: 96, sign: false }); - data.append(i32 { mag: 124, sign: false }); - data.append(i32 { mag: 63, sign: true }); - data.append(i32 { mag: 95, sign: false }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 97, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 31, sign: true }); + data.append(i32 { mag: 120, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 70, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_3D_default/output_0.cairo b/src/tests/nodes/argmax_i32_3D_default/output_0.cairo index 8caab753d..a698fcbf9 100644 --- a/src/tests/nodes/argmax_i32_3D_default/output_0.cairo +++ b/src/tests/nodes/argmax_i32_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_3D_keepdims_false.cairo b/src/tests/nodes/argmax_i32_3D_keepdims_false.cairo index df885177c..7b3d014fa 100644 --- a/src/tests/nodes/argmax_i32_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_i32_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_i32_3D_keepdims_false/input_0.cairo index 201e925e4..bdcee588b 100644 --- a/src/tests/nodes/argmax_i32_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_i32_3D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 100, sign: true }); - data.append(i32 { mag: 96, sign: false }); - data.append(i32 { mag: 5, sign: false }); - data.append(i32 { mag: 30, sign: true }); - data.append(i32 { mag: 13, sign: false }); - data.append(i32 { mag: 123, sign: true }); - data.append(i32 { mag: 60, sign: true }); - data.append(i32 { mag: 59, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 17, sign: true }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 84, sign: false }); + data.append(i32 { mag: 85, sign: true }); + data.append(i32 { mag: 97, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 115, sign: true }); + data.append(i32 { mag: 124, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_i32_3D_keepdims_false/output_0.cairo index 71366ef08..0cc7de207 100644 --- a/src/tests/nodes/argmax_i32_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_i32_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,8 +11,6 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_3D_last_index.cairo b/src/tests/nodes/argmax_i32_3D_last_index.cairo index b36c519e1..2855ba0cd 100644 --- a/src/tests/nodes/argmax_i32_3D_last_index.cairo +++ b/src/tests/nodes/argmax_i32_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i32_3D_last_index/input_0.cairo b/src/tests/nodes/argmax_i32_3D_last_index/input_0.cairo index 4d6cb014f..ebcfa868e 100644 --- a/src/tests/nodes/argmax_i32_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_i32_3D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 21, sign: true }); - data.append(i32 { mag: 39, sign: false }); - data.append(i32 { mag: 79, sign: true }); - data.append(i32 { mag: 123, sign: false }); - data.append(i32 { mag: 56, sign: false }); - data.append(i32 { mag: 12, sign: true }); - data.append(i32 { mag: 77, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 7, sign: true }); + data.append(i32 { mag: 88, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 72, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 87, sign: false }); + data.append(i32 { mag: 67, sign: true }); + data.append(i32 { mag: 110, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i32_3D_last_index/output_0.cairo b/src/tests/nodes/argmax_i32_3D_last_index/output_0.cairo index 8905ac83f..49547e6c9 100644 --- a/src/tests/nodes/argmax_i32_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_i32_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,10 +10,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(1); + data.append(0); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_1D_default.cairo b/src/tests/nodes/argmax_i8_1D_default.cairo index e04a6011c..14112acf6 100644 --- a/src/tests/nodes/argmax_i8_1D_default.cairo +++ b/src/tests/nodes/argmax_i8_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_1D_default/input_0.cairo b/src/tests/nodes/argmax_i8_1D_default/input_0.cairo index fd95f8346..011898e90 100644 --- a/src/tests/nodes/argmax_i8_1D_default/input_0.cairo +++ b/src/tests/nodes/argmax_i8_1D_default/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 69, sign: false }); - data.append(i8 { mag: 58, sign: true }); - data.append(i8 { mag: 52, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 67, sign: true }); + data.append(i8 { mag: 109, sign: true }); + data.append(i8 { mag: 77, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_1D_default/output_0.cairo b/src/tests/nodes/argmax_i8_1D_default/output_0.cairo index 01dca80e5..eda6965eb 100644 --- a/src/tests/nodes/argmax_i8_1D_default/output_0.cairo +++ b/src/tests/nodes/argmax_i8_1D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_1D_keepdims_false.cairo b/src/tests/nodes/argmax_i8_1D_keepdims_false.cairo index 064e5f9a3..05baf1c96 100644 --- a/src/tests/nodes/argmax_i8_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_i8_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_i8_1D_keepdims_false/input_0.cairo index a22c12e1e..8cec9600d 100644 --- a/src/tests/nodes/argmax_i8_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_i8_1D_keepdims_false/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 120, sign: false }); - data.append(i8 { mag: 116, sign: false }); - data.append(i8 { mag: 53, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 78, sign: false }); + data.append(i8 { mag: 118, sign: true }); + data.append(i8 { mag: 52, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_i8_1D_keepdims_false/output_0.cairo index 01dca80e5..eda6965eb 100644 --- a/src/tests/nodes/argmax_i8_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_i8_1D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_1D_last_index.cairo b/src/tests/nodes/argmax_i8_1D_last_index.cairo index 4c0ab844c..f4c00289c 100644 --- a/src/tests/nodes/argmax_i8_1D_last_index.cairo +++ b/src/tests/nodes/argmax_i8_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_1D_last_index/input_0.cairo b/src/tests/nodes/argmax_i8_1D_last_index/input_0.cairo index ddf1843cf..a8c356d5e 100644 --- a/src/tests/nodes/argmax_i8_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_i8_1D_last_index/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 94, sign: true }); - data.append(i8 { mag: 81, sign: true }); - data.append(i8 { mag: 119, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 33, sign: false }); + data.append(i8 { mag: 18, sign: false }); + data.append(i8 { mag: 63, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_1D_last_index/output_0.cairo b/src/tests/nodes/argmax_i8_1D_last_index/output_0.cairo index d2248bdc0..eda6965eb 100644 --- a/src/tests/nodes/argmax_i8_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_i8_1D_last_index/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_2D_default.cairo b/src/tests/nodes/argmax_i8_2D_default.cairo index ddb76bb6b..d0b9881cc 100644 --- a/src/tests/nodes/argmax_i8_2D_default.cairo +++ b/src/tests/nodes/argmax_i8_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_2D_default/input_0.cairo b/src/tests/nodes/argmax_i8_2D_default/input_0.cairo index eb3452d72..aba762fd1 100644 --- a/src/tests/nodes/argmax_i8_2D_default/input_0.cairo +++ b/src/tests/nodes/argmax_i8_2D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 95, sign: true }); - data.append(i8 { mag: 17, sign: false }); - data.append(i8 { mag: 118, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 105, sign: true }); + data.append(i8 { mag: 39, sign: false }); + data.append(i8 { mag: 80, sign: true }); + data.append(i8 { mag: 123, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_2D_default/output_0.cairo b/src/tests/nodes/argmax_i8_2D_default/output_0.cairo index 66bf81a47..5541876d4 100644 --- a/src/tests/nodes/argmax_i8_2D_default/output_0.cairo +++ b/src/tests/nodes/argmax_i8_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_2D_keepdims_false.cairo b/src/tests/nodes/argmax_i8_2D_keepdims_false.cairo index a174f99ad..06c55c802 100644 --- a/src/tests/nodes/argmax_i8_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_i8_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_i8_2D_keepdims_false/input_0.cairo index eb713cb7d..6d532e7b6 100644 --- a/src/tests/nodes/argmax_i8_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_i8_2D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 80, sign: true }); - data.append(i8 { mag: 111, sign: true }); - data.append(i8 { mag: 47, sign: false }); - data.append(i8 { mag: 71, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 10, sign: false }); + data.append(i8 { mag: 127, sign: true }); + data.append(i8 { mag: 94, sign: true }); + data.append(i8 { mag: 66, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_i8_2D_keepdims_false/output_0.cairo index 166f1bf27..eb0060f3e 100644 --- a/src/tests/nodes/argmax_i8_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_i8_2D_keepdims_false/output_0.cairo @@ -1,16 +1,13 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); + data.append(0); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_2D_last_index.cairo b/src/tests/nodes/argmax_i8_2D_last_index.cairo index f96a9d980..6a9ebb9bc 100644 --- a/src/tests/nodes/argmax_i8_2D_last_index.cairo +++ b/src/tests/nodes/argmax_i8_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_2D_last_index/input_0.cairo b/src/tests/nodes/argmax_i8_2D_last_index/input_0.cairo index bb8f95c61..ab4f8f6fa 100644 --- a/src/tests/nodes/argmax_i8_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_i8_2D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 112, sign: false }); - data.append(i8 { mag: 67, sign: false }); - data.append(i8 { mag: 100, sign: true }); - data.append(i8 { mag: 115, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 96, sign: true }); + data.append(i8 { mag: 84, sign: true }); + data.append(i8 { mag: 15, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_2D_last_index/output_0.cairo b/src/tests/nodes/argmax_i8_2D_last_index/output_0.cairo index 63fe1399a..6e8934615 100644 --- a/src/tests/nodes/argmax_i8_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_i8_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_3D_default.cairo b/src/tests/nodes/argmax_i8_3D_default.cairo index 083f721ce..fd4bfaf05 100644 --- a/src/tests/nodes/argmax_i8_3D_default.cairo +++ b/src/tests/nodes/argmax_i8_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_3D_default/input_0.cairo b/src/tests/nodes/argmax_i8_3D_default/input_0.cairo index 479527fba..9f5b78aea 100644 --- a/src/tests/nodes/argmax_i8_3D_default/input_0.cairo +++ b/src/tests/nodes/argmax_i8_3D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 29, sign: false }); - data.append(i8 { mag: 35, sign: true }); - data.append(i8 { mag: 76, sign: false }); - data.append(i8 { mag: 117, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 104, sign: true }); - data.append(i8 { mag: 57, sign: true }); - data.append(i8 { mag: 61, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 17, sign: false }); + data.append(i8 { mag: 34, sign: true }); + data.append(i8 { mag: 12, sign: true }); + data.append(i8 { mag: 112, sign: false }); + data.append(i8 { mag: 10, sign: false }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 49, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_3D_default/output_0.cairo b/src/tests/nodes/argmax_i8_3D_default/output_0.cairo index f89a23dc4..47371f78a 100644 --- a/src/tests/nodes/argmax_i8_3D_default/output_0.cairo +++ b/src/tests/nodes/argmax_i8_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,9 +11,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_3D_keepdims_false.cairo b/src/tests/nodes/argmax_i8_3D_keepdims_false.cairo index c9c0b0bd5..c477a9858 100644 --- a/src/tests/nodes/argmax_i8_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_i8_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_i8_3D_keepdims_false/input_0.cairo index dfddd4b2e..7086d8dd8 100644 --- a/src/tests/nodes/argmax_i8_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_i8_3D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 118, sign: false }); - data.append(i8 { mag: 72, sign: false }); - data.append(i8 { mag: 115, sign: false }); - data.append(i8 { mag: 60, sign: false }); - data.append(i8 { mag: 48, sign: false }); - data.append(i8 { mag: 51, sign: false }); - data.append(i8 { mag: 112, sign: true }); - data.append(i8 { mag: 72, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 25, sign: true }); + data.append(i8 { mag: 88, sign: false }); + data.append(i8 { mag: 44, sign: true }); + data.append(i8 { mag: 124, sign: false }); + data.append(i8 { mag: 35, sign: false }); + data.append(i8 { mag: 21, sign: false }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 39, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_i8_3D_keepdims_false/output_0.cairo index 619c5c756..b7f7a3c83 100644 --- a/src/tests/nodes/argmax_i8_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_i8_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(1); data.append(0); + data.append(1); data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_3D_last_index.cairo b/src/tests/nodes/argmax_i8_3D_last_index.cairo index c7b81b67d..1c1006fa6 100644 --- a/src/tests/nodes/argmax_i8_3D_last_index.cairo +++ b/src/tests/nodes/argmax_i8_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_i8_3D_last_index/input_0.cairo b/src/tests/nodes/argmax_i8_3D_last_index/input_0.cairo index 8c776495d..a18462dc9 100644 --- a/src/tests/nodes/argmax_i8_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_i8_3D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 14, sign: false }); - data.append(i8 { mag: 43, sign: true }); - data.append(i8 { mag: 126, sign: true }); - data.append(i8 { mag: 49, sign: false }); - data.append(i8 { mag: 127, sign: true }); - data.append(i8 { mag: 88, sign: true }); - data.append(i8 { mag: 79, sign: false }); - data.append(i8 { mag: 61, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 116, sign: true }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 10, sign: false }); + data.append(i8 { mag: 44, sign: false }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 87, sign: false }); + data.append(i8 { mag: 87, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_i8_3D_last_index/output_0.cairo b/src/tests/nodes/argmax_i8_3D_last_index/output_0.cairo index 5ee5ea034..9763d507f 100644 --- a/src/tests/nodes/argmax_i8_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_i8_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,10 +10,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_1D_default.cairo b/src/tests/nodes/argmax_u32_1D_default.cairo index 9a7197278..0bbfe1dc7 100644 --- a/src/tests/nodes/argmax_u32_1D_default.cairo +++ b/src/tests/nodes/argmax_u32_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_1D_default/input_0.cairo b/src/tests/nodes/argmax_u32_1D_default/input_0.cairo index 78a92fc42..baf00496a 100644 --- a/src/tests/nodes/argmax_u32_1D_default/input_0.cairo +++ b/src/tests/nodes/argmax_u32_1D_default/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(99); - data.append(86); - data.append(10); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(22); + data.append(149); + data.append(157); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_1D_default/output_0.cairo b/src/tests/nodes/argmax_u32_1D_default/output_0.cairo index 01dca80e5..56f9cff0f 100644 --- a/src/tests/nodes/argmax_u32_1D_default/output_0.cairo +++ b/src/tests/nodes/argmax_u32_1D_default/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_1D_keepdims_false.cairo b/src/tests/nodes/argmax_u32_1D_keepdims_false.cairo index 8e088f052..1b4410a8d 100644 --- a/src/tests/nodes/argmax_u32_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_u32_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_u32_1D_keepdims_false/input_0.cairo index 17ff22242..3508dd9f2 100644 --- a/src/tests/nodes/argmax_u32_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_u32_1D_keepdims_false/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(146); - data.append(163); - data.append(109); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(159); + data.append(31); + data.append(202); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_u32_1D_keepdims_false/output_0.cairo index b0d7ca254..56f9cff0f 100644 --- a/src/tests/nodes/argmax_u32_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_u32_1D_keepdims_false/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_1D_last_index.cairo b/src/tests/nodes/argmax_u32_1D_last_index.cairo index dfff69a2a..0065e3f25 100644 --- a/src/tests/nodes/argmax_u32_1D_last_index.cairo +++ b/src/tests/nodes/argmax_u32_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_1D_last_index/input_0.cairo b/src/tests/nodes/argmax_u32_1D_last_index/input_0.cairo index 7f27c65ee..28eabceaf 100644 --- a/src/tests/nodes/argmax_u32_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_u32_1D_last_index/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(2); - data.append(116); - data.append(115); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(177); + data.append(78); + data.append(187); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_1D_last_index/output_0.cairo b/src/tests/nodes/argmax_u32_1D_last_index/output_0.cairo index b0d7ca254..56f9cff0f 100644 --- a/src/tests/nodes/argmax_u32_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_u32_1D_last_index/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_2D_default.cairo b/src/tests/nodes/argmax_u32_2D_default.cairo index f0d2af318..e2416badc 100644 --- a/src/tests/nodes/argmax_u32_2D_default.cairo +++ b/src/tests/nodes/argmax_u32_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_2D_default/input_0.cairo b/src/tests/nodes/argmax_u32_2D_default/input_0.cairo index c1c34ece2..90fd94e8b 100644 --- a/src/tests/nodes/argmax_u32_2D_default/input_0.cairo +++ b/src/tests/nodes/argmax_u32_2D_default/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(99); - data.append(74); - data.append(145); - data.append(211); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(208); + data.append(4); + data.append(108); + data.append(60); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_2D_default/output_0.cairo b/src/tests/nodes/argmax_u32_2D_default/output_0.cairo index b3594e764..6e8934615 100644 --- a/src/tests/nodes/argmax_u32_2D_default/output_0.cairo +++ b/src/tests/nodes/argmax_u32_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(0); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_2D_keepdims_false.cairo b/src/tests/nodes/argmax_u32_2D_keepdims_false.cairo index 196eafb5c..ddda36dda 100644 --- a/src/tests/nodes/argmax_u32_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_u32_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_u32_2D_keepdims_false/input_0.cairo index 71d76e1e6..a2c436dbd 100644 --- a/src/tests/nodes/argmax_u32_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_u32_2D_keepdims_false/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(68); - data.append(141); - data.append(8); - data.append(59); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(229); + data.append(129); + data.append(171); + data.append(10); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_u32_2D_keepdims_false/output_0.cairo index 6cb485b7a..af0e54527 100644 --- a/src/tests/nodes/argmax_u32_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_u32_2D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_2D_last_index.cairo b/src/tests/nodes/argmax_u32_2D_last_index.cairo index 993afcf0b..97f5bd13b 100644 --- a/src/tests/nodes/argmax_u32_2D_last_index.cairo +++ b/src/tests/nodes/argmax_u32_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_2D_last_index/input_0.cairo b/src/tests/nodes/argmax_u32_2D_last_index/input_0.cairo index eb9647585..91083cbff 100644 --- a/src/tests/nodes/argmax_u32_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_u32_2D_last_index/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(194); - data.append(52); - data.append(102); - data.append(202); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(162); + data.append(67); + data.append(147); + data.append(150); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_2D_last_index/output_0.cairo b/src/tests/nodes/argmax_u32_2D_last_index/output_0.cairo index d3bc368dc..6e8934615 100644 --- a/src/tests/nodes/argmax_u32_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_u32_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_3D_default.cairo b/src/tests/nodes/argmax_u32_3D_default.cairo index 6e3fa873d..2115a9d15 100644 --- a/src/tests/nodes/argmax_u32_3D_default.cairo +++ b/src/tests/nodes/argmax_u32_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_3D_default/input_0.cairo b/src/tests/nodes/argmax_u32_3D_default/input_0.cairo index 1c5c0c66e..cc7a436d2 100644 --- a/src/tests/nodes/argmax_u32_3D_default/input_0.cairo +++ b/src/tests/nodes/argmax_u32_3D_default/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(205); - data.append(21); - data.append(93); - data.append(199); - data.append(44); - data.append(76); - data.append(60); - data.append(73); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(113); + data.append(207); + data.append(34); + data.append(249); + data.append(186); + data.append(56); + data.append(153); + data.append(92); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_3D_default/output_0.cairo b/src/tests/nodes/argmax_u32_3D_default/output_0.cairo index f8ee9d526..b0d2c103c 100644 --- a/src/tests/nodes/argmax_u32_3D_default/output_0.cairo +++ b/src/tests/nodes/argmax_u32_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); data.append(0); + data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_3D_keepdims_false.cairo b/src/tests/nodes/argmax_u32_3D_keepdims_false.cairo index e444f2574..402adf2d7 100644 --- a/src/tests/nodes/argmax_u32_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmax_u32_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmax_u32_3D_keepdims_false/input_0.cairo index 35cd5d207..00aba455e 100644 --- a/src/tests/nodes/argmax_u32_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmax_u32_3D_keepdims_false/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(126); - data.append(36); - data.append(190); - data.append(190); - data.append(114); - data.append(158); - data.append(103); - data.append(89); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(37); + data.append(156); + data.append(115); + data.append(212); + data.append(45); + data.append(237); + data.append(24); + data.append(136); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmax_u32_3D_keepdims_false/output_0.cairo index 1b8e294d7..386b678ef 100644 --- a/src/tests/nodes/argmax_u32_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmax_u32_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); + data.append(1); data.append(1); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_3D_last_index.cairo b/src/tests/nodes/argmax_u32_3D_last_index.cairo index 4bf18139d..a670579ec 100644 --- a/src/tests/nodes/argmax_u32_3D_last_index.cairo +++ b/src/tests/nodes/argmax_u32_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmax_u32_3D_last_index/input_0.cairo b/src/tests/nodes/argmax_u32_3D_last_index/input_0.cairo index 7f51637ff..f9a0aa88e 100644 --- a/src/tests/nodes/argmax_u32_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmax_u32_3D_last_index/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(238); - data.append(156); - data.append(136); - data.append(146); - data.append(150); - data.append(69); - data.append(43); - data.append(25); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(39); + data.append(86); + data.append(127); + data.append(185); + data.append(36); + data.append(197); + data.append(160); + data.append(37); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmax_u32_3D_last_index/output_0.cairo b/src/tests/nodes/argmax_u32_3D_last_index/output_0.cairo index 583e7fa91..1970e5f5a 100644 --- a/src/tests/nodes/argmax_u32_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmax_u32_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,10 +10,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); + data.append(1); + data.append(1); data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_1D_default.cairo b/src/tests/nodes/argmin_fp16x16_1D_default.cairo index 854c8bf5b..1b1ca67e6 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_default.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_1D_default/input_0.cairo b/src/tests/nodes/argmin_fp16x16_1D_default/input_0.cairo index 03efaa1c8..dcc350ee5 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_default/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_default/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7012352, sign: true }); - data.append(FixedType { mag: 6029312, sign: false }); - data.append(FixedType { mag: 7340032, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 1114112, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_1D_default/output_0.cairo b/src/tests/nodes/argmin_fp16x16_1D_default/output_0.cairo index d2248bdc0..eda6965eb 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_default/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_default/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_1D_keepdims_false.cairo b/src/tests/nodes/argmin_fp16x16_1D_keepdims_false.cairo index ad2a993a8..699b99db3 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/input_0.cairo index ede30630e..dd5476cd9 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5111808, sign: true }); - data.append(FixedType { mag: 5242880, sign: true }); - data.append(FixedType { mag: 2818048, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 7929856, sign: false }); + data.append(FP16x16 { mag: 7471104, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/output_0.cairo index b0d7ca254..56f9cff0f 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_keepdims_false/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_1D_last_index.cairo b/src/tests/nodes/argmin_fp16x16_1D_last_index.cairo index 8a38b5d2f..52d96accc 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_last_index.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_1D_last_index/input_0.cairo b/src/tests/nodes/argmin_fp16x16_1D_last_index/input_0.cairo index 14b976476..c5dfb9f2b 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_last_index/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 3670016, sign: false }); - data.append(FixedType { mag: 6488064, sign: false }); - data.append(FixedType { mag: 7471104, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 4063232, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_1D_last_index/output_0.cairo b/src/tests/nodes/argmin_fp16x16_1D_last_index/output_0.cairo index d2248bdc0..1565560fe 100644 --- a/src/tests/nodes/argmin_fp16x16_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_1D_last_index/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_2D_default.cairo b/src/tests/nodes/argmin_fp16x16_2D_default.cairo index 35bb64258..8890ede98 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_default.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_2D_default/input_0.cairo b/src/tests/nodes/argmin_fp16x16_2D_default/input_0.cairo index 7f5992462..456fb9a91 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_default/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5898240, sign: false }); - data.append(FixedType { mag: 1245184, sign: false }); - data.append(FixedType { mag: 7208960, sign: false }); - data.append(FixedType { mag: 8060928, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 4718592, sign: true }); + data.append(FP16x16 { mag: 8060928, sign: false }); + data.append(FP16x16 { mag: 7208960, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_2D_default/output_0.cairo b/src/tests/nodes/argmin_fp16x16_2D_default/output_0.cairo index 63fe1399a..18c2bb3fe 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_default/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_2D_keepdims_false.cairo b/src/tests/nodes/argmin_fp16x16_2D_keepdims_false.cairo index e6c023ce6..115a5dbd5 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/input_0.cairo index de8f8de9a..8b660c61b 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6946816, sign: false }); - data.append(FixedType { mag: 6029312, sign: false }); - data.append(FixedType { mag: 4980736, sign: true }); - data.append(FixedType { mag: 2686976, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 6422528, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: true }); + data.append(FP16x16 { mag: 6553600, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/output_0.cairo index 166f1bf27..d895ba817 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_2D_last_index.cairo b/src/tests/nodes/argmin_fp16x16_2D_last_index.cairo index 5b506926e..151f78614 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_last_index.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_2D_last_index/input_0.cairo b/src/tests/nodes/argmin_fp16x16_2D_last_index/input_0.cairo index ab70fef51..c42a678da 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_last_index/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7274496, sign: true }); - data.append(FixedType { mag: 1376256, sign: true }); - data.append(FixedType { mag: 4259840, sign: false }); - data.append(FixedType { mag: 4784128, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 8060928, sign: true }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 8192000, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_2D_last_index/output_0.cairo b/src/tests/nodes/argmin_fp16x16_2D_last_index/output_0.cairo index 63fe1399a..6e8934615 100644 --- a/src/tests/nodes/argmin_fp16x16_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_3D_default.cairo b/src/tests/nodes/argmin_fp16x16_3D_default.cairo index 1feb6c782..7a69bd614 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_default.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_3D_default/input_0.cairo b/src/tests/nodes/argmin_fp16x16_3D_default/input_0.cairo index c53a10c5a..ea0cdb441 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_default/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_default/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7995392, sign: false }); - data.append(FixedType { mag: 3014656, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 4128768, sign: false }); - data.append(FixedType { mag: 5046272, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 4456448, sign: true }); - data.append(FixedType { mag: 5570560, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 6422528, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: true }); + data.append(FP16x16 { mag: 4390912, sign: true }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 4784128, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_3D_default/output_0.cairo b/src/tests/nodes/argmin_fp16x16_3D_default/output_0.cairo index ec0386ae5..bfea2aecb 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_default/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,10 +10,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(0); - data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_3D_keepdims_false.cairo b/src/tests/nodes/argmin_fp16x16_3D_keepdims_false.cairo index 6fbe949ca..1c3ed9e49 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/input_0.cairo index 0ab50c68c..d4ceeab3f 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6553600, sign: true }); - data.append(FixedType { mag: 5570560, sign: false }); - data.append(FixedType { mag: 2097152, sign: true }); - data.append(FixedType { mag: 7602176, sign: true }); - data.append(FixedType { mag: 5373952, sign: false }); - data.append(FixedType { mag: 1179648, sign: true }); - data.append(FixedType { mag: 2162688, sign: true }); - data.append(FixedType { mag: 3080192, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 7929856, sign: true }); + data.append(FP16x16 { mag: 2228224, sign: true }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: true }); + data.append(FP16x16 { mag: 1638400, sign: true }); + data.append(FP16x16 { mag: 6815744, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/output_0.cairo index f8f4c946c..ea6cc3c4d 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); + data.append(0); data.append(1); data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_3D_last_index.cairo b/src/tests/nodes/argmin_fp16x16_3D_last_index.cairo index b4af55d09..66fa5aee2 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_last_index.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp16x16_3D_last_index/input_0.cairo b/src/tests/nodes/argmin_fp16x16_3D_last_index/input_0.cairo index fd4ddd1ca..21be41b2b 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_last_index/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6553600, sign: false }); - data.append(FixedType { mag: 7667712, sign: true }); - data.append(FixedType { mag: 6815744, sign: true }); - data.append(FixedType { mag: 6488064, sign: true }); - data.append(FixedType { mag: 7274496, sign: false }); - data.append(FixedType { mag: 6750208, sign: false }); - data.append(FixedType { mag: 7405568, sign: false }); - data.append(FixedType { mag: 720896, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 7471104, sign: false }); + data.append(FP16x16 { mag: 4063232, sign: true }); + data.append(FP16x16 { mag: 5111808, sign: true }); + data.append(FP16x16 { mag: 1310720, sign: true }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 7274496, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp16x16_3D_last_index/output_0.cairo b/src/tests/nodes/argmin_fp16x16_3D_last_index/output_0.cairo index 583e7fa91..9763d507f 100644 --- a/src/tests/nodes/argmin_fp16x16_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_fp16x16_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,10 +10,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_1D_default.cairo b/src/tests/nodes/argmin_fp8x23_1D_default.cairo index 287586722..2e591e8dc 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_default.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_1D_default/input_0.cairo b/src/tests/nodes/argmin_fp8x23_1D_default/input_0.cairo index 1b68bc674..5b477194d 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_default/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_default/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 889192448, sign: false }); - data.append(FixedType { mag: 914358272, sign: true }); - data.append(FixedType { mag: 570425344, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 956301312, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_1D_default/output_0.cairo b/src/tests/nodes/argmin_fp8x23_1D_default/output_0.cairo index b0d7ca254..56f9cff0f 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_default/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_default/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_1D_keepdims_false.cairo b/src/tests/nodes/argmin_fp8x23_1D_keepdims_false.cairo index 0504e8091..21b291ae2 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/input_0.cairo index 390ac3335..b1b78c84d 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 746586112, sign: true }); - data.append(FixedType { mag: 360710144, sign: true }); - data.append(FixedType { mag: 956301312, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 822083584, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 897581056, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/output_0.cairo index 01dca80e5..1565560fe 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_keepdims_false/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_1D_last_index.cairo b/src/tests/nodes/argmin_fp8x23_1D_last_index.cairo index 32247295f..52fac5d7c 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_last_index.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_1D_last_index/input_0.cairo b/src/tests/nodes/argmin_fp8x23_1D_last_index/input_0.cairo index e38f6cc5f..5d61a20e0 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_last_index/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 805306368, sign: true }); - data.append(FixedType { mag: 159383552, sign: true }); - data.append(FixedType { mag: 335544320, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 738197504, sign: true }); + data.append(FP8x23 { mag: 301989888, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_1D_last_index/output_0.cairo b/src/tests/nodes/argmin_fp8x23_1D_last_index/output_0.cairo index 01dca80e5..1565560fe 100644 --- a/src/tests/nodes/argmin_fp8x23_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_1D_last_index/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_2D_default.cairo b/src/tests/nodes/argmin_fp8x23_2D_default.cairo index 11bd582f5..e0f07cc0c 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_default.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_2D_default/input_0.cairo b/src/tests/nodes/argmin_fp8x23_2D_default/input_0.cairo index 1bc363146..750ea8e95 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_default/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 125829120, sign: true }); - data.append(FixedType { mag: 142606336, sign: false }); - data.append(FixedType { mag: 595591168, sign: false }); - data.append(FixedType { mag: 570425344, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 788529152, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 905969664, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_2D_default/output_0.cairo b/src/tests/nodes/argmin_fp8x23_2D_default/output_0.cairo index d3bc368dc..18c2bb3fe 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_default/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_2D_keepdims_false.cairo b/src/tests/nodes/argmin_fp8x23_2D_keepdims_false.cairo index b33c580d4..365e0fd30 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/input_0.cairo index 1f42a0262..448042f28 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 595591168, sign: true }); - data.append(FixedType { mag: 922746880, sign: true }); - data.append(FixedType { mag: 75497472, sign: true }); - data.append(FixedType { mag: 360710144, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 704643072, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 369098752, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/output_0.cairo index 6cb485b7a..2f17092da 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_keepdims_false/output_0.cairo @@ -1,16 +1,13 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); + data.append(1); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_2D_last_index.cairo b/src/tests/nodes/argmin_fp8x23_2D_last_index.cairo index f83b14c74..3eac0de88 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_last_index.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_2D_last_index/input_0.cairo b/src/tests/nodes/argmin_fp8x23_2D_last_index/input_0.cairo index 67b9240b8..87198252b 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_last_index/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 545259520, sign: true }); - data.append(FixedType { mag: 763363328, sign: true }); - data.append(FixedType { mag: 679477248, sign: false }); - data.append(FixedType { mag: 343932928, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 394264576, sign: true }); + data.append(FP8x23 { mag: 922746880, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 738197504, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_2D_last_index/output_0.cairo b/src/tests/nodes/argmin_fp8x23_2D_last_index/output_0.cairo index 63fe1399a..6e8934615 100644 --- a/src/tests/nodes/argmin_fp8x23_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_3D_default.cairo b/src/tests/nodes/argmin_fp8x23_3D_default.cairo index e353b08f5..29bd82f7c 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_default.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_3D_default/input_0.cairo b/src/tests/nodes/argmin_fp8x23_3D_default/input_0.cairo index 489ba0f08..cf05b975c 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_default/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_default/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 134217728, sign: true }); - data.append(FixedType { mag: 511705088, sign: true }); - data.append(FixedType { mag: 637534208, sign: false }); - data.append(FixedType { mag: 167772160, sign: true }); - data.append(FixedType { mag: 746586112, sign: false }); - data.append(FixedType { mag: 293601280, sign: true }); - data.append(FixedType { mag: 461373440, sign: true }); - data.append(FixedType { mag: 402653184, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 922746880, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 754974720, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 947912704, sign: true }); + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_3D_default/output_0.cairo b/src/tests/nodes/argmin_fp8x23_3D_default/output_0.cairo index 11ea0410a..8851cfbb7 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_default/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_3D_keepdims_false.cairo b/src/tests/nodes/argmin_fp8x23_3D_keepdims_false.cairo index d7e5fccf2..f5478105e 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/input_0.cairo index 1478351bf..08e88c4de 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 92274688, sign: false }); - data.append(FixedType { mag: 218103808, sign: false }); - data.append(FixedType { mag: 545259520, sign: true }); - data.append(FixedType { mag: 855638016, sign: false }); - data.append(FixedType { mag: 377487360, sign: true }); - data.append(FixedType { mag: 209715200, sign: true }); - data.append(FixedType { mag: 92274688, sign: true }); - data.append(FixedType { mag: 654311424, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 889192448, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: false }); + data.append(FP8x23 { mag: 729808896, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 847249408, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/output_0.cairo index a7ee4b7f0..386b678ef 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,8 +11,6 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_3D_last_index.cairo b/src/tests/nodes/argmin_fp8x23_3D_last_index.cairo index ec01cb626..fcf5ebef3 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_last_index.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_fp8x23_3D_last_index/input_0.cairo b/src/tests/nodes/argmin_fp8x23_3D_last_index/input_0.cairo index 078e92a71..6c6ee884c 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_last_index/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 603979776, sign: false }); - data.append(FixedType { mag: 671088640, sign: true }); - data.append(FixedType { mag: 822083584, sign: false }); - data.append(FixedType { mag: 746586112, sign: true }); - data.append(FixedType { mag: 377487360, sign: false }); - data.append(FixedType { mag: 293601280, sign: false }); - data.append(FixedType { mag: 645922816, sign: false }); - data.append(FixedType { mag: 880803840, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 713031680, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 805306368, sign: true }); + data.append(FP8x23 { mag: 486539264, sign: true }); + data.append(FP8x23 { mag: 587202560, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: true }); + data.append(FP8x23 { mag: 58720256, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_fp8x23_3D_last_index/output_0.cairo b/src/tests/nodes/argmin_fp8x23_3D_last_index/output_0.cairo index ec0386ae5..8851cfbb7 100644 --- a/src/tests/nodes/argmin_fp8x23_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_fp8x23_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,10 +10,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(0); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_1D_default.cairo b/src/tests/nodes/argmin_i32_1D_default.cairo index 74a9f6ab0..1c5becbe1 100644 --- a/src/tests/nodes/argmin_i32_1D_default.cairo +++ b/src/tests/nodes/argmin_i32_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_1D_default/input_0.cairo b/src/tests/nodes/argmin_i32_1D_default/input_0.cairo index d87c5929c..6bee6657d 100644 --- a/src/tests/nodes/argmin_i32_1D_default/input_0.cairo +++ b/src/tests/nodes/argmin_i32_1D_default/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 10, sign: true }); - data.append(i32 { mag: 34, sign: true }); - data.append(i32 { mag: 18, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 63, sign: true }); + data.append(i32 { mag: 75, sign: true }); + data.append(i32 { mag: 117, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_1D_default/output_0.cairo b/src/tests/nodes/argmin_i32_1D_default/output_0.cairo index b0d7ca254..56f9cff0f 100644 --- a/src/tests/nodes/argmin_i32_1D_default/output_0.cairo +++ b/src/tests/nodes/argmin_i32_1D_default/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_1D_keepdims_false.cairo b/src/tests/nodes/argmin_i32_1D_keepdims_false.cairo index 471824288..8fb6cfbb7 100644 --- a/src/tests/nodes/argmin_i32_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_i32_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_i32_1D_keepdims_false/input_0.cairo index 9478b4cac..eb195d6dd 100644 --- a/src/tests/nodes/argmin_i32_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_i32_1D_keepdims_false/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 96, sign: false }); - data.append(i32 { mag: 6, sign: true }); - data.append(i32 { mag: 80, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 108, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 39, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_i32_1D_keepdims_false/output_0.cairo index d2248bdc0..56f9cff0f 100644 --- a/src/tests/nodes/argmin_i32_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_i32_1D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_1D_last_index.cairo b/src/tests/nodes/argmin_i32_1D_last_index.cairo index c9db2b8ef..bdd262983 100644 --- a/src/tests/nodes/argmin_i32_1D_last_index.cairo +++ b/src/tests/nodes/argmin_i32_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_1D_last_index/input_0.cairo b/src/tests/nodes/argmin_i32_1D_last_index/input_0.cairo index c4ba13458..963804af6 100644 --- a/src/tests/nodes/argmin_i32_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_i32_1D_last_index/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 201, sign: false }); - data.append(i32 { mag: 32, sign: false }); - data.append(i32 { mag: 149, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 249, sign: false }); + data.append(i32 { mag: 73, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_1D_last_index/output_0.cairo b/src/tests/nodes/argmin_i32_1D_last_index/output_0.cairo index b0d7ca254..eda6965eb 100644 --- a/src/tests/nodes/argmin_i32_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_i32_1D_last_index/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_2D_default.cairo b/src/tests/nodes/argmin_i32_2D_default.cairo index f650f854b..a47464d74 100644 --- a/src/tests/nodes/argmin_i32_2D_default.cairo +++ b/src/tests/nodes/argmin_i32_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_2D_default/input_0.cairo b/src/tests/nodes/argmin_i32_2D_default/input_0.cairo index 23e0373e6..6c2ecdc75 100644 --- a/src/tests/nodes/argmin_i32_2D_default/input_0.cairo +++ b/src/tests/nodes/argmin_i32_2D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 6, sign: false }); - data.append(i32 { mag: 64, sign: true }); - data.append(i32 { mag: 121, sign: true }); - data.append(i32 { mag: 28, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 112, sign: true }); + data.append(i32 { mag: 55, sign: true }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 52, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_2D_default/output_0.cairo b/src/tests/nodes/argmin_i32_2D_default/output_0.cairo index 66bf81a47..4fb656f2a 100644 --- a/src/tests/nodes/argmin_i32_2D_default/output_0.cairo +++ b/src/tests/nodes/argmin_i32_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_2D_keepdims_false.cairo b/src/tests/nodes/argmin_i32_2D_keepdims_false.cairo index c911bf7e8..f350ee0c0 100644 --- a/src/tests/nodes/argmin_i32_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_i32_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_i32_2D_keepdims_false/input_0.cairo index 427592d1d..cb4190105 100644 --- a/src/tests/nodes/argmin_i32_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_i32_2D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 113, sign: false }); - data.append(i32 { mag: 11, sign: true }); - data.append(i32 { mag: 47, sign: false }); - data.append(i32 { mag: 89, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 65, sign: true }); + data.append(i32 { mag: 59, sign: true }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 68, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_i32_2D_keepdims_false/output_0.cairo index 166f1bf27..af0e54527 100644 --- a/src/tests/nodes/argmin_i32_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_i32_2D_keepdims_false/output_0.cairo @@ -1,16 +1,13 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_2D_last_index.cairo b/src/tests/nodes/argmin_i32_2D_last_index.cairo index e7ff5631c..f845bfb3b 100644 --- a/src/tests/nodes/argmin_i32_2D_last_index.cairo +++ b/src/tests/nodes/argmin_i32_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_2D_last_index/input_0.cairo b/src/tests/nodes/argmin_i32_2D_last_index/input_0.cairo index 43965073c..893757290 100644 --- a/src/tests/nodes/argmin_i32_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_i32_2D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 13, sign: false }); - data.append(i32 { mag: 106, sign: false }); - data.append(i32 { mag: 54, sign: true }); - data.append(i32 { mag: 59, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 98, sign: false }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 14, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_2D_last_index/output_0.cairo b/src/tests/nodes/argmin_i32_2D_last_index/output_0.cairo index b3594e764..18c2bb3fe 100644 --- a/src/tests/nodes/argmin_i32_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_i32_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_3D_default.cairo b/src/tests/nodes/argmin_i32_3D_default.cairo index 4b4a7cc51..e7f363236 100644 --- a/src/tests/nodes/argmin_i32_3D_default.cairo +++ b/src/tests/nodes/argmin_i32_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_3D_default/input_0.cairo b/src/tests/nodes/argmin_i32_3D_default/input_0.cairo index f5474387f..2c763628a 100644 --- a/src/tests/nodes/argmin_i32_3D_default/input_0.cairo +++ b/src/tests/nodes/argmin_i32_3D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 56, sign: false }); - data.append(i32 { mag: 40, sign: true }); - data.append(i32 { mag: 32, sign: true }); - data.append(i32 { mag: 42, sign: true }); - data.append(i32 { mag: 64, sign: false }); - data.append(i32 { mag: 95, sign: true }); - data.append(i32 { mag: 117, sign: true }); - data.append(i32 { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 33, sign: true }); + data.append(i32 { mag: 64, sign: true }); + data.append(i32 { mag: 9, sign: true }); + data.append(i32 { mag: 55, sign: true }); + data.append(i32 { mag: 108, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_3D_default/output_0.cairo b/src/tests/nodes/argmin_i32_3D_default/output_0.cairo index b4a58fe55..8851cfbb7 100644 --- a/src/tests/nodes/argmin_i32_3D_default/output_0.cairo +++ b/src/tests/nodes/argmin_i32_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); + data.append(1); data.append(1); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_3D_keepdims_false.cairo b/src/tests/nodes/argmin_i32_3D_keepdims_false.cairo index c280b2565..39acd02cf 100644 --- a/src/tests/nodes/argmin_i32_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_i32_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_i32_3D_keepdims_false/input_0.cairo index 00876660e..96a3094b8 100644 --- a/src/tests/nodes/argmin_i32_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_i32_3D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 78, sign: false }); - data.append(i32 { mag: 52, sign: false }); - data.append(i32 { mag: 26, sign: true }); - data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 108, sign: true }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 122, sign: true }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 64, sign: true }); + data.append(i32 { mag: 80, sign: true }); data.append(i32 { mag: 122, sign: false }); - data.append(i32 { mag: 68, sign: true }); - data.append(i32 { mag: 41, sign: true }); - data.append(i32 { mag: 32, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_i32_3D_keepdims_false/output_0.cairo index fec9e9f5b..8304bcded 100644 --- a/src/tests/nodes/argmin_i32_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_i32_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,8 +11,6 @@ fn output_0() -> Tensor { data.append(0); data.append(1); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_3D_last_index.cairo b/src/tests/nodes/argmin_i32_3D_last_index.cairo index 7a9f36a1a..619963622 100644 --- a/src/tests/nodes/argmin_i32_3D_last_index.cairo +++ b/src/tests/nodes/argmin_i32_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i32_3D_last_index/input_0.cairo b/src/tests/nodes/argmin_i32_3D_last_index/input_0.cairo index cfbdbc568..672970547 100644 --- a/src/tests/nodes/argmin_i32_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_i32_3D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 21, sign: false }); - data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 69, sign: true }); + data.append(i32 { mag: 117, sign: false }); + data.append(i32 { mag: 92, sign: true }); data.append(i32 { mag: 7, sign: false }); - data.append(i32 { mag: 51, sign: false }); - data.append(i32 { mag: 76, sign: true }); - data.append(i32 { mag: 122, sign: false }); - data.append(i32 { mag: 41, sign: false }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 99, sign: true }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 33, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i32_3D_last_index/output_0.cairo b/src/tests/nodes/argmin_i32_3D_last_index/output_0.cairo index 2697687ae..a698fcbf9 100644 --- a/src/tests/nodes/argmin_i32_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_i32_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(0); data.append(1); data.append(0); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_1D_default.cairo b/src/tests/nodes/argmin_i8_1D_default.cairo index 57c0134a9..de5a94bc9 100644 --- a/src/tests/nodes/argmin_i8_1D_default.cairo +++ b/src/tests/nodes/argmin_i8_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_1D_default/input_0.cairo b/src/tests/nodes/argmin_i8_1D_default/input_0.cairo index 886edfec2..6dbaca36a 100644 --- a/src/tests/nodes/argmin_i8_1D_default/input_0.cairo +++ b/src/tests/nodes/argmin_i8_1D_default/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 86, sign: true }); - data.append(i8 { mag: 122, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 62, sign: false }); + data.append(i8 { mag: 69, sign: false }); + data.append(i8 { mag: 94, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_1D_default/output_0.cairo b/src/tests/nodes/argmin_i8_1D_default/output_0.cairo index 01dca80e5..eda6965eb 100644 --- a/src/tests/nodes/argmin_i8_1D_default/output_0.cairo +++ b/src/tests/nodes/argmin_i8_1D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_1D_keepdims_false.cairo b/src/tests/nodes/argmin_i8_1D_keepdims_false.cairo index ce61480c8..a5b9b2b46 100644 --- a/src/tests/nodes/argmin_i8_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_i8_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_i8_1D_keepdims_false/input_0.cairo index a10fb808f..78b033855 100644 --- a/src/tests/nodes/argmin_i8_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_i8_1D_keepdims_false/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 27, sign: true }); - data.append(i8 { mag: 76, sign: false }); - data.append(i8 { mag: 116, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 98, sign: true }); + data.append(i8 { mag: 86, sign: true }); + data.append(i8 { mag: 72, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_i8_1D_keepdims_false/output_0.cairo index 01dca80e5..eda6965eb 100644 --- a/src/tests/nodes/argmin_i8_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_i8_1D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_1D_last_index.cairo b/src/tests/nodes/argmin_i8_1D_last_index.cairo index 2d2614479..7e7105583 100644 --- a/src/tests/nodes/argmin_i8_1D_last_index.cairo +++ b/src/tests/nodes/argmin_i8_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_1D_last_index/input_0.cairo b/src/tests/nodes/argmin_i8_1D_last_index/input_0.cairo index 215a3a75d..276a97682 100644 --- a/src/tests/nodes/argmin_i8_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_i8_1D_last_index/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 33, sign: true }); - data.append(i8 { mag: 108, sign: true }); - data.append(i8 { mag: 48, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 86, sign: false }); + data.append(i8 { mag: 85, sign: true }); + data.append(i8 { mag: 17, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_1D_last_index/output_0.cairo b/src/tests/nodes/argmin_i8_1D_last_index/output_0.cairo index b0d7ca254..1565560fe 100644 --- a/src/tests/nodes/argmin_i8_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_i8_1D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_2D_default.cairo b/src/tests/nodes/argmin_i8_2D_default.cairo index 7819fddb5..a29c862d7 100644 --- a/src/tests/nodes/argmin_i8_2D_default.cairo +++ b/src/tests/nodes/argmin_i8_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_2D_default/input_0.cairo b/src/tests/nodes/argmin_i8_2D_default/input_0.cairo index 7f0363fa5..2e4de7245 100644 --- a/src/tests/nodes/argmin_i8_2D_default/input_0.cairo +++ b/src/tests/nodes/argmin_i8_2D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 37, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 6, sign: false }); - data.append(i8 { mag: 14, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 63, sign: true }); + data.append(i8 { mag: 73, sign: true }); + data.append(i8 { mag: 52, sign: true }); + data.append(i8 { mag: 113, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_2D_default/output_0.cairo b/src/tests/nodes/argmin_i8_2D_default/output_0.cairo index 63fe1399a..6e8934615 100644 --- a/src/tests/nodes/argmin_i8_2D_default/output_0.cairo +++ b/src/tests/nodes/argmin_i8_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_2D_keepdims_false.cairo b/src/tests/nodes/argmin_i8_2D_keepdims_false.cairo index 75ed24175..986a30216 100644 --- a/src/tests/nodes/argmin_i8_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_i8_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_i8_2D_keepdims_false/input_0.cairo index 46a466f3b..023aabe50 100644 --- a/src/tests/nodes/argmin_i8_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_i8_2D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 126, sign: false }); - data.append(i8 { mag: 22, sign: false }); - data.append(i8 { mag: 70, sign: true }); - data.append(i8 { mag: 43, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 74, sign: true }); + data.append(i8 { mag: 53, sign: true }); + data.append(i8 { mag: 75, sign: true }); + data.append(i8 { mag: 103, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_i8_2D_keepdims_false/output_0.cairo index 166f1bf27..2f17092da 100644 --- a/src/tests/nodes/argmin_i8_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_i8_2D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,8 +8,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_2D_last_index.cairo b/src/tests/nodes/argmin_i8_2D_last_index.cairo index d7e7aaae8..55a20cbb2 100644 --- a/src/tests/nodes/argmin_i8_2D_last_index.cairo +++ b/src/tests/nodes/argmin_i8_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_2D_last_index/input_0.cairo b/src/tests/nodes/argmin_i8_2D_last_index/input_0.cairo index 0faad52eb..8831598a9 100644 --- a/src/tests/nodes/argmin_i8_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_i8_2D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 68, sign: true }); - data.append(i8 { mag: 43, sign: false }); - data.append(i8 { mag: 13, sign: false }); - data.append(i8 { mag: 91, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 67, sign: false }); + data.append(i8 { mag: 57, sign: false }); + data.append(i8 { mag: 86, sign: true }); + data.append(i8 { mag: 24, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_2D_last_index/output_0.cairo b/src/tests/nodes/argmin_i8_2D_last_index/output_0.cairo index 63fe1399a..18c2bb3fe 100644 --- a/src/tests/nodes/argmin_i8_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_i8_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_3D_default.cairo b/src/tests/nodes/argmin_i8_3D_default.cairo index c5d708707..76eaa3aa0 100644 --- a/src/tests/nodes/argmin_i8_3D_default.cairo +++ b/src/tests/nodes/argmin_i8_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_3D_default/input_0.cairo b/src/tests/nodes/argmin_i8_3D_default/input_0.cairo index 394f511ac..ecb9c7434 100644 --- a/src/tests/nodes/argmin_i8_3D_default/input_0.cairo +++ b/src/tests/nodes/argmin_i8_3D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 78, sign: false }); - data.append(i8 { mag: 7, sign: false }); - data.append(i8 { mag: 12, sign: false }); - data.append(i8 { mag: 18, sign: true }); - data.append(i8 { mag: 106, sign: false }); - data.append(i8 { mag: 120, sign: false }); - data.append(i8 { mag: 26, sign: false }); - data.append(i8 { mag: 14, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 109, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 97, sign: true }); + data.append(i8 { mag: 110, sign: true }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 114, sign: true }); + data.append(i8 { mag: 70, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_3D_default/output_0.cairo b/src/tests/nodes/argmin_i8_3D_default/output_0.cairo index 583e7fa91..b0d2c103c 100644 --- a/src/tests/nodes/argmin_i8_3D_default/output_0.cairo +++ b/src/tests/nodes/argmin_i8_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(1); data.append(0); + data.append(1); data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_3D_keepdims_false.cairo b/src/tests/nodes/argmin_i8_3D_keepdims_false.cairo index e57d3320a..58a17208a 100644 --- a/src/tests/nodes/argmin_i8_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_i8_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_i8_3D_keepdims_false/input_0.cairo index e0c7dfa07..cf55d4fa2 100644 --- a/src/tests/nodes/argmin_i8_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_i8_3D_keepdims_false/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -12,14 +11,12 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 122, sign: true }); - data.append(i8 { mag: 69, sign: false }); - data.append(i8 { mag: 109, sign: true }); - data.append(i8 { mag: 107, sign: false }); - data.append(i8 { mag: 45, sign: false }); - data.append(i8 { mag: 29, sign: true }); - data.append(i8 { mag: 112, sign: true }); - data.append(i8 { mag: 78, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 53, sign: true }); + data.append(i8 { mag: 45, sign: true }); + data.append(i8 { mag: 56, sign: true }); + data.append(i8 { mag: 72, sign: true }); + data.append(i8 { mag: 89, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_i8_3D_keepdims_false/output_0.cairo index fec9e9f5b..8304bcded 100644 --- a/src/tests/nodes/argmin_i8_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_i8_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,8 +11,6 @@ fn output_0() -> Tensor { data.append(0); data.append(1); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_3D_last_index.cairo b/src/tests/nodes/argmin_i8_3D_last_index.cairo index 02086b5b9..68d7ff9e8 100644 --- a/src/tests/nodes/argmin_i8_3D_last_index.cairo +++ b/src/tests/nodes/argmin_i8_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_i8_3D_last_index/input_0.cairo b/src/tests/nodes/argmin_i8_3D_last_index/input_0.cairo index df951c7e2..fbc71e6ef 100644 --- a/src/tests/nodes/argmin_i8_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_i8_3D_last_index/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 110, sign: true }); - data.append(i8 { mag: 46, sign: false }); - data.append(i8 { mag: 50, sign: false }); - data.append(i8 { mag: 96, sign: false }); - data.append(i8 { mag: 43, sign: false }); - data.append(i8 { mag: 47, sign: true }); - data.append(i8 { mag: 74, sign: false }); - data.append(i8 { mag: 73, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 48, sign: false }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 46, sign: true }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 94, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 98, sign: false }); + data.append(i8 { mag: 114, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_i8_3D_last_index/output_0.cairo b/src/tests/nodes/argmin_i8_3D_last_index/output_0.cairo index db3256051..451c4b7ce 100644 --- a/src/tests/nodes/argmin_i8_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_i8_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); + data.append(1); data.append(1); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_1D_default.cairo b/src/tests/nodes/argmin_u32_1D_default.cairo index 4fd20a669..4c50c9862 100644 --- a/src/tests/nodes/argmin_u32_1D_default.cairo +++ b/src/tests/nodes/argmin_u32_1D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_1D_default/input_0.cairo b/src/tests/nodes/argmin_u32_1D_default/input_0.cairo index d9b2cf01c..64da2a068 100644 --- a/src/tests/nodes/argmin_u32_1D_default/input_0.cairo +++ b/src/tests/nodes/argmin_u32_1D_default/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(91); - data.append(218); - data.append(115); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(4); + data.append(97); + data.append(18); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_1D_default/output_0.cairo b/src/tests/nodes/argmin_u32_1D_default/output_0.cairo index 01dca80e5..eda6965eb 100644 --- a/src/tests/nodes/argmin_u32_1D_default/output_0.cairo +++ b/src/tests/nodes/argmin_u32_1D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_1D_keepdims_false.cairo b/src/tests/nodes/argmin_u32_1D_keepdims_false.cairo index e676d4dba..bb48fb618 100644 --- a/src/tests/nodes/argmin_u32_1D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_u32_1D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_1D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_u32_1D_keepdims_false/input_0.cairo index be83e5b73..bf6f439f7 100644 --- a/src/tests/nodes/argmin_u32_1D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_u32_1D_keepdims_false/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(119); - data.append(212); - data.append(167); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(36); + data.append(24); + data.append(185); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_1D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_u32_1D_keepdims_false/output_0.cairo index 01dca80e5..1565560fe 100644 --- a/src/tests/nodes/argmin_u32_1D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_u32_1D_keepdims_false/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_1D_last_index.cairo b/src/tests/nodes/argmin_u32_1D_last_index.cairo index dcc97fd42..ff0a959c2 100644 --- a/src/tests/nodes/argmin_u32_1D_last_index.cairo +++ b/src/tests/nodes/argmin_u32_1D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_1D_last_index/input_0.cairo b/src/tests/nodes/argmin_u32_1D_last_index/input_0.cairo index 9408e067a..e8fc6e12b 100644 --- a/src/tests/nodes/argmin_u32_1D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_u32_1D_last_index/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(235); - data.append(37); - data.append(139); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(202); + data.append(105); + data.append(177); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_1D_last_index/output_0.cairo b/src/tests/nodes/argmin_u32_1D_last_index/output_0.cairo index b0d7ca254..1565560fe 100644 --- a/src/tests/nodes/argmin_u32_1D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_u32_1D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_2D_default.cairo b/src/tests/nodes/argmin_u32_2D_default.cairo index 3892a0de5..ca41d100b 100644 --- a/src/tests/nodes/argmin_u32_2D_default.cairo +++ b/src/tests/nodes/argmin_u32_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_2D_default/input_0.cairo b/src/tests/nodes/argmin_u32_2D_default/input_0.cairo index 358c876ba..b90f77a87 100644 --- a/src/tests/nodes/argmin_u32_2D_default/input_0.cairo +++ b/src/tests/nodes/argmin_u32_2D_default/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(5); - data.append(48); - data.append(65); - data.append(136); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(250); + data.append(71); + data.append(159); + data.append(119); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_2D_default/output_0.cairo b/src/tests/nodes/argmin_u32_2D_default/output_0.cairo index 63fe1399a..5541876d4 100644 --- a/src/tests/nodes/argmin_u32_2D_default/output_0.cairo +++ b/src/tests/nodes/argmin_u32_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(1); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_2D_keepdims_false.cairo b/src/tests/nodes/argmin_u32_2D_keepdims_false.cairo index a41c89236..0f689a77c 100644 --- a/src/tests/nodes/argmin_u32_2D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_u32_2D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_2D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_u32_2D_keepdims_false/input_0.cairo index d997a7780..8a488d6a4 100644 --- a/src/tests/nodes/argmin_u32_2D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_u32_2D_keepdims_false/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(119); - data.append(10); - data.append(247); - data.append(85); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(205); + data.append(39); + data.append(206); + data.append(94); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_2D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_u32_2D_keepdims_false/output_0.cairo index 6cb485b7a..af0e54527 100644 --- a/src/tests/nodes/argmin_u32_2D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_u32_2D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_2D_last_index.cairo b/src/tests/nodes/argmin_u32_2D_last_index.cairo index 75d43c98b..358077442 100644 --- a/src/tests/nodes/argmin_u32_2D_last_index.cairo +++ b/src/tests/nodes/argmin_u32_2D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_2D_last_index/input_0.cairo b/src/tests/nodes/argmin_u32_2D_last_index/input_0.cairo index f61122abe..4282a704b 100644 --- a/src/tests/nodes/argmin_u32_2D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_u32_2D_last_index/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(173); - data.append(178); - data.append(94); - data.append(35); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(182); + data.append(6); + data.append(161); + data.append(123); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_2D_last_index/output_0.cairo b/src/tests/nodes/argmin_u32_2D_last_index/output_0.cairo index b3594e764..5541876d4 100644 --- a/src/tests/nodes/argmin_u32_2D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_u32_2D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_3D_default.cairo b/src/tests/nodes/argmin_u32_3D_default.cairo index 564104796..a68092a38 100644 --- a/src/tests/nodes/argmin_u32_3D_default.cairo +++ b/src/tests/nodes/argmin_u32_3D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_3D_default/input_0.cairo b/src/tests/nodes/argmin_u32_3D_default/input_0.cairo index 5768d844a..3e8155d19 100644 --- a/src/tests/nodes/argmin_u32_3D_default/input_0.cairo +++ b/src/tests/nodes/argmin_u32_3D_default/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(137); - data.append(2); - data.append(134); - data.append(142); - data.append(236); - data.append(246); - data.append(96); - data.append(150); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(183); + data.append(101); + data.append(207); + data.append(197); + data.append(120); + data.append(204); + data.append(156); + data.append(234); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_3D_default/output_0.cairo b/src/tests/nodes/argmin_u32_3D_default/output_0.cairo index 5ee5ea034..b0d2c103c 100644 --- a/src/tests/nodes/argmin_u32_3D_default/output_0.cairo +++ b/src/tests/nodes/argmin_u32_3D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); + data.append(1); data.append(0); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_3D_keepdims_false.cairo b/src/tests/nodes/argmin_u32_3D_keepdims_false.cairo index 322998bc5..d4cc43f00 100644 --- a/src/tests/nodes/argmin_u32_3D_keepdims_false.cairo +++ b/src/tests/nodes/argmin_u32_3D_keepdims_false.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_3D_keepdims_false/input_0.cairo b/src/tests/nodes/argmin_u32_3D_keepdims_false/input_0.cairo index b5ea05992..24ab83d7e 100644 --- a/src/tests/nodes/argmin_u32_3D_keepdims_false/input_0.cairo +++ b/src/tests/nodes/argmin_u32_3D_keepdims_false/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(136); - data.append(153); - data.append(113); - data.append(185); - data.append(177); - data.append(209); - data.append(38); - data.append(211); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(15); + data.append(205); + data.append(192); + data.append(220); + data.append(182); + data.append(184); + data.append(11); + data.append(97); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_3D_keepdims_false/output_0.cairo b/src/tests/nodes/argmin_u32_3D_keepdims_false/output_0.cairo index 157fe88f9..fdae52d6a 100644 --- a/src/tests/nodes/argmin_u32_3D_keepdims_false/output_0.cairo +++ b/src/tests/nodes/argmin_u32_3D_keepdims_false/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_3D_last_index.cairo b/src/tests/nodes/argmin_u32_3D_last_index.cairo index f0bafa376..1bf0bf127 100644 --- a/src/tests/nodes/argmin_u32_3D_last_index.cairo +++ b/src/tests/nodes/argmin_u32_3D_last_index.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/argmin_u32_3D_last_index/input_0.cairo b/src/tests/nodes/argmin_u32_3D_last_index/input_0.cairo index 721b2ac8e..0182a32a3 100644 --- a/src/tests/nodes/argmin_u32_3D_last_index/input_0.cairo +++ b/src/tests/nodes/argmin_u32_3D_last_index/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(238); - data.append(240); - data.append(209); - data.append(189); - data.append(242); - data.append(56); - data.append(128); - data.append(113); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(153); + data.append(28); + data.append(204); + data.append(0); + data.append(69); + data.append(220); + data.append(126); + data.append(80); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/argmin_u32_3D_last_index/output_0.cairo b/src/tests/nodes/argmin_u32_3D_last_index/output_0.cairo index 70d6bf379..b0d2c103c 100644 --- a/src/tests/nodes/argmin_u32_3D_last_index/output_0.cairo +++ b/src/tests/nodes/argmin_u32_3D_last_index/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(1); data.append(1); + data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asin_fp16x16.cairo b/src/tests/nodes/asin_fp16x16.cairo index 8667fd10a..4ed6e61f5 100644 --- a/src/tests/nodes/asin_fp16x16.cairo +++ b/src/tests/nodes/asin_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/asin_fp16x16/input_0.cairo b/src/tests/nodes/asin_fp16x16/input_0.cairo index 4355eaac3..7fc563b23 100644 --- a/src/tests/nodes/asin_fp16x16/input_0.cairo +++ b/src/tests/nodes/asin_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 39178, sign: true }); - data.append(FixedType { mag: 15181, sign: true }); - data.append(FixedType { mag: 30205, sign: true }); - data.append(FixedType { mag: 13386, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 24425, sign: false }); + data.append(FP16x16 { mag: 40100, sign: true }); + data.append(FP16x16 { mag: 37592, sign: true }); + data.append(FP16x16 { mag: 55159, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asin_fp16x16/output_0.cairo b/src/tests/nodes/asin_fp16x16/output_0.cairo index 1ce379ef4..1501342b1 100644 --- a/src/tests/nodes/asin_fp16x16/output_0.cairo +++ b/src/tests/nodes/asin_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 41993, sign: true }); - data.append(FixedType { mag: 15320, sign: true }); - data.append(FixedType { mag: 31391, sign: true }); - data.append(FixedType { mag: 13480, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 25029, sign: false }); + data.append(FP16x16 { mag: 43152, sign: true }); + data.append(FP16x16 { mag: 40036, sign: true }); + data.append(FP16x16 { mag: 65559, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asin_fp8x23.cairo b/src/tests/nodes/asin_fp8x23.cairo index e4ffa5738..1ab699444 100644 --- a/src/tests/nodes/asin_fp8x23.cairo +++ b/src/tests/nodes/asin_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/asin_fp8x23/input_0.cairo b/src/tests/nodes/asin_fp8x23/input_0.cairo index a553ac63f..8e3fe6424 100644 --- a/src/tests/nodes/asin_fp8x23/input_0.cairo +++ b/src/tests/nodes/asin_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2340803, sign: true }); - data.append(FixedType { mag: 1785691, sign: false }); - data.append(FixedType { mag: 1184830, sign: true }); - data.append(FixedType { mag: 2276088, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 5018963, sign: true }); + data.append(FP8x23 { mag: 1475178, sign: false }); + data.append(FP8x23 { mag: 4332453, sign: false }); + data.append(FP8x23 { mag: 3833460, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asin_fp8x23/output_0.cairo b/src/tests/nodes/asin_fp8x23/output_0.cairo index 6b7d301be..114fd9150 100644 --- a/src/tests/nodes/asin_fp8x23/output_0.cairo +++ b/src/tests/nodes/asin_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2372298, sign: true }); - data.append(FixedType { mag: 1799460, sign: false }); - data.append(FixedType { mag: 1188806, sign: true }); - data.append(FixedType { mag: 2304984, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 5380341, sign: true }); + data.append(FP8x23 { mag: 1482889, sign: false }); + data.append(FP8x23 { mag: 4552681, sign: false }); + data.append(FP8x23 { mag: 3981246, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asinh_fp16x16.cairo b/src/tests/nodes/asinh_fp16x16.cairo index 8a0fff6bb..1a94c21d4 100644 --- a/src/tests/nodes/asinh_fp16x16.cairo +++ b/src/tests/nodes/asinh_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/asinh_fp16x16/input_0.cairo b/src/tests/nodes/asinh_fp16x16/input_0.cairo index 3fce3c8be..94ef84d7a 100644 --- a/src/tests/nodes/asinh_fp16x16/input_0.cairo +++ b/src/tests/nodes/asinh_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 276699, sign: false }); - data.append(FixedType { mag: 249503, sign: false }); - data.append(FixedType { mag: 249091, sign: false }); - data.append(FixedType { mag: 241997, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 184210, sign: false }); + data.append(FP16x16 { mag: 129479, sign: false }); + data.append(FP16x16 { mag: 277479, sign: false }); + data.append(FP16x16 { mag: 131054, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asinh_fp16x16/output_0.cairo b/src/tests/nodes/asinh_fp16x16/output_0.cairo index 0e958f1e2..6376e4230 100644 --- a/src/tests/nodes/asinh_fp16x16/output_0.cairo +++ b/src/tests/nodes/asinh_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 140720, sign: false }); - data.append(FixedType { mag: 134141, sign: false }); - data.append(FixedType { mag: 134037, sign: false }); - data.append(FixedType { mag: 132207, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 115137, sign: false }); + data.append(FP16x16 { mag: 93894, sign: false }); + data.append(FP16x16 { mag: 140899, sign: false }); + data.append(FP16x16 { mag: 94602, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asinh_fp8x23.cairo b/src/tests/nodes/asinh_fp8x23.cairo index c9248937f..f4670f968 100644 --- a/src/tests/nodes/asinh_fp8x23.cairo +++ b/src/tests/nodes/asinh_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/asinh_fp8x23/input_0.cairo b/src/tests/nodes/asinh_fp8x23/input_0.cairo index 9d359bb62..f59934d7b 100644 --- a/src/tests/nodes/asinh_fp8x23/input_0.cairo +++ b/src/tests/nodes/asinh_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 33826578, sign: false }); - data.append(FixedType { mag: 11114336, sign: false }); - data.append(FixedType { mag: 28274183, sign: false }); - data.append(FixedType { mag: 11950034, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 27455781, sign: false }); + data.append(FP8x23 { mag: 18897191, sign: false }); + data.append(FP8x23 { mag: 21438360, sign: false }); + data.append(FP8x23 { mag: 14100507, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asinh_fp8x23/output_0.cairo b/src/tests/nodes/asinh_fp8x23/output_0.cairo index 255f254a7..19b823afe 100644 --- a/src/tests/nodes/asinh_fp8x23/output_0.cairo +++ b/src/tests/nodes/asinh_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 17637476, sign: false }); - data.append(FixedType { mag: 9173457, sign: false }); - data.append(FixedType { mag: 16186111, sign: false }); - data.append(FixedType { mag: 9665119, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 15950180, sign: false }); + data.append(FP8x23 { mag: 13012932, sign: false }); + data.append(FP8x23 { mag: 13989712, sign: false }); + data.append(FP8x23 { mag: 10830545, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/asinh_i32_fp16x16.cairo b/src/tests/nodes/asinh_i32_fp16x16.cairo deleted file mode 100644 index b59cb2014..000000000 --- a/src/tests/nodes/asinh_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_asinh_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.asinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i32_fp16x16/input_0.cairo b/src/tests/nodes/asinh_i32_fp16x16/input_0.cairo deleted file mode 100644 index 24c93e422..000000000 --- a/src/tests/nodes/asinh_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 3, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i32_fp16x16/output_0.cairo b/src/tests/nodes/asinh_i32_fp16x16/output_0.cairo deleted file mode 100644 index dfcae114d..000000000 --- a/src/tests/nodes/asinh_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 119173, sign: false }); - data.append(FixedType { mag: 57761, sign: false }); - data.append(FixedType { mag: 94610, sign: false }); - data.append(FixedType { mag: 57761, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i32_fp8x23.cairo b/src/tests/nodes/asinh_i32_fp8x23.cairo deleted file mode 100644 index 36b7c6022..000000000 --- a/src/tests/nodes/asinh_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_asinh_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.asinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i32_fp8x23/input_0.cairo b/src/tests/nodes/asinh_i32_fp8x23/input_0.cairo deleted file mode 100644 index a0f547c1a..000000000 --- a/src/tests/nodes/asinh_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i32_fp8x23/output_0.cairo b/src/tests/nodes/asinh_i32_fp8x23/output_0.cairo deleted file mode 100644 index d0809859d..000000000 --- a/src/tests/nodes/asinh_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 12110092, sign: false }); - data.append(FixedType { mag: 7393497, sign: false }); - data.append(FixedType { mag: 17571722, sign: false }); - data.append(FixedType { mag: 15254234, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i8_fp16x16.cairo b/src/tests/nodes/asinh_i8_fp16x16.cairo deleted file mode 100644 index 7591d4a21..000000000 --- a/src/tests/nodes/asinh_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_asinh_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.asinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i8_fp16x16/input_0.cairo b/src/tests/nodes/asinh_i8_fp16x16/input_0.cairo deleted file mode 100644 index f4d349949..000000000 --- a/src/tests/nodes/asinh_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i8_fp16x16/output_0.cairo b/src/tests/nodes/asinh_i8_fp16x16/output_0.cairo deleted file mode 100644 index caa4f5bfb..000000000 --- a/src/tests/nodes/asinh_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 57761, sign: false }); - data.append(FixedType { mag: 94610, sign: false }); - data.append(FixedType { mag: 137279, sign: false }); - data.append(FixedType { mag: 137279, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i8_fp8x23.cairo b/src/tests/nodes/asinh_i8_fp8x23.cairo deleted file mode 100644 index 0eb8f4975..000000000 --- a/src/tests/nodes/asinh_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_asinh_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.asinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i8_fp8x23/input_0.cairo b/src/tests/nodes/asinh_i8_fp8x23/input_0.cairo deleted file mode 100644 index 3b34a63e0..000000000 --- a/src/tests/nodes/asinh_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: false }); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_i8_fp8x23/output_0.cairo b/src/tests/nodes/asinh_i8_fp8x23/output_0.cairo deleted file mode 100644 index 62a250542..000000000 --- a/src/tests/nodes/asinh_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7393280, sign: false }); - data.append(FixedType { mag: 17563648, sign: false }); - data.append(FixedType { mag: 12107776, sign: false }); - data.append(FixedType { mag: 17563648, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_u32_fp16x16.cairo b/src/tests/nodes/asinh_u32_fp16x16.cairo deleted file mode 100644 index 11e7fd59c..000000000 --- a/src/tests/nodes/asinh_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_asinh_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.asinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_u32_fp16x16/input_0.cairo b/src/tests/nodes/asinh_u32_fp16x16/input_0.cairo deleted file mode 100644 index 6ee958e67..000000000 --- a/src/tests/nodes/asinh_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(1); - data.append(3); - data.append(4); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_u32_fp16x16/output_0.cairo b/src/tests/nodes/asinh_u32_fp16x16/output_0.cairo deleted file mode 100644 index a688a2f95..000000000 --- a/src/tests/nodes/asinh_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 57761, sign: false }); - data.append(FixedType { mag: 119173, sign: false }); - data.append(FixedType { mag: 137279, sign: false }); - data.append(FixedType { mag: 137279, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_u32_fp8x23.cairo b/src/tests/nodes/asinh_u32_fp8x23.cairo deleted file mode 100644 index bc24fb346..000000000 --- a/src/tests/nodes/asinh_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_asinh_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.asinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_u32_fp8x23/input_0.cairo b/src/tests/nodes/asinh_u32_fp8x23/input_0.cairo deleted file mode 100644 index dbd8a3675..000000000 --- a/src/tests/nodes/asinh_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(3); - data.append(4); - data.append(1); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/asinh_u32_fp8x23/output_0.cairo b/src/tests/nodes/asinh_u32_fp8x23/output_0.cairo deleted file mode 100644 index f1f456003..000000000 --- a/src/tests/nodes/asinh_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 15254234, sign: false }); - data.append(FixedType { mag: 17571722, sign: false }); - data.append(FixedType { mag: 7393497, sign: false }); - data.append(FixedType { mag: 17571722, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_fp16x16.cairo b/src/tests/nodes/atan_fp16x16.cairo index 5069cfbaf..e112ce4f5 100644 --- a/src/tests/nodes/atan_fp16x16.cairo +++ b/src/tests/nodes/atan_fp16x16.cairo @@ -1,10 +1,11 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/atan_fp16x16/input_0.cairo b/src/tests/nodes/atan_fp16x16/input_0.cairo index 707dd0059..6101ec85b 100644 --- a/src/tests/nodes/atan_fp16x16/input_0.cairo +++ b/src/tests/nodes/atan_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7774631, sign: false }); - data.append(FixedType { mag: 6318193, sign: false }); - data.append(FixedType { mag: 90137, sign: true }); - data.append(FixedType { mag: 3857711, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 6783373, sign: false }); + data.append(FP16x16 { mag: 8040908, sign: false }); + data.append(FP16x16 { mag: 4875319, sign: false }); + data.append(FP16x16 { mag: 7007700, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/atan_fp16x16/output_0.cairo b/src/tests/nodes/atan_fp16x16/output_0.cairo index 8325ff117..72126e5ce 100644 --- a/src/tests/nodes/atan_fp16x16/output_0.cairo +++ b/src/tests/nodes/atan_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 102391, sign: false }); - data.append(FixedType { mag: 102263, sign: false }); - data.append(FixedType { mag: 61743, sign: true }); - data.append(FixedType { mag: 101830, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 102310, sign: false }); + data.append(FP16x16 { mag: 102409, sign: false }); + data.append(FP16x16 { mag: 102062, sign: false }); + data.append(FP16x16 { mag: 102330, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/atan_fp8x23.cairo b/src/tests/nodes/atan_fp8x23.cairo index 7871b372a..71c6d2168 100644 --- a/src/tests/nodes/atan_fp8x23.cairo +++ b/src/tests/nodes/atan_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/atan_fp8x23/input_0.cairo b/src/tests/nodes/atan_fp8x23/input_0.cairo index fa1915f96..b83196538 100644 --- a/src/tests/nodes/atan_fp8x23/input_0.cairo +++ b/src/tests/nodes/atan_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 912484668, sign: false }); - data.append(FixedType { mag: 261874397, sign: false }); - data.append(FixedType { mag: 35394242, sign: true }); - data.append(FixedType { mag: 977878458, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 18618993, sign: false }); + data.append(FP8x23 { mag: 5949940, sign: false }); + data.append(FP8x23 { mag: 999751667, sign: false }); + data.append(FP8x23 { mag: 150920617, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/atan_fp8x23/output_0.cairo b/src/tests/nodes/atan_fp8x23/output_0.cairo index 0146efc5b..aba8b0eb5 100644 --- a/src/tests/nodes/atan_fp8x23/output_0.cairo +++ b/src/tests/nodes/atan_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 13099679, sign: false }); - data.append(FixedType { mag: 12908174, sign: false }); - data.append(FixedType { mag: 11224672, sign: true }); - data.append(FixedType { mag: 13104835, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 9625869, sign: false }); + data.append(FP8x23 { mag: 5175204, sign: false }); + data.append(FP8x23 { mag: 13106410, sign: false }); + data.append(FP8x23 { mag: 12711010, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/atan_i32_fp16x16.cairo b/src/tests/nodes/atan_i32_fp16x16.cairo deleted file mode 100644 index 94f840a03..000000000 --- a/src/tests/nodes/atan_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_atan_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.atan(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i32_fp16x16/input_0.cairo b/src/tests/nodes/atan_i32_fp16x16/input_0.cairo deleted file mode 100644 index 930078c81..000000000 --- a/src/tests/nodes/atan_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 112, sign: false }); - data.append(i32 { mag: 116, sign: false }); - data.append(i32 { mag: 14, sign: false }); - data.append(i32 { mag: 48, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i32_fp16x16/output_0.cairo b/src/tests/nodes/atan_i32_fp16x16/output_0.cairo deleted file mode 100644 index 99c1a3048..000000000 --- a/src/tests/nodes/atan_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 102358, sign: false }); - data.append(FixedType { mag: 102378, sign: false }); - data.append(FixedType { mag: 98270, sign: false }); - data.append(FixedType { mag: 101578, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i32_fp8x23.cairo b/src/tests/nodes/atan_i32_fp8x23.cairo deleted file mode 100644 index 2bb8c0098..000000000 --- a/src/tests/nodes/atan_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_atan_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.atan(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i32_fp8x23/input_0.cairo b/src/tests/nodes/atan_i32_fp8x23/input_0.cairo deleted file mode 100644 index 845088b4f..000000000 --- a/src/tests/nodes/atan_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 4, sign: false }); - data.append(i32 { mag: 108, sign: false }); - data.append(i32 { mag: 88, sign: false }); - data.append(i32 { mag: 120, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i32_fp8x23/output_0.cairo b/src/tests/nodes/atan_i32_fp8x23/output_0.cairo deleted file mode 100644 index 3be7be31c..000000000 --- a/src/tests/nodes/atan_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 11121764, sign: false }); - data.append(FixedType { mag: 13099124, sign: false }); - data.append(FixedType { mag: 13081473, sign: false }); - data.append(FixedType { mag: 13106891, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i8_fp16x16.cairo b/src/tests/nodes/atan_i8_fp16x16.cairo deleted file mode 100644 index a6ea9defa..000000000 --- a/src/tests/nodes/atan_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_atan_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.atan(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i8_fp16x16/input_0.cairo b/src/tests/nodes/atan_i8_fp16x16/input_0.cairo deleted file mode 100644 index f6c8657ee..000000000 --- a/src/tests/nodes/atan_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 115, sign: false }); - data.append(i8 { mag: 51, sign: false }); - data.append(i8 { mag: 81, sign: false }); - data.append(i8 { mag: 40, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i8_fp16x16/output_0.cairo b/src/tests/nodes/atan_i8_fp16x16/output_0.cairo deleted file mode 100644 index e3de7d90f..000000000 --- a/src/tests/nodes/atan_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 102373, sign: false }); - data.append(FixedType { mag: 101658, sign: false }); - data.append(FixedType { mag: 102134, sign: false }); - data.append(FixedType { mag: 101305, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i8_fp8x23.cairo b/src/tests/nodes/atan_i8_fp8x23.cairo deleted file mode 100644 index 9fee3df7e..000000000 --- a/src/tests/nodes/atan_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_atan_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.atan(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i8_fp8x23/input_0.cairo b/src/tests/nodes/atan_i8_fp8x23/input_0.cairo deleted file mode 100644 index e19326dae..000000000 --- a/src/tests/nodes/atan_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 9, sign: true }); - data.append(i8 { mag: 10, sign: true }); - data.append(i8 { mag: 9, sign: true }); - data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_i8_fp8x23/output_0.cairo b/src/tests/nodes/atan_i8_fp8x23/output_0.cairo deleted file mode 100644 index badb38bf1..000000000 --- a/src/tests/nodes/atan_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 12247040, sign: true }); - data.append(FixedType { mag: 12337152, sign: true }); - data.append(FixedType { mag: 12247040, sign: true }); - data.append(FixedType { mag: 10477568, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_u32_fp16x16.cairo b/src/tests/nodes/atan_u32_fp16x16.cairo deleted file mode 100644 index e617f536a..000000000 --- a/src/tests/nodes/atan_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_atan_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.atan(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/atan_u32_fp16x16/input_0.cairo b/src/tests/nodes/atan_u32_fp16x16/input_0.cairo deleted file mode 100644 index 3933b128a..000000000 --- a/src/tests/nodes/atan_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(92); - data.append(11); - data.append(66); - data.append(123); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_u32_fp16x16/output_0.cairo b/src/tests/nodes/atan_u32_fp16x16/output_0.cairo deleted file mode 100644 index 16c0ef252..000000000 --- a/src/tests/nodes/atan_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 102231, sign: false }); - data.append(FixedType { mag: 97002, sign: false }); - data.append(FixedType { mag: 101950, sign: false }); - data.append(FixedType { mag: 102410, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_u32_fp8x23.cairo b/src/tests/nodes/atan_u32_fp8x23.cairo deleted file mode 100644 index 526e3a98c..000000000 --- a/src/tests/nodes/atan_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_atan_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.atan(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/atan_u32_fp8x23/input_0.cairo b/src/tests/nodes/atan_u32_fp8x23/input_0.cairo deleted file mode 100644 index d27ea3cc1..000000000 --- a/src/tests/nodes/atan_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(102); - data.append(114); - data.append(119); - data.append(93); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/atan_u32_fp8x23/output_0.cairo b/src/tests/nodes/atan_u32_fp8x23/output_0.cairo deleted file mode 100644 index 0c4e1eddd..000000000 --- a/src/tests/nodes/atan_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 13094556, sign: false }); - data.append(FixedType { mag: 13103212, sign: false }); - data.append(FixedType { mag: 13106303, sign: false }); - data.append(FixedType { mag: 13086598, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/ceil_fp16x16.cairo b/src/tests/nodes/ceil_fp16x16.cairo index 08b46c5d3..8f1c60b48 100644 --- a/src/tests/nodes/ceil_fp16x16.cairo +++ b/src/tests/nodes/ceil_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/ceil_fp16x16/input_0.cairo b/src/tests/nodes/ceil_fp16x16/input_0.cairo index ce79b88a1..b1665abb1 100644 --- a/src/tests/nodes/ceil_fp16x16/input_0.cairo +++ b/src/tests/nodes/ceil_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 23485, sign: false }); - data.append(FixedType { mag: 36237, sign: true }); - data.append(FixedType { mag: 31610, sign: false }); - data.append(FixedType { mag: 1040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 57980, sign: false }); + data.append(FP16x16 { mag: 13481, sign: false }); + data.append(FP16x16 { mag: 37024, sign: false }); + data.append(FP16x16 { mag: 38899, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/ceil_fp16x16/output_0.cairo b/src/tests/nodes/ceil_fp16x16/output_0.cairo index 7900b0b85..c30a1e465 100644 --- a/src/tests/nodes/ceil_fp16x16/output_0.cairo +++ b/src/tests/nodes/ceil_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/ceil_fp8x23.cairo b/src/tests/nodes/ceil_fp8x23.cairo index 9f44e7063..15b9eb6d3 100644 --- a/src/tests/nodes/ceil_fp8x23.cairo +++ b/src/tests/nodes/ceil_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/ceil_fp8x23/input_0.cairo b/src/tests/nodes/ceil_fp8x23/input_0.cairo index bff612cc6..c708e015d 100644 --- a/src/tests/nodes/ceil_fp8x23/input_0.cairo +++ b/src/tests/nodes/ceil_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 4332983, sign: true }); - data.append(FixedType { mag: 5907229, sign: true }); - data.append(FixedType { mag: 7324851, sign: false }); - data.append(FixedType { mag: 1964182, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 395238, sign: true }); + data.append(FP8x23 { mag: 8327668, sign: false }); + data.append(FP8x23 { mag: 3848433, sign: true }); + data.append(FP8x23 { mag: 3761123, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/ceil_fp8x23/output_0.cairo b/src/tests/nodes/ceil_fp8x23/output_0.cairo index 38c5d9e4a..1b4e2b036 100644 --- a/src/tests/nodes/ceil_fp8x23/output_0.cairo +++ b/src/tests/nodes/ceil_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_1d.cairo b/src/tests/nodes/concat_fp16x16_1d.cairo new file mode 100644 index 000000000..7f5c0604c --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_1d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp16x16_1d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_1d/input_0.cairo b/src/tests/nodes/concat_fp16x16_1d/input_0.cairo new file mode 100644 index 000000000..3bb7db502 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_1d/input_0.cairo @@ -0,0 +1,16 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_1d/input_1.cairo b/src/tests/nodes/concat_fp16x16_1d/input_1.cairo new file mode 100644 index 000000000..babceb629 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_1d/input_1.cairo @@ -0,0 +1,16 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_1d/output_0.cairo b/src/tests/nodes/concat_fp16x16_1d/output_0.cairo new file mode 100644 index 000000000..a7d1a2cb4 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_1d/output_0.cairo @@ -0,0 +1,19 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_2d.cairo b/src/tests/nodes/concat_fp16x16_2d.cairo new file mode 100644 index 000000000..5667ab403 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_2d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp16x16_2d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_2d/input_0.cairo b/src/tests/nodes/concat_fp16x16_2d/input_0.cairo new file mode 100644 index 000000000..8009dcc45 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_2d/input_0.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_2d/input_1.cairo b/src/tests/nodes/concat_fp16x16_2d/input_1.cairo new file mode 100644 index 000000000..488c15f80 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_2d/input_1.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_2d/output_0.cairo b/src/tests/nodes/concat_fp16x16_2d/output_0.cairo new file mode 100644 index 000000000..2f8bd96c2 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_2d/output_0.cairo @@ -0,0 +1,22 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_1.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_1.cairo new file mode 100644 index 000000000..2f6976d58 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp16x16_3d_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1 ].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_1/input_0.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_1/input_0.cairo new file mode 100644 index 000000000..e0824f678 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_1/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_1/input_1.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_1/input_1.cairo new file mode 100644 index 000000000..c233f3bb8 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_1/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_1/output_0.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_1/output_0.cairo new file mode 100644 index 000000000..ee0f5f514 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_1/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(6); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_2.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_2.cairo new file mode 100644 index 000000000..4f6e55520 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp16x16_3d_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 2); + + assert_eq(y, z); +} diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_2/input_0.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_2/input_0.cairo new file mode 100644 index 000000000..e0824f678 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_2/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_2/input_1.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_2/input_1.cairo new file mode 100644 index 000000000..c233f3bb8 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_2/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_axis_2/output_0.cairo b/src/tests/nodes/concat_fp16x16_3d_axis_2/output_0.cairo new file mode 100644 index 000000000..ea28151bc --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_axis_2/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(6); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_default.cairo b/src/tests/nodes/concat_fp16x16_3d_default.cairo new file mode 100644 index 000000000..f7ab8a10d --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_default.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp16x16_3d_default() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_default/input_0.cairo b/src/tests/nodes/concat_fp16x16_3d_default/input_0.cairo new file mode 100644 index 000000000..e0824f678 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_default/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_default/input_1.cairo b/src/tests/nodes/concat_fp16x16_3d_default/input_1.cairo new file mode 100644 index 000000000..c233f3bb8 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_default/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_default/output_0.cairo b/src/tests/nodes/concat_fp16x16_3d_default/output_0.cairo new file mode 100644 index 000000000..e754615e0 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_default/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1.cairo new file mode 100644 index 000000000..29b38d736 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp16x16_3d_three_tensors_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 1); + + assert_eq(y, z); +} diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_0.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_0.cairo new file mode 100644 index 000000000..e0824f678 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_1.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_1.cairo new file mode 100644 index 000000000..c233f3bb8 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_2.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_2.cairo new file mode 100644 index 000000000..cbde97f54 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/input_2.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 4063232, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 4325376, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 4521984, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 4784128, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: false }); + data.append(FP16x16 { mag: 4980736, sign: false }); + data.append(FP16x16 { mag: 5046272, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/output_0.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/output_0.cairo new file mode 100644 index 000000000..08a81cd42 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_1/output_0.cairo @@ -0,0 +1,96 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(9); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 4063232, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 4325376, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 4521984, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 4784128, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: false }); + data.append(FP16x16 { mag: 4980736, sign: false }); + data.append(FP16x16 { mag: 5046272, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2.cairo new file mode 100644 index 000000000..ee8a5efac --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp16x16_3d_three_tensors_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 2); + + assert_eq(y, z); +} diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_0.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_0.cairo new file mode 100644 index 000000000..e0824f678 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_1.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_1.cairo new file mode 100644 index 000000000..c233f3bb8 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_2.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_2.cairo new file mode 100644 index 000000000..cbde97f54 --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/input_2.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 4063232, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 4325376, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 4521984, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 4784128, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: false }); + data.append(FP16x16 { mag: 4980736, sign: false }); + data.append(FP16x16 { mag: 5046272, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/output_0.cairo b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/output_0.cairo new file mode 100644 index 000000000..198aca06b --- /dev/null +++ b/src/tests/nodes/concat_fp16x16_3d_three_tensors_axis_2/output_0.cairo @@ -0,0 +1,96 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(9); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 4063232, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 4325376, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 4521984, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 4784128, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: false }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 3276800, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: false }); + data.append(FP16x16 { mag: 4980736, sign: false }); + data.append(FP16x16 { mag: 5046272, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_1d.cairo b/src/tests/nodes/concat_fp8x23_1d.cairo new file mode 100644 index 000000000..f4558f2dc --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_1d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp8x23_1d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_1d/input_0.cairo b/src/tests/nodes/concat_fp8x23_1d/input_0.cairo new file mode 100644 index 000000000..617c82eee --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_1d/input_0.cairo @@ -0,0 +1,16 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + 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: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_1d/input_1.cairo b/src/tests/nodes/concat_fp8x23_1d/input_1.cairo new file mode 100644 index 000000000..41cc35eff --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_1d/input_1.cairo @@ -0,0 +1,16 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_1d/output_0.cairo b/src/tests/nodes/concat_fp8x23_1d/output_0.cairo new file mode 100644 index 000000000..93ad38d28 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_1d/output_0.cairo @@ -0,0 +1,19 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + + 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: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_2d.cairo b/src/tests/nodes/concat_fp8x23_2d.cairo new file mode 100644 index 000000000..1161ae825 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_2d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp8x23_2d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_2d/input_0.cairo b/src/tests/nodes/concat_fp8x23_2d/input_0.cairo new file mode 100644 index 000000000..738ae80d4 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_2d/input_0.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_2d/input_1.cairo b/src/tests/nodes/concat_fp8x23_2d/input_1.cairo new file mode 100644 index 000000000..1fbbf0089 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_2d/input_1.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_2d/output_0.cairo b/src/tests/nodes/concat_fp8x23_2d/output_0.cairo new file mode 100644 index 000000000..c4ed893d9 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_2d/output_0.cairo @@ -0,0 +1,22 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_1.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_1.cairo new file mode 100644 index 000000000..608eab0ac --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp8x23_3d_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_1/input_0.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_1/input_0.cairo new file mode 100644 index 000000000..372300cc0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_1/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_1/input_1.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_1/input_1.cairo new file mode 100644 index 000000000..686b022f0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_1/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_1/output_0.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_1/output_0.cairo new file mode 100644 index 000000000..2d44abdfe --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_1/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(6); + 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: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_2.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_2.cairo new file mode 100644 index 000000000..1e372ed29 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp8x23_3d_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_2/input_0.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_2/input_0.cairo new file mode 100644 index 000000000..372300cc0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_2/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_2/input_1.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_2/input_1.cairo new file mode 100644 index 000000000..686b022f0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_2/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_axis_2/output_0.cairo b/src/tests/nodes/concat_fp8x23_3d_axis_2/output_0.cairo new file mode 100644 index 000000000..bfa59db9b --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_axis_2/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(6); + + 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: false }); + data.append(FP8x23 { mag: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_default.cairo b/src/tests/nodes/concat_fp8x23_3d_default.cairo new file mode 100644 index 000000000..58d71551b --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_default.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp8x23_3d_default() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_default/input_0.cairo b/src/tests/nodes/concat_fp8x23_3d_default/input_0.cairo new file mode 100644 index 000000000..372300cc0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_default/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_default/input_1.cairo b/src/tests/nodes/concat_fp8x23_3d_default/input_1.cairo new file mode 100644 index 000000000..686b022f0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_default/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_default/output_0.cairo b/src/tests/nodes/concat_fp8x23_3d_default/output_0.cairo new file mode 100644 index 000000000..27027c97c --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_default/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + shape.append(3); + 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: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1.cairo new file mode 100644 index 000000000..2ff90ab30 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp8x23_3d_three_tensors_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2 ].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_0.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_0.cairo new file mode 100644 index 000000000..372300cc0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_1.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_1.cairo new file mode 100644 index 000000000..686b022f0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_2.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_2.cairo new file mode 100644 index 000000000..c37d60e56 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/input_2.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 503316480, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: false }); + data.append(FP8x23 { mag: 520093696, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 545259520, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 562036736, sign: false }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 603979776, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/output_0.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/output_0.cairo new file mode 100644 index 000000000..e7c521235 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_1/output_0.cairo @@ -0,0 +1,96 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(9); + 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: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 503316480, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: false }); + data.append(FP8x23 { mag: 520093696, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 545259520, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 562036736, sign: false }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + data.append(FP8x23 { mag: 603979776, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2.cairo new file mode 100644 index 000000000..5c1722456 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_fp8x23_3d_three_tensors_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2 ].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_0.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_0.cairo new file mode 100644 index 000000000..372300cc0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_1.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_1.cairo new file mode 100644 index 000000000..686b022f0 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_2.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_2.cairo new file mode 100644 index 000000000..c37d60e56 --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/input_2.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 503316480, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: false }); + data.append(FP8x23 { mag: 520093696, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 545259520, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 562036736, sign: false }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 603979776, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/output_0.cairo b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/output_0.cairo new file mode 100644 index 000000000..f79ebe78e --- /dev/null +++ b/src/tests/nodes/concat_fp8x23_3d_three_tensors_axis_2/output_0.cairo @@ -0,0 +1,96 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(9); + + 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: false }); + data.append(FP8x23 { mag: 226492416, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 503316480, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: false }); + data.append(FP8x23 { mag: 520093696, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 545259520, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 562036736, sign: false }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 603979776, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_1d.cairo b/src/tests/nodes/concat_i32_1d.cairo new file mode 100644 index 000000000..153e9d6c1 --- /dev/null +++ b/src/tests/nodes/concat_i32_1d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i32_1d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_1d/input_0.cairo b/src/tests/nodes/concat_i32_1d/input_0.cairo new file mode 100644 index 000000000..e9ce9f192 --- /dev/null +++ b/src/tests/nodes/concat_i32_1d/input_0.cairo @@ -0,0 +1,15 @@ +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); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_1d/input_1.cairo b/src/tests/nodes/concat_i32_1d/input_1.cairo new file mode 100644 index 000000000..3694655d5 --- /dev/null +++ b/src/tests/nodes/concat_i32_1d/input_1.cairo @@ -0,0 +1,15 @@ +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); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_1d/output_0.cairo b/src/tests/nodes/concat_i32_1d/output_0.cairo new file mode 100644 index 000000000..8513ed945 --- /dev/null +++ b/src/tests/nodes/concat_i32_1d/output_0.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + + let mut data = ArrayTrait::new(); + 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: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_2d.cairo b/src/tests/nodes/concat_i32_2d.cairo new file mode 100644 index 000000000..4946993fc --- /dev/null +++ b/src/tests/nodes/concat_i32_2d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i32_2d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_2d/input_0.cairo b/src/tests/nodes/concat_i32_2d/input_0.cairo new file mode 100644 index 000000000..fb4bacc7b --- /dev/null +++ b/src/tests/nodes/concat_i32_2d/input_0.cairo @@ -0,0 +1,17 @@ +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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_2d/input_1.cairo b/src/tests/nodes/concat_i32_2d/input_1.cairo new file mode 100644 index 000000000..e2ff14a65 --- /dev/null +++ b/src/tests/nodes/concat_i32_2d/input_1.cairo @@ -0,0 +1,17 @@ +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(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_2d/output_0.cairo b/src/tests/nodes/concat_i32_2d/output_0.cairo new file mode 100644 index 000000000..8940f4f2e --- /dev/null +++ b/src/tests/nodes/concat_i32_2d/output_0.cairo @@ -0,0 +1,21 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(2); + + let mut data = ArrayTrait::new(); + 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: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_1.cairo b/src/tests/nodes/concat_i32_3d_axis_1.cairo new file mode 100644 index 000000000..cec13240f --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i32_3d_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_1/input_0.cairo b/src/tests/nodes/concat_i32_3d_axis_1/input_0.cairo new file mode 100644 index 000000000..aa97ad7e4 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_1/input_0.cairo @@ -0,0 +1,41 @@ +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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_1/input_1.cairo b/src/tests/nodes/concat_i32_3d_axis_1/input_1.cairo new file mode 100644 index 000000000..edf434c98 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_1/input_1.cairo @@ -0,0 +1,41 @@ +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: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_1/output_0.cairo b/src/tests/nodes/concat_i32_3d_axis_1/output_0.cairo new file mode 100644 index 000000000..8e0dae429 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_1/output_0.cairo @@ -0,0 +1,68 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(6); + shape.append(3); + + let mut data = ArrayTrait::new(); + 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: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_2.cairo b/src/tests/nodes/concat_i32_3d_axis_2.cairo new file mode 100644 index 000000000..6ff92f720 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i32_3d_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_2/input_0.cairo b/src/tests/nodes/concat_i32_3d_axis_2/input_0.cairo new file mode 100644 index 000000000..aa97ad7e4 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_2/input_0.cairo @@ -0,0 +1,41 @@ +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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_2/input_1.cairo b/src/tests/nodes/concat_i32_3d_axis_2/input_1.cairo new file mode 100644 index 000000000..edf434c98 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_2/input_1.cairo @@ -0,0 +1,41 @@ +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: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_axis_2/output_0.cairo b/src/tests/nodes/concat_i32_3d_axis_2/output_0.cairo new file mode 100644 index 000000000..f424384cf --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_axis_2/output_0.cairo @@ -0,0 +1,68 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(6); + + let mut data = ArrayTrait::new(); + 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: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_default.cairo b/src/tests/nodes/concat_i32_3d_default.cairo new file mode 100644 index 000000000..936890cd3 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_default.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i32_3d_default() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_default/input_0.cairo b/src/tests/nodes/concat_i32_3d_default/input_0.cairo new file mode 100644 index 000000000..aa97ad7e4 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_default/input_0.cairo @@ -0,0 +1,41 @@ +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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_default/input_1.cairo b/src/tests/nodes/concat_i32_3d_default/input_1.cairo new file mode 100644 index 000000000..edf434c98 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_default/input_1.cairo @@ -0,0 +1,41 @@ +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: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_default/output_0.cairo b/src/tests/nodes/concat_i32_3d_default/output_0.cairo new file mode 100644 index 000000000..4ccedc484 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_default/output_0.cairo @@ -0,0 +1,68 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + 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: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_1.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1.cairo new file mode 100644 index 000000000..f83b54529 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i32_3d_three_tensors_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_0.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_0.cairo new file mode 100644 index 000000000..aa97ad7e4 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_0.cairo @@ -0,0 +1,41 @@ +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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_1.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_1.cairo new file mode 100644 index 000000000..edf434c98 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_1.cairo @@ -0,0 +1,41 @@ +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: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_2.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_2.cairo new file mode 100644 index 000000000..26b58e89a --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/input_2.cairo @@ -0,0 +1,41 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 58, sign: false }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 60, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 62, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 68, sign: false }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 72, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 77, sign: false }); + data.append(i32 { mag: 78, sign: false }); + data.append(i32 { mag: 79, sign: false }); + data.append(i32 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/output_0.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/output_0.cairo new file mode 100644 index 000000000..bd6dca687 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_1/output_0.cairo @@ -0,0 +1,95 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(9); + shape.append(3); + + let mut data = ArrayTrait::new(); + 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: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 58, sign: false }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 60, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 62, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 68, sign: false }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + data.append(i32 { mag: 72, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 77, sign: false }); + data.append(i32 { mag: 78, sign: false }); + data.append(i32 { mag: 79, sign: false }); + data.append(i32 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_2.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2.cairo new file mode 100644 index 000000000..56bad9b55 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i32_3d_three_tensors_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_0.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_0.cairo new file mode 100644 index 000000000..aa97ad7e4 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_0.cairo @@ -0,0 +1,41 @@ +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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_1.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_1.cairo new file mode 100644 index 000000000..edf434c98 --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_1.cairo @@ -0,0 +1,41 @@ +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: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_2.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_2.cairo new file mode 100644 index 000000000..26b58e89a --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/input_2.cairo @@ -0,0 +1,41 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 58, sign: false }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 60, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 62, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 68, sign: false }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 72, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 77, sign: false }); + data.append(i32 { mag: 78, sign: false }); + data.append(i32 { mag: 79, sign: false }); + data.append(i32 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/output_0.cairo b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/output_0.cairo new file mode 100644 index 000000000..47a42821b --- /dev/null +++ b/src/tests/nodes/concat_i32_3d_three_tensors_axis_2/output_0.cairo @@ -0,0 +1,95 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(9); + + let mut data = ArrayTrait::new(); + 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: 27, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 58, sign: false }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 60, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 62, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 13, sign: false }); + data.append(i32 { mag: 14, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 68, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 46, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 72, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 77, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 53, sign: false }); + data.append(i32 { mag: 78, sign: false }); + data.append(i32 { mag: 79, sign: false }); + data.append(i32 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_1d.cairo b/src/tests/nodes/concat_i8_1d.cairo new file mode 100644 index 000000000..82587bdbd --- /dev/null +++ b/src/tests/nodes/concat_i8_1d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i8_1d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_1d/input_0.cairo b/src/tests/nodes/concat_i8_1d/input_0.cairo new file mode 100644 index 000000000..345f34d8c --- /dev/null +++ b/src/tests/nodes/concat_i8_1d/input_0.cairo @@ -0,0 +1,16 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_1d/input_1.cairo b/src/tests/nodes/concat_i8_1d/input_1.cairo new file mode 100644 index 000000000..e52565231 --- /dev/null +++ b/src/tests/nodes/concat_i8_1d/input_1.cairo @@ -0,0 +1,16 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_1d/output_0.cairo b/src/tests/nodes/concat_i8_1d/output_0.cairo new file mode 100644 index 000000000..d595c6ff9 --- /dev/null +++ b/src/tests/nodes/concat_i8_1d/output_0.cairo @@ -0,0 +1,19 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_2d.cairo b/src/tests/nodes/concat_i8_2d.cairo new file mode 100644 index 000000000..662e0c669 --- /dev/null +++ b/src/tests/nodes/concat_i8_2d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i8_2d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_2d/input_0.cairo b/src/tests/nodes/concat_i8_2d/input_0.cairo new file mode 100644 index 000000000..06f8f1737 --- /dev/null +++ b/src/tests/nodes/concat_i8_2d/input_0.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_2d/input_1.cairo b/src/tests/nodes/concat_i8_2d/input_1.cairo new file mode 100644 index 000000000..38a8a66a8 --- /dev/null +++ b/src/tests/nodes/concat_i8_2d/input_1.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_1() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_2d/output_0.cairo b/src/tests/nodes/concat_i8_2d/output_0.cairo new file mode 100644 index 000000000..77011ad63 --- /dev/null +++ b/src/tests/nodes/concat_i8_2d/output_0.cairo @@ -0,0 +1,22 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_1.cairo b/src/tests/nodes/concat_i8_3d_axis_1.cairo new file mode 100644 index 000000000..d8587be03 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i8_3d_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_1/input_0.cairo b/src/tests/nodes/concat_i8_3d_axis_1/input_0.cairo new file mode 100644 index 000000000..609111d3d --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_1/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_1/input_1.cairo b/src/tests/nodes/concat_i8_3d_axis_1/input_1.cairo new file mode 100644 index 000000000..c38024167 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_1/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_1/output_0.cairo b/src/tests/nodes/concat_i8_3d_axis_1/output_0.cairo new file mode 100644 index 000000000..0c57d7014 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_1/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(6); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_2.cairo b/src/tests/nodes/concat_i8_3d_axis_2.cairo new file mode 100644 index 000000000..f974a8273 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i8_3d_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_2/input_0.cairo b/src/tests/nodes/concat_i8_3d_axis_2/input_0.cairo new file mode 100644 index 000000000..609111d3d --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_2/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_2/input_1.cairo b/src/tests/nodes/concat_i8_3d_axis_2/input_1.cairo new file mode 100644 index 000000000..c38024167 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_2/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_axis_2/output_0.cairo b/src/tests/nodes/concat_i8_3d_axis_2/output_0.cairo new file mode 100644 index 000000000..49d2702e1 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_axis_2/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(6); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_default.cairo b/src/tests/nodes/concat_i8_3d_default.cairo new file mode 100644 index 000000000..9c1159d15 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_default.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i8_3d_default() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_default/input_0.cairo b/src/tests/nodes/concat_i8_3d_default/input_0.cairo new file mode 100644 index 000000000..609111d3d --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_default/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_default/input_1.cairo b/src/tests/nodes/concat_i8_3d_default/input_1.cairo new file mode 100644 index 000000000..c38024167 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_default/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_default/output_0.cairo b/src/tests/nodes/concat_i8_3d_default/output_0.cairo new file mode 100644 index 000000000..58df2dbe5 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_default/output_0.cairo @@ -0,0 +1,69 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + data.append(FP8x23 { mag: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_1.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1.cairo new file mode 100644 index 000000000..6fc3f9b99 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i8_3d_three_tensors_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_0.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_0.cairo new file mode 100644 index 000000000..609111d3d --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_1.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_1.cairo new file mode 100644 index 000000000..c38024167 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_2.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_2.cairo new file mode 100644 index 000000000..7ae4b9db0 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/input_2.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 54, sign: false }); + data.append(FP8x23 { mag: 55, sign: false }); + data.append(FP8x23 { mag: 56, sign: false }); + data.append(FP8x23 { mag: 57, sign: false }); + data.append(FP8x23 { mag: 58, sign: false }); + data.append(FP8x23 { mag: 59, sign: false }); + data.append(FP8x23 { mag: 60, sign: false }); + data.append(FP8x23 { mag: 61, sign: false }); + data.append(FP8x23 { mag: 62, sign: false }); + data.append(FP8x23 { mag: 63, sign: false }); + data.append(FP8x23 { mag: 64, sign: false }); + data.append(FP8x23 { mag: 65, sign: false }); + data.append(FP8x23 { mag: 66, sign: false }); + data.append(FP8x23 { mag: 67, sign: false }); + data.append(FP8x23 { mag: 68, sign: false }); + data.append(FP8x23 { mag: 69, sign: false }); + data.append(FP8x23 { mag: 70, sign: false }); + data.append(FP8x23 { mag: 71, sign: false }); + data.append(FP8x23 { mag: 72, sign: false }); + data.append(FP8x23 { mag: 73, sign: false }); + data.append(FP8x23 { mag: 74, sign: false }); + data.append(FP8x23 { mag: 75, sign: false }); + data.append(FP8x23 { mag: 76, sign: false }); + data.append(FP8x23 { mag: 77, sign: false }); + data.append(FP8x23 { mag: 78, sign: false }); + data.append(FP8x23 { mag: 79, sign: false }); + data.append(FP8x23 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/output_0.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/output_0.cairo new file mode 100644 index 000000000..fff9fef15 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_1/output_0.cairo @@ -0,0 +1,96 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(9); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 54, sign: false }); + data.append(FP8x23 { mag: 55, sign: false }); + data.append(FP8x23 { mag: 56, sign: false }); + data.append(FP8x23 { mag: 57, sign: false }); + data.append(FP8x23 { mag: 58, sign: false }); + data.append(FP8x23 { mag: 59, sign: false }); + data.append(FP8x23 { mag: 60, sign: false }); + data.append(FP8x23 { mag: 61, sign: false }); + data.append(FP8x23 { mag: 62, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 63, sign: false }); + data.append(FP8x23 { mag: 64, sign: false }); + data.append(FP8x23 { mag: 65, sign: false }); + data.append(FP8x23 { mag: 66, sign: false }); + data.append(FP8x23 { mag: 67, sign: false }); + data.append(FP8x23 { mag: 68, sign: false }); + data.append(FP8x23 { mag: 69, sign: false }); + data.append(FP8x23 { mag: 70, sign: false }); + data.append(FP8x23 { mag: 71, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + data.append(FP8x23 { mag: 72, sign: false }); + data.append(FP8x23 { mag: 73, sign: false }); + data.append(FP8x23 { mag: 74, sign: false }); + data.append(FP8x23 { mag: 75, sign: false }); + data.append(FP8x23 { mag: 76, sign: false }); + data.append(FP8x23 { mag: 77, sign: false }); + data.append(FP8x23 { mag: 78, sign: false }); + data.append(FP8x23 { mag: 79, sign: false }); + data.append(FP8x23 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_2.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2.cairo new file mode 100644 index 000000000..549959afa --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_i8_3d_three_tensors_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_0.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_0.cairo new file mode 100644 index 000000000..609111d3d --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_0.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_1.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_1.cairo new file mode 100644 index 000000000..c38024167 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_1.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_2.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_2.cairo new file mode 100644 index 000000000..7ae4b9db0 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/input_2.cairo @@ -0,0 +1,42 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 54, sign: false }); + data.append(FP8x23 { mag: 55, sign: false }); + data.append(FP8x23 { mag: 56, sign: false }); + data.append(FP8x23 { mag: 57, sign: false }); + data.append(FP8x23 { mag: 58, sign: false }); + data.append(FP8x23 { mag: 59, sign: false }); + data.append(FP8x23 { mag: 60, sign: false }); + data.append(FP8x23 { mag: 61, sign: false }); + data.append(FP8x23 { mag: 62, sign: false }); + data.append(FP8x23 { mag: 63, sign: false }); + data.append(FP8x23 { mag: 64, sign: false }); + data.append(FP8x23 { mag: 65, sign: false }); + data.append(FP8x23 { mag: 66, sign: false }); + data.append(FP8x23 { mag: 67, sign: false }); + data.append(FP8x23 { mag: 68, sign: false }); + data.append(FP8x23 { mag: 69, sign: false }); + data.append(FP8x23 { mag: 70, sign: false }); + data.append(FP8x23 { mag: 71, sign: false }); + data.append(FP8x23 { mag: 72, sign: false }); + data.append(FP8x23 { mag: 73, sign: false }); + data.append(FP8x23 { mag: 74, sign: false }); + data.append(FP8x23 { mag: 75, sign: false }); + data.append(FP8x23 { mag: 76, sign: false }); + data.append(FP8x23 { mag: 77, sign: false }); + data.append(FP8x23 { mag: 78, sign: false }); + data.append(FP8x23 { mag: 79, sign: false }); + data.append(FP8x23 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/output_0.cairo b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/output_0.cairo new file mode 100644 index 000000000..49d8bb277 --- /dev/null +++ b/src/tests/nodes/concat_i8_3d_three_tensors_axis_2/output_0.cairo @@ -0,0 +1,96 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(9); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 27, sign: false }); + data.append(FP8x23 { mag: 28, sign: false }); + data.append(FP8x23 { mag: 29, sign: false }); + data.append(FP8x23 { mag: 54, sign: false }); + data.append(FP8x23 { mag: 55, sign: false }); + data.append(FP8x23 { mag: 56, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + data.append(FP8x23 { mag: 30, sign: false }); + data.append(FP8x23 { mag: 31, sign: false }); + data.append(FP8x23 { mag: 32, sign: false }); + data.append(FP8x23 { mag: 57, sign: false }); + data.append(FP8x23 { mag: 58, sign: false }); + data.append(FP8x23 { mag: 59, sign: false }); + data.append(FP8x23 { mag: 6, sign: false }); + data.append(FP8x23 { mag: 7, sign: false }); + data.append(FP8x23 { mag: 8, sign: false }); + data.append(FP8x23 { mag: 33, sign: false }); + data.append(FP8x23 { mag: 34, sign: false }); + data.append(FP8x23 { mag: 35, sign: false }); + data.append(FP8x23 { mag: 60, sign: false }); + data.append(FP8x23 { mag: 61, sign: false }); + data.append(FP8x23 { mag: 62, sign: false }); + data.append(FP8x23 { mag: 9, sign: false }); + data.append(FP8x23 { mag: 10, sign: false }); + data.append(FP8x23 { mag: 11, sign: false }); + data.append(FP8x23 { mag: 36, sign: false }); + data.append(FP8x23 { mag: 37, sign: false }); + data.append(FP8x23 { mag: 38, sign: false }); + data.append(FP8x23 { mag: 63, sign: false }); + data.append(FP8x23 { mag: 64, sign: false }); + data.append(FP8x23 { mag: 65, sign: false }); + data.append(FP8x23 { mag: 12, sign: false }); + data.append(FP8x23 { mag: 13, sign: false }); + data.append(FP8x23 { mag: 14, sign: false }); + data.append(FP8x23 { mag: 39, sign: false }); + data.append(FP8x23 { mag: 40, sign: false }); + data.append(FP8x23 { mag: 41, sign: false }); + data.append(FP8x23 { mag: 66, sign: false }); + data.append(FP8x23 { mag: 67, sign: false }); + data.append(FP8x23 { mag: 68, sign: false }); + data.append(FP8x23 { mag: 15, sign: false }); + data.append(FP8x23 { mag: 16, sign: false }); + data.append(FP8x23 { mag: 17, sign: false }); + data.append(FP8x23 { mag: 42, sign: false }); + data.append(FP8x23 { mag: 43, sign: false }); + data.append(FP8x23 { mag: 44, sign: false }); + data.append(FP8x23 { mag: 69, sign: false }); + data.append(FP8x23 { mag: 70, sign: false }); + data.append(FP8x23 { mag: 71, sign: false }); + data.append(FP8x23 { mag: 18, sign: false }); + data.append(FP8x23 { mag: 19, sign: false }); + data.append(FP8x23 { mag: 20, sign: false }); + data.append(FP8x23 { mag: 45, sign: false }); + data.append(FP8x23 { mag: 46, sign: false }); + data.append(FP8x23 { mag: 47, sign: false }); + data.append(FP8x23 { mag: 72, sign: false }); + data.append(FP8x23 { mag: 73, sign: false }); + data.append(FP8x23 { mag: 74, sign: false }); + data.append(FP8x23 { mag: 21, sign: false }); + data.append(FP8x23 { mag: 22, sign: false }); + data.append(FP8x23 { mag: 23, sign: false }); + data.append(FP8x23 { mag: 48, sign: false }); + data.append(FP8x23 { mag: 49, sign: false }); + data.append(FP8x23 { mag: 50, sign: false }); + data.append(FP8x23 { mag: 75, sign: false }); + data.append(FP8x23 { mag: 76, sign: false }); + data.append(FP8x23 { mag: 77, sign: false }); + data.append(FP8x23 { mag: 24, sign: false }); + data.append(FP8x23 { mag: 25, sign: false }); + data.append(FP8x23 { mag: 26, sign: false }); + data.append(FP8x23 { mag: 51, sign: false }); + data.append(FP8x23 { mag: 52, sign: false }); + data.append(FP8x23 { mag: 53, sign: false }); + data.append(FP8x23 { mag: 78, sign: false }); + data.append(FP8x23 { mag: 79, sign: false }); + data.append(FP8x23 { mag: 80, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_1d.cairo b/src/tests/nodes/concat_u32_1d.cairo new file mode 100644 index 000000000..700e7bd2f --- /dev/null +++ b/src/tests/nodes/concat_u32_1d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_u32_1d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_1d/input_0.cairo b/src/tests/nodes/concat_u32_1d/input_0.cairo new file mode 100644 index 000000000..26ecd350b --- /dev/null +++ b/src/tests/nodes/concat_u32_1d/input_0.cairo @@ -0,0 +1,14 @@ +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); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_1d/input_1.cairo b/src/tests/nodes/concat_u32_1d/input_1.cairo new file mode 100644 index 000000000..ee5e4ed99 --- /dev/null +++ b/src/tests/nodes/concat_u32_1d/input_1.cairo @@ -0,0 +1,14 @@ +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); + + let mut data = ArrayTrait::new(); + data.append(3); + data.append(4); + data.append(5); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_1d/output_0.cairo b/src/tests/nodes/concat_u32_1d/output_0.cairo new file mode 100644 index 000000000..3b6302d9f --- /dev/null +++ b/src/tests/nodes/concat_u32_1d/output_0.cairo @@ -0,0 +1,17 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_2d.cairo b/src/tests/nodes/concat_u32_2d.cairo new file mode 100644 index 000000000..7ae4a8eed --- /dev/null +++ b/src/tests/nodes/concat_u32_2d.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_u32_2d() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_2d/input_0.cairo b/src/tests/nodes/concat_u32_2d/input_0.cairo new file mode 100644 index 000000000..6c324ceb6 --- /dev/null +++ b/src/tests/nodes/concat_u32_2d/input_0.cairo @@ -0,0 +1,16 @@ +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(1); + data.append(2); + data.append(3); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_2d/input_1.cairo b/src/tests/nodes/concat_u32_2d/input_1.cairo new file mode 100644 index 000000000..df41e2c70 --- /dev/null +++ b/src/tests/nodes/concat_u32_2d/input_1.cairo @@ -0,0 +1,16 @@ +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(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_2d/output_0.cairo b/src/tests/nodes/concat_u32_2d/output_0.cairo new file mode 100644 index 000000000..d2b9b09cb --- /dev/null +++ b/src/tests/nodes/concat_u32_2d/output_0.cairo @@ -0,0 +1,20 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(4); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_1.cairo b/src/tests/nodes/concat_u32_3d_axis_1.cairo new file mode 100644 index 000000000..32698c264 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_1.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_u32_3d_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_1/input_0.cairo b/src/tests/nodes/concat_u32_3d_axis_1/input_0.cairo new file mode 100644 index 000000000..353984f4f --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_1/input_0.cairo @@ -0,0 +1,40 @@ +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(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_1/input_1.cairo b/src/tests/nodes/concat_u32_3d_axis_1/input_1.cairo new file mode 100644 index 000000000..ce950d8a0 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_1/input_1.cairo @@ -0,0 +1,40 @@ +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(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_1/output_0.cairo b/src/tests/nodes/concat_u32_3d_axis_1/output_0.cairo new file mode 100644 index 000000000..143fd9c91 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_1/output_0.cairo @@ -0,0 +1,67 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(6); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_2.cairo b/src/tests/nodes/concat_u32_3d_axis_2.cairo new file mode 100644 index 000000000..6788eaa38 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_2.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_u32_3d_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_2/input_0.cairo b/src/tests/nodes/concat_u32_3d_axis_2/input_0.cairo new file mode 100644 index 000000000..353984f4f --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_2/input_0.cairo @@ -0,0 +1,40 @@ +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(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_2/input_1.cairo b/src/tests/nodes/concat_u32_3d_axis_2/input_1.cairo new file mode 100644 index 000000000..ce950d8a0 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_2/input_1.cairo @@ -0,0 +1,40 @@ +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(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_axis_2/output_0.cairo b/src/tests/nodes/concat_u32_3d_axis_2/output_0.cairo new file mode 100644 index 000000000..b9bb512d9 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_axis_2/output_0.cairo @@ -0,0 +1,67 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(6); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(27); + data.append(28); + data.append(29); + data.append(3); + data.append(4); + data.append(5); + data.append(30); + data.append(31); + data.append(32); + data.append(6); + data.append(7); + data.append(8); + data.append(33); + data.append(34); + data.append(35); + data.append(9); + data.append(10); + data.append(11); + data.append(36); + data.append(37); + data.append(38); + data.append(12); + data.append(13); + data.append(14); + data.append(39); + data.append(40); + data.append(41); + data.append(15); + data.append(16); + data.append(17); + data.append(42); + data.append(43); + data.append(44); + data.append(18); + data.append(19); + data.append(20); + data.append(45); + data.append(46); + data.append(47); + data.append(21); + data.append(22); + data.append(23); + data.append(48); + data.append(49); + data.append(50); + data.append(24); + data.append(25); + data.append(26); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_default.cairo b/src/tests/nodes/concat_u32_3d_default.cairo new file mode 100644 index 000000000..5ffbd651b --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_default.cairo @@ -0,0 +1,22 @@ +mod input_0; +mod input_1; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_u32_3d_default() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1].span(), 0); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_default/input_0.cairo b/src/tests/nodes/concat_u32_3d_default/input_0.cairo new file mode 100644 index 000000000..353984f4f --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_default/input_0.cairo @@ -0,0 +1,40 @@ +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(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_default/input_1.cairo b/src/tests/nodes/concat_u32_3d_default/input_1.cairo new file mode 100644 index 000000000..ce950d8a0 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_default/input_1.cairo @@ -0,0 +1,40 @@ +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(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_default/output_0.cairo b/src/tests/nodes/concat_u32_3d_default/output_0.cairo new file mode 100644 index 000000000..d4ad140b0 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_default/output_0.cairo @@ -0,0 +1,67 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(6); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + data.append(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_1.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1.cairo new file mode 100644 index 000000000..b15cde11b --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_u32_3d_three_tensors_axis_1() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 1); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_0.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_0.cairo new file mode 100644 index 000000000..353984f4f --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_0.cairo @@ -0,0 +1,40 @@ +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(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_1.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_1.cairo new file mode 100644 index 000000000..ce950d8a0 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_1.cairo @@ -0,0 +1,40 @@ +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(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_2.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_2.cairo new file mode 100644 index 000000000..686accc0a --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/input_2.cairo @@ -0,0 +1,40 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(54); + data.append(55); + data.append(56); + data.append(57); + data.append(58); + data.append(59); + data.append(60); + data.append(61); + data.append(62); + data.append(63); + data.append(64); + data.append(65); + data.append(66); + data.append(67); + data.append(68); + data.append(69); + data.append(70); + data.append(71); + data.append(72); + data.append(73); + data.append(74); + data.append(75); + data.append(76); + data.append(77); + data.append(78); + data.append(79); + data.append(80); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/output_0.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/output_0.cairo new file mode 100644 index 000000000..944680ca8 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_1/output_0.cairo @@ -0,0 +1,94 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(9); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(54); + data.append(55); + data.append(56); + data.append(57); + data.append(58); + data.append(59); + data.append(60); + data.append(61); + data.append(62); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(63); + data.append(64); + data.append(65); + data.append(66); + data.append(67); + data.append(68); + data.append(69); + data.append(70); + data.append(71); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + data.append(72); + data.append(73); + data.append(74); + data.append(75); + data.append(76); + data.append(77); + data.append(78); + data.append(79); + data.append(80); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_2.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2.cairo new file mode 100644 index 000000000..233842e37 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2.cairo @@ -0,0 +1,24 @@ +mod input_0; +mod input_1; +mod input_2; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_concat_u32_3d_three_tensors_axis_2() { + let input_0 = input_0::input_0(); + let input_1 = input_1::input_1(); + let input_2 = input_2::input_2(); + let z = output_0::output_0(); + + let y = TensorTrait::concat(array![input_0, input_1, input_2].span(), 2); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_0.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_0.cairo new file mode 100644 index 000000000..353984f4f --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_0.cairo @@ -0,0 +1,40 @@ +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(0); + data.append(1); + data.append(2); + data.append(3); + data.append(4); + data.append(5); + data.append(6); + data.append(7); + data.append(8); + data.append(9); + data.append(10); + data.append(11); + data.append(12); + data.append(13); + data.append(14); + data.append(15); + data.append(16); + data.append(17); + data.append(18); + data.append(19); + data.append(20); + data.append(21); + data.append(22); + data.append(23); + data.append(24); + data.append(25); + data.append(26); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_1.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_1.cairo new file mode 100644 index 000000000..ce950d8a0 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_1.cairo @@ -0,0 +1,40 @@ +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(27); + data.append(28); + data.append(29); + data.append(30); + data.append(31); + data.append(32); + data.append(33); + data.append(34); + data.append(35); + data.append(36); + data.append(37); + data.append(38); + data.append(39); + data.append(40); + data.append(41); + data.append(42); + data.append(43); + data.append(44); + data.append(45); + data.append(46); + data.append(47); + data.append(48); + data.append(49); + data.append(50); + data.append(51); + data.append(52); + data.append(53); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_2.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_2.cairo new file mode 100644 index 000000000..686accc0a --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/input_2.cairo @@ -0,0 +1,40 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn input_2() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(3); + + let mut data = ArrayTrait::new(); + data.append(54); + data.append(55); + data.append(56); + data.append(57); + data.append(58); + data.append(59); + data.append(60); + data.append(61); + data.append(62); + data.append(63); + data.append(64); + data.append(65); + data.append(66); + data.append(67); + data.append(68); + data.append(69); + data.append(70); + data.append(71); + data.append(72); + data.append(73); + data.append(74); + data.append(75); + data.append(76); + data.append(77); + data.append(78); + data.append(79); + data.append(80); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/output_0.cairo b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/output_0.cairo new file mode 100644 index 000000000..c2b13d310 --- /dev/null +++ b/src/tests/nodes/concat_u32_3d_three_tensors_axis_2/output_0.cairo @@ -0,0 +1,94 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(3); + shape.append(9); + + let mut data = ArrayTrait::new(); + data.append(0); + data.append(1); + data.append(2); + data.append(27); + data.append(28); + data.append(29); + data.append(54); + data.append(55); + data.append(56); + data.append(3); + data.append(4); + data.append(5); + data.append(30); + data.append(31); + data.append(32); + data.append(57); + data.append(58); + data.append(59); + data.append(6); + data.append(7); + data.append(8); + data.append(33); + data.append(34); + data.append(35); + data.append(60); + data.append(61); + data.append(62); + data.append(9); + data.append(10); + data.append(11); + data.append(36); + data.append(37); + data.append(38); + data.append(63); + data.append(64); + data.append(65); + data.append(12); + data.append(13); + data.append(14); + data.append(39); + data.append(40); + data.append(41); + data.append(66); + data.append(67); + data.append(68); + data.append(15); + data.append(16); + data.append(17); + data.append(42); + data.append(43); + data.append(44); + data.append(69); + data.append(70); + data.append(71); + data.append(18); + data.append(19); + data.append(20); + data.append(45); + data.append(46); + data.append(47); + data.append(72); + data.append(73); + data.append(74); + data.append(21); + data.append(22); + data.append(23); + data.append(48); + data.append(49); + data.append(50); + data.append(75); + data.append(76); + data.append(77); + data.append(24); + data.append(25); + data.append(26); + data.append(51); + data.append(52); + data.append(53); + data.append(78); + data.append(79); + data.append(80); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/cos_fp16x16.cairo b/src/tests/nodes/cos_fp16x16.cairo index 29771fb04..dbfb6b27f 100644 --- a/src/tests/nodes/cos_fp16x16.cairo +++ b/src/tests/nodes/cos_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cos_fp16x16/input_0.cairo b/src/tests/nodes/cos_fp16x16/input_0.cairo index 9bbabc1a7..5ae705b41 100644 --- a/src/tests/nodes/cos_fp16x16/input_0.cairo +++ b/src/tests/nodes/cos_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1124701, sign: false }); - data.append(FixedType { mag: 8168605, sign: false }); - data.append(FixedType { mag: 1101252, sign: false }); - data.append(FixedType { mag: 3797411, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 1737975, sign: false }); + data.append(FP16x16 { mag: 6312706, sign: false }); + data.append(FP16x16 { mag: 5651744, sign: false }); + data.append(FP16x16 { mag: 6320564, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cos_fp16x16/output_0.cairo b/src/tests/nodes/cos_fp16x16/output_0.cairo index 27bd09e09..7d3e451d1 100644 --- a/src/tests/nodes/cos_fp16x16/output_0.cairo +++ b/src/tests/nodes/cos_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7661, sign: true }); - data.append(FixedType { mag: 34261, sign: false }); - data.append(FixedType { mag: 29970, sign: true }); - data.append(FixedType { mag: 11446, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 11999, sign: false }); + data.append(FP16x16 { mag: 31746, sign: true }); + data.append(FP16x16 { mag: 10118, sign: true }); + data.append(FP16x16 { mag: 38375, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cos_fp8x23.cairo b/src/tests/nodes/cos_fp8x23.cairo index 1736fa9dd..93bd1b161 100644 --- a/src/tests/nodes/cos_fp8x23.cairo +++ b/src/tests/nodes/cos_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cos_fp8x23/input_0.cairo b/src/tests/nodes/cos_fp8x23/input_0.cairo index 323d59fb3..d13e263ef 100644 --- a/src/tests/nodes/cos_fp8x23/input_0.cairo +++ b/src/tests/nodes/cos_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 659237788, sign: false }); - data.append(FixedType { mag: 648364998, sign: false }); - data.append(FixedType { mag: 215345765, sign: false }); - data.append(FixedType { mag: 592758692, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 658990, sign: true }); + data.append(FP8x23 { mag: 330978878, sign: false }); + data.append(FP8x23 { mag: 820031043, sign: false }); + data.append(FP8x23 { mag: 154991942, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cos_fp8x23/output_0.cairo b/src/tests/nodes/cos_fp8x23/output_0.cairo index baf2e319a..810a3468c 100644 --- a/src/tests/nodes/cos_fp8x23/output_0.cairo +++ b/src/tests/nodes/cos_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8379165, sign: true }); - data.append(FixedType { mag: 2655577, sign: true }); - data.append(FixedType { mag: 7201553, sign: false }); - data.append(FixedType { mag: 197048, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8362736, sign: false }); + data.append(FP8x23 { mag: 1550053, sign: true }); + data.append(FP8x23 { mag: 7833162, sign: true }); + data.append(FP8x23 { mag: 7811558, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cos_i32_fp16x16.cairo b/src/tests/nodes/cos_i32_fp16x16.cairo deleted file mode 100644 index e51e7223a..000000000 --- a/src/tests/nodes/cos_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cos_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cos(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i32_fp16x16/input_0.cairo b/src/tests/nodes/cos_i32_fp16x16/input_0.cairo deleted file mode 100644 index 2b076617c..000000000 --- a/src/tests/nodes/cos_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 96, sign: false }); - data.append(i32 { mag: 98, sign: false }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 15, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i32_fp16x16/output_0.cairo b/src/tests/nodes/cos_i32_fp16x16/output_0.cairo deleted file mode 100644 index 2cf3ae23b..000000000 --- a/src/tests/nodes/cos_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 11824, sign: true }); - data.append(FixedType { mag: 53692, sign: true }); - data.append(FixedType { mag: 64880, sign: true }); - data.append(FixedType { mag: 49786, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i32_fp8x23.cairo b/src/tests/nodes/cos_i32_fp8x23.cairo deleted file mode 100644 index b5864259f..000000000 --- a/src/tests/nodes/cos_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cos_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cos(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i32_fp8x23/input_0.cairo b/src/tests/nodes/cos_i32_fp8x23/input_0.cairo deleted file mode 100644 index fe791e2a6..000000000 --- a/src/tests/nodes/cos_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 110, sign: false }); - data.append(i32 { mag: 61, sign: false }); - data.append(i32 { mag: 124, sign: false }); - data.append(i32 { mag: 95, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i32_fp8x23/output_0.cairo b/src/tests/nodes/cos_i32_fp8x23/output_0.cairo deleted file mode 100644 index ed32888f7..000000000 --- a/src/tests/nodes/cos_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8380393, sign: true }); - data.append(FixedType { mag: 2165113, sign: true }); - data.append(FixedType { mag: 778263, sign: true }); - data.append(FixedType { mag: 6125139, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i8_fp16x16.cairo b/src/tests/nodes/cos_i8_fp16x16.cairo deleted file mode 100644 index 89005fac5..000000000 --- a/src/tests/nodes/cos_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cos_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cos(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i8_fp16x16/input_0.cairo b/src/tests/nodes/cos_i8_fp16x16/input_0.cairo deleted file mode 100644 index 576e335a8..000000000 --- a/src/tests/nodes/cos_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 81, sign: false }); - data.append(i8 { mag: 87, sign: false }); - data.append(i8 { mag: 31, sign: false }); - data.append(i8 { mag: 55, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i8_fp16x16/output_0.cairo b/src/tests/nodes/cos_i8_fp16x16/output_0.cairo deleted file mode 100644 index 220a04da4..000000000 --- a/src/tests/nodes/cos_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 50900, sign: false }); - data.append(FixedType { mag: 37339, sign: false }); - data.append(FixedType { mag: 59948, sign: false }); - data.append(FixedType { mag: 1450, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i8_fp8x23.cairo b/src/tests/nodes/cos_i8_fp8x23.cairo deleted file mode 100644 index a09cbb62e..000000000 --- a/src/tests/nodes/cos_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cos_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cos(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i8_fp8x23/input_0.cairo b/src/tests/nodes/cos_i8_fp8x23/input_0.cairo deleted file mode 100644 index c9c7ea432..000000000 --- a/src/tests/nodes/cos_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 3, sign: false }); - data.append(i8 { mag: 5, sign: true }); - data.append(i8 { mag: 4, sign: true }); - data.append(i8 { mag: 4, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_i8_fp8x23/output_0.cairo b/src/tests/nodes/cos_i8_fp8x23/output_0.cairo deleted file mode 100644 index f2319934f..000000000 --- a/src/tests/nodes/cos_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8306688, sign: true }); - data.append(FixedType { mag: 2379776, sign: false }); - data.append(FixedType { mag: 5484544, sign: true }); - data.append(FixedType { mag: 5484544, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_u32_fp16x16.cairo b/src/tests/nodes/cos_u32_fp16x16.cairo deleted file mode 100644 index 3ab953abc..000000000 --- a/src/tests/nodes/cos_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cos_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cos(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cos_u32_fp16x16/input_0.cairo b/src/tests/nodes/cos_u32_fp16x16/input_0.cairo deleted file mode 100644 index d410ab347..000000000 --- a/src/tests/nodes/cos_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(63); - data.append(124); - data.append(56); - data.append(7); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_u32_fp16x16/output_0.cairo b/src/tests/nodes/cos_u32_fp16x16/output_0.cairo deleted file mode 100644 index 4eab32a03..000000000 --- a/src/tests/nodes/cos_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 64611, sign: false }); - data.append(FixedType { mag: 6080, sign: true }); - data.append(FixedType { mag: 55916, sign: false }); - data.append(FixedType { mag: 49407, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_u32_fp8x23.cairo b/src/tests/nodes/cos_u32_fp8x23.cairo deleted file mode 100644 index 44af02592..000000000 --- a/src/tests/nodes/cos_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cos_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cos(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cos_u32_fp8x23/input_0.cairo b/src/tests/nodes/cos_u32_fp8x23/input_0.cairo deleted file mode 100644 index 07d23c9de..000000000 --- a/src/tests/nodes/cos_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(35); - data.append(79); - data.append(61); - data.append(114); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cos_u32_fp8x23/output_0.cairo b/src/tests/nodes/cos_u32_fp8x23/output_0.cairo deleted file mode 100644 index a6d8e8d21..000000000 --- a/src/tests/nodes/cos_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7580719, sign: true }); - data.append(FixedType { mag: 7515949, sign: true }); - data.append(FixedType { mag: 2165113, sign: true }); - data.append(FixedType { mag: 5196915, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_fp16x16.cairo b/src/tests/nodes/cosh_fp16x16.cairo index 4ca6c2e23..772a93f25 100644 --- a/src/tests/nodes/cosh_fp16x16.cairo +++ b/src/tests/nodes/cosh_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cosh_fp16x16/input_0.cairo b/src/tests/nodes/cosh_fp16x16/input_0.cairo index f95750f7c..1b196b149 100644 --- a/src/tests/nodes/cosh_fp16x16/input_0.cairo +++ b/src/tests/nodes/cosh_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 174763, sign: false }); - data.append(FixedType { mag: 5569, sign: false }); - data.append(FixedType { mag: 19618, sign: true }); - data.append(FixedType { mag: 34591, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 180002, sign: false }); + data.append(FP16x16 { mag: 115071, sign: true }); + data.append(FP16x16 { mag: 111643, sign: true }); + data.append(FP16x16 { mag: 184638, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cosh_fp16x16/output_0.cairo b/src/tests/nodes/cosh_fp16x16/output_0.cairo index f23814806..8b4f0f741 100644 --- a/src/tests/nodes/cosh_fp16x16/output_0.cairo +++ b/src/tests/nodes/cosh_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 473877, sign: false }); - data.append(FixedType { mag: 65772, sign: false }); - data.append(FixedType { mag: 68494, sign: false }); - data.append(FixedType { mag: 74879, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 512946, sign: false }); + data.append(FP16x16 { mag: 195335, sign: false }); + data.append(FP16x16 { mag: 185972, sign: false }); + data.append(FP16x16 { mag: 550252, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cosh_fp8x23.cairo b/src/tests/nodes/cosh_fp8x23.cairo index 888c49561..f12f6c751 100644 --- a/src/tests/nodes/cosh_fp8x23.cairo +++ b/src/tests/nodes/cosh_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cosh_fp8x23/input_0.cairo b/src/tests/nodes/cosh_fp8x23/input_0.cairo index dc491b7fd..66dea31f1 100644 --- a/src/tests/nodes/cosh_fp8x23/input_0.cairo +++ b/src/tests/nodes/cosh_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1254371, sign: false }); - data.append(FixedType { mag: 21304437, sign: false }); - data.append(FixedType { mag: 12450493, sign: true }); - data.append(FixedType { mag: 6511071, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 23096690, sign: true }); + data.append(FP8x23 { mag: 10692965, sign: false }); + data.append(FP8x23 { mag: 17437172, sign: true }); + data.append(FP8x23 { mag: 24645388, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cosh_fp8x23/output_0.cairo b/src/tests/nodes/cosh_fp8x23/output_0.cairo index e59958899..6069e6a4a 100644 --- a/src/tests/nodes/cosh_fp8x23/output_0.cairo +++ b/src/tests/nodes/cosh_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8482567, sign: false }); - data.append(FixedType { mag: 53496638, sign: false }); - data.append(FixedType { mag: 19453932, sign: false }); - data.append(FixedType { mag: 11044927, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 66096700, sign: false }); + data.append(FP8x23 { mag: 16178040, sign: false }); + data.append(FP8x23 { mag: 34053341, sign: false }); + data.append(FP8x23 { mag: 79399253, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cosh_i32_fp16x16.cairo b/src/tests/nodes/cosh_i32_fp16x16.cairo deleted file mode 100644 index 296aec2f6..000000000 --- a/src/tests/nodes/cosh_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cosh_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i32_fp16x16/input_0.cairo b/src/tests/nodes/cosh_i32_fp16x16/input_0.cairo deleted file mode 100644 index b2df0dfd9..000000000 --- a/src/tests/nodes/cosh_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i32_fp16x16/output_0.cairo b/src/tests/nodes/cosh_i32_fp16x16/output_0.cairo deleted file mode 100644 index 4fd9e2f4e..000000000 --- a/src/tests/nodes/cosh_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 101127, sign: false }); - data.append(FixedType { mag: 246559, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 659794, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i32_fp8x23.cairo b/src/tests/nodes/cosh_i32_fp8x23.cairo deleted file mode 100644 index d1481350e..000000000 --- a/src/tests/nodes/cosh_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cosh_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i32_fp8x23/input_0.cairo b/src/tests/nodes/cosh_i32_fp8x23/input_0.cairo deleted file mode 100644 index 263e64c52..000000000 --- a/src/tests/nodes/cosh_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i32_fp8x23/output_0.cairo b/src/tests/nodes/cosh_i32_fp8x23/output_0.cairo deleted file mode 100644 index f8eb15e22..000000000 --- a/src/tests/nodes/cosh_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 84453669, sign: false }); - data.append(FixedType { mag: 84453669, sign: false }); - data.append(FixedType { mag: 12944298, sign: false }); - data.append(FixedType { mag: 12944298, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i8_fp16x16.cairo b/src/tests/nodes/cosh_i8_fp16x16.cairo deleted file mode 100644 index 98d1c0e6d..000000000 --- a/src/tests/nodes/cosh_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cosh_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i8_fp16x16/input_0.cairo b/src/tests/nodes/cosh_i8_fp16x16/input_0.cairo deleted file mode 100644 index 25d95d873..000000000 --- a/src/tests/nodes/cosh_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i8_fp16x16/output_0.cairo b/src/tests/nodes/cosh_i8_fp16x16/output_0.cairo deleted file mode 100644 index da4fc6879..000000000 --- a/src/tests/nodes/cosh_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 101127, sign: false }); - data.append(FixedType { mag: 101127, sign: false }); - data.append(FixedType { mag: 101127, sign: false }); - data.append(FixedType { mag: 246559, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i8_fp8x23.cairo b/src/tests/nodes/cosh_i8_fp8x23.cairo deleted file mode 100644 index ac7b90dd3..000000000 --- a/src/tests/nodes/cosh_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cosh_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i8_fp8x23/input_0.cairo b/src/tests/nodes/cosh_i8_fp8x23/input_0.cairo deleted file mode 100644 index 90c297b15..000000000 --- a/src/tests/nodes/cosh_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_i8_fp8x23/output_0.cairo b/src/tests/nodes/cosh_i8_fp8x23/output_0.cairo deleted file mode 100644 index 9fc2ff00f..000000000 --- a/src/tests/nodes/cosh_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 31555584, sign: false }); - data.append(FixedType { mag: 31555584, sign: false }); - data.append(FixedType { mag: 31555584, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_u32_fp16x16.cairo b/src/tests/nodes/cosh_u32_fp16x16.cairo deleted file mode 100644 index ea78253c5..000000000 --- a/src/tests/nodes/cosh_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cosh_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_u32_fp16x16/input_0.cairo b/src/tests/nodes/cosh_u32_fp16x16/input_0.cairo deleted file mode 100644 index a556ee0cd..000000000 --- a/src/tests/nodes/cosh_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -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(1); - data.append(5); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_u32_fp16x16/output_0.cairo b/src/tests/nodes/cosh_u32_fp16x16/output_0.cairo deleted file mode 100644 index abc914ab7..000000000 --- a/src/tests/nodes/cosh_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 101127, sign: false }); - data.append(FixedType { mag: 4863423, sign: false }); - data.append(FixedType { mag: 101127, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_u32_fp8x23.cairo b/src/tests/nodes/cosh_u32_fp8x23.cairo deleted file mode 100644 index 44f266fc2..000000000 --- a/src/tests/nodes/cosh_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_cosh_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.cosh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_u32_fp8x23/input_0.cairo b/src/tests/nodes/cosh_u32_fp8x23/input_0.cairo deleted file mode 100644 index 05bd283d2..000000000 --- a/src/tests/nodes/cosh_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(4); - data.append(4); - data.append(1); - data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cosh_u32_fp8x23/output_0.cairo b/src/tests/nodes/cosh_u32_fp8x23/output_0.cairo deleted file mode 100644 index 6105cd097..000000000 --- a/src/tests/nodes/cosh_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 229078060, sign: false }); - data.append(FixedType { mag: 229078060, sign: false }); - data.append(FixedType { mag: 12944298, sign: false }); - data.append(FixedType { mag: 84453669, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_default.cairo b/src/tests/nodes/cumsum_fp16x16_1d_default.cairo index dbc928e3b..8bee503e5 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_default.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp16x16_1d_default/input_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_default/input_0.cairo index 1b5c91363..175583ac6 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_default/input_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_default/output_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_default/output_0.cairo index c11cd7137..9e94ff3a3 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_default/output_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_default/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 655360, sign: false }); - data.append(FixedType { mag: 983040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_exclusive.cairo b/src/tests/nodes/cumsum_fp16x16_1d_exclusive.cairo index f92156016..f1b19e9d6 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_exclusive.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp16x16_1d_exclusive/input_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_exclusive/input_0.cairo index 1b5c91363..175583ac6 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_exclusive/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_exclusive/output_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_exclusive/output_0.cairo index 46a015daf..a6a0cc910 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_exclusive/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 655360, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_reverse.cairo b/src/tests/nodes/cumsum_fp16x16_1d_reverse.cairo index 519490576..ec84dbad4 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_reverse.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_reverse.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp16x16_1d_reverse/input_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_reverse/input_0.cairo index 1b5c91363..175583ac6 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_reverse/input_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_reverse/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_reverse/output_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_reverse/output_0.cairo index 1abc4fbf0..0dd64716f 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_reverse/output_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_reverse/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 983040, sign: false }); - data.append(FixedType { mag: 917504, sign: false }); - data.append(FixedType { mag: 786432, sign: false }); - data.append(FixedType { mag: 589824, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive.cairo b/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive.cairo index 7c92f7e3e..a488da6fd 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/input_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/input_0.cairo index 1b5c91363..175583ac6 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/output_0.cairo b/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/output_0.cairo index 7f6b2493b..f654a1f59 100644 --- a/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_1d_reverse_exclusive/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 917504, sign: false }); - data.append(FixedType { mag: 786432, sign: false }); - data.append(FixedType { mag: 589824, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_2d_axis_0.cairo b/src/tests/nodes/cumsum_fp16x16_2d_axis_0.cairo index 63f9ea47b..5492b5631 100644 --- a/src/tests/nodes/cumsum_fp16x16_2d_axis_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_2d_axis_0.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp16x16_2d_axis_0/input_0.cairo b/src/tests/nodes/cumsum_fp16x16_2d_axis_0/input_0.cairo index 934814fd2..062fb7dd6 100644 --- a/src/tests/nodes/cumsum_fp16x16_2d_axis_0/input_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_2d_axis_0/input_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_2d_axis_0/output_0.cairo b/src/tests/nodes/cumsum_fp16x16_2d_axis_0/output_0.cairo index cb01a5629..3f72a9934 100644 --- a/src/tests/nodes/cumsum_fp16x16_2d_axis_0/output_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_2d_axis_0/output_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 458752, sign: false }); - data.append(FixedType { mag: 589824, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_2d_axis_1.cairo b/src/tests/nodes/cumsum_fp16x16_2d_axis_1.cairo index a671d28a2..1637170e9 100644 --- a/src/tests/nodes/cumsum_fp16x16_2d_axis_1.cairo +++ b/src/tests/nodes/cumsum_fp16x16_2d_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp16x16_2d_axis_1/input_0.cairo b/src/tests/nodes/cumsum_fp16x16_2d_axis_1/input_0.cairo index 934814fd2..062fb7dd6 100644 --- a/src/tests/nodes/cumsum_fp16x16_2d_axis_1/input_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_2d_axis_1/input_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp16x16_2d_axis_1/output_0.cairo b/src/tests/nodes/cumsum_fp16x16_2d_axis_1/output_0.cairo index 175a17a16..a4aaa86cc 100644 --- a/src/tests/nodes/cumsum_fp16x16_2d_axis_1/output_0.cairo +++ b/src/tests/nodes/cumsum_fp16x16_2d_axis_1/output_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 589824, sign: false }); - data.append(FixedType { mag: 983040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 983040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_default.cairo b/src/tests/nodes/cumsum_fp8x23_1d_default.cairo index 5ecfa0fcb..64dc9537b 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_default.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp8x23_1d_default/input_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_default/input_0.cairo index 14f535fbf..7c097058a 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_default/input_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_default/output_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_default/output_0.cairo index c56a40a87..0567359ee 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_default/output_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_default/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 50331648, sign: false }); - data.append(FixedType { mag: 83886080, sign: false }); - data.append(FixedType { mag: 125829120, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_exclusive.cairo b/src/tests/nodes/cumsum_fp8x23_1d_exclusive.cairo index 8383c1b6c..ae75e2f77 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_exclusive.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp8x23_1d_exclusive/input_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_exclusive/input_0.cairo index 14f535fbf..7c097058a 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_exclusive/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_exclusive/output_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_exclusive/output_0.cairo index 34e150e89..0272f6c36 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_exclusive/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 50331648, sign: false }); - data.append(FixedType { mag: 83886080, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 50331648, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_reverse.cairo b/src/tests/nodes/cumsum_fp8x23_1d_reverse.cairo index 078f33843..80a866b5b 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_reverse.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_reverse.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp8x23_1d_reverse/input_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_reverse/input_0.cairo index 14f535fbf..7c097058a 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_reverse/input_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_reverse/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_reverse/output_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_reverse/output_0.cairo index aa3f91d81..fe3108e56 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_reverse/output_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_reverse/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 125829120, sign: false }); - data.append(FixedType { mag: 117440512, sign: false }); - data.append(FixedType { mag: 100663296, sign: false }); - data.append(FixedType { mag: 75497472, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive.cairo b/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive.cairo index 111b30c3a..8ad9e5de1 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/input_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/input_0.cairo index 14f535fbf..7c097058a 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/output_0.cairo b/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/output_0.cairo index de2450141..41aa2f72f 100644 --- a/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_1d_reverse_exclusive/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(5); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 117440512, sign: false }); - data.append(FixedType { mag: 100663296, sign: false }); - data.append(FixedType { mag: 75497472, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_2d_axis_0.cairo b/src/tests/nodes/cumsum_fp8x23_2d_axis_0.cairo index 5d1660fc1..11dae065c 100644 --- a/src/tests/nodes/cumsum_fp8x23_2d_axis_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_2d_axis_0.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp8x23_2d_axis_0/input_0.cairo b/src/tests/nodes/cumsum_fp8x23_2d_axis_0/input_0.cairo index b21b34933..1f68e2bc8 100644 --- a/src/tests/nodes/cumsum_fp8x23_2d_axis_0/input_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_2d_axis_0/input_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - data.append(FixedType { mag: 50331648, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_2d_axis_0/output_0.cairo b/src/tests/nodes/cumsum_fp8x23_2d_axis_0/output_0.cairo index 750721b85..15d59ba23 100644 --- a/src/tests/nodes/cumsum_fp8x23_2d_axis_0/output_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_2d_axis_0/output_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - data.append(FixedType { mag: 58720256, sign: false }); - data.append(FixedType { mag: 75497472, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_2d_axis_1.cairo b/src/tests/nodes/cumsum_fp8x23_2d_axis_1.cairo index 78b5b6848..61bc3d1c4 100644 --- a/src/tests/nodes/cumsum_fp8x23_2d_axis_1.cairo +++ b/src/tests/nodes/cumsum_fp8x23_2d_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_fp8x23_2d_axis_1/input_0.cairo b/src/tests/nodes/cumsum_fp8x23_2d_axis_1/input_0.cairo index b21b34933..1f68e2bc8 100644 --- a/src/tests/nodes/cumsum_fp8x23_2d_axis_1/input_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_2d_axis_1/input_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - data.append(FixedType { mag: 50331648, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_fp8x23_2d_axis_1/output_0.cairo b/src/tests/nodes/cumsum_fp8x23_2d_axis_1/output_0.cairo index bc3e164c5..04c5f8028 100644 --- a/src/tests/nodes/cumsum_fp8x23_2d_axis_1/output_0.cairo +++ b/src/tests/nodes/cumsum_fp8x23_2d_axis_1/output_0.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 50331648, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 75497472, sign: false }); - data.append(FixedType { mag: 125829120, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_default.cairo b/src/tests/nodes/cumsum_i32_1d_default.cairo index 86846ccbf..a6cea41e5 100644 --- a/src/tests/nodes/cumsum_i32_1d_default.cairo +++ b/src/tests/nodes/cumsum_i32_1d_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i32_1d_default/input_0.cairo b/src/tests/nodes/cumsum_i32_1d_default/input_0.cairo index 390c70006..0ac4a9f61 100644 --- a/src/tests/nodes/cumsum_i32_1d_default/input_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 3, sign: false }); data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_default/output_0.cairo b/src/tests/nodes/cumsum_i32_1d_default/output_0.cairo index a68b8ac1c..60da35a37 100644 --- a/src/tests/nodes/cumsum_i32_1d_default/output_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_default/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i32 { mag: 6, sign: false }); data.append(i32 { mag: 10, sign: false }); data.append(i32 { mag: 15, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_exclusive.cairo b/src/tests/nodes/cumsum_i32_1d_exclusive.cairo index 259a427d3..58b497bb4 100644 --- a/src/tests/nodes/cumsum_i32_1d_exclusive.cairo +++ b/src/tests/nodes/cumsum_i32_1d_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i32_1d_exclusive/input_0.cairo b/src/tests/nodes/cumsum_i32_1d_exclusive/input_0.cairo index 390c70006..0ac4a9f61 100644 --- a/src/tests/nodes/cumsum_i32_1d_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_exclusive/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 3, sign: false }); data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_exclusive/output_0.cairo b/src/tests/nodes/cumsum_i32_1d_exclusive/output_0.cairo index 666d84df3..1299ea06c 100644 --- a/src/tests/nodes/cumsum_i32_1d_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_exclusive/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i32 { mag: 3, sign: false }); data.append(i32 { mag: 6, sign: false }); data.append(i32 { mag: 10, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_reverse.cairo b/src/tests/nodes/cumsum_i32_1d_reverse.cairo index bc0de66e6..88a21cb5f 100644 --- a/src/tests/nodes/cumsum_i32_1d_reverse.cairo +++ b/src/tests/nodes/cumsum_i32_1d_reverse.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i32_1d_reverse/input_0.cairo b/src/tests/nodes/cumsum_i32_1d_reverse/input_0.cairo index 390c70006..0ac4a9f61 100644 --- a/src/tests/nodes/cumsum_i32_1d_reverse/input_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_reverse/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 3, sign: false }); data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_reverse/output_0.cairo b/src/tests/nodes/cumsum_i32_1d_reverse/output_0.cairo index b49d1eb8c..2fcc00a39 100644 --- a/src/tests/nodes/cumsum_i32_1d_reverse/output_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_reverse/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i32 { mag: 12, sign: false }); data.append(i32 { mag: 9, sign: false }); data.append(i32 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_reverse_exclusive.cairo b/src/tests/nodes/cumsum_i32_1d_reverse_exclusive.cairo index 6dc74511d..d3c9d8cf1 100644 --- a/src/tests/nodes/cumsum_i32_1d_reverse_exclusive.cairo +++ b/src/tests/nodes/cumsum_i32_1d_reverse_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/input_0.cairo b/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/input_0.cairo index 390c70006..0ac4a9f61 100644 --- a/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 3, sign: false }); data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/output_0.cairo b/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/output_0.cairo index 38282b7bb..60333d5cb 100644 --- a/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_i32_1d_reverse_exclusive/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i32 { mag: 9, sign: false }); data.append(i32 { mag: 5, sign: false }); data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_2d_axis_0.cairo b/src/tests/nodes/cumsum_i32_2d_axis_0.cairo index 0d7cbad82..9564c8627 100644 --- a/src/tests/nodes/cumsum_i32_2d_axis_0.cairo +++ b/src/tests/nodes/cumsum_i32_2d_axis_0.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i32_2d_axis_0/input_0.cairo b/src/tests/nodes/cumsum_i32_2d_axis_0/input_0.cairo index 5f49d52d4..ae45ce844 100644 --- a/src/tests/nodes/cumsum_i32_2d_axis_0/input_0.cairo +++ b/src/tests/nodes/cumsum_i32_2d_axis_0/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -16,7 +15,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); data.append(i32 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_2d_axis_0/output_0.cairo b/src/tests/nodes/cumsum_i32_2d_axis_0/output_0.cairo index 303877fe4..a6ac4eec4 100644 --- a/src/tests/nodes/cumsum_i32_2d_axis_0/output_0.cairo +++ b/src/tests/nodes/cumsum_i32_2d_axis_0/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -16,7 +15,5 @@ fn output_0() -> Tensor { data.append(i32 { mag: 5, sign: false }); data.append(i32 { mag: 7, sign: false }); data.append(i32 { mag: 9, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_2d_axis_1.cairo b/src/tests/nodes/cumsum_i32_2d_axis_1.cairo index a33764a4a..6336d5204 100644 --- a/src/tests/nodes/cumsum_i32_2d_axis_1.cairo +++ b/src/tests/nodes/cumsum_i32_2d_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i32_2d_axis_1/input_0.cairo b/src/tests/nodes/cumsum_i32_2d_axis_1/input_0.cairo index 5f49d52d4..ae45ce844 100644 --- a/src/tests/nodes/cumsum_i32_2d_axis_1/input_0.cairo +++ b/src/tests/nodes/cumsum_i32_2d_axis_1/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -16,7 +15,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 5, sign: false }); data.append(i32 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i32_2d_axis_1/output_0.cairo b/src/tests/nodes/cumsum_i32_2d_axis_1/output_0.cairo index 7dacd5740..fe9c23754 100644 --- a/src/tests/nodes/cumsum_i32_2d_axis_1/output_0.cairo +++ b/src/tests/nodes/cumsum_i32_2d_axis_1/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -16,7 +15,5 @@ fn output_0() -> Tensor { data.append(i32 { mag: 4, sign: false }); data.append(i32 { mag: 9, sign: false }); data.append(i32 { mag: 15, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_default.cairo b/src/tests/nodes/cumsum_i8_1d_default.cairo index a1a09ba95..9b4d9a835 100644 --- a/src/tests/nodes/cumsum_i8_1d_default.cairo +++ b/src/tests/nodes/cumsum_i8_1d_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i8_1d_default/input_0.cairo b/src/tests/nodes/cumsum_i8_1d_default/input_0.cairo index 5dea728e3..96c706cdb 100644 --- a/src/tests/nodes/cumsum_i8_1d_default/input_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_default/output_0.cairo b/src/tests/nodes/cumsum_i8_1d_default/output_0.cairo index 0020a682b..5edbc3a6e 100644 --- a/src/tests/nodes/cumsum_i8_1d_default/output_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_default/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i8 { mag: 6, sign: false }); data.append(i8 { mag: 10, sign: false }); data.append(i8 { mag: 15, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_exclusive.cairo b/src/tests/nodes/cumsum_i8_1d_exclusive.cairo index d460ee27c..52c366960 100644 --- a/src/tests/nodes/cumsum_i8_1d_exclusive.cairo +++ b/src/tests/nodes/cumsum_i8_1d_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i8_1d_exclusive/input_0.cairo b/src/tests/nodes/cumsum_i8_1d_exclusive/input_0.cairo index 5dea728e3..96c706cdb 100644 --- a/src/tests/nodes/cumsum_i8_1d_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_exclusive/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_exclusive/output_0.cairo b/src/tests/nodes/cumsum_i8_1d_exclusive/output_0.cairo index e8a2677f7..80272b3c0 100644 --- a/src/tests/nodes/cumsum_i8_1d_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_exclusive/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 6, sign: false }); data.append(i8 { mag: 10, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_reverse.cairo b/src/tests/nodes/cumsum_i8_1d_reverse.cairo index 8c9ab4e50..83595125d 100644 --- a/src/tests/nodes/cumsum_i8_1d_reverse.cairo +++ b/src/tests/nodes/cumsum_i8_1d_reverse.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i8_1d_reverse/input_0.cairo b/src/tests/nodes/cumsum_i8_1d_reverse/input_0.cairo index 5dea728e3..96c706cdb 100644 --- a/src/tests/nodes/cumsum_i8_1d_reverse/input_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_reverse/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_reverse/output_0.cairo b/src/tests/nodes/cumsum_i8_1d_reverse/output_0.cairo index c5ba0ed5c..480def7de 100644 --- a/src/tests/nodes/cumsum_i8_1d_reverse/output_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_reverse/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i8 { mag: 12, sign: false }); data.append(i8 { mag: 9, sign: false }); data.append(i8 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_reverse_exclusive.cairo b/src/tests/nodes/cumsum_i8_1d_reverse_exclusive.cairo index d1bea9d7b..2a344e9b8 100644 --- a/src/tests/nodes/cumsum_i8_1d_reverse_exclusive.cairo +++ b/src/tests/nodes/cumsum_i8_1d_reverse_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/input_0.cairo b/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/input_0.cairo index 5dea728e3..96c706cdb 100644 --- a/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/output_0.cairo b/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/output_0.cairo index 7f0009207..c3980cbf3 100644 --- a/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_i8_1d_reverse_exclusive/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,7 +13,5 @@ fn output_0() -> Tensor { data.append(i8 { mag: 9, sign: false }); data.append(i8 { mag: 5, sign: false }); data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_2d_axis_0.cairo b/src/tests/nodes/cumsum_i8_2d_axis_0.cairo index 0ecd56f8a..9f06d8788 100644 --- a/src/tests/nodes/cumsum_i8_2d_axis_0.cairo +++ b/src/tests/nodes/cumsum_i8_2d_axis_0.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i8_2d_axis_0/input_0.cairo b/src/tests/nodes/cumsum_i8_2d_axis_0/input_0.cairo index 76e0a7ee5..e1bb10267 100644 --- a/src/tests/nodes/cumsum_i8_2d_axis_0/input_0.cairo +++ b/src/tests/nodes/cumsum_i8_2d_axis_0/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -16,7 +15,5 @@ fn input_0() -> Tensor { data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 5, sign: false }); data.append(i8 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_2d_axis_0/output_0.cairo b/src/tests/nodes/cumsum_i8_2d_axis_0/output_0.cairo index ef2cf4fe1..a18fc8584 100644 --- a/src/tests/nodes/cumsum_i8_2d_axis_0/output_0.cairo +++ b/src/tests/nodes/cumsum_i8_2d_axis_0/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -16,7 +15,5 @@ fn output_0() -> Tensor { data.append(i8 { mag: 5, sign: false }); data.append(i8 { mag: 7, sign: false }); data.append(i8 { mag: 9, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_2d_axis_1.cairo b/src/tests/nodes/cumsum_i8_2d_axis_1.cairo index 58d00eb00..7d2669176 100644 --- a/src/tests/nodes/cumsum_i8_2d_axis_1.cairo +++ b/src/tests/nodes/cumsum_i8_2d_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_i8_2d_axis_1/input_0.cairo b/src/tests/nodes/cumsum_i8_2d_axis_1/input_0.cairo index 76e0a7ee5..e1bb10267 100644 --- a/src/tests/nodes/cumsum_i8_2d_axis_1/input_0.cairo +++ b/src/tests/nodes/cumsum_i8_2d_axis_1/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -16,7 +15,5 @@ fn input_0() -> Tensor { data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 5, sign: false }); data.append(i8 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_i8_2d_axis_1/output_0.cairo b/src/tests/nodes/cumsum_i8_2d_axis_1/output_0.cairo index 6d9af8387..99eab414d 100644 --- a/src/tests/nodes/cumsum_i8_2d_axis_1/output_0.cairo +++ b/src/tests/nodes/cumsum_i8_2d_axis_1/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -16,7 +15,5 @@ fn output_0() -> Tensor { data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 9, sign: false }); data.append(i8 { mag: 15, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_default.cairo b/src/tests/nodes/cumsum_u32_1d_default.cairo index bc2a6b894..5e9d98156 100644 --- a/src/tests/nodes/cumsum_u32_1d_default.cairo +++ b/src/tests/nodes/cumsum_u32_1d_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_u32_1d_default/input_0.cairo b/src/tests/nodes/cumsum_u32_1d_default/input_0.cairo index 6a30c058d..622c5d695 100644 --- a/src/tests/nodes/cumsum_u32_1d_default/input_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_default/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn input_0() -> Tensor { data.append(3); data.append(4); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_default/output_0.cairo b/src/tests/nodes/cumsum_u32_1d_default/output_0.cairo index 3ec20cf1e..c2d0bdbf6 100644 --- a/src/tests/nodes/cumsum_u32_1d_default/output_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(6); data.append(10); data.append(15); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_exclusive.cairo b/src/tests/nodes/cumsum_u32_1d_exclusive.cairo index c1d178f12..2223740e6 100644 --- a/src/tests/nodes/cumsum_u32_1d_exclusive.cairo +++ b/src/tests/nodes/cumsum_u32_1d_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_u32_1d_exclusive/input_0.cairo b/src/tests/nodes/cumsum_u32_1d_exclusive/input_0.cairo index 6a30c058d..622c5d695 100644 --- a/src/tests/nodes/cumsum_u32_1d_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_exclusive/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn input_0() -> Tensor { data.append(3); data.append(4); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_exclusive/output_0.cairo b/src/tests/nodes/cumsum_u32_1d_exclusive/output_0.cairo index 2858f930a..f5fec21fc 100644 --- a/src/tests/nodes/cumsum_u32_1d_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_exclusive/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(3); data.append(6); data.append(10); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_reverse.cairo b/src/tests/nodes/cumsum_u32_1d_reverse.cairo index 6297aa523..cab7a64f6 100644 --- a/src/tests/nodes/cumsum_u32_1d_reverse.cairo +++ b/src/tests/nodes/cumsum_u32_1d_reverse.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_u32_1d_reverse/input_0.cairo b/src/tests/nodes/cumsum_u32_1d_reverse/input_0.cairo index 6a30c058d..622c5d695 100644 --- a/src/tests/nodes/cumsum_u32_1d_reverse/input_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_reverse/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn input_0() -> Tensor { data.append(3); data.append(4); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_reverse/output_0.cairo b/src/tests/nodes/cumsum_u32_1d_reverse/output_0.cairo index 603b312ba..5650f5bdc 100644 --- a/src/tests/nodes/cumsum_u32_1d_reverse/output_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_reverse/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(12); data.append(9); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_reverse_exclusive.cairo b/src/tests/nodes/cumsum_u32_1d_reverse_exclusive.cairo index 36845fbdb..0ac724f0b 100644 --- a/src/tests/nodes/cumsum_u32_1d_reverse_exclusive.cairo +++ b/src/tests/nodes/cumsum_u32_1d_reverse_exclusive.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/input_0.cairo b/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/input_0.cairo index 6a30c058d..622c5d695 100644 --- a/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/input_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn input_0() -> Tensor { data.append(3); data.append(4); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/output_0.cairo b/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/output_0.cairo index 190ae26a5..e6f2a8444 100644 --- a/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/output_0.cairo +++ b/src/tests/nodes/cumsum_u32_1d_reverse_exclusive/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(9); data.append(5); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_2d_axis_0.cairo b/src/tests/nodes/cumsum_u32_2d_axis_0.cairo index 86a4b7f6d..c21143147 100644 --- a/src/tests/nodes/cumsum_u32_2d_axis_0.cairo +++ b/src/tests/nodes/cumsum_u32_2d_axis_0.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_u32_2d_axis_0/input_0.cairo b/src/tests/nodes/cumsum_u32_2d_axis_0/input_0.cairo index f9ecdfb1a..6e6b0b0c3 100644 --- a/src/tests/nodes/cumsum_u32_2d_axis_0/input_0.cairo +++ b/src/tests/nodes/cumsum_u32_2d_axis_0/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -15,7 +14,5 @@ fn input_0() -> Tensor { data.append(4); data.append(5); data.append(6); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_2d_axis_0/output_0.cairo b/src/tests/nodes/cumsum_u32_2d_axis_0/output_0.cairo index 00df5dc3c..21198b1fe 100644 --- a/src/tests/nodes/cumsum_u32_2d_axis_0/output_0.cairo +++ b/src/tests/nodes/cumsum_u32_2d_axis_0/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -15,7 +14,5 @@ fn output_0() -> Tensor { data.append(5); data.append(7); data.append(9); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_2d_axis_1.cairo b/src/tests/nodes/cumsum_u32_2d_axis_1.cairo index 5ba61ccbd..145a334e4 100644 --- a/src/tests/nodes/cumsum_u32_2d_axis_1.cairo +++ b/src/tests/nodes/cumsum_u32_2d_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/cumsum_u32_2d_axis_1/input_0.cairo b/src/tests/nodes/cumsum_u32_2d_axis_1/input_0.cairo index f9ecdfb1a..6e6b0b0c3 100644 --- a/src/tests/nodes/cumsum_u32_2d_axis_1/input_0.cairo +++ b/src/tests/nodes/cumsum_u32_2d_axis_1/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -15,7 +14,5 @@ fn input_0() -> Tensor { data.append(4); data.append(5); data.append(6); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/cumsum_u32_2d_axis_1/output_0.cairo b/src/tests/nodes/cumsum_u32_2d_axis_1/output_0.cairo index f5fec9c79..322f993c8 100644 --- a/src/tests/nodes/cumsum_u32_2d_axis_1/output_0.cairo +++ b/src/tests/nodes/cumsum_u32_2d_axis_1/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -15,7 +14,5 @@ fn output_0() -> Tensor { data.append(4); data.append(9); data.append(15); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp16x16.cairo b/src/tests/nodes/div_fp16x16.cairo index f3cce6fcf..1c65ce822 100644 --- a/src/tests/nodes/div_fp16x16.cairo +++ b/src/tests/nodes/div_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/div_fp16x16/input_0.cairo b/src/tests/nodes/div_fp16x16/input_0.cairo index c72691b25..ebec1dd71 100644 --- a/src/tests/nodes/div_fp16x16/input_0.cairo +++ b/src/tests/nodes/div_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: 65536, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp16x16/input_1.cairo b/src/tests/nodes/div_fp16x16/input_1.cairo index e876b7815..5664c9473 100644 --- a/src/tests/nodes/div_fp16x16/input_1.cairo +++ b/src/tests/nodes/div_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 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: 65536, 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: 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: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, 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 }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp16x16/output_0.cairo b/src/tests/nodes/div_fp16x16/output_0.cairo index 2fcb02c80..a9d2fed91 100644 --- a/src/tests/nodes/div_fp16x16/output_0.cairo +++ b/src/tests/nodes/div_fp16x16/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp16x16_broadcast.cairo b/src/tests/nodes/div_fp16x16_broadcast.cairo index e34d6165b..ab365df13 100644 --- a/src/tests/nodes/div_fp16x16_broadcast.cairo +++ b/src/tests/nodes/div_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorDiv}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/div_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/div_fp16x16_broadcast/input_0.cairo index 2e31e794d..0e7830f68 100644 --- a/src/tests/nodes/div_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/div_fp16x16_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, 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: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, 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: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/div_fp16x16_broadcast/input_1.cairo index ceebffc97..b40221126 100644 --- a/src/tests/nodes/div_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/div_fp16x16_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/div_fp16x16_broadcast/output_0.cairo index 6a2bcb425..bc5d6d0fa 100644 --- a/src/tests/nodes/div_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/div_fp16x16_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, 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: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 32768, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp8x23.cairo b/src/tests/nodes/div_fp8x23.cairo index 02ce3e12b..9b3cd41b2 100644 --- a/src/tests/nodes/div_fp8x23.cairo +++ b/src/tests/nodes/div_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/div_fp8x23/input_0.cairo b/src/tests/nodes/div_fp8x23/input_0.cairo index 27e734b92..5207a2e67 100644 --- a/src/tests/nodes/div_fp8x23/input_0.cairo +++ b/src/tests/nodes/div_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 16777216, sign: false }); + 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: 16777216, sign: false }); + 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: 8388608, 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp8x23/input_1.cairo b/src/tests/nodes/div_fp8x23/input_1.cairo index 75120ea60..fba559547 100644 --- a/src/tests/nodes/div_fp8x23/input_1.cairo +++ b/src/tests/nodes/div_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: false }); + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp8x23/output_0.cairo b/src/tests/nodes/div_fp8x23/output_0.cairo index 3a3fa43e2..6e05358a7 100644 --- a/src/tests/nodes/div_fp8x23/output_0.cairo +++ b/src/tests/nodes/div_fp8x23/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 4194304, sign: false }); + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 4194304, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 16777216, 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()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp8x23_broadcast.cairo b/src/tests/nodes/div_fp8x23_broadcast.cairo index a809c3028..98247d410 100644 --- a/src/tests/nodes/div_fp8x23_broadcast.cairo +++ b/src/tests/nodes/div_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorDiv}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/div_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/div_fp8x23_broadcast/input_0.cairo index 2e60fe300..3f8fd0134 100644 --- a/src/tests/nodes/div_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/div_fp8x23_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: false }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/div_fp8x23_broadcast/input_1.cairo index be9b9e7cc..cf2ddd464 100644 --- a/src/tests/nodes/div_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/div_fp8x23_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/div_fp8x23_broadcast/output_0.cairo index 018962054..fd04e1ce4 100644 --- a/src/tests/nodes/div_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/div_fp8x23_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + data.append(FP8x23 { mag: 4194304, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i32.cairo b/src/tests/nodes/div_i32.cairo index 3886e83f0..55ea834d1 100644 --- a/src/tests/nodes/div_i32.cairo +++ b/src/tests/nodes/div_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_div_i32() { let y = input_0 / input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/div_i32/input_0.cairo b/src/tests/nodes/div_i32/input_0.cairo index da372e35c..e40e76185 100644 --- a/src/tests/nodes/div_i32/input_0.cairo +++ b/src/tests/nodes/div_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,33 +11,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 2, 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: 1, sign: false }); - data.append(i32 { mag: 1, 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: 2, 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: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); 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: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, 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: 2, sign: false }); + data.append(i32 { mag: 1, 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: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i32/input_1.cairo b/src/tests/nodes/div_i32/input_1.cairo index d94921270..cfc7cc5ca 100644 --- a/src/tests/nodes/div_i32/input_1.cairo +++ b/src/tests/nodes/div_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -16,29 +15,27 @@ fn input_1() -> Tensor { data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: false }); - 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: 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: 2, sign: false }); data.append(i32 { mag: 2, 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: 1, sign: false }); data.append(i32 { mag: 1, 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: 1, sign: false }); 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: 2, 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: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i32/output_0.cairo b/src/tests/nodes/div_i32/output_0.cairo index c40b28c01..358bed425 100644 --- a/src/tests/nodes/div_i32/output_0.cairo +++ b/src/tests/nodes/div_i32/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,33 +11,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); 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: 1, sign: false }); - 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: 1, sign: false }); data.append(i32 { mag: 1, 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: 2, sign: false }); - 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: 2, sign: false }); 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: 0, sign: false }); data.append(i32 { mag: 2, sign: false }); + 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: 0, sign: false }); data.append(i32 { mag: 1, 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: 1, sign: false }); data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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 }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i32_broadcast.cairo b/src/tests/nodes/div_i32_broadcast.cairo index 9f8d6af8e..0d00bb6d0 100644 --- a/src/tests/nodes/div_i32_broadcast.cairo +++ b/src/tests/nodes/div_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorDiv}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_div_i32_broadcast() { let y = input_0 / input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/div_i32_broadcast/input_0.cairo b/src/tests/nodes/div_i32_broadcast/input_0.cairo index 42ef70667..6e8ea6c4b 100644 --- a/src/tests/nodes/div_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/div_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,33 +11,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, 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: 2, sign: false }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: false }); - 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: 2, sign: false }); + data.append(i32 { mag: 1, 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: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 2, 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: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); 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: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i32_broadcast/input_1.cairo b/src/tests/nodes/div_i32_broadcast/input_1.cairo index 5c245f8bf..efeeb68df 100644 --- a/src/tests/nodes/div_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/div_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i32_broadcast/output_0.cairo b/src/tests/nodes/div_i32_broadcast/output_0.cairo index 0854c96ae..4a93a54a2 100644 --- a/src/tests/nodes/div_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/div_i32_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, 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: 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: 0, 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: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); 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: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, 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: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, 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: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i8.cairo b/src/tests/nodes/div_i8.cairo index 36a86b3be..86ce3b8cc 100644 --- a/src/tests/nodes/div_i8.cairo +++ b/src/tests/nodes/div_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_div_i8() { let y = input_0 / input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/div_i8/input_0.cairo b/src/tests/nodes/div_i8/input_0.cairo index ae295d942..9b38ea284 100644 --- a/src/tests/nodes/div_i8/input_0.cairo +++ b/src/tests/nodes/div_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -13,32 +12,30 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i8/input_1.cairo b/src/tests/nodes/div_i8/input_1.cairo index a46ee6563..f708358c8 100644 --- a/src/tests/nodes/div_i8/input_1.cairo +++ b/src/tests/nodes/div_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -12,16 +11,11 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); @@ -29,8 +23,10 @@ fn input_1() -> Tensor { data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); @@ -38,7 +34,8 @@ fn input_1() -> Tensor { data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i8/output_0.cairo b/src/tests/nodes/div_i8/output_0.cairo index 28f31d38c..f3984d981 100644 --- a/src/tests/nodes/div_i8/output_0.cairo +++ b/src/tests/nodes/div_i8/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,33 +11,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i8_broadcast.cairo b/src/tests/nodes/div_i8_broadcast.cairo index f264c5ed5..360b783ee 100644 --- a/src/tests/nodes/div_i8_broadcast.cairo +++ b/src/tests/nodes/div_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorDiv}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_div_i8_broadcast() { let y = input_0 / input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/div_i8_broadcast/input_0.cairo b/src/tests/nodes/div_i8_broadcast/input_0.cairo index 8df73bfba..3ca175b18 100644 --- a/src/tests/nodes/div_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/div_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -16,29 +15,27 @@ fn input_0() -> Tensor { data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i8_broadcast/input_1.cairo b/src/tests/nodes/div_i8_broadcast/input_1.cairo index 7c39646e2..ffe7f6894 100644 --- a/src/tests/nodes/div_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/div_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -14,7 +13,5 @@ fn input_1() -> Tensor { data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_i8_broadcast/output_0.cairo b/src/tests/nodes/div_i8_broadcast/output_0.cairo index c7efc133a..e40d4d24c 100644 --- a/src/tests/nodes/div_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/div_i8_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -16,29 +15,27 @@ fn output_0() -> Tensor { data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_u32.cairo b/src/tests/nodes/div_u32.cairo index 8b4dc4573..1d0ff31b6 100644 --- a/src/tests/nodes/div_u32.cairo +++ b/src/tests/nodes/div_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_div_u32() { let y = input_0 / input_1; assert_eq(y, z); -} \ No newline at end of file +} diff --git a/src/tests/nodes/div_u32/input_0.cairo b/src/tests/nodes/div_u32/input_0.cairo index 18e0e8b27..c2c6b44f3 100644 --- a/src/tests/nodes/div_u32/input_0.cairo +++ b/src/tests/nodes/div_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(5); - data.append(5); - data.append(5); data.append(4); - data.append(5); + data.append(4); data.append(3); data.append(3); + data.append(5); data.append(3); + data.append(5); + data.append(5); + data.append(4); + data.append(4); data.append(3); data.append(3); - data.append(4); data.append(5); data.append(3); - data.append(5); data.append(4); data.append(3); data.append(4); - data.append(3); data.append(4); data.append(3); - data.append(5); data.append(3); data.append(3); data.append(4); - data.append(5); data.append(3); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(4); + data.append(4); + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_u32/input_1.cairo b/src/tests/nodes/div_u32/input_1.cairo index e66b42bdf..0283570db 100644 --- a/src/tests/nodes/div_u32/input_1.cairo +++ b/src/tests/nodes/div_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,31 +12,29 @@ fn input_1() -> Tensor { data.append(2); data.append(2); data.append(1); - data.append(1); - data.append(2); - data.append(2); - data.append(2); data.append(2); data.append(1); + data.append(1); data.append(2); data.append(2); data.append(2); data.append(2); data.append(2); + data.append(1); + data.append(1); + data.append(1); data.append(2); + data.append(1); data.append(2); - data.append(2); - data.append(2); + data.append(1); data.append(2); data.append(1); data.append(1); - data.append(2); + data.append(1); data.append(1); data.append(2); data.append(2); - data.append(1); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_u32/output_0.cairo b/src/tests/nodes/div_u32/output_0.cairo index 11c26ee86..d43ae3e2b 100644 --- a/src/tests/nodes/div_u32/output_0.cairo +++ b/src/tests/nodes/div_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,32 +11,30 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); data.append(2); - data.append(5); - data.append(4); - data.append(2); - data.append(1); - data.append(1); - data.append(1); data.append(3); data.append(1); + data.append(5); + data.append(3); data.append(2); data.append(2); - data.append(1); - data.append(2); data.append(2); - data.append(1); data.append(2); data.append(1); - data.append(2); data.append(3); data.append(5); - data.append(1); data.append(3); data.append(2); + data.append(3); data.append(2); + data.append(4); + data.append(1); + data.append(3); + data.append(3); + data.append(4); data.append(3); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + data.append(2); + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_u32_broadcast.cairo b/src/tests/nodes/div_u32_broadcast.cairo index 8851264a1..e1988ad32 100644 --- a/src/tests/nodes/div_u32_broadcast.cairo +++ b/src/tests/nodes/div_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorDiv}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorDiv}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_div_u32_broadcast() { let y = input_0 / input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/div_u32_broadcast/input_0.cairo b/src/tests/nodes/div_u32_broadcast/input_0.cairo index 69839ac8e..e9c930eb7 100644 --- a/src/tests/nodes/div_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/div_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(3); - data.append(3); - data.append(3); - data.append(5); - data.append(3); data.append(4); - data.append(3); data.append(4); data.append(5); - data.append(5); data.append(4); data.append(5); data.append(4); data.append(4); data.append(3); - data.append(5); + data.append(3); + data.append(3); + data.append(3); data.append(5); data.append(4); data.append(4); + data.append(3); + data.append(3); + data.append(3); + data.append(4); data.append(5); data.append(5); data.append(4); + data.append(4); + data.append(3); + data.append(3); data.append(3); data.append(3); - data.append(5); data.append(4); - data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_u32_broadcast/input_1.cairo b/src/tests/nodes/div_u32_broadcast/input_1.cairo index 69e61900e..114a06d12 100644 --- a/src/tests/nodes/div_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/div_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(2); data.append(1); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/div_u32_broadcast/output_0.cairo b/src/tests/nodes/div_u32_broadcast/output_0.cairo index befd81ef4..7db27318f 100644 --- a/src/tests/nodes/div_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/div_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(1); - data.append(1); - data.append(1); + data.append(4); + data.append(4); data.append(5); - data.append(3); data.append(4); - data.append(1); - data.append(2); - data.append(2); - data.append(2); - data.append(2); - data.append(2); + data.append(5); data.append(4); data.append(4); data.append(3); - data.append(2); - data.append(2); - data.append(2); - data.append(2); - data.append(2); - data.append(2); + data.append(3); + data.append(3); + data.append(3); + data.append(5); + data.append(4); data.append(4); data.append(3); data.append(3); - data.append(2); - data.append(2); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + data.append(4); + data.append(5); + data.append(5); + data.append(4); + data.append(4); + data.append(3); + data.append(3); + data.append(3); + data.append(3); + data.append(4); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp16x16.cairo b/src/tests/nodes/equal_fp16x16.cairo index e15710ad0..e5f8ba27f 100644 --- a/src/tests/nodes/equal_fp16x16.cairo +++ b/src/tests/nodes/equal_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_fp16x16/input_0.cairo b/src/tests/nodes/equal_fp16x16/input_0.cairo index 16b74c29b..bb2d30b13 100644 --- a/src/tests/nodes/equal_fp16x16/input_0.cairo +++ b/src/tests/nodes/equal_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp16x16/input_1.cairo b/src/tests/nodes/equal_fp16x16/input_1.cairo index f204ba5a8..022b7aeff 100644 --- a/src/tests/nodes/equal_fp16x16/input_1.cairo +++ b/src/tests/nodes/equal_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 0, 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: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + 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: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, 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: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp16x16/output_0.cairo b/src/tests/nodes/equal_fp16x16/output_0.cairo index 4ab3771e3..4ac107912 100644 --- a/src/tests/nodes/equal_fp16x16/output_0.cairo +++ b/src/tests/nodes/equal_fp16x16/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -17,7 +16,9 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); @@ -26,18 +27,14 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(1); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(0); - data.append(0); - data.append(1); data.append(1); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp16x16_broadcast.cairo b/src/tests/nodes/equal_fp16x16_broadcast.cairo index 9b4b7b155..a2939736f 100644 --- a/src/tests/nodes/equal_fp16x16_broadcast.cairo +++ b/src/tests/nodes/equal_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/equal_fp16x16_broadcast/input_0.cairo index d71231702..f8c2e9849 100644 --- a/src/tests/nodes/equal_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/equal_fp16x16_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/equal_fp16x16_broadcast/input_1.cairo index f97d91601..0e549709b 100644 --- a/src/tests/nodes/equal_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/equal_fp16x16_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/equal_fp16x16_broadcast/output_0.cairo index b681bb975..386b678ef 100644 --- a/src/tests/nodes/equal_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/equal_fp16x16_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); + data.append(1); data.append(0); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp8x23.cairo b/src/tests/nodes/equal_fp8x23.cairo index 937752d81..bf987d766 100644 --- a/src/tests/nodes/equal_fp8x23.cairo +++ b/src/tests/nodes/equal_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_fp8x23/input_0.cairo b/src/tests/nodes/equal_fp8x23/input_0.cairo index 52ebf010f..bad79cb47 100644 --- a/src/tests/nodes/equal_fp8x23/input_0.cairo +++ b/src/tests/nodes/equal_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, 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: false }); + data.append(FP8x23 { mag: 8388608, 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: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, 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: 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: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp8x23/input_1.cairo b/src/tests/nodes/equal_fp8x23/input_1.cairo index 946791c68..5ab3d78e3 100644 --- a/src/tests/nodes/equal_fp8x23/input_1.cairo +++ b/src/tests/nodes/equal_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + 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: 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: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp8x23/output_0.cairo b/src/tests/nodes/equal_fp8x23/output_0.cairo index aed703aca..993dfb719 100644 --- a/src/tests/nodes/equal_fp8x23/output_0.cairo +++ b/src/tests/nodes/equal_fp8x23/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,19 +12,20 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); @@ -36,8 +36,5 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp8x23_broadcast.cairo b/src/tests/nodes/equal_fp8x23_broadcast.cairo index d7955aaad..aef83cbfb 100644 --- a/src/tests/nodes/equal_fp8x23_broadcast.cairo +++ b/src/tests/nodes/equal_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/equal_fp8x23_broadcast/input_0.cairo index 3e37426aa..d93db0659 100644 --- a/src/tests/nodes/equal_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/equal_fp8x23_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/equal_fp8x23_broadcast/input_1.cairo index e885029d8..64713b1ba 100644 --- a/src/tests/nodes/equal_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/equal_fp8x23_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/equal_fp8x23_broadcast/output_0.cairo index 1b8e294d7..0cc7de207 100644 --- a/src/tests/nodes/equal_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/equal_fp8x23_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i32.cairo b/src/tests/nodes/equal_i32.cairo index dccd1db40..8f42d32cd 100644 --- a/src/tests/nodes/equal_i32.cairo +++ b/src/tests/nodes/equal_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_i32/input_0.cairo b/src/tests/nodes/equal_i32/input_0.cairo index 7d447e13b..9abf4e9b7 100644 --- a/src/tests/nodes/equal_i32/input_0.cairo +++ b/src/tests/nodes/equal_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, 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: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, 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: 0, 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: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); 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: 1, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i32/input_1.cairo b/src/tests/nodes/equal_i32/input_1.cairo index 2e262f58c..a7ab8ba6d 100644 --- a/src/tests/nodes/equal_i32/input_1.cairo +++ b/src/tests/nodes/equal_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + 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: true }); data.append(i32 { mag: 2, 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: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 3, sign: true }); - 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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - 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: 3, sign: true }); 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: 1, sign: true }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i32/output_0.cairo b/src/tests/nodes/equal_i32/output_0.cairo index 4bb0a6764..26c1da5a9 100644 --- a/src/tests/nodes/equal_i32/output_0.cairo +++ b/src/tests/nodes/equal_i32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(0); @@ -23,21 +20,21 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i32_broadcast.cairo b/src/tests/nodes/equal_i32_broadcast.cairo index 1b66d05ce..3c0d2da8a 100644 --- a/src/tests/nodes/equal_i32_broadcast.cairo +++ b/src/tests/nodes/equal_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_i32_broadcast/input_0.cairo b/src/tests/nodes/equal_i32_broadcast/input_0.cairo index f0397c72d..93feb7d50 100644 --- a/src/tests/nodes/equal_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/equal_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i32_broadcast/input_1.cairo b/src/tests/nodes/equal_i32_broadcast/input_1.cairo index c03f71e92..2e88b9154 100644 --- a/src/tests/nodes/equal_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/equal_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i32_broadcast/output_0.cairo b/src/tests/nodes/equal_i32_broadcast/output_0.cairo index f862ecf85..2101f7fc8 100644 --- a/src/tests/nodes/equal_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/equal_i32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,8 +11,6 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i8.cairo b/src/tests/nodes/equal_i8.cairo index 9eef128ad..78eadad98 100644 --- a/src/tests/nodes/equal_i8.cairo +++ b/src/tests/nodes/equal_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_i8/input_0.cairo b/src/tests/nodes/equal_i8/input_0.cairo index 3b8debc1f..865d1dbf2 100644 --- a/src/tests/nodes/equal_i8/input_0.cairo +++ b/src/tests/nodes/equal_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); 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: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); 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: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i8/input_1.cairo b/src/tests/nodes/equal_i8/input_1.cairo index 0542d4105..bb19add34 100644 --- a/src/tests/nodes/equal_i8/input_1.cairo +++ b/src/tests/nodes/equal_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); + 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: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, 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: true }); + data.append(i8 { mag: 1, sign: false }); 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: 1, 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: 1, sign: true }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); 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: 2, sign: true }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i8/output_0.cairo b/src/tests/nodes/equal_i8/output_0.cairo index 8f64120de..72bdf3492 100644 --- a/src/tests/nodes/equal_i8/output_0.cairo +++ b/src/tests/nodes/equal_i8/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,21 +11,18 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - data.append(1); - data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(0); @@ -37,7 +33,8 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i8_broadcast.cairo b/src/tests/nodes/equal_i8_broadcast.cairo index d014d6d2e..751d192e4 100644 --- a/src/tests/nodes/equal_i8_broadcast.cairo +++ b/src/tests/nodes/equal_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_i8_broadcast/input_0.cairo b/src/tests/nodes/equal_i8_broadcast/input_0.cairo index 9d996d1f8..8ac6798f4 100644 --- a/src/tests/nodes/equal_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/equal_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i8_broadcast/input_1.cairo b/src/tests/nodes/equal_i8_broadcast/input_1.cairo index 518b780b5..b16e2e8ed 100644 --- a/src/tests/nodes/equal_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/equal_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_i8_broadcast/output_0.cairo b/src/tests/nodes/equal_i8_broadcast/output_0.cairo index 1b8e294d7..d9b9dedff 100644 --- a/src/tests/nodes/equal_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/equal_i8_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_u32.cairo b/src/tests/nodes/equal_u32.cairo index 5121b0095..6a3e0cf29 100644 --- a/src/tests/nodes/equal_u32.cairo +++ b/src/tests/nodes/equal_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_u32/input_0.cairo b/src/tests/nodes/equal_u32/input_0.cairo index 48c8bef22..ae27571e9 100644 --- a/src/tests/nodes/equal_u32/input_0.cairo +++ b/src/tests/nodes/equal_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(3); data.append(5); - data.append(0); + data.append(5); + data.append(4); + data.append(5); + data.append(4); + data.append(1); + data.append(5); + data.append(1); data.append(3); data.append(3); + data.append(4); data.append(1); - data.append(5); data.append(3); - data.append(0); data.append(5); + data.append(4); + data.append(0); data.append(1); data.append(2); - data.append(3); - data.append(0); data.append(4); - data.append(5); + data.append(3); data.append(1); - data.append(2); - data.append(0); data.append(1); - data.append(4); + data.append(0); + data.append(0); data.append(0); data.append(4); - data.append(1); - data.append(5); - data.append(2); - data.append(5); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_u32/input_1.cairo b/src/tests/nodes/equal_u32/input_1.cairo index 913270d32..f4b8dcf2b 100644 --- a/src/tests/nodes/equal_u32/input_1.cairo +++ b/src/tests/nodes/equal_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(2); - data.append(5); - data.append(2); - data.append(5); + data.append(4); + data.append(3); data.append(0); - data.append(2); - data.append(5); data.append(1); + data.append(5); data.append(3); data.append(2); data.append(1); - data.append(1); - data.append(1); - data.append(1); - data.append(1); + data.append(0); data.append(4); + data.append(5); data.append(4); - data.append(0); - data.append(2); - data.append(0); - data.append(2); data.append(5); data.append(2); data.append(1); + data.append(5); + data.append(1); data.append(2); + data.append(0); + data.append(4); + data.append(1); data.append(1); + data.append(0); + data.append(5); + data.append(1); + data.append(5); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_u32/output_0.cairo b/src/tests/nodes/equal_u32/output_0.cairo index 3766af84f..48ee1ad7d 100644 --- a/src/tests/nodes/equal_u32/output_0.cairo +++ b/src/tests/nodes/equal_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -14,12 +13,14 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); @@ -29,15 +30,11 @@ fn output_0() -> Tensor { data.append(0); data.append(1); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(1); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_u32_broadcast.cairo b/src/tests/nodes/equal_u32_broadcast.cairo index f61525429..4ceb32a0e 100644 --- a/src/tests/nodes/equal_u32_broadcast.cairo +++ b/src/tests/nodes/equal_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/equal_u32_broadcast/input_0.cairo b/src/tests/nodes/equal_u32_broadcast/input_0.cairo index 0ccf29d1f..fdbf9ca33 100644 --- a/src/tests/nodes/equal_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/equal_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(2); data.append(4); - data.append(3); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_u32_broadcast/input_1.cairo b/src/tests/nodes/equal_u32_broadcast/input_1.cairo index 2d99c65d5..b3f2c616b 100644 --- a/src/tests/nodes/equal_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/equal_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(2); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/equal_u32_broadcast/output_0.cairo b/src/tests/nodes/equal_u32_broadcast/output_0.cairo index b681bb975..df2800d42 100644 --- a/src/tests/nodes/equal_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/equal_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/exp_fp16x16.cairo b/src/tests/nodes/exp_fp16x16.cairo index 9aa055f1d..0d18bff68 100644 --- a/src/tests/nodes/exp_fp16x16.cairo +++ b/src/tests/nodes/exp_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/exp_fp16x16/input_0.cairo b/src/tests/nodes/exp_fp16x16/input_0.cairo index 4dfda1e62..e58d3c935 100644 --- a/src/tests/nodes/exp_fp16x16/input_0.cairo +++ b/src/tests/nodes/exp_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 68670, sign: true }); - data.append(FixedType { mag: 37714, sign: true }); - data.append(FixedType { mag: 196163, sign: true }); - data.append(FixedType { mag: 10079, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 194862, sign: false }); + data.append(FP16x16 { mag: 38141, sign: true }); + data.append(FP16x16 { mag: 110238, sign: false }); + data.append(FP16x16 { mag: 63859, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/exp_fp16x16/output_0.cairo b/src/tests/nodes/exp_fp16x16/output_0.cairo index 6b1fe72be..ac9ad4ec0 100644 --- a/src/tests/nodes/exp_fp16x16/output_0.cairo +++ b/src/tests/nodes/exp_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 22983, sign: false }); - data.append(FixedType { mag: 36859, sign: false }); - data.append(FixedType { mag: 3285, sign: false }); - data.append(FixedType { mag: 76431, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 1281733, sign: false }); + data.append(FP16x16 { mag: 36620, sign: false }); + data.append(FP16x16 { mag: 352377, sign: false }); + data.append(FP16x16 { mag: 24734, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/exp_fp8x23.cairo b/src/tests/nodes/exp_fp8x23.cairo index 46cc4ee8a..e7b4e9cef 100644 --- a/src/tests/nodes/exp_fp8x23.cairo +++ b/src/tests/nodes/exp_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/exp_fp8x23/input_0.cairo b/src/tests/nodes/exp_fp8x23/input_0.cairo index ad32cb8e7..62073f39a 100644 --- a/src/tests/nodes/exp_fp8x23/input_0.cairo +++ b/src/tests/nodes/exp_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 22965160, sign: true }); - data.append(FixedType { mag: 15758081, sign: false }); - data.append(FixedType { mag: 23575455, sign: true }); - data.append(FixedType { mag: 2203079, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 11235841, sign: true }); + data.append(FP8x23 { mag: 5119248, sign: false }); + data.append(FP8x23 { mag: 735081, sign: true }); + data.append(FP8x23 { mag: 19148930, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/exp_fp8x23/output_0.cairo b/src/tests/nodes/exp_fp8x23/output_0.cairo index 2cb3822dd..a902d063b 100644 --- a/src/tests/nodes/exp_fp8x23/output_0.cairo +++ b/src/tests/nodes/exp_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 542924, sign: false }); - data.append(FixedType { mag: 54892916, sign: false }); - data.append(FixedType { mag: 504827, sign: false }); - data.append(FixedType { mag: 10908061, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 2197802, sign: false }); + data.append(FP8x23 { mag: 15442702, sign: false }); + data.append(FP8x23 { mag: 7684813, sign: false }); + data.append(FP8x23 { mag: 855682, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/exp_i32_fp16x16.cairo b/src/tests/nodes/exp_i32_fp16x16.cairo deleted file mode 100644 index 1be4dc061..000000000 --- a/src/tests/nodes/exp_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_exp_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.exp(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i32_fp16x16/input_0.cairo b/src/tests/nodes/exp_i32_fp16x16/input_0.cairo deleted file mode 100644 index 2a1785f40..000000000 --- a/src/tests/nodes/exp_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i32_fp16x16/output_0.cairo b/src/tests/nodes/exp_i32_fp16x16/output_0.cairo deleted file mode 100644 index c9fba6376..000000000 --- a/src/tests/nodes/exp_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 178145, sign: false }); - data.append(FixedType { mag: 484249, sign: false }); - data.append(FixedType { mag: 8869, sign: false }); - data.append(FixedType { mag: 8869, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i32_fp8x23.cairo b/src/tests/nodes/exp_i32_fp8x23.cairo deleted file mode 100644 index 7f05236b3..000000000 --- a/src/tests/nodes/exp_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_exp_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.exp(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i32_fp8x23/input_0.cairo b/src/tests/nodes/exp_i32_fp8x23/input_0.cairo deleted file mode 100644 index 38d352e0e..000000000 --- a/src/tests/nodes/exp_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i32_fp8x23/output_0.cairo b/src/tests/nodes/exp_i32_fp8x23/output_0.cairo deleted file mode 100644 index c27ff7254..000000000 --- a/src/tests/nodes/exp_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 61983895, sign: false }); - data.append(FixedType { mag: 3085996, sign: false }); - data.append(FixedType { mag: 22802600, sign: false }); - data.append(FixedType { mag: 61983895, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i8_fp16x16.cairo b/src/tests/nodes/exp_i8_fp16x16.cairo deleted file mode 100644 index 48ab0cb77..000000000 --- a/src/tests/nodes/exp_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_exp_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.exp(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i8_fp16x16/input_0.cairo b/src/tests/nodes/exp_i8_fp16x16/input_0.cairo deleted file mode 100644 index dc9db41fa..000000000 --- a/src/tests/nodes/exp_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i8_fp16x16/output_0.cairo b/src/tests/nodes/exp_i8_fp16x16/output_0.cairo deleted file mode 100644 index 22b7b6291..000000000 --- a/src/tests/nodes/exp_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 3262, sign: false }); - data.append(FixedType { mag: 178145, sign: false }); - data.append(FixedType { mag: 3262, sign: false }); - data.append(FixedType { mag: 8869, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i8_fp8x23.cairo b/src/tests/nodes/exp_i8_fp8x23.cairo deleted file mode 100644 index e583e0887..000000000 --- a/src/tests/nodes/exp_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_exp_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.exp(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i8_fp8x23/input_0.cairo b/src/tests/nodes/exp_i8_fp8x23/input_0.cairo deleted file mode 100644 index e884d3d52..000000000 --- a/src/tests/nodes/exp_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_i8_fp8x23/output_0.cairo b/src/tests/nodes/exp_i8_fp8x23/output_0.cairo deleted file mode 100644 index d961f99d3..000000000 --- a/src/tests/nodes/exp_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 22806528, sign: false }); - data.append(FixedType { mag: 1135616, sign: false }); - data.append(FixedType { mag: 22806528, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_u32_fp16x16.cairo b/src/tests/nodes/exp_u32_fp16x16.cairo deleted file mode 100644 index 624feac15..000000000 --- a/src/tests/nodes/exp_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_exp_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.exp(); - - // assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/exp_u32_fp16x16/input_0.cairo b/src/tests/nodes/exp_u32_fp16x16/input_0.cairo deleted file mode 100644 index 1e000796f..000000000 --- a/src/tests/nodes/exp_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -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(1); - data.append(2); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_u32_fp16x16/output_0.cairo b/src/tests/nodes/exp_u32_fp16x16/output_0.cairo deleted file mode 100644 index 99f86f289..000000000 --- a/src/tests/nodes/exp_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 178145, sign: false }); - data.append(FixedType { mag: 484249, sign: false }); - data.append(FixedType { mag: 3578144, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_u32_fp8x23.cairo b/src/tests/nodes/exp_u32_fp8x23.cairo deleted file mode 100644 index 78498e131..000000000 --- a/src/tests/nodes/exp_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_exp_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.exp(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/exp_u32_fp8x23/input_0.cairo b/src/tests/nodes/exp_u32_fp8x23/input_0.cairo deleted file mode 100644 index b49b1c681..000000000 --- a/src/tests/nodes/exp_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(5); - data.append(3); - data.append(2); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/exp_u32_fp8x23/output_0.cairo b/src/tests/nodes/exp_u32_fp8x23/output_0.cairo deleted file mode 100644 index f824f5e97..000000000 --- a/src/tests/nodes/exp_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1244979813, sign: false }); - data.append(FixedType { mag: 168489695, sign: false }); - data.append(FixedType { mag: 61983895, sign: false }); - data.append(FixedType { mag: 458002478, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp16x16.cairo b/src/tests/nodes/greater_equal_fp16x16.cairo index 447c6ec2e..81145c607 100644 --- a/src/tests/nodes/greater_equal_fp16x16.cairo +++ b/src/tests/nodes/greater_equal_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_fp16x16/input_0.cairo b/src/tests/nodes/greater_equal_fp16x16/input_0.cairo index b62593df5..3e4cf0178 100644 --- a/src/tests/nodes/greater_equal_fp16x16/input_0.cairo +++ b/src/tests/nodes/greater_equal_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: 0, 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: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp16x16/input_1.cairo b/src/tests/nodes/greater_equal_fp16x16/input_1.cairo index a6eb5059f..7dca8c177 100644 --- a/src/tests/nodes/greater_equal_fp16x16/input_1.cairo +++ b/src/tests/nodes/greater_equal_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp16x16/output_0.cairo b/src/tests/nodes/greater_equal_fp16x16/output_0.cairo index fc96061c1..0563fc097 100644 --- a/src/tests/nodes/greater_equal_fp16x16/output_0.cairo +++ b/src/tests/nodes/greater_equal_fp16x16/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(0); + data.append(1); data.append(1); data.append(1); data.append(1); @@ -20,24 +19,22 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); + data.append(1); + data.append(1); data.append(0); data.append(0); - data.append(0); + data.append(1); data.append(0); data.append(1); data.append(1); - data.append(0); data.append(1); data.append(1); data.append(1); - data.append(0); - data.append(0); data.append(1); data.append(0); data.append(1); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp16x16_broadcast.cairo b/src/tests/nodes/greater_equal_fp16x16_broadcast.cairo index 11f153bb5..bf4b63b6f 100644 --- a/src/tests/nodes/greater_equal_fp16x16_broadcast.cairo +++ b/src/tests/nodes/greater_equal_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/greater_equal_fp16x16_broadcast/input_0.cairo index 423aba9fb..e69833180 100644 --- a/src/tests/nodes/greater_equal_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_equal_fp16x16_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + 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: 196608, 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: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/greater_equal_fp16x16_broadcast/input_1.cairo index d5c05608e..e662e53b4 100644 --- a/src/tests/nodes/greater_equal_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_equal_fp16x16_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/greater_equal_fp16x16_broadcast/output_0.cairo index 975b0ffb4..3798b1601 100644 --- a/src/tests/nodes/greater_equal_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_equal_fp16x16_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,31 +12,29 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(0); - data.append(1); data.append(1); data.append(0); + data.append(1); data.append(0); data.append(1); data.append(1); + data.append(1); + data.append(0); data.append(0); data.append(0); data.append(1); data.append(0); data.append(1); data.append(1); + data.append(1); + data.append(0); + data.append(0); + data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(1); data.append(1); data.append(1); - data.append(1); - data.append(0); - data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp8x23.cairo b/src/tests/nodes/greater_equal_fp8x23.cairo index 134d31af4..13482e0ec 100644 --- a/src/tests/nodes/greater_equal_fp8x23.cairo +++ b/src/tests/nodes/greater_equal_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_fp8x23/input_0.cairo b/src/tests/nodes/greater_equal_fp8x23/input_0.cairo index b5f1b3366..805430286 100644 --- a/src/tests/nodes/greater_equal_fp8x23/input_0.cairo +++ b/src/tests/nodes/greater_equal_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 8388608, sign: true }); + 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: 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: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + 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: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp8x23/input_1.cairo b/src/tests/nodes/greater_equal_fp8x23/input_1.cairo index b53f4eced..517179318 100644 --- a/src/tests/nodes/greater_equal_fp8x23/input_1.cairo +++ b/src/tests/nodes/greater_equal_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, 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: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + 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: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 0, 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp8x23/output_0.cairo b/src/tests/nodes/greater_equal_fp8x23/output_0.cairo index 08adacf80..0345ba65f 100644 --- a/src/tests/nodes/greater_equal_fp8x23/output_0.cairo +++ b/src/tests/nodes/greater_equal_fp8x23/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,9 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(0); data.append(1); data.append(1); - data.append(1); - data.append(0); data.append(0); data.append(0); data.append(1); @@ -21,6 +19,8 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(0); + data.append(1); + data.append(0); data.append(0); data.append(0); data.append(1); @@ -31,13 +31,10 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); + data.append(0); data.append(1); data.append(1); data.append(0); - data.append(0); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp8x23_broadcast.cairo b/src/tests/nodes/greater_equal_fp8x23_broadcast.cairo index f97544055..dd979b6fc 100644 --- a/src/tests/nodes/greater_equal_fp8x23_broadcast.cairo +++ b/src/tests/nodes/greater_equal_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/greater_equal_fp8x23_broadcast/input_0.cairo index dc4edec46..bb87b4eed 100644 --- a/src/tests/nodes/greater_equal_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_equal_fp8x23_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 8388608, 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: 25165824, sign: true }); + 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: true }); + 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: 16777216, sign: true }); + 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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + 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: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/greater_equal_fp8x23_broadcast/input_1.cairo index afd7ade1f..65f5c6465 100644 --- a/src/tests/nodes/greater_equal_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_equal_fp8x23_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/greater_equal_fp8x23_broadcast/output_0.cairo index 61366a731..5856dd1da 100644 --- a/src/tests/nodes/greater_equal_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_equal_fp8x23_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); + data.append(1); data.append(1); data.append(1); data.append(0); data.append(0); + data.append(1); + data.append(1); + data.append(1); data.append(0); + data.append(1); + data.append(1); + data.append(1); data.append(0); data.append(0); data.append(1); data.append(1); data.append(1); data.append(1); - data.append(0); - data.append(0); - data.append(0); data.append(1); - data.append(0); - data.append(0); data.append(1); data.append(1); data.append(1); - data.append(0); - data.append(0); + data.append(1); data.append(1); data.append(1); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i32.cairo b/src/tests/nodes/greater_equal_i32.cairo index 5190128c7..84368ba93 100644 --- a/src/tests/nodes/greater_equal_i32.cairo +++ b/src/tests/nodes/greater_equal_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_i32/input_0.cairo b/src/tests/nodes/greater_equal_i32/input_0.cairo index f23e15a94..cec68dfb0 100644 --- a/src/tests/nodes/greater_equal_i32/input_0.cairo +++ b/src/tests/nodes/greater_equal_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,33 +11,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); 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: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 3, sign: true }); - 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: 1, sign: true }); data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, 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: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i32/input_1.cairo b/src/tests/nodes/greater_equal_i32/input_1.cairo index c1d9fe60e..5fa17db22 100644 --- a/src/tests/nodes/greater_equal_i32/input_1.cairo +++ b/src/tests/nodes/greater_equal_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 0, 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: 0, sign: false }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, 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: 1, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, 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: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); + 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: 2, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i32/output_0.cairo b/src/tests/nodes/greater_equal_i32/output_0.cairo index 944ee000d..ec54ffc3b 100644 --- a/src/tests/nodes/greater_equal_i32/output_0.cairo +++ b/src/tests/nodes/greater_equal_i32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,9 +9,6 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(1); - data.append(1); - data.append(1); data.append(0); data.append(1); data.append(1); @@ -22,22 +18,23 @@ fn output_0() -> Tensor { data.append(0); data.append(1); data.append(1); - data.append(0); data.append(1); data.append(1); - data.append(0); - data.append(1); data.append(1); data.append(1); data.append(1); data.append(1); data.append(1); data.append(0); + data.append(0); + data.append(0); + data.append(1); + data.append(1); data.append(1); data.append(0); data.append(1); + data.append(0); + data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i32_broadcast.cairo b/src/tests/nodes/greater_equal_i32_broadcast.cairo index 46a2c39c6..bd83f9308 100644 --- a/src/tests/nodes/greater_equal_i32_broadcast.cairo +++ b/src/tests/nodes/greater_equal_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_i32_broadcast/input_0.cairo b/src/tests/nodes/greater_equal_i32_broadcast/input_0.cairo index c4497df2c..ea1897d83 100644 --- a/src/tests/nodes/greater_equal_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_equal_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, 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: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: true }); + 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: 3, 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: 2, sign: false }); 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: 0, sign: false }); 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: 3, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 2, sign: true }); - 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: 1, sign: false }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i32_broadcast/input_1.cairo b/src/tests/nodes/greater_equal_i32_broadcast/input_1.cairo index 419b62e58..ba1463129 100644 --- a/src/tests/nodes/greater_equal_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_equal_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i32_broadcast/output_0.cairo b/src/tests/nodes/greater_equal_i32_broadcast/output_0.cairo index 875f749b5..105f89e17 100644 --- a/src/tests/nodes/greater_equal_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_equal_i32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,6 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(0); data.append(1); data.append(1); data.append(0); @@ -21,23 +19,22 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(0); + data.append(0); data.append(1); data.append(0); data.append(1); data.append(1); data.append(1); data.append(0); - data.append(0); - data.append(0); data.append(1); - data.append(0); - data.append(0); + data.append(1); + data.append(1); + data.append(1); + data.append(1); + data.append(1); data.append(1); data.append(1); data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i8.cairo b/src/tests/nodes/greater_equal_i8.cairo index d488222fc..cc946f038 100644 --- a/src/tests/nodes/greater_equal_i8.cairo +++ b/src/tests/nodes/greater_equal_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_i8/input_0.cairo b/src/tests/nodes/greater_equal_i8/input_0.cairo index 79d69a00c..969578186 100644 --- a/src/tests/nodes/greater_equal_i8/input_0.cairo +++ b/src/tests/nodes/greater_equal_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: false }); - 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: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, 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: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: false }); + 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: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i8/input_1.cairo b/src/tests/nodes/greater_equal_i8/input_1.cairo index 0a3a0b6f5..4fc9266f5 100644 --- a/src/tests/nodes/greater_equal_i8/input_1.cairo +++ b/src/tests/nodes/greater_equal_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -12,33 +11,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 2, 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: 3, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); + 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: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: true }); 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: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); - 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: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i8/output_0.cairo b/src/tests/nodes/greater_equal_i8/output_0.cairo index 402651eba..6d6aadf7f 100644 --- a/src/tests/nodes/greater_equal_i8/output_0.cairo +++ b/src/tests/nodes/greater_equal_i8/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); + data.append(0); + data.append(0); + data.append(0); data.append(1); data.append(1); - data.append(1); - data.append(1); - data.append(1); + data.append(0); data.append(1); data.append(1); data.append(0); data.append(1); + data.append(0); + data.append(0); data.append(1); data.append(1); data.append(1); data.append(0); - data.append(1); data.append(0); data.append(1); - data.append(0); data.append(1); data.append(1); + data.append(0); data.append(1); data.append(1); data.append(0); data.append(0); data.append(1); - data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i8_broadcast.cairo b/src/tests/nodes/greater_equal_i8_broadcast.cairo index 01a4e635c..0cf3a3bbd 100644 --- a/src/tests/nodes/greater_equal_i8_broadcast.cairo +++ b/src/tests/nodes/greater_equal_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_i8_broadcast/input_0.cairo b/src/tests/nodes/greater_equal_i8_broadcast/input_0.cairo index 0f899f1bb..aa0ee407a 100644 --- a/src/tests/nodes/greater_equal_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_equal_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, 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: 1, sign: false }); + 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: 0, sign: false }); - 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: 2, sign: false }); + 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: true }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); + 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: 3, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i8_broadcast/input_1.cairo b/src/tests/nodes/greater_equal_i8_broadcast/input_1.cairo index 0f63b5bd3..b238febac 100644 --- a/src/tests/nodes/greater_equal_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_equal_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); + 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: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_i8_broadcast/output_0.cairo b/src/tests/nodes/greater_equal_i8_broadcast/output_0.cairo index 3cc7383d5..a1d7a1547 100644 --- a/src/tests/nodes/greater_equal_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_equal_i8_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,31 +12,29 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(1); - data.append(1); - data.append(1); - data.append(1); - data.append(1); - data.append(1); + data.append(0); data.append(0); data.append(1); data.append(1); data.append(1); data.append(1); + data.append(0); data.append(1); - data.append(1); + data.append(0); data.append(1); data.append(1); data.append(0); data.append(1); data.append(1); data.append(1); + data.append(0); + data.append(0); + data.append(0); + data.append(0); data.append(1); + data.append(0); data.append(1); data.append(1); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_u32.cairo b/src/tests/nodes/greater_equal_u32.cairo index 6c6c166a5..1d35a2070 100644 --- a/src/tests/nodes/greater_equal_u32.cairo +++ b/src/tests/nodes/greater_equal_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_u32/input_0.cairo b/src/tests/nodes/greater_equal_u32/input_0.cairo index c5739bd0d..59ddf51b1 100644 --- a/src/tests/nodes/greater_equal_u32/input_0.cairo +++ b/src/tests/nodes/greater_equal_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(2); data.append(4); data.append(1); - data.append(1); - data.append(3); + data.append(2); data.append(5); data.append(4); data.append(2); - data.append(2); - data.append(5); - data.append(5); - data.append(5); - data.append(1); + data.append(4); data.append(5); data.append(1); + data.append(0); data.append(2); - data.append(5); - data.append(4); - data.append(3); data.append(4); + data.append(2); + data.append(0); data.append(4); + data.append(1); + data.append(2); data.append(5); - data.append(3); - data.append(3); - data.append(4); data.append(1); - data.append(3); + data.append(2); + data.append(2); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(4); + data.append(2); + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_u32/input_1.cairo b/src/tests/nodes/greater_equal_u32/input_1.cairo index 61526cb82..cf5cdf751 100644 --- a/src/tests/nodes/greater_equal_u32/input_1.cairo +++ b/src/tests/nodes/greater_equal_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); - data.append(4); data.append(5); - data.append(1); - data.append(0); data.append(5); - data.append(0); + data.append(3); + data.append(5); data.append(1); + data.append(5); data.append(2); data.append(5); data.append(5); + data.append(2); + data.append(3); + data.append(2); + data.append(5); data.append(1); + data.append(4); + data.append(0); data.append(1); - data.append(1); - data.append(5); + data.append(0); data.append(3); - data.append(2); - data.append(2); data.append(0); - data.append(2); - data.append(5); - data.append(2); + data.append(1); data.append(4); - data.append(2); data.append(4); data.append(0); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_u32/output_0.cairo b/src/tests/nodes/greater_equal_u32/output_0.cairo index ccd1fc902..99310ca0d 100644 --- a/src/tests/nodes/greater_equal_u32/output_0.cairo +++ b/src/tests/nodes/greater_equal_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,13 +12,18 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); + data.append(0); data.append(1); data.append(1); data.append(0); data.append(1); data.append(1); + data.append(0); + data.append(0); + data.append(0); data.append(1); - data.append(1); + data.append(0); + data.append(0); data.append(1); data.append(1); data.append(1); @@ -30,14 +34,7 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(1); - data.append(1); data.append(0); - data.append(1); data.append(0); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_u32_broadcast.cairo b/src/tests/nodes/greater_equal_u32_broadcast.cairo index ddcf010ea..72219a061 100644 --- a/src/tests/nodes/greater_equal_u32_broadcast.cairo +++ b/src/tests/nodes/greater_equal_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_equal_u32_broadcast/input_0.cairo b/src/tests/nodes/greater_equal_u32_broadcast/input_0.cairo index 57a150a43..7b6c92b34 100644 --- a/src/tests/nodes/greater_equal_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_equal_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(5); data.append(3); - data.append(2); + data.append(1); + data.append(4); data.append(0); data.append(4); - data.append(2); - data.append(3); - data.append(3); - data.append(2); data.append(0); + data.append(4); data.append(3); - data.append(2); - data.append(3); + data.append(4); + data.append(0); data.append(1); data.append(5); - data.append(1); + data.append(5); + data.append(5); + data.append(0); + data.append(5); + data.append(0); data.append(3); data.append(5); - data.append(2); - data.append(2); + data.append(5); data.append(3); + data.append(3); + data.append(3); + data.append(5); data.append(1); - data.append(0); - data.append(1); - data.append(4); - data.append(4); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_u32_broadcast/input_1.cairo b/src/tests/nodes/greater_equal_u32_broadcast/input_1.cairo index b8bb3745d..6b21f0921 100644 --- a/src/tests/nodes/greater_equal_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_equal_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); - data.append(4); + data.append(1); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_equal_u32_broadcast/output_0.cairo b/src/tests/nodes/greater_equal_u32_broadcast/output_0.cairo index 8fe7450d6..6c038a7d6 100644 --- a/src/tests/nodes/greater_equal_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_equal_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -18,11 +17,12 @@ fn output_0() -> Tensor { data.append(0); data.append(1); data.append(1); + data.append(1); data.append(0); data.append(1); data.append(1); data.append(1); - data.append(0); + data.append(1); data.append(0); data.append(1); data.append(0); @@ -31,13 +31,10 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(0); - data.append(0); - data.append(0); data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp16x16.cairo b/src/tests/nodes/greater_fp16x16.cairo index 28f2f0d64..0cc99e81c 100644 --- a/src/tests/nodes/greater_fp16x16.cairo +++ b/src/tests/nodes/greater_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_fp16x16/input_0.cairo b/src/tests/nodes/greater_fp16x16/input_0.cairo index 9f0692b08..413c5e23c 100644 --- a/src/tests/nodes/greater_fp16x16/input_0.cairo +++ b/src/tests/nodes/greater_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, 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: 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: 131072, sign: false }); + 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: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, 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: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp16x16/input_1.cairo b/src/tests/nodes/greater_fp16x16/input_1.cairo index dd9936e44..09ed30ca1 100644 --- a/src/tests/nodes/greater_fp16x16/input_1.cairo +++ b/src/tests/nodes/greater_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: true }); + data.append(FP16x16 { mag: 196608, 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: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp16x16/output_0.cairo b/src/tests/nodes/greater_fp16x16/output_0.cairo index 8a3195ed4..ab7cf0d44 100644 --- a/src/tests/nodes/greater_fp16x16/output_0.cairo +++ b/src/tests/nodes/greater_fp16x16/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(1); - data.append(0); - data.append(0); - data.append(0); data.append(1); - data.append(0); + data.append(1); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(1); data.append(1); - data.append(0); + data.append(1); data.append(1); data.append(1); data.append(0); + data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp16x16_broadcast.cairo b/src/tests/nodes/greater_fp16x16_broadcast.cairo index 4ca90ad20..260e69a26 100644 --- a/src/tests/nodes/greater_fp16x16_broadcast.cairo +++ b/src/tests/nodes/greater_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/greater_fp16x16_broadcast/input_0.cairo index face910c4..29e9cf24e 100644 --- a/src/tests/nodes/greater_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_fp16x16_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/greater_fp16x16_broadcast/input_1.cairo index fafd3e877..03404f090 100644 --- a/src/tests/nodes/greater_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_fp16x16_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/greater_fp16x16_broadcast/output_0.cairo index 57df22f21..e7b1da4b1 100644 --- a/src/tests/nodes/greater_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_fp16x16_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,8 +11,6 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp8x23.cairo b/src/tests/nodes/greater_fp8x23.cairo index b01b80c75..e187524d0 100644 --- a/src/tests/nodes/greater_fp8x23.cairo +++ b/src/tests/nodes/greater_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_fp8x23/input_0.cairo b/src/tests/nodes/greater_fp8x23/input_0.cairo index 2d43a22ef..9c6d968c1 100644 --- a/src/tests/nodes/greater_fp8x23/input_0.cairo +++ b/src/tests/nodes/greater_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 8388608, sign: true }); + 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: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp8x23/input_1.cairo b/src/tests/nodes/greater_fp8x23/input_1.cairo index b272de937..973023ed5 100644 --- a/src/tests/nodes/greater_fp8x23/input_1.cairo +++ b/src/tests/nodes/greater_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 8388608, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp8x23/output_0.cairo b/src/tests/nodes/greater_fp8x23/output_0.cairo index 27af4f3af..275f357bf 100644 --- a/src/tests/nodes/greater_fp8x23/output_0.cairo +++ b/src/tests/nodes/greater_fp8x23/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,17 +9,18 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(1); + data.append(1); + data.append(1); data.append(0); - data.append(0); + data.append(1); + data.append(1); data.append(0); data.append(1); data.append(0); @@ -28,7 +28,6 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(1); data.append(1); @@ -37,7 +36,5 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp8x23_broadcast.cairo b/src/tests/nodes/greater_fp8x23_broadcast.cairo index ea4bc172d..4c99a88ea 100644 --- a/src/tests/nodes/greater_fp8x23_broadcast.cairo +++ b/src/tests/nodes/greater_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/greater_fp8x23_broadcast/input_0.cairo index 1bcedede2..ac784d111 100644 --- a/src/tests/nodes/greater_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_fp8x23_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/greater_fp8x23_broadcast/input_1.cairo index 70af415ea..fb94adec2 100644 --- a/src/tests/nodes/greater_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_fp8x23_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/greater_fp8x23_broadcast/output_0.cairo index b681bb975..0cc7de207 100644 --- a/src/tests/nodes/greater_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_fp8x23_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i32.cairo b/src/tests/nodes/greater_i32.cairo index e3df2ceb6..c754aae9f 100644 --- a/src/tests/nodes/greater_i32.cairo +++ b/src/tests/nodes/greater_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_i32/input_0.cairo b/src/tests/nodes/greater_i32/input_0.cairo index d186b7c0b..e13a83564 100644 --- a/src/tests/nodes/greater_i32/input_0.cairo +++ b/src/tests/nodes/greater_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, 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: 2, sign: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 0, 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: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, 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: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i32/input_1.cairo b/src/tests/nodes/greater_i32/input_1.cairo index 9d2777df5..679b09655 100644 --- a/src/tests/nodes/greater_i32/input_1.cairo +++ b/src/tests/nodes/greater_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - 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: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); - 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: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, 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: 1, sign: false }); data.append(i32 { mag: 0, sign: false }); - 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: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); + 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: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, 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: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i32/output_0.cairo b/src/tests/nodes/greater_i32/output_0.cairo index 8403c44d3..fc2a80e83 100644 --- a/src/tests/nodes/greater_i32/output_0.cairo +++ b/src/tests/nodes/greater_i32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(1); - data.append(0); data.append(0); data.append(0); data.append(0); @@ -19,25 +16,25 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(1); - data.append(1); data.append(0); data.append(1); data.append(0); - data.append(1); + data.append(0); + data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); + data.append(1); data.append(0); data.append(1); + data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i32_broadcast.cairo b/src/tests/nodes/greater_i32_broadcast.cairo index 2b9d96521..b27b7a1d9 100644 --- a/src/tests/nodes/greater_i32_broadcast.cairo +++ b/src/tests/nodes/greater_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_i32_broadcast/input_0.cairo b/src/tests/nodes/greater_i32_broadcast/input_0.cairo index b3a10714d..a89883f85 100644 --- a/src/tests/nodes/greater_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i32_broadcast/input_1.cairo b/src/tests/nodes/greater_i32_broadcast/input_1.cairo index b734e30ee..6cabdde08 100644 --- a/src/tests/nodes/greater_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i32_broadcast/output_0.cairo b/src/tests/nodes/greater_i32_broadcast/output_0.cairo index 57df22f21..328774a25 100644 --- a/src/tests/nodes/greater_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_i32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); - data.append(1); + data.append(0); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i8.cairo b/src/tests/nodes/greater_i8.cairo index daa58d42e..cc6f1d298 100644 --- a/src/tests/nodes/greater_i8.cairo +++ b/src/tests/nodes/greater_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_i8/input_0.cairo b/src/tests/nodes/greater_i8/input_0.cairo index 4d7a9840c..5bf63e116 100644 --- a/src/tests/nodes/greater_i8/input_0.cairo +++ b/src/tests/nodes/greater_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, 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: 2, 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: 2, sign: false }); data.append(i8 { mag: 1, sign: true }); 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: 2, sign: true }); - data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i8/input_1.cairo b/src/tests/nodes/greater_i8/input_1.cairo index aed826310..cc263f1d9 100644 --- a/src/tests/nodes/greater_i8/input_1.cairo +++ b/src/tests/nodes/greater_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); + 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: 0, sign: false }); 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: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, 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: true }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); + 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: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 1, sign: false }); + 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: 3, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i8/output_0.cairo b/src/tests/nodes/greater_i8/output_0.cairo index d5a824713..8df4f4ebf 100644 --- a/src/tests/nodes/greater_i8/output_0.cairo +++ b/src/tests/nodes/greater_i8/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,31 +12,29 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); - data.append(0); - data.append(0); data.append(1); data.append(0); - data.append(0); + data.append(1); data.append(0); data.append(1); data.append(1); - data.append(0); - data.append(0); data.append(1); data.append(1); data.append(0); data.append(1); data.append(1); data.append(1); + data.append(1); data.append(0); data.append(1); data.append(0); + data.append(0); + data.append(0); data.append(1); data.append(1); data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i8_broadcast.cairo b/src/tests/nodes/greater_i8_broadcast.cairo index ffef35894..1fa576230 100644 --- a/src/tests/nodes/greater_i8_broadcast.cairo +++ b/src/tests/nodes/greater_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_i8_broadcast/input_0.cairo b/src/tests/nodes/greater_i8_broadcast/input_0.cairo index 121cdfab1..d04b52ef1 100644 --- a/src/tests/nodes/greater_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 3, sign: true }); + 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: 1, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i8_broadcast/input_1.cairo b/src/tests/nodes/greater_i8_broadcast/input_1.cairo index bfa6eed4a..7b08376db 100644 --- a/src/tests/nodes/greater_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_i8_broadcast/output_0.cairo b/src/tests/nodes/greater_i8_broadcast/output_0.cairo index 7f1577c02..328774a25 100644 --- a/src/tests/nodes/greater_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_i8_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); data.append(1); + data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_u32.cairo b/src/tests/nodes/greater_u32.cairo index e77669503..f0357234f 100644 --- a/src/tests/nodes/greater_u32.cairo +++ b/src/tests/nodes/greater_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_u32/input_0.cairo b/src/tests/nodes/greater_u32/input_0.cairo index 20e7906ae..fd617f80f 100644 --- a/src/tests/nodes/greater_u32/input_0.cairo +++ b/src/tests/nodes/greater_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); + data.append(2); data.append(5); - data.append(1); - data.append(3); + data.append(2); data.append(0); data.append(5); data.append(4); - data.append(5); - data.append(3); + data.append(2); data.append(3); data.append(2); - data.append(0); - data.append(0); - data.append(0); data.append(3); + data.append(1); data.append(0); + data.append(2); + data.append(5); + data.append(0); + data.append(5); data.append(4); - data.append(1); - data.append(1); + data.append(3); + data.append(3); + data.append(5); data.append(0); data.append(3); + data.append(5); + data.append(3); data.append(1); data.append(3); - data.append(0); - data.append(2); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_u32/input_1.cairo b/src/tests/nodes/greater_u32/input_1.cairo index 13fe65747..daf06d0ec 100644 --- a/src/tests/nodes/greater_u32/input_1.cairo +++ b/src/tests/nodes/greater_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(5); - data.append(5); - data.append(2); data.append(0); - data.append(1); - data.append(4); data.append(5); - data.append(2); data.append(4); - data.append(5); - data.append(3); data.append(4); + data.append(0); + data.append(0); + data.append(3); data.append(5); + data.append(0); data.append(3); - data.append(1); + data.append(2); data.append(3); data.append(0); + data.append(2); + data.append(5); data.append(5); - data.append(1); data.append(5); - data.append(3); data.append(0); + data.append(4); + data.append(2); + data.append(5); + data.append(5); data.append(1); data.append(0); - data.append(0); - data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_u32/output_0.cairo b/src/tests/nodes/greater_u32/output_0.cairo index 011697fb1..6ec7401a6 100644 --- a/src/tests/nodes/greater_u32/output_0.cairo +++ b/src/tests/nodes/greater_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); - data.append(1); - data.append(1); data.append(1); data.append(0); data.append(0); data.append(1); data.append(1); + data.append(1); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); + data.append(1); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(1); - data.append(0); - data.append(1); - data.append(0); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_u32_broadcast.cairo b/src/tests/nodes/greater_u32_broadcast.cairo index df0699fc5..14765b7aa 100644 --- a/src/tests/nodes/greater_u32_broadcast.cairo +++ b/src/tests/nodes/greater_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/greater_u32_broadcast/input_0.cairo b/src/tests/nodes/greater_u32_broadcast/input_0.cairo index 15e66e192..e1e81a8b4 100644 --- a/src/tests/nodes/greater_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/greater_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(3); - data.append(4); - data.append(2); + data.append(5); + data.append(5); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_u32_broadcast/input_1.cairo b/src/tests/nodes/greater_u32_broadcast/input_1.cairo index 1e31cd10c..6dbc8d99b 100644 --- a/src/tests/nodes/greater_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/greater_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(2); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + data.append(4); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/greater_u32_broadcast/output_0.cairo b/src/tests/nodes/greater_u32_broadcast/output_0.cairo index a7ee4b7f0..d9b9dedff 100644 --- a/src/tests/nodes/greater_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/greater_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); - data.append(1); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_fp16x16.cairo b/src/tests/nodes/leaky_relu_fp16x16.cairo index eb9077405..166df1924 100644 --- a/src/tests/nodes/leaky_relu_fp16x16.cairo +++ b/src/tests/nodes/leaky_relu_fp16x16.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/leaky_relu_fp16x16/input_0.cairo b/src/tests/nodes/leaky_relu_fp16x16/input_0.cairo index 1b016d917..59ff9a98d 100644 --- a/src/tests/nodes/leaky_relu_fp16x16/input_0.cairo +++ b/src/tests/nodes/leaky_relu_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 453171, sign: false }); - data.append(FixedType { mag: 73289, sign: false }); - data.append(FixedType { mag: 90437, sign: true }); - data.append(FixedType { mag: 316640, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 401540, sign: false }); + data.append(FP16x16 { mag: 47813, sign: true }); + data.append(FP16x16 { mag: 206992, sign: false }); + data.append(FP16x16 { mag: 323041, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_fp16x16/output_0.cairo b/src/tests/nodes/leaky_relu_fp16x16/output_0.cairo index 19ca34a6d..4ee4947bc 100644 --- a/src/tests/nodes/leaky_relu_fp16x16/output_0.cairo +++ b/src/tests/nodes/leaky_relu_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 453171, sign: false }); - data.append(FixedType { mag: 73289, sign: false }); - data.append(FixedType { mag: 9043, sign: true }); - data.append(FixedType { mag: 316640, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 401540, sign: false }); + data.append(FP16x16 { mag: 4781, sign: true }); + data.append(FP16x16 { mag: 206992, sign: false }); + data.append(FP16x16 { mag: 32304, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_fp8x23.cairo b/src/tests/nodes/leaky_relu_fp8x23.cairo index e31922753..05110795c 100644 --- a/src/tests/nodes/leaky_relu_fp8x23.cairo +++ b/src/tests/nodes/leaky_relu_fp8x23.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/leaky_relu_fp8x23/input_0.cairo b/src/tests/nodes/leaky_relu_fp8x23/input_0.cairo index 948a06bd9..93effa14d 100644 --- a/src/tests/nodes/leaky_relu_fp8x23/input_0.cairo +++ b/src/tests/nodes/leaky_relu_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 10631720, sign: false }); - data.append(FixedType { mag: 50119017, sign: false }); - data.append(FixedType { mag: 13888927, sign: false }); - data.append(FixedType { mag: 6576321, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 12477177, sign: false }); + data.append(FP8x23 { mag: 29017046, sign: false }); + data.append(FP8x23 { mag: 26929960, sign: true }); + data.append(FP8x23 { mag: 689284, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_fp8x23/output_0.cairo b/src/tests/nodes/leaky_relu_fp8x23/output_0.cairo index f04a7961c..da0ea5456 100644 --- a/src/tests/nodes/leaky_relu_fp8x23/output_0.cairo +++ b/src/tests/nodes/leaky_relu_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 10631721, sign: false }); - data.append(FixedType { mag: 50119016, sign: false }); - data.append(FixedType { mag: 13888927, sign: false }); - data.append(FixedType { mag: 657632, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 12477178, sign: false }); + data.append(FP8x23 { mag: 29017046, sign: false }); + data.append(FP8x23 { mag: 2692996, sign: true }); + data.append(FP8x23 { mag: 689284, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i32_fp16x16.cairo b/src/tests/nodes/leaky_relu_i32_fp16x16.cairo deleted file mode 100644 index 5ab5e37d4..000000000 --- a/src/tests/nodes/leaky_relu_i32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_leaky_relu_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::leaky_relu(@input_0, @FixedTrait::new(6554, false)); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i32_fp16x16/input_0.cairo b/src/tests/nodes/leaky_relu_i32_fp16x16/input_0.cairo deleted file mode 100644 index 538668cef..000000000 --- a/src/tests/nodes/leaky_relu_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 4, sign: false }); - data.append(i32 { mag: 5, sign: false }); - data.append(i32 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i32_fp16x16/output_0.cairo b/src/tests/nodes/leaky_relu_i32_fp16x16/output_0.cairo deleted file mode 100644 index d45647b71..000000000 --- a/src/tests/nodes/leaky_relu_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 13107, sign: true }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i32_fp8x23.cairo b/src/tests/nodes/leaky_relu_i32_fp8x23.cairo deleted file mode 100644 index 6c6bb3b43..000000000 --- a/src/tests/nodes/leaky_relu_i32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_leaky_relu_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::leaky_relu(@input_0, @FixedTrait::new(838861, false)); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i32_fp8x23/input_0.cairo b/src/tests/nodes/leaky_relu_i32_fp8x23/input_0.cairo deleted file mode 100644 index 006d212aa..000000000 --- a/src/tests/nodes/leaky_relu_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 3, sign: true }); - data.append(i32 { mag: 7, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i32_fp8x23/output_0.cairo b/src/tests/nodes/leaky_relu_i32_fp8x23/output_0.cairo deleted file mode 100644 index d8a41747c..000000000 --- a/src/tests/nodes/leaky_relu_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2516582, sign: true }); - data.append(FixedType { mag: 58720256, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i8_fp16x16.cairo b/src/tests/nodes/leaky_relu_i8_fp16x16.cairo deleted file mode 100644 index 5c2ad32ab..000000000 --- a/src/tests/nodes/leaky_relu_i8_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_leaky_relu_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::leaky_relu(@input_0, @FixedTrait::new(6554, false)); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i8_fp16x16/input_0.cairo b/src/tests/nodes/leaky_relu_i8_fp16x16/input_0.cairo deleted file mode 100644 index 01061a4c3..000000000 --- a/src/tests/nodes/leaky_relu_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 3, sign: true }); - data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 7, sign: false }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i8_fp16x16/output_0.cairo b/src/tests/nodes/leaky_relu_i8_fp16x16/output_0.cairo deleted file mode 100644 index 09c8c4f96..000000000 --- a/src/tests/nodes/leaky_relu_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 19660, sign: true }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 458752, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i8_fp8x23.cairo b/src/tests/nodes/leaky_relu_i8_fp8x23.cairo deleted file mode 100644 index ff5f3dee3..000000000 --- a/src/tests/nodes/leaky_relu_i8_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_leaky_relu_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::leaky_relu(@input_0, @FixedTrait::new(838861, false)); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i8_fp8x23/input_0.cairo b/src/tests/nodes/leaky_relu_i8_fp8x23/input_0.cairo deleted file mode 100644 index 207cf60cd..000000000 --- a/src/tests/nodes/leaky_relu_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 5, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/leaky_relu_i8_fp8x23/output_0.cairo b/src/tests/nodes/leaky_relu_i8_fp8x23/output_0.cairo deleted file mode 100644 index e6d6698fb..000000000 --- a/src/tests/nodes/leaky_relu_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 4194304, sign: true }); - data.append(FixedType { mag: 2516582, sign: true }); - data.append(FixedType { mag: 2516582, sign: true }); - data.append(FixedType { mag: 25165824, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp16x16.cairo b/src/tests/nodes/less_equal_fp16x16.cairo index 3c7b2d8f7..e5aa67a91 100644 --- a/src/tests/nodes/less_equal_fp16x16.cairo +++ b/src/tests/nodes/less_equal_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_fp16x16/input_0.cairo b/src/tests/nodes/less_equal_fp16x16/input_0.cairo index 119163dc1..e45b1c3a0 100644 --- a/src/tests/nodes/less_equal_fp16x16/input_0.cairo +++ b/src/tests/nodes/less_equal_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp16x16/input_1.cairo b/src/tests/nodes/less_equal_fp16x16/input_1.cairo index 4bc99cbe5..4a0f45254 100644 --- a/src/tests/nodes/less_equal_fp16x16/input_1.cairo +++ b/src/tests/nodes/less_equal_fp16x16/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp16x16/output_0.cairo b/src/tests/nodes/less_equal_fp16x16/output_0.cairo index 04e17d1f2..fdae52d6a 100644 --- a/src/tests/nodes/less_equal_fp16x16/output_0.cairo +++ b/src/tests/nodes/less_equal_fp16x16/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(0); data.append(1); data.append(1); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp16x16_broadcast.cairo b/src/tests/nodes/less_equal_fp16x16_broadcast.cairo index 145050226..28e877b85 100644 --- a/src/tests/nodes/less_equal_fp16x16_broadcast.cairo +++ b/src/tests/nodes/less_equal_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/less_equal_fp16x16_broadcast/input_0.cairo index 96e6840a9..cad6713ff 100644 --- a/src/tests/nodes/less_equal_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/less_equal_fp16x16_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/less_equal_fp16x16_broadcast/input_1.cairo index f97d91601..378bd0a89 100644 --- a/src/tests/nodes/less_equal_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/less_equal_fp16x16_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/less_equal_fp16x16_broadcast/output_0.cairo index 01c472c0e..fdae52d6a 100644 --- a/src/tests/nodes/less_equal_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/less_equal_fp16x16_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); data.append(1); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp8x23.cairo b/src/tests/nodes/less_equal_fp8x23.cairo index b19a134ba..6e4cfe75d 100644 --- a/src/tests/nodes/less_equal_fp8x23.cairo +++ b/src/tests/nodes/less_equal_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_fp8x23/input_0.cairo b/src/tests/nodes/less_equal_fp8x23/input_0.cairo index 37af04feb..1e987a572 100644 --- a/src/tests/nodes/less_equal_fp8x23/input_0.cairo +++ b/src/tests/nodes/less_equal_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp8x23/input_1.cairo b/src/tests/nodes/less_equal_fp8x23/input_1.cairo index 227cbadbc..50338a1e0 100644 --- a/src/tests/nodes/less_equal_fp8x23/input_1.cairo +++ b/src/tests/nodes/less_equal_fp8x23/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp8x23/output_0.cairo b/src/tests/nodes/less_equal_fp8x23/output_0.cairo index f8f4c946c..328774a25 100644 --- a/src/tests/nodes/less_equal_fp8x23/output_0.cairo +++ b/src/tests/nodes/less_equal_fp8x23/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,9 +10,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(1); - data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp8x23_broadcast.cairo b/src/tests/nodes/less_equal_fp8x23_broadcast.cairo index b29af61b1..f4425ce6f 100644 --- a/src/tests/nodes/less_equal_fp8x23_broadcast.cairo +++ b/src/tests/nodes/less_equal_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/less_equal_fp8x23_broadcast/input_0.cairo index 0b938524d..55785eaea 100644 --- a/src/tests/nodes/less_equal_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/less_equal_fp8x23_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/less_equal_fp8x23_broadcast/input_1.cairo index 70af415ea..fdcd11d36 100644 --- a/src/tests/nodes/less_equal_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/less_equal_fp8x23_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/less_equal_fp8x23_broadcast/output_0.cairo index fec9e9f5b..b7f7a3c83 100644 --- a/src/tests/nodes/less_equal_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/less_equal_fp8x23_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(1); data.append(1); + data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i32.cairo b/src/tests/nodes/less_equal_i32.cairo index 9531ba0b7..07417edc7 100644 --- a/src/tests/nodes/less_equal_i32.cairo +++ b/src/tests/nodes/less_equal_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_i32/input_0.cairo b/src/tests/nodes/less_equal_i32/input_0.cairo index faa213d06..76d7a597a 100644 --- a/src/tests/nodes/less_equal_i32/input_0.cairo +++ b/src/tests/nodes/less_equal_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i32/input_1.cairo b/src/tests/nodes/less_equal_i32/input_1.cairo index d3da2e0ce..b713f9cdf 100644 --- a/src/tests/nodes/less_equal_i32/input_1.cairo +++ b/src/tests/nodes/less_equal_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i32/output_0.cairo b/src/tests/nodes/less_equal_i32/output_0.cairo index 71366ef08..d9b9dedff 100644 --- a/src/tests/nodes/less_equal_i32/output_0.cairo +++ b/src/tests/nodes/less_equal_i32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(0); data.append(1); data.append(0); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i32_broadcast.cairo b/src/tests/nodes/less_equal_i32_broadcast.cairo index c685ff6df..30528a72d 100644 --- a/src/tests/nodes/less_equal_i32_broadcast.cairo +++ b/src/tests/nodes/less_equal_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_i32_broadcast/input_0.cairo b/src/tests/nodes/less_equal_i32_broadcast/input_0.cairo index a0be9aa75..044d66961 100644 --- a/src/tests/nodes/less_equal_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/less_equal_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i32_broadcast/input_1.cairo b/src/tests/nodes/less_equal_i32_broadcast/input_1.cairo index 56ec9b835..ef4d6e029 100644 --- a/src/tests/nodes/less_equal_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/less_equal_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i32_broadcast/output_0.cairo b/src/tests/nodes/less_equal_i32_broadcast/output_0.cairo index 77d9dfd7c..2a00c3c50 100644 --- a/src/tests/nodes/less_equal_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/less_equal_i32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,9 +10,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); data.append(1); + data.append(1); data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i8.cairo b/src/tests/nodes/less_equal_i8.cairo index 6091e42e6..432c158b9 100644 --- a/src/tests/nodes/less_equal_i8.cairo +++ b/src/tests/nodes/less_equal_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_i8/input_0.cairo b/src/tests/nodes/less_equal_i8/input_0.cairo index 0ac0f1b53..9f38b3caa 100644 --- a/src/tests/nodes/less_equal_i8/input_0.cairo +++ b/src/tests/nodes/less_equal_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i8/input_1.cairo b/src/tests/nodes/less_equal_i8/input_1.cairo index c7fe91fb7..28d5cb3d4 100644 --- a/src/tests/nodes/less_equal_i8/input_1.cairo +++ b/src/tests/nodes/less_equal_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i8/output_0.cairo b/src/tests/nodes/less_equal_i8/output_0.cairo index 157fe88f9..2094003c4 100644 --- a/src/tests/nodes/less_equal_i8/output_0.cairo +++ b/src/tests/nodes/less_equal_i8/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i8_broadcast.cairo b/src/tests/nodes/less_equal_i8_broadcast.cairo index 3b74d6504..f83a1ebbc 100644 --- a/src/tests/nodes/less_equal_i8_broadcast.cairo +++ b/src/tests/nodes/less_equal_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_i8_broadcast/input_0.cairo b/src/tests/nodes/less_equal_i8_broadcast/input_0.cairo index 7f92fccdf..af8ae9475 100644 --- a/src/tests/nodes/less_equal_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/less_equal_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,10 +10,8 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i8_broadcast/input_1.cairo b/src/tests/nodes/less_equal_i8_broadcast/input_1.cairo index bfa6eed4a..f2ee05092 100644 --- a/src/tests/nodes/less_equal_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/less_equal_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_i8_broadcast/output_0.cairo b/src/tests/nodes/less_equal_i8_broadcast/output_0.cairo index 0a76aeb0c..386b678ef 100644 --- a/src/tests/nodes/less_equal_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/less_equal_i8_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); - data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_u32.cairo b/src/tests/nodes/less_equal_u32.cairo index 67e7cf883..b9de4d683 100644 --- a/src/tests/nodes/less_equal_u32.cairo +++ b/src/tests/nodes/less_equal_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_u32/input_0.cairo b/src/tests/nodes/less_equal_u32/input_0.cairo index 48aa4edc1..a1dd52918 100644 --- a/src/tests/nodes/less_equal_u32/input_0.cairo +++ b/src/tests/nodes/less_equal_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(4); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_u32/input_1.cairo b/src/tests/nodes/less_equal_u32/input_1.cairo index 757d81ad0..ff87f088a 100644 --- a/src/tests/nodes/less_equal_u32/input_1.cairo +++ b/src/tests/nodes/less_equal_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(3); - data.append(5); + data.append(0); data.append(2); + data.append(5); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_u32/output_0.cairo b/src/tests/nodes/less_equal_u32/output_0.cairo index 04e17d1f2..fdae52d6a 100644 --- a/src/tests/nodes/less_equal_u32/output_0.cairo +++ b/src/tests/nodes/less_equal_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(0); data.append(1); data.append(1); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_u32_broadcast.cairo b/src/tests/nodes/less_equal_u32_broadcast.cairo index 841d2bd48..6db6cba0f 100644 --- a/src/tests/nodes/less_equal_u32_broadcast.cairo +++ b/src/tests/nodes/less_equal_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_equal_u32_broadcast/input_0.cairo b/src/tests/nodes/less_equal_u32_broadcast/input_0.cairo index 7512c9c61..d4284899e 100644 --- a/src/tests/nodes/less_equal_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/less_equal_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(1); + data.append(2); data.append(3); - data.append(0); - data.append(4); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_u32_broadcast/input_1.cairo b/src/tests/nodes/less_equal_u32_broadcast/input_1.cairo index 7f31fac51..cd189c89d 100644 --- a/src/tests/nodes/less_equal_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/less_equal_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(1); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_equal_u32_broadcast/output_0.cairo b/src/tests/nodes/less_equal_u32_broadcast/output_0.cairo index 0a76aeb0c..b7f7a3c83 100644 --- a/src/tests/nodes/less_equal_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/less_equal_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp16x16.cairo b/src/tests/nodes/less_fp16x16.cairo index bbc5b14d9..21781b9e0 100644 --- a/src/tests/nodes/less_fp16x16.cairo +++ b/src/tests/nodes/less_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_fp16x16/input_0.cairo b/src/tests/nodes/less_fp16x16/input_0.cairo index a755e8e78..47ba0c652 100644 --- a/src/tests/nodes/less_fp16x16/input_0.cairo +++ b/src/tests/nodes/less_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, 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: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp16x16/input_1.cairo b/src/tests/nodes/less_fp16x16/input_1.cairo index 04b3c16f4..df51f1840 100644 --- a/src/tests/nodes/less_fp16x16/input_1.cairo +++ b/src/tests/nodes/less_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, 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: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp16x16/output_0.cairo b/src/tests/nodes/less_fp16x16/output_0.cairo index b98755bb8..57a138cc0 100644 --- a/src/tests/nodes/less_fp16x16/output_0.cairo +++ b/src/tests/nodes/less_fp16x16/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,8 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); data.append(1); - data.append(0); - data.append(0); - data.append(0); + data.append(1); data.append(1); data.append(1); data.append(0); @@ -22,22 +18,23 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(1); + data.append(1); data.append(0); + data.append(1); + data.append(1); + data.append(1); data.append(0); data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(1); - data.append(0); + data.append(1); data.append(0); data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp16x16_broadcast.cairo b/src/tests/nodes/less_fp16x16_broadcast.cairo index 1af5233b7..f12f65642 100644 --- a/src/tests/nodes/less_fp16x16_broadcast.cairo +++ b/src/tests/nodes/less_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/less_fp16x16_broadcast/input_0.cairo index 9616a95aa..e186777e0 100644 --- a/src/tests/nodes/less_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/less_fp16x16_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + 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: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/less_fp16x16_broadcast/input_1.cairo index 526811cab..1f86b7108 100644 --- a/src/tests/nodes/less_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/less_fp16x16_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/less_fp16x16_broadcast/output_0.cairo index 64aa5d76f..718bd3ae5 100644 --- a/src/tests/nodes/less_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/less_fp16x16_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,31 +12,29 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(0); - data.append(0); + data.append(1); data.append(0); data.append(1); data.append(1); - data.append(0); data.append(1); - data.append(0); data.append(1); data.append(0); data.append(0); - data.append(1); - data.append(1); - data.append(1); + data.append(0); + data.append(0); data.append(0); data.append(0); data.append(1); data.append(1); + data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); - data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + data.append(1); + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp8x23.cairo b/src/tests/nodes/less_fp8x23.cairo index 4dd20b457..acf56a881 100644 --- a/src/tests/nodes/less_fp8x23.cairo +++ b/src/tests/nodes/less_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_fp8x23/input_0.cairo b/src/tests/nodes/less_fp8x23/input_0.cairo index ba76ff7e0..d25e75ea8 100644 --- a/src/tests/nodes/less_fp8x23/input_0.cairo +++ b/src/tests/nodes/less_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, 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: 0, sign: false }); + 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: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp8x23/input_1.cairo b/src/tests/nodes/less_fp8x23/input_1.cairo index d2bdc8739..268729957 100644 --- a/src/tests/nodes/less_fp8x23/input_1.cairo +++ b/src/tests/nodes/less_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 8388608, sign: false }); + 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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: false }); + 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: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp8x23/output_0.cairo b/src/tests/nodes/less_fp8x23/output_0.cairo index f0509a4c0..b8295128c 100644 --- a/src/tests/nodes/less_fp8x23/output_0.cairo +++ b/src/tests/nodes/less_fp8x23/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); data.append(1); data.append(0); data.append(0); @@ -21,23 +18,23 @@ fn output_0() -> Tensor { data.append(0); data.append(1); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); data.append(1); - data.append(0); data.append(1); data.append(1); - data.append(0); data.append(1); data.append(1); + data.append(0); + data.append(0); + data.append(0); + data.append(0); data.append(1); data.append(1); data.append(0); data.append(1); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp8x23_broadcast.cairo b/src/tests/nodes/less_fp8x23_broadcast.cairo index b29ed54e5..52adce60c 100644 --- a/src/tests/nodes/less_fp8x23_broadcast.cairo +++ b/src/tests/nodes/less_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/less_fp8x23_broadcast/input_0.cairo index dbac91100..dcf3b113f 100644 --- a/src/tests/nodes/less_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/less_fp8x23_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/less_fp8x23_broadcast/input_1.cairo index 25d26431b..d586a2c4b 100644 --- a/src/tests/nodes/less_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/less_fp8x23_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/less_fp8x23_broadcast/output_0.cairo index d550be669..0b1d736f2 100644 --- a/src/tests/nodes/less_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/less_fp8x23_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,17 +10,17 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); + data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); - data.append(1); data.append(0); data.append(1); + data.append(1); data.append(0); data.append(0); data.append(0); @@ -29,15 +28,13 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(1); - data.append(1); - data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i32.cairo b/src/tests/nodes/less_i32.cairo index ef564eb00..57541a095 100644 --- a/src/tests/nodes/less_i32.cairo +++ b/src/tests/nodes/less_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_i32/input_0.cairo b/src/tests/nodes/less_i32/input_0.cairo index 60ded4474..dc2a71d6f 100644 --- a/src/tests/nodes/less_i32/input_0.cairo +++ b/src/tests/nodes/less_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, 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: 3, sign: true }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); 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: 2, sign: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, 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: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 3, sign: true }); - 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: 1, sign: true }); data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i32/input_1.cairo b/src/tests/nodes/less_i32/input_1.cairo index da168e186..f8a774df8 100644 --- a/src/tests/nodes/less_i32/input_1.cairo +++ b/src/tests/nodes/less_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + 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: 3, sign: true }); + 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: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, 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: 0, sign: false }); data.append(i32 { mag: 1, 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: true }); data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, 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: 3, sign: true }); + 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: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i32/output_0.cairo b/src/tests/nodes/less_i32/output_0.cairo index 032dba6f6..ea0f32c51 100644 --- a/src/tests/nodes/less_i32/output_0.cairo +++ b/src/tests/nodes/less_i32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(1); + data.append(0); + data.append(0); + data.append(0); data.append(1); data.append(0); data.append(0); data.append(1); data.append(1); data.append(0); - data.append(1); data.append(0); data.append(1); - data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(1); data.append(0); data.append(0); data.append(1); data.append(1); - data.append(1); - data.append(1); - data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i32_broadcast.cairo b/src/tests/nodes/less_i32_broadcast.cairo index 3aebd93de..09b42704a 100644 --- a/src/tests/nodes/less_i32_broadcast.cairo +++ b/src/tests/nodes/less_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_i32_broadcast/input_0.cairo b/src/tests/nodes/less_i32_broadcast/input_0.cairo index b6d9cdc38..b5d1adb86 100644 --- a/src/tests/nodes/less_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/less_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { 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: 2, sign: true }); data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: false }); 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: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: true }); - 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: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, 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: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i32_broadcast/input_1.cairo b/src/tests/nodes/less_i32_broadcast/input_1.cairo index c0e7c7553..5a96f6820 100644 --- a/src/tests/nodes/less_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/less_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,9 +11,7 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i32_broadcast/output_0.cairo b/src/tests/nodes/less_i32_broadcast/output_0.cairo index d0fd2d6ab..0b9fd5642 100644 --- a/src/tests/nodes/less_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/less_i32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -16,9 +15,9 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); - data.append(1); + data.append(0); + data.append(0); data.append(1); data.append(1); data.append(0); @@ -26,18 +25,16 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(0); + data.append(0); + data.append(1); + data.append(1); data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i8.cairo b/src/tests/nodes/less_i8.cairo index e0a253815..c05e8d799 100644 --- a/src/tests/nodes/less_i8.cairo +++ b/src/tests/nodes/less_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_i8/input_0.cairo b/src/tests/nodes/less_i8/input_0.cairo index bdd3d6ebc..c2184a707 100644 --- a/src/tests/nodes/less_i8/input_0.cairo +++ b/src/tests/nodes/less_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); - 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: 1, sign: true }); data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - 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: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i8/input_1.cairo b/src/tests/nodes/less_i8/input_1.cairo index d156b14c9..571aad2d3 100644 --- a/src/tests/nodes/less_i8/input_1.cairo +++ b/src/tests/nodes/less_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -12,33 +11,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 2, sign: false }); + 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: 2, sign: true }); data.append(i8 { mag: 0, 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: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - 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: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i8/output_0.cairo b/src/tests/nodes/less_i8/output_0.cairo index 7c7a9c586..deae6c067 100644 --- a/src/tests/nodes/less_i8/output_0.cairo +++ b/src/tests/nodes/less_i8/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,14 +9,9 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); - data.append(1); - data.append(0); data.append(1); data.append(1); data.append(0); - data.append(1); data.append(0); data.append(1); data.append(0); @@ -28,16 +22,19 @@ fn output_0() -> Tensor { data.append(0); data.append(1); data.append(1); - data.append(0); data.append(1); + data.append(1); + data.append(1); + data.append(0); data.append(0); data.append(1); data.append(0); + data.append(0); + data.append(1); + data.append(1); data.append(1); data.append(0); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i8_broadcast.cairo b/src/tests/nodes/less_i8_broadcast.cairo index 1a472b164..5d5671acb 100644 --- a/src/tests/nodes/less_i8_broadcast.cairo +++ b/src/tests/nodes/less_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_i8_broadcast/input_0.cairo b/src/tests/nodes/less_i8_broadcast/input_0.cairo index 25bb5bb5a..bc6e75c58 100644 --- a/src/tests/nodes/less_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/less_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, 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: 2, sign: false }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); - 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: 3, sign: true }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); + 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: 2, sign: true }); data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i8_broadcast/input_1.cairo b/src/tests/nodes/less_i8_broadcast/input_1.cairo index 27578b470..6c082b2d3 100644 --- a/src/tests/nodes/less_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/less_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -13,8 +12,6 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_i8_broadcast/output_0.cairo b/src/tests/nodes/less_i8_broadcast/output_0.cairo index 75179d0ca..48ad45772 100644 --- a/src/tests/nodes/less_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/less_i8_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -15,14 +14,10 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(0); - data.append(0); - data.append(0); - data.append(0); - data.append(1); data.append(1); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); @@ -30,14 +25,16 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(1); + data.append(1); + data.append(1); + data.append(1); + data.append(1); data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_u32.cairo b/src/tests/nodes/less_u32.cairo index f36132b9e..e3043c8cc 100644 --- a/src/tests/nodes/less_u32.cairo +++ b/src/tests/nodes/less_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_u32/input_0.cairo b/src/tests/nodes/less_u32/input_0.cairo index a347dd623..6289bb4f0 100644 --- a/src/tests/nodes/less_u32/input_0.cairo +++ b/src/tests/nodes/less_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(5); - data.append(4); + data.append(2); + data.append(1); + data.append(2); data.append(3); data.append(3); data.append(5); - data.append(3); - data.append(4); data.append(5); data.append(5); - data.append(4); + data.append(1); data.append(5); + data.append(3); + data.append(3); + data.append(3); data.append(5); - data.append(4); - data.append(2); data.append(2); - data.append(5); data.append(3); data.append(0); data.append(1); - data.append(4); - data.append(2); - data.append(0); data.append(2); data.append(5); - data.append(2); + data.append(5); + data.append(1); + data.append(5); + data.append(3); data.append(2); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_u32/input_1.cairo b/src/tests/nodes/less_u32/input_1.cairo index 1ad1c3c7e..1d3cc89f6 100644 --- a/src/tests/nodes/less_u32/input_1.cairo +++ b/src/tests/nodes/less_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(0); + data.append(4); + data.append(5); data.append(5); + data.append(4); data.append(0); data.append(4); data.append(3); data.append(5); - data.append(2); - data.append(4); + data.append(0); data.append(2); data.append(5); data.append(1); - data.append(5); - data.append(2); data.append(3); - data.append(3); - data.append(2); - data.append(5); - data.append(5); data.append(5); data.append(0); data.append(1); + data.append(4); + data.append(4); data.append(0); data.append(4); + data.append(5); data.append(3); - data.append(1); - data.append(2); data.append(0); - data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + data.append(4); + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_u32/output_0.cairo b/src/tests/nodes/less_u32/output_0.cairo index 59d558992..df422974f 100644 --- a/src/tests/nodes/less_u32/output_0.cairo +++ b/src/tests/nodes/less_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(0); + data.append(1); + data.append(1); + data.append(1); data.append(1); data.append(0); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); - data.append(0); - data.append(0); - data.append(0); + data.append(1); data.append(0); data.append(0); data.append(1); data.append(0); - data.append(0); data.append(1); data.append(1); - data.append(0); + data.append(1); data.append(0); data.append(0); data.append(1); - data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_u32_broadcast.cairo b/src/tests/nodes/less_u32_broadcast.cairo index e07dfdbc0..f6f451556 100644 --- a/src/tests/nodes/less_u32_broadcast.cairo +++ b/src/tests/nodes/less_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/less_u32_broadcast/input_0.cairo b/src/tests/nodes/less_u32_broadcast/input_0.cairo index 238da0d59..d484854b7 100644 --- a/src/tests/nodes/less_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/less_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(3); - data.append(1); - data.append(0); - data.append(2); - data.append(1); - data.append(3); - data.append(3); - data.append(3); - data.append(3); + data.append(5); + data.append(5); data.append(0); + data.append(4); data.append(1); data.append(3); - data.append(1); - data.append(1); - data.append(0); - data.append(0); data.append(0); - data.append(5); data.append(4); + data.append(5); data.append(2); data.append(2); data.append(0); data.append(3); - data.append(2); data.append(0); + data.append(5); + data.append(4); data.append(0); + data.append(5); + data.append(3); + data.append(1); + data.append(3); + data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(0); + data.append(3); + data.append(2); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_u32_broadcast/input_1.cairo b/src/tests/nodes/less_u32_broadcast/input_1.cairo index 8d9a24b87..26f1f9845 100644 --- a/src/tests/nodes/less_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/less_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(0); data.append(3); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/less_u32_broadcast/output_0.cairo b/src/tests/nodes/less_u32_broadcast/output_0.cairo index 92d2318f0..e092a6421 100644 --- a/src/tests/nodes/less_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/less_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,16 +11,13 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - data.append(0); data.append(1); data.append(1); - data.append(0); data.append(1); data.append(1); data.append(1); data.append(0); data.append(0); - data.append(0); data.append(1); data.append(1); data.append(1); @@ -29,6 +25,7 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(1); @@ -37,7 +34,7 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp16x16.cairo b/src/tests/nodes/linear_fp16x16.cairo index 70dfb0ecf..6814a5879 100644 --- a/src/tests/nodes/linear_fp16x16.cairo +++ b/src/tests/nodes/linear_fp16x16.cairo @@ -4,11 +4,10 @@ mod input_2; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/linear_fp16x16/input_0.cairo b/src/tests/nodes/linear_fp16x16/input_0.cairo index 036a4bab1..deb804047 100644 --- a/src/tests/nodes/linear_fp16x16/input_0.cairo +++ b/src/tests/nodes/linear_fp16x16/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 243480, sign: false }); - data.append(FixedType { mag: 81530, sign: false }); - data.append(FixedType { mag: 33568, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 57550, sign: false }); + data.append(FP16x16 { mag: 313427, sign: true }); + data.append(FP16x16 { mag: 31559, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp16x16/input_1.cairo b/src/tests/nodes/linear_fp16x16/input_1.cairo index 3374a61a8..139b1e374 100644 --- a/src/tests/nodes/linear_fp16x16/input_1.cairo +++ b/src/tests/nodes/linear_fp16x16/input_1.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 406504, sign: false }); - data.append(FixedType { mag: 169826, sign: true }); - data.append(FixedType { mag: 286936, sign: false }); - data.append(FixedType { mag: 216587, sign: true }); - data.append(FixedType { mag: 320888, sign: true }); - data.append(FixedType { mag: 186065, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 316249, sign: true }); + data.append(FP16x16 { mag: 223592, sign: true }); + data.append(FP16x16 { mag: 238282, sign: true }); + data.append(FP16x16 { mag: 452809, sign: false }); + data.append(FP16x16 { mag: 234567, sign: false }); + data.append(FP16x16 { mag: 135020, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp16x16/input_2.cairo b/src/tests/nodes/linear_fp16x16/input_2.cairo index 07ddb20ed..5b0cd4ce2 100644 --- a/src/tests/nodes/linear_fp16x16/input_2.cairo +++ b/src/tests/nodes/linear_fp16x16/input_2.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_2() -> Tensor { +fn input_2() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 17100, sign: true }); - data.append(FixedType { mag: 360167, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 362925, sign: false }); + data.append(FP16x16 { mag: 184207, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp16x16/output_0.cairo b/src/tests/nodes/linear_fp16x16/output_0.cairo index ad1ea6673..3563bee17 100644 --- a/src/tests/nodes/linear_fp16x16/output_0.cairo +++ b/src/tests/nodes/linear_fp16x16/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1134904, sign: false }); - data.append(FixedType { mag: 939012, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 1039798, sign: false }); + data.append(FP16x16 { mag: 843374, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp8x23.cairo b/src/tests/nodes/linear_fp8x23.cairo index 619ee0bbe..10914205a 100644 --- a/src/tests/nodes/linear_fp8x23.cairo +++ b/src/tests/nodes/linear_fp8x23.cairo @@ -4,11 +4,10 @@ mod input_2; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/linear_fp8x23/input_0.cairo b/src/tests/nodes/linear_fp8x23/input_0.cairo index b7711dbbd..76f1d5631 100644 --- a/src/tests/nodes/linear_fp8x23/input_0.cairo +++ b/src/tests/nodes/linear_fp8x23/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16576692, sign: false }); - data.append(FixedType { mag: 41797636, sign: false }); - data.append(FixedType { mag: 10487655, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 11919257, sign: false }); + data.append(FP8x23 { mag: 4840922, sign: false }); + data.append(FP8x23 { mag: 47921258, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp8x23/input_1.cairo b/src/tests/nodes/linear_fp8x23/input_1.cairo index b09fdd3da..e7c115b6e 100644 --- a/src/tests/nodes/linear_fp8x23/input_1.cairo +++ b/src/tests/nodes/linear_fp8x23/input_1.cairo @@ -1,21 +1,20 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1236715, sign: false }); - data.append(FixedType { mag: 4771319, sign: false }); - data.append(FixedType { mag: 8392691, sign: false }); - data.append(FixedType { mag: 36629024, sign: true }); - data.append(FixedType { mag: 34768195, sign: false }); - data.append(FixedType { mag: 2858178, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 52315818, sign: false }); + data.append(FP8x23 { mag: 2320148, sign: false }); + data.append(FP8x23 { mag: 22884193, sign: true }); + data.append(FP8x23 { mag: 21749272, sign: false }); + data.append(FP8x23 { mag: 29980322, sign: true }); + data.append(FP8x23 { mag: 34817611, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp8x23/input_2.cairo b/src/tests/nodes/linear_fp8x23/input_2.cairo index 198c14455..df5d5093a 100644 --- a/src/tests/nodes/linear_fp8x23/input_2.cairo +++ b/src/tests/nodes/linear_fp8x23/input_2.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_2() -> Tensor { +fn input_2() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 34671437, sign: true }); - data.append(FixedType { mag: 27817938, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8723741, sign: false }); + data.append(FP8x23 { mag: 54398803, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_fp8x23/output_0.cairo b/src/tests/nodes/linear_fp8x23/output_0.cairo index 7dccc53bb..6075c78e7 100644 --- a/src/tests/nodes/linear_fp8x23/output_0.cairo +++ b/src/tests/nodes/linear_fp8x23/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 18946433, sign: true }); - data.append(FixedType { mag: 125100432, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 46332113, sign: true }); + data.append(FP8x23 { mag: 130900238, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i32.cairo b/src/tests/nodes/linear_i32.cairo index 7e3ca8c88..47644ee5a 100644 --- a/src/tests/nodes/linear_i32.cairo +++ b/src/tests/nodes/linear_i32.cairo @@ -4,11 +4,10 @@ mod input_2; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::I32NN; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/linear_i32/input_0.cairo b/src/tests/nodes/linear_i32/input_0.cairo index 8662d4ca0..ceac57bb9 100644 --- a/src/tests/nodes/linear_i32/input_0.cairo +++ b/src/tests/nodes/linear_i32/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 8, sign: false }); - data.append(i32 { mag: 7, sign: false }); - data.append(i32 { mag: 5, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i32/input_1.cairo b/src/tests/nodes/linear_i32/input_1.cairo index 777f600cb..cd9b1a41a 100644 --- a/src/tests/nodes/linear_i32/input_1.cairo +++ b/src/tests/nodes/linear_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,13 +9,11 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 7, sign: false }); - data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i32/input_2.cairo b/src/tests/nodes/linear_i32/input_2.cairo index f0580c1ef..b51f38563 100644 --- a/src/tests/nodes/linear_i32/input_2.cairo +++ b/src/tests/nodes/linear_i32/input_2.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn input_2() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 4, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i32/output_0.cairo b/src/tests/nodes/linear_i32/output_0.cairo index d65df270e..d22ac08d8 100644 --- a/src/tests/nodes/linear_i32/output_0.cairo +++ b/src/tests/nodes/linear_i32/output_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 79, sign: true }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 19, sign: true }); + data.append(i32 { mag: 36, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i8.cairo b/src/tests/nodes/linear_i8.cairo index 94cb1f96c..906f4ede1 100644 --- a/src/tests/nodes/linear_i8.cairo +++ b/src/tests/nodes/linear_i8.cairo @@ -4,11 +4,10 @@ mod input_2; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::I8NN; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/linear_i8/input_0.cairo b/src/tests/nodes/linear_i8/input_0.cairo index b384db765..71ad2ee24 100644 --- a/src/tests/nodes/linear_i8/input_0.cairo +++ b/src/tests/nodes/linear_i8/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i8/input_1.cairo b/src/tests/nodes/linear_i8/input_1.cairo index 235be773b..1af283f23 100644 --- a/src/tests/nodes/linear_i8/input_1.cairo +++ b/src/tests/nodes/linear_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,12 +10,10 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); - 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: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i8/input_2.cairo b/src/tests/nodes/linear_i8/input_2.cairo index 855176afc..a64f62901 100644 --- a/src/tests/nodes/linear_i8/input_2.cairo +++ b/src/tests/nodes/linear_i8/input_2.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn input_2() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_i8/output_0.cairo b/src/tests/nodes/linear_i8/output_0.cairo index 1617613e7..a274958e0 100644 --- a/src/tests/nodes/linear_i8/output_0.cairo +++ b/src/tests/nodes/linear_i8/output_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 7, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_u32.cairo b/src/tests/nodes/linear_u32.cairo index 91e47e715..d0f695299 100644 --- a/src/tests/nodes/linear_u32.cairo +++ b/src/tests/nodes/linear_u32.cairo @@ -4,11 +4,10 @@ mod input_2; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::U32NN; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/linear_u32/input_0.cairo b/src/tests/nodes/linear_u32/input_0.cairo index 1c5b420be..1155cc0bc 100644 --- a/src/tests/nodes/linear_u32/input_0.cairo +++ b/src/tests/nodes/linear_u32/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(3); - data.append(3); + data.append(0); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_u32/input_1.cairo b/src/tests/nodes/linear_u32/input_1.cairo index c67a3e693..4ed09b8c4 100644 --- a/src/tests/nodes/linear_u32/input_1.cairo +++ b/src/tests/nodes/linear_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,13 +8,11 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(5); - data.append(3); + data.append(1); + data.append(4); + data.append(4); + data.append(4); + data.append(2); data.append(0); - data.append(3); - data.append(0); - data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_u32/input_2.cairo b/src/tests/nodes/linear_u32/input_2.cairo index 1822f94cf..cb612d623 100644 --- a/src/tests/nodes/linear_u32/input_2.cairo +++ b/src/tests/nodes/linear_u32/input_2.cairo @@ -1,16 +1,13 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_2() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/linear_u32/output_0.cairo b/src/tests/nodes/linear_u32/output_0.cairo index 4091d642a..7c2e0d428 100644 --- a/src/tests/nodes/linear_u32/output_0.cairo +++ b/src/tests/nodes/linear_u32/output_0.cairo @@ -1,16 +1,13 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(24); - data.append(21); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(41); + data.append(11); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/log_fp16x16.cairo b/src/tests/nodes/log_fp16x16.cairo index 6658f477f..798670a05 100644 --- a/src/tests/nodes/log_fp16x16.cairo +++ b/src/tests/nodes/log_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/log_fp16x16/input_0.cairo b/src/tests/nodes/log_fp16x16/input_0.cairo index e5c9cee2e..559a20755 100644 --- a/src/tests/nodes/log_fp16x16/input_0.cairo +++ b/src/tests/nodes/log_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1128814, sign: false }); - data.append(FixedType { mag: 6863846, sign: false }); - data.append(FixedType { mag: 920075, sign: false }); - data.append(FixedType { mag: 7713567, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 2469811, sign: false }); + data.append(FP16x16 { mag: 841664, sign: false }); + data.append(FP16x16 { mag: 6861780, sign: false }); + data.append(FP16x16 { mag: 3475757, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/log_fp16x16/output_0.cairo b/src/tests/nodes/log_fp16x16/output_0.cairo index da628dbfa..3674d50ee 100644 --- a/src/tests/nodes/log_fp16x16/output_0.cairo +++ b/src/tests/nodes/log_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 186536, sign: false }); - data.append(FixedType { mag: 304835, sign: false }); - data.append(FixedType { mag: 173136, sign: false }); - data.append(FixedType { mag: 312484, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 237849, sign: false }); + data.append(FP16x16 { mag: 167299, sign: false }); + data.append(FP16x16 { mag: 304815, sign: false }); + data.append(FP16x16 { mag: 260241, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/log_fp8x23.cairo b/src/tests/nodes/log_fp8x23.cairo index 6b6c1c117..65a79077e 100644 --- a/src/tests/nodes/log_fp8x23.cairo +++ b/src/tests/nodes/log_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/log_fp8x23/input_0.cairo b/src/tests/nodes/log_fp8x23/input_0.cairo index 57e281ede..2be00adcd 100644 --- a/src/tests/nodes/log_fp8x23/input_0.cairo +++ b/src/tests/nodes/log_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 529321914, sign: false }); - data.append(FixedType { mag: 645273413, sign: false }); - data.append(FixedType { mag: 920206991, sign: false }); - data.append(FixedType { mag: 949171945, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 193551844, sign: false }); + data.append(FP8x23 { mag: 202689108, sign: false }); + data.append(FP8x23 { mag: 535508695, sign: false }); + data.append(FP8x23 { mag: 235726980, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/log_fp8x23/output_0.cairo b/src/tests/nodes/log_fp8x23/output_0.cairo index a859ccec6..0c8318b27 100644 --- a/src/tests/nodes/log_fp8x23/output_0.cairo +++ b/src/tests/nodes/log_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 34768449, sign: false }); - data.append(FixedType { mag: 36430042, sign: false }); - data.append(FixedType { mag: 39407365, sign: false }); - data.append(FixedType { mag: 39667339, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 26329079, sign: false }); + data.append(FP8x23 { mag: 26716028, sign: false }); + data.append(FP8x23 { mag: 34865928, sign: false }); + data.append(FP8x23 { mag: 27982715, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/log_i32_fp16x16.cairo b/src/tests/nodes/log_i32_fp16x16.cairo deleted file mode 100644 index cbfaab34d..000000000 --- a/src/tests/nodes/log_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_log_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.log(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/log_i32_fp16x16/input_0.cairo b/src/tests/nodes/log_i32_fp16x16/input_0.cairo deleted file mode 100644 index c88f7a53b..000000000 --- a/src/tests/nodes/log_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 116, sign: false }); - data.append(i32 { mag: 88, sign: false }); - data.append(i32 { mag: 85, sign: false }); - data.append(i32 { mag: 94, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_i32_fp16x16/output_0.cairo b/src/tests/nodes/log_i32_fp16x16/output_0.cairo deleted file mode 100644 index 3a3802271..000000000 --- a/src/tests/nodes/log_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 311531, sign: false }); - data.append(FixedType { mag: 293426, sign: false }); - data.append(FixedType { mag: 291153, sign: false }); - data.append(FixedType { mag: 297749, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_i32_fp8x23.cairo b/src/tests/nodes/log_i32_fp8x23.cairo deleted file mode 100644 index 9afa4b191..000000000 --- a/src/tests/nodes/log_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_log_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.log(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/log_i32_fp8x23/input_0.cairo b/src/tests/nodes/log_i32_fp8x23/input_0.cairo deleted file mode 100644 index 945f62f70..000000000 --- a/src/tests/nodes/log_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 20, sign: false }); - data.append(i32 { mag: 40, sign: false }); - data.append(i32 { mag: 59, sign: false }); - data.append(i32 { mag: 85, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_i32_fp8x23/output_0.cairo b/src/tests/nodes/log_i32_fp8x23/output_0.cairo deleted file mode 100644 index a11f0e3d6..000000000 --- a/src/tests/nodes/log_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 25130023, sign: false }); - data.append(FixedType { mag: 30944563, sign: false }); - data.append(FixedType { mag: 34204863, sign: false }); - data.append(FixedType { mag: 37267659, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_i8_fp16x16.cairo b/src/tests/nodes/log_i8_fp16x16.cairo deleted file mode 100644 index 96c3fa585..000000000 --- a/src/tests/nodes/log_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_log_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.log(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/log_i8_fp16x16/input_0.cairo b/src/tests/nodes/log_i8_fp16x16/input_0.cairo deleted file mode 100644 index 3a5c6c37a..000000000 --- a/src/tests/nodes/log_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 67, sign: false }); - data.append(i8 { mag: 103, sign: false }); - data.append(i8 { mag: 37, sign: false }); - data.append(i8 { mag: 68, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_i8_fp16x16/output_0.cairo b/src/tests/nodes/log_i8_fp16x16/output_0.cairo deleted file mode 100644 index 5ee016823..000000000 --- a/src/tests/nodes/log_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 275558, sign: false }); - data.append(FixedType { mag: 303741, sign: false }); - data.append(FixedType { mag: 236645, sign: false }); - data.append(FixedType { mag: 276529, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_i8_fp8x23.cairo b/src/tests/nodes/log_i8_fp8x23.cairo deleted file mode 100644 index 685159977..000000000 --- a/src/tests/nodes/log_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_log_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.log(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/log_i8_fp8x23/input_0.cairo b/src/tests/nodes/log_i8_fp8x23/input_0.cairo deleted file mode 100644 index 146e79db2..000000000 --- a/src/tests/nodes/log_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 3, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_i8_fp8x23/output_0.cairo b/src/tests/nodes/log_i8_fp8x23/output_0.cairo deleted file mode 100644 index 36057daf7..000000000 --- a/src/tests/nodes/log_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 9216000, sign: false }); - data.append(FixedType { mag: 5816320, sign: false }); - data.append(FixedType { mag: 9216000, sign: false }); - data.append(FixedType { mag: 11632640, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_u32_fp16x16.cairo b/src/tests/nodes/log_u32_fp16x16.cairo deleted file mode 100644 index 0d7b2a88c..000000000 --- a/src/tests/nodes/log_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_log_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.log(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/log_u32_fp16x16/input_0.cairo b/src/tests/nodes/log_u32_fp16x16/input_0.cairo deleted file mode 100644 index 7cc477047..000000000 --- a/src/tests/nodes/log_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(18); - data.append(112); - data.append(41); - data.append(31); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_u32_fp16x16/output_0.cairo b/src/tests/nodes/log_u32_fp16x16/output_0.cairo deleted file mode 100644 index 7d1b0da79..000000000 --- a/src/tests/nodes/log_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 189423, sign: false }); - data.append(FixedType { mag: 309231, sign: false }); - data.append(FixedType { mag: 243372, sign: false }); - data.append(FixedType { mag: 225049, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_u32_fp8x23.cairo b/src/tests/nodes/log_u32_fp8x23.cairo deleted file mode 100644 index eb32ba0b8..000000000 --- a/src/tests/nodes/log_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_log_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.log(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/log_u32_fp8x23/input_0.cairo b/src/tests/nodes/log_u32_fp8x23/input_0.cairo deleted file mode 100644 index c0ebafa18..000000000 --- a/src/tests/nodes/log_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(12); - data.append(111); - data.append(35); - data.append(111); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/log_u32_fp8x23/output_0.cairo b/src/tests/nodes/log_u32_fp8x23/output_0.cairo deleted file mode 100644 index 8fea2ee69..000000000 --- a/src/tests/nodes/log_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 20844907, sign: false }); - data.append(FixedType { mag: 39506402, sign: false }); - data.append(FixedType { mag: 29824421, sign: false }); - data.append(FixedType { mag: 39506402, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp16x16_axis_0.cairo b/src/tests/nodes/logsoftmax_fp16x16_axis_0.cairo index c04e2476b..e0bb07e4d 100644 --- a/src/tests/nodes/logsoftmax_fp16x16_axis_0.cairo +++ b/src/tests/nodes/logsoftmax_fp16x16_axis_0.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/logsoftmax_fp16x16_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_fp16x16_axis_0/input_0.cairo index 2a6dddad4..74c447c63 100644 --- a/src/tests/nodes/logsoftmax_fp16x16_axis_0/input_0.cairo +++ b/src/tests/nodes/logsoftmax_fp16x16_axis_0/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 116037, sign: false }); - data.append(FixedType { mag: 94428, sign: false }); - data.append(FixedType { mag: 182052, sign: false }); - data.append(FixedType { mag: 91686, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 174259, sign: false }); + data.append(FP16x16 { mag: 162527, sign: false }); + data.append(FP16x16 { mag: 121375, sign: false }); + data.append(FP16x16 { mag: 140007, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp16x16_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_fp16x16_axis_0/output_0.cairo index 763d8bfa8..ee95f26c8 100644 --- a/src/tests/nodes/logsoftmax_fp16x16_axis_0/output_0.cairo +++ b/src/tests/nodes/logsoftmax_fp16x16_axis_0/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 86416, sign: true }); - data.append(FixedType { mag: 3721, sign: true }); - data.append(FixedType { mag: 20401, sign: true }); - data.append(FixedType { mag: 189836, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 24179, sign: true }); + data.append(FP16x16 { mag: 644, sign: true }); + data.append(FP16x16 { mag: 77063, sign: true }); + data.append(FP16x16 { mag: 303179, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp16x16_axis_1.cairo b/src/tests/nodes/logsoftmax_fp16x16_axis_1.cairo index 76a403a3a..2c5076d76 100644 --- a/src/tests/nodes/logsoftmax_fp16x16_axis_1.cairo +++ b/src/tests/nodes/logsoftmax_fp16x16_axis_1.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/logsoftmax_fp16x16_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_fp16x16_axis_1/input_0.cairo index 1e24ca02b..4b561ef8c 100644 --- a/src/tests/nodes/logsoftmax_fp16x16_axis_1/input_0.cairo +++ b/src/tests/nodes/logsoftmax_fp16x16_axis_1/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 37143, sign: true }); - data.append(FixedType { mag: 194436, sign: true }); - data.append(FixedType { mag: 74078, sign: true }); - data.append(FixedType { mag: 43388, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131507, sign: true }); + data.append(FP16x16 { mag: 114767, sign: true }); + data.append(FP16x16 { mag: 44400, sign: true }); + data.append(FP16x16 { mag: 107661, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp16x16_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_fp16x16_axis_1/output_0.cairo index 0f209e76a..b5890e4de 100644 --- a/src/tests/nodes/logsoftmax_fp16x16_axis_1/output_0.cairo +++ b/src/tests/nodes/logsoftmax_fp16x16_axis_1/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5690, sign: true }); - data.append(FixedType { mag: 162983, sign: true }); - data.append(FixedType { mag: 127562, sign: true }); - data.append(FixedType { mag: 10096, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 54329, sign: true }); + data.append(FP16x16 { mag: 37588, sign: true }); + data.append(FP16x16 { mag: 158203, sign: true }); + data.append(FP16x16 { mag: 6141, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp8x23_axis_0.cairo b/src/tests/nodes/logsoftmax_fp8x23_axis_0.cairo index 57d0e731d..d17151ee0 100644 --- a/src/tests/nodes/logsoftmax_fp8x23_axis_0.cairo +++ b/src/tests/nodes/logsoftmax_fp8x23_axis_0.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/logsoftmax_fp8x23_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_fp8x23_axis_0/input_0.cairo index b1c480a2e..09a55d417 100644 --- a/src/tests/nodes/logsoftmax_fp8x23_axis_0/input_0.cairo +++ b/src/tests/nodes/logsoftmax_fp8x23_axis_0/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 9437097, sign: false }); - data.append(FixedType { mag: 439107, sign: true }); - data.append(FixedType { mag: 8701053, sign: false }); - data.append(FixedType { mag: 11846800, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 13176366, sign: false }); + data.append(FP8x23 { mag: 22787205, sign: true }); + data.append(FP8x23 { mag: 3037628, sign: false }); + data.append(FP8x23 { mag: 15135492, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp8x23_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_fp8x23_axis_0/output_0.cairo index 60e6a9890..a2f21ecad 100644 --- a/src/tests/nodes/logsoftmax_fp8x23_axis_0/output_0.cairo +++ b/src/tests/nodes/logsoftmax_fp8x23_axis_0/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5454588, sign: true }); - data.append(FixedType { mag: 14030456, sign: true }); - data.append(FixedType { mag: 6190632, sign: true }); - data.append(FixedType { mag: 1744548, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 2191868, sign: true }); + data.append(FP8x23 { mag: 10484172, sign: true }); + data.append(FP8x23 { mag: 12330606, sign: true }); + data.append(FP8x23 { mag: 2832460, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp8x23_axis_1.cairo b/src/tests/nodes/logsoftmax_fp8x23_axis_1.cairo index 00cdca872..170e93bbd 100644 --- a/src/tests/nodes/logsoftmax_fp8x23_axis_1.cairo +++ b/src/tests/nodes/logsoftmax_fp8x23_axis_1.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/logsoftmax_fp8x23_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_fp8x23_axis_1/input_0.cairo index 5f55de1f5..025a7cd96 100644 --- a/src/tests/nodes/logsoftmax_fp8x23_axis_1/input_0.cairo +++ b/src/tests/nodes/logsoftmax_fp8x23_axis_1/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6023735, sign: true }); - data.append(FixedType { mag: 7861841, sign: false }); - data.append(FixedType { mag: 20034366, sign: true }); - data.append(FixedType { mag: 4664398, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 14864085, sign: false }); + data.append(FP8x23 { mag: 748527, sign: false }); + data.append(FP8x23 { mag: 13216170, sign: false }); + data.append(FP8x23 { mag: 10738967, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_fp8x23_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_fp8x23_axis_1/output_0.cairo index 18e030f00..c6e156022 100644 --- a/src/tests/nodes/logsoftmax_fp8x23_axis_1/output_0.cairo +++ b/src/tests/nodes/logsoftmax_fp8x23_axis_1/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 15352108, sign: true }); - data.append(FixedType { mag: 1466530, sign: true }); - data.append(FixedType { mag: 25129093, sign: true }); - data.append(FixedType { mag: 430328, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 1430064, sign: true }); + data.append(FP8x23 { mag: 15545622, sign: true }); + data.append(FP8x23 { mag: 469121, sign: true }); + data.append(FP8x23 { mag: 24424260, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0.cairo b/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0.cairo deleted file mode 100644 index aa32e1c18..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i32_fp16x16_axis_0() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0/input_0.cairo deleted file mode 100644 index 2b954a490..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0/output_0.cairo deleted file mode 100644 index 318abfcaa..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_0/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 139390, sign: true }); - data.append(FixedType { mag: 20529, sign: true }); - data.append(FixedType { mag: 8318, sign: true }); - data.append(FixedType { mag: 86065, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1.cairo b/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1.cairo deleted file mode 100644 index a6df42bca..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i32_fp16x16_axis_1() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1/input_0.cairo deleted file mode 100644 index ac01a2e9f..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1/output_0.cairo deleted file mode 100644 index e82b83053..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp16x16_axis_1/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 20529, sign: true }); - data.append(FixedType { mag: 86065, sign: true }); - data.append(FixedType { mag: 139390, sign: true }); - data.append(FixedType { mag: 8318, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0.cairo b/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0.cairo deleted file mode 100644 index 5fa8a76a1..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i32_fp8x23_axis_0() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0/input_0.cairo deleted file mode 100644 index b9a63b8c1..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0/output_0.cairo deleted file mode 100644 index eecf02e67..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_0/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 11016437, sign: true }); - data.append(FixedType { mag: 17841965, sign: true }); - data.append(FixedType { mag: 2627829, sign: true }); - data.append(FixedType { mag: 1064749, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1.cairo b/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1.cairo deleted file mode 100644 index b2e84d218..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i32_fp8x23_axis_1() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1/input_0.cairo deleted file mode 100644 index 4d1feb904..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1/output_0.cairo deleted file mode 100644 index 3ecc6c1d7..000000000 --- a/src/tests/nodes/logsoftmax_i32_fp8x23_axis_1/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 11016437, sign: true }); - data.append(FixedType { mag: 2627829, sign: true }); - data.append(FixedType { mag: 11016437, sign: true }); - data.append(FixedType { mag: 2627829, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0.cairo b/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0.cairo deleted file mode 100644 index bb252df0f..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i8_fp16x16_axis_0() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0/input_0.cairo deleted file mode 100644 index 9a44712e1..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0/output_0.cairo deleted file mode 100644 index c74a797f5..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_0/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 20529, sign: true }); - data.append(FixedType { mag: 3184, sign: true }); - data.append(FixedType { mag: 86065, sign: true }); - data.append(FixedType { mag: 199792, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1.cairo b/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1.cairo deleted file mode 100644 index 2e8dd74af..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i8_fp16x16_axis_1() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1/input_0.cairo deleted file mode 100644 index c64e4dffd..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1/output_0.cairo deleted file mode 100644 index 1a8da4f3e..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp16x16_axis_1/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 3184, sign: true }); - data.append(FixedType { mag: 199792, sign: true }); - data.append(FixedType { mag: 139390, sign: true }); - data.append(FixedType { mag: 8318, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0.cairo b/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0.cairo deleted file mode 100644 index 6525caa26..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i8_fp8x23_axis_0() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0/input_0.cairo deleted file mode 100644 index effc4e221..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0/output_0.cairo deleted file mode 100644 index 32cc41b50..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_0/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2627829, sign: true }); - data.append(FixedType { mag: 17841965, sign: true }); - data.append(FixedType { mag: 11016437, sign: true }); - data.append(FixedType { mag: 1064749, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1.cairo b/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1.cairo deleted file mode 100644 index 4aac09b2a..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_i8_fp8x23_axis_1() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1/input_0.cairo deleted file mode 100644 index c9e9c1076..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1/output_0.cairo deleted file mode 100644 index f2d3e7e30..000000000 --- a/src/tests/nodes/logsoftmax_i8_fp8x23_axis_1/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2627829, sign: true }); - data.append(FixedType { mag: 11016437, sign: true }); - data.append(FixedType { mag: 33706684, sign: true }); - data.append(FixedType { mag: 152252, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0.cairo b/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0.cairo deleted file mode 100644 index 196c45b69..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_u32_fp16x16_axis_0() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0/input_0.cairo deleted file mode 100644 index 4f0431c26..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(1); - data.append(2); - data.append(2); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0/output_0.cairo deleted file mode 100644 index 098b42248..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_0/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 86065, sign: true }); - data.append(FixedType { mag: 8318, sign: true }); - data.append(FixedType { mag: 20529, sign: true }); - data.append(FixedType { mag: 139390, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1.cairo b/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1.cairo deleted file mode 100644 index c683128e1..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_u32_fp16x16_axis_1() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1/input_0.cairo deleted file mode 100644 index 17eef421b..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(2); - data.append(0); - data.append(1); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1/output_0.cairo deleted file mode 100644 index d42777fa1..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp16x16_axis_1/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8318, sign: true }); - data.append(FixedType { mag: 139390, sign: true }); - data.append(FixedType { mag: 86065, sign: true }); - data.append(FixedType { mag: 20529, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0.cairo b/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0.cairo deleted file mode 100644 index 2defbcdbf..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_u32_fp8x23_axis_0() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0/input_0.cairo b/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0/input_0.cairo deleted file mode 100644 index 2f4a2789a..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -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(1); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0/output_0.cairo b/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0/output_0.cairo deleted file mode 100644 index 79f0e52c2..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_0/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 11016437, sign: true }); - data.append(FixedType { mag: 5814539, sign: true }); - data.append(FixedType { mag: 2627829, sign: true }); - data.append(FixedType { mag: 5814539, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1.cairo b/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1.cairo deleted file mode 100644 index a0dd259e0..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_logsoftmax_u32_fp8x23_axis_1() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::logsoftmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1/input_0.cairo b/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1/input_0.cairo deleted file mode 100644 index 3cfa93365..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(2); - data.append(2); - data.append(2); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1/output_0.cairo b/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1/output_0.cairo deleted file mode 100644 index 911b7dca2..000000000 --- a/src/tests/nodes/logsoftmax_u32_fp8x23_axis_1/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5814539, sign: true }); - data.append(FixedType { mag: 5814539, sign: true }); - data.append(FixedType { mag: 1064749, sign: true }); - data.append(FixedType { mag: 17841965, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_1d.cairo b/src/tests/nodes/matmul_fp16x16_1d.cairo index 243bde5e7..8556790f4 100644 --- a/src/tests/nodes/matmul_fp16x16_1d.cairo +++ b/src/tests/nodes/matmul_fp16x16_1d.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp16x16_1d/input_0.cairo b/src/tests/nodes/matmul_fp16x16_1d/input_0.cairo index dac0b7384..a0c78663c 100644 --- a/src/tests/nodes/matmul_fp16x16_1d/input_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_1d/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_1d/input_1.cairo b/src/tests/nodes/matmul_fp16x16_1d/input_1.cairo index 43a655e24..1419b7daa 100644 --- a/src/tests/nodes/matmul_fp16x16_1d/input_1.cairo +++ b/src/tests/nodes/matmul_fp16x16_1d/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_1d/output_0.cairo b/src/tests/nodes/matmul_fp16x16_1d/output_0.cairo index e22669fa4..3ce41e725 100644 --- a/src/tests/nodes/matmul_fp16x16_1d/output_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_1d/output_0.cairo @@ -1,15 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 262144, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_1x2.cairo b/src/tests/nodes/matmul_fp16x16_1x2.cairo index 3177a1dd3..339b9b8ae 100644 --- a/src/tests/nodes/matmul_fp16x16_1x2.cairo +++ b/src/tests/nodes/matmul_fp16x16_1x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp16x16_1x2/input_0.cairo b/src/tests/nodes/matmul_fp16x16_1x2/input_0.cairo index b2e5545b7..b98069ece 100644 --- a/src/tests/nodes/matmul_fp16x16_1x2/input_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_1x2/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_1x2/input_1.cairo b/src/tests/nodes/matmul_fp16x16_1x2/input_1.cairo index 48a17469d..4c0f897cb 100644 --- a/src/tests/nodes/matmul_fp16x16_1x2/input_1.cairo +++ b/src/tests/nodes/matmul_fp16x16_1x2/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_1x2/output_0.cairo b/src/tests/nodes/matmul_fp16x16_1x2/output_0.cairo index f573a4bfe..83656aa97 100644 --- a/src/tests/nodes/matmul_fp16x16_1x2/output_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_1x2/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 262144, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_2x1.cairo b/src/tests/nodes/matmul_fp16x16_2x1.cairo index 4994ca7f2..c1c383260 100644 --- a/src/tests/nodes/matmul_fp16x16_2x1.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x1.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp16x16_2x1/input_0.cairo b/src/tests/nodes/matmul_fp16x16_2x1/input_0.cairo index 5d9d87819..7d22f7d54 100644 --- a/src/tests/nodes/matmul_fp16x16_2x1/input_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x1/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_2x1/input_1.cairo b/src/tests/nodes/matmul_fp16x16_2x1/input_1.cairo index dd6f8c702..d75464bd3 100644 --- a/src/tests/nodes/matmul_fp16x16_2x1/input_1.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x1/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_2x1/output_0.cairo b/src/tests/nodes/matmul_fp16x16_2x1/output_0.cairo index 04e8e1097..426f51bc1 100644 --- a/src/tests/nodes/matmul_fp16x16_2x1/output_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x1/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 262144, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_2x2.cairo b/src/tests/nodes/matmul_fp16x16_2x2.cairo index e0ce71bac..2d4985e5a 100644 --- a/src/tests/nodes/matmul_fp16x16_2x2.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp16x16_2x2/input_0.cairo b/src/tests/nodes/matmul_fp16x16_2x2/input_0.cairo index 26dd5c35c..c6205f8dd 100644 --- a/src/tests/nodes/matmul_fp16x16_2x2/input_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x2/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_2x2/input_1.cairo b/src/tests/nodes/matmul_fp16x16_2x2/input_1.cairo index 502f4112c..02910be0e 100644 --- a/src/tests/nodes/matmul_fp16x16_2x2/input_1.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x2/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + 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()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp16x16_2x2/output_0.cairo b/src/tests/nodes/matmul_fp16x16_2x2/output_0.cairo index b676f46fe..c72087538 100644 --- a/src/tests/nodes/matmul_fp16x16_2x2/output_0.cairo +++ b/src/tests/nodes/matmul_fp16x16_2x2/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 655360, sign: true }); - data.append(FixedType { mag: 720896, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_1d.cairo b/src/tests/nodes/matmul_fp8x23_1d.cairo index 753cdecb0..ba112de69 100644 --- a/src/tests/nodes/matmul_fp8x23_1d.cairo +++ b/src/tests/nodes/matmul_fp8x23_1d.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp8x23_1d/input_0.cairo b/src/tests/nodes/matmul_fp8x23_1d/input_0.cairo index fcf013b64..3f614c0af 100644 --- a/src/tests/nodes/matmul_fp8x23_1d/input_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_1d/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_1d/input_1.cairo b/src/tests/nodes/matmul_fp8x23_1d/input_1.cairo index 9feb2dec7..15375e10e 100644 --- a/src/tests/nodes/matmul_fp8x23_1d/input_1.cairo +++ b/src/tests/nodes/matmul_fp8x23_1d/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_1d/output_0.cairo b/src/tests/nodes/matmul_fp8x23_1d/output_0.cairo index ba8ee2c51..e5f232990 100644 --- a/src/tests/nodes/matmul_fp8x23_1d/output_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_1d/output_0.cairo @@ -1,15 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 100663296, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_1x2.cairo b/src/tests/nodes/matmul_fp8x23_1x2.cairo index 65bf89655..c2ff4a6b1 100644 --- a/src/tests/nodes/matmul_fp8x23_1x2.cairo +++ b/src/tests/nodes/matmul_fp8x23_1x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp8x23_1x2/input_0.cairo b/src/tests/nodes/matmul_fp8x23_1x2/input_0.cairo index 1ddf2e8dc..d971c4d64 100644 --- a/src/tests/nodes/matmul_fp8x23_1x2/input_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_1x2/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_1x2/input_1.cairo b/src/tests/nodes/matmul_fp8x23_1x2/input_1.cairo index 870873113..650ca9d78 100644 --- a/src/tests/nodes/matmul_fp8x23_1x2/input_1.cairo +++ b/src/tests/nodes/matmul_fp8x23_1x2/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_1x2/output_0.cairo b/src/tests/nodes/matmul_fp8x23_1x2/output_0.cairo index 07d2e5f47..b9c97f2fe 100644 --- a/src/tests/nodes/matmul_fp8x23_1x2/output_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_1x2/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 75497472, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 75497472, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_2x1.cairo b/src/tests/nodes/matmul_fp8x23_2x1.cairo index a12395014..1d675ede9 100644 --- a/src/tests/nodes/matmul_fp8x23_2x1.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x1.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp8x23_2x1/input_0.cairo b/src/tests/nodes/matmul_fp8x23_2x1/input_0.cairo index 7bcb26a3f..d7410502c 100644 --- a/src/tests/nodes/matmul_fp8x23_2x1/input_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x1/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_2x1/input_1.cairo b/src/tests/nodes/matmul_fp8x23_2x1/input_1.cairo index 3bdb9ad45..cc394e291 100644 --- a/src/tests/nodes/matmul_fp8x23_2x1/input_1.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x1/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_2x1/output_0.cairo b/src/tests/nodes/matmul_fp8x23_2x1/output_0.cairo index 45863c5a2..ced97c1f4 100644 --- a/src/tests/nodes/matmul_fp8x23_2x1/output_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x1/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_2x2.cairo b/src/tests/nodes/matmul_fp8x23_2x2.cairo index 6fb8f65e0..d990a05e5 100644 --- a/src/tests/nodes/matmul_fp8x23_2x2.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_fp8x23_2x2/input_0.cairo b/src/tests/nodes/matmul_fp8x23_2x2/input_0.cairo index 832c6d938..fa1873060 100644 --- a/src/tests/nodes/matmul_fp8x23_2x2/input_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x2/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_2x2/input_1.cairo b/src/tests/nodes/matmul_fp8x23_2x2/input_1.cairo index 6004c63d1..d9c90cdad 100644 --- a/src/tests/nodes/matmul_fp8x23_2x2/input_1.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x2/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_fp8x23_2x2/output_0.cairo b/src/tests/nodes/matmul_fp8x23_2x2/output_0.cairo index 8739dfe66..b7896ce63 100644 --- a/src/tests/nodes/matmul_fp8x23_2x2/output_0.cairo +++ b/src/tests/nodes/matmul_fp8x23_2x2/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 50331648, sign: true }); - data.append(FixedType { mag: 67108864, sign: true }); - data.append(FixedType { mag: 50331648, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_1d.cairo b/src/tests/nodes/matmul_i32_1d.cairo index a0814d281..954e022b4 100644 --- a/src/tests/nodes/matmul_i32_1d.cairo +++ b/src/tests/nodes/matmul_i32_1d.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i32_1d/input_0.cairo b/src/tests/nodes/matmul_i32_1d/input_0.cairo index c33357708..550f589d1 100644 --- a/src/tests/nodes/matmul_i32_1d/input_0.cairo +++ b/src/tests/nodes/matmul_i32_1d/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 124, sign: false }); - data.append(i32 { mag: 61, sign: true }); - data.append(i32 { mag: 113, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 49, sign: true }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 37, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_1d/input_1.cairo b/src/tests/nodes/matmul_i32_1d/input_1.cairo index 0cb3f4628..29dbdaed4 100644 --- a/src/tests/nodes/matmul_i32_1d/input_1.cairo +++ b/src/tests/nodes/matmul_i32_1d/input_1.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 122, sign: true }); - data.append(i32 { mag: 81, sign: true }); - data.append(i32 { mag: 97, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 103, sign: true }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 59, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_1d/output_0.cairo b/src/tests/nodes/matmul_i32_1d/output_0.cairo index 3a63a6baa..def32662a 100644 --- a/src/tests/nodes/matmul_i32_1d/output_0.cairo +++ b/src/tests/nodes/matmul_i32_1d/output_0.cairo @@ -1,16 +1,13 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 774, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 681, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_1x2.cairo b/src/tests/nodes/matmul_i32_1x2.cairo index b05eb0166..4be4880f0 100644 --- a/src/tests/nodes/matmul_i32_1x2.cairo +++ b/src/tests/nodes/matmul_i32_1x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i32_1x2/input_0.cairo b/src/tests/nodes/matmul_i32_1x2/input_0.cairo index deda9f2a3..a734c416d 100644 --- a/src/tests/nodes/matmul_i32_1x2/input_0.cairo +++ b/src/tests/nodes/matmul_i32_1x2/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 113, sign: false }); - data.append(i32 { mag: 116, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 36, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_1x2/input_1.cairo b/src/tests/nodes/matmul_i32_1x2/input_1.cairo index 6e6213f05..65bc44676 100644 --- a/src/tests/nodes/matmul_i32_1x2/input_1.cairo +++ b/src/tests/nodes/matmul_i32_1x2/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 81, sign: true }); - data.append(i32 { mag: 49, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 84, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_1x2/output_0.cairo b/src/tests/nodes/matmul_i32_1x2/output_0.cairo index bc1aaff9a..37731af6b 100644 --- a/src/tests/nodes/matmul_i32_1x2/output_0.cairo +++ b/src/tests/nodes/matmul_i32_1x2/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 14837, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1524, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_2x1.cairo b/src/tests/nodes/matmul_i32_2x1.cairo index 48f898f26..acc587c1c 100644 --- a/src/tests/nodes/matmul_i32_2x1.cairo +++ b/src/tests/nodes/matmul_i32_2x1.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i32_2x1/input_0.cairo b/src/tests/nodes/matmul_i32_2x1/input_0.cairo index 151ee76bc..3b07896d4 100644 --- a/src/tests/nodes/matmul_i32_2x1/input_0.cairo +++ b/src/tests/nodes/matmul_i32_2x1/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 126, sign: true }); - data.append(i32 { mag: 29, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 37, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_2x1/input_1.cairo b/src/tests/nodes/matmul_i32_2x1/input_1.cairo index 622c06b09..bc5c5431e 100644 --- a/src/tests/nodes/matmul_i32_2x1/input_1.cairo +++ b/src/tests/nodes/matmul_i32_2x1/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 18, sign: true }); - data.append(i32 { mag: 22, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 113, sign: true }); + data.append(i32 { mag: 106, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_2x1/output_0.cairo b/src/tests/nodes/matmul_i32_2x1/output_0.cairo index 10e4179c9..f932c0e37 100644 --- a/src/tests/nodes/matmul_i32_2x1/output_0.cairo +++ b/src/tests/nodes/matmul_i32_2x1/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2268, sign: false }); - data.append(i32 { mag: 2772, sign: true }); - data.append(i32 { mag: 522, sign: true }); - data.append(i32 { mag: 638, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 5876, sign: true }); + data.append(i32 { mag: 5512, sign: false }); + data.append(i32 { mag: 4181, sign: true }); + data.append(i32 { mag: 3922, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_2x2.cairo b/src/tests/nodes/matmul_i32_2x2.cairo index f9ab7ebbb..19aa4c19b 100644 --- a/src/tests/nodes/matmul_i32_2x2.cairo +++ b/src/tests/nodes/matmul_i32_2x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i32_2x2/input_0.cairo b/src/tests/nodes/matmul_i32_2x2/input_0.cairo index 4bebd06ab..3159fa0d6 100644 --- a/src/tests/nodes/matmul_i32_2x2/input_0.cairo +++ b/src/tests/nodes/matmul_i32_2x2/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 49, sign: false }); - data.append(i32 { mag: 73, sign: true }); - data.append(i32 { mag: 44, sign: false }); - data.append(i32 { mag: 8, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 72, sign: true }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 56, sign: true }); + data.append(i32 { mag: 53, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_2x2/input_1.cairo b/src/tests/nodes/matmul_i32_2x2/input_1.cairo index 93b628f81..133eb9025 100644 --- a/src/tests/nodes/matmul_i32_2x2/input_1.cairo +++ b/src/tests/nodes/matmul_i32_2x2/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 9, sign: true }); - data.append(i32 { mag: 79, sign: false }); - data.append(i32 { mag: 105, sign: false }); - data.append(i32 { mag: 15, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 120, sign: true }); + data.append(i32 { mag: 22, sign: true }); + data.append(i32 { mag: 71, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i32_2x2/output_0.cairo b/src/tests/nodes/matmul_i32_2x2/output_0.cairo index 73b413e94..03ebfea85 100644 --- a/src/tests/nodes/matmul_i32_2x2/output_0.cairo +++ b/src/tests/nodes/matmul_i32_2x2/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 8106, sign: true }); - data.append(i32 { mag: 2776, sign: false }); - data.append(i32 { mag: 1236, sign: true }); - data.append(i32 { mag: 3356, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 5136, sign: true }); + data.append(i32 { mag: 15456, sign: false }); + data.append(i32 { mag: 3518, sign: true }); + data.append(i32 { mag: 10483, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_1d.cairo b/src/tests/nodes/matmul_i8_1d.cairo index 52176427f..1ff75eba2 100644 --- a/src/tests/nodes/matmul_i8_1d.cairo +++ b/src/tests/nodes/matmul_i8_1d.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i8_1d/input_0.cairo b/src/tests/nodes/matmul_i8_1d/input_0.cairo index d2976de83..9a84e6554 100644 --- a/src/tests/nodes/matmul_i8_1d/input_0.cairo +++ b/src/tests/nodes/matmul_i8_1d/input_0.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 4, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_1d/input_1.cairo b/src/tests/nodes/matmul_i8_1d/input_1.cairo index fd5a52ab1..4a8d022fd 100644 --- a/src/tests/nodes/matmul_i8_1d/input_1.cairo +++ b/src/tests/nodes/matmul_i8_1d/input_1.cairo @@ -1,18 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_1d/output_0.cairo b/src/tests/nodes/matmul_i8_1d/output_0.cairo index f88bc63b3..4f87aadd1 100644 --- a/src/tests/nodes/matmul_i8_1d/output_0.cairo +++ b/src/tests/nodes/matmul_i8_1d/output_0.cairo @@ -1,16 +1,13 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 9, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 14, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_1x2.cairo b/src/tests/nodes/matmul_i8_1x2.cairo index f74a4968a..644709321 100644 --- a/src/tests/nodes/matmul_i8_1x2.cairo +++ b/src/tests/nodes/matmul_i8_1x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i8_1x2/input_0.cairo b/src/tests/nodes/matmul_i8_1x2/input_0.cairo index 87c4a62e2..c31d9d71c 100644 --- a/src/tests/nodes/matmul_i8_1x2/input_0.cairo +++ b/src/tests/nodes/matmul_i8_1x2/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,9 +9,7 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_1x2/input_1.cairo b/src/tests/nodes/matmul_i8_1x2/input_1.cairo index c8929aafc..5a58f617e 100644 --- a/src/tests/nodes/matmul_i8_1x2/input_1.cairo +++ b/src/tests/nodes/matmul_i8_1x2/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,8 +10,6 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_1x2/output_0.cairo b/src/tests/nodes/matmul_i8_1x2/output_0.cairo index 2a8696efc..93c06ad93 100644 --- a/src/tests/nodes/matmul_i8_1x2/output_0.cairo +++ b/src/tests/nodes/matmul_i8_1x2/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,8 +9,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 8, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_2x1.cairo b/src/tests/nodes/matmul_i8_2x1.cairo index 2cd344cfb..9bc6aa743 100644 --- a/src/tests/nodes/matmul_i8_2x1.cairo +++ b/src/tests/nodes/matmul_i8_2x1.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i8_2x1/input_0.cairo b/src/tests/nodes/matmul_i8_2x1/input_0.cairo index 5c1e58633..909aa526b 100644 --- a/src/tests/nodes/matmul_i8_2x1/input_0.cairo +++ b/src/tests/nodes/matmul_i8_2x1/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,9 +9,7 @@ fn input_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_2x1/input_1.cairo b/src/tests/nodes/matmul_i8_2x1/input_1.cairo index ba66f2b91..669f471e6 100644 --- a/src/tests/nodes/matmul_i8_2x1/input_1.cairo +++ b/src/tests/nodes/matmul_i8_2x1/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,8 +10,6 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_2x1/output_0.cairo b/src/tests/nodes/matmul_i8_2x1/output_0.cairo index 07196122e..efb300e6a 100644 --- a/src/tests/nodes/matmul_i8_2x1/output_0.cairo +++ b/src/tests/nodes/matmul_i8_2x1/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 9, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_2x2.cairo b/src/tests/nodes/matmul_i8_2x2.cairo index d20570a40..5b2a18259 100644 --- a/src/tests/nodes/matmul_i8_2x2.cairo +++ b/src/tests/nodes/matmul_i8_2x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_i8_2x2/input_0.cairo b/src/tests/nodes/matmul_i8_2x2/input_0.cairo index 2d19e5799..84f324f02 100644 --- a/src/tests/nodes/matmul_i8_2x2/input_0.cairo +++ b/src/tests/nodes/matmul_i8_2x2/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 4, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_2x2/input_1.cairo b/src/tests/nodes/matmul_i8_2x2/input_1.cairo index 23c0601f7..6282b84be 100644 --- a/src/tests/nodes/matmul_i8_2x2/input_1.cairo +++ b/src/tests/nodes/matmul_i8_2x2/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_i8_2x2/output_0.cairo b/src/tests/nodes/matmul_i8_2x2/output_0.cairo index f1421131f..761ce0efe 100644 --- a/src/tests/nodes/matmul_i8_2x2/output_0.cairo +++ b/src/tests/nodes/matmul_i8_2x2/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 12, sign: false }); - data.append(i8 { mag: 18, sign: false }); - data.append(i8 { mag: 14, sign: true }); - data.append(i8 { mag: 20, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 9, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_1d.cairo b/src/tests/nodes/matmul_u32_1d.cairo index e262be4cb..4da598379 100644 --- a/src/tests/nodes/matmul_u32_1d.cairo +++ b/src/tests/nodes/matmul_u32_1d.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_u32_1d/input_0.cairo b/src/tests/nodes/matmul_u32_1d/input_0.cairo index 8e583d92d..603829563 100644 --- a/src/tests/nodes/matmul_u32_1d/input_0.cairo +++ b/src/tests/nodes/matmul_u32_1d/input_0.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(78); - data.append(41); - data.append(143); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(160); + data.append(50); + data.append(195); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_1d/input_1.cairo b/src/tests/nodes/matmul_u32_1d/input_1.cairo index aa105f224..001202e79 100644 --- a/src/tests/nodes/matmul_u32_1d/input_1.cairo +++ b/src/tests/nodes/matmul_u32_1d/input_1.cairo @@ -1,17 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +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); let mut data = ArrayTrait::new(); - data.append(177); - data.append(153); - data.append(86); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(15); + data.append(90); + data.append(53); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_1d/output_0.cairo b/src/tests/nodes/matmul_u32_1d/output_0.cairo index 1e15d9284..c835ea3ec 100644 --- a/src/tests/nodes/matmul_u32_1d/output_0.cairo +++ b/src/tests/nodes/matmul_u32_1d/output_0.cairo @@ -1,15 +1,12 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(32377); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(17235); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_1x2.cairo b/src/tests/nodes/matmul_u32_1x2.cairo index b82531f3c..7dd094095 100644 --- a/src/tests/nodes/matmul_u32_1x2.cairo +++ b/src/tests/nodes/matmul_u32_1x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_u32_1x2/input_0.cairo b/src/tests/nodes/matmul_u32_1x2/input_0.cairo index 3dfa9a50b..ddc6791d4 100644 --- a/src/tests/nodes/matmul_u32_1x2/input_0.cairo +++ b/src/tests/nodes/matmul_u32_1x2/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(8); - data.append(229); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(38); + data.append(186); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_1x2/input_1.cairo b/src/tests/nodes/matmul_u32_1x2/input_1.cairo index b032d165d..ddff242e0 100644 --- a/src/tests/nodes/matmul_u32_1x2/input_1.cairo +++ b/src/tests/nodes/matmul_u32_1x2/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(230); - data.append(197); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(192); + data.append(48); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_1x2/output_0.cairo b/src/tests/nodes/matmul_u32_1x2/output_0.cairo index 2cd0c210f..fae32e724 100644 --- a/src/tests/nodes/matmul_u32_1x2/output_0.cairo +++ b/src/tests/nodes/matmul_u32_1x2/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,8 +8,6 @@ fn output_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(46953); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(16224); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_2x1.cairo b/src/tests/nodes/matmul_u32_2x1.cairo index b5a35f8cd..b2d62cf9e 100644 --- a/src/tests/nodes/matmul_u32_2x1.cairo +++ b/src/tests/nodes/matmul_u32_2x1.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_u32_2x1/input_0.cairo b/src/tests/nodes/matmul_u32_2x1/input_0.cairo index 88e52d3db..27ee8eff4 100644 --- a/src/tests/nodes/matmul_u32_2x1/input_0.cairo +++ b/src/tests/nodes/matmul_u32_2x1/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_0() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(238); - data.append(25); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(36); + data.append(127); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_2x1/input_1.cairo b/src/tests/nodes/matmul_u32_2x1/input_1.cairo index 36d4266ef..596735161 100644 --- a/src/tests/nodes/matmul_u32_2x1/input_1.cairo +++ b/src/tests/nodes/matmul_u32_2x1/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(50); - data.append(113); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(184); + data.append(114); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_2x1/output_0.cairo b/src/tests/nodes/matmul_u32_2x1/output_0.cairo index 132c7302e..d560be99c 100644 --- a/src/tests/nodes/matmul_u32_2x1/output_0.cairo +++ b/src/tests/nodes/matmul_u32_2x1/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(11900); - data.append(26894); - data.append(1250); - data.append(2825); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(6624); + data.append(4104); + data.append(23368); + data.append(14478); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_2x2.cairo b/src/tests/nodes/matmul_u32_2x2.cairo index 0da9b68b4..7844925c9 100644 --- a/src/tests/nodes/matmul_u32_2x2.cairo +++ b/src/tests/nodes/matmul_u32_2x2.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/matmul_u32_2x2/input_0.cairo b/src/tests/nodes/matmul_u32_2x2/input_0.cairo index e554dc216..c111fcee5 100644 --- a/src/tests/nodes/matmul_u32_2x2/input_0.cairo +++ b/src/tests/nodes/matmul_u32_2x2/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(244); - data.append(99); - data.append(109); - data.append(162); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(66); + data.append(225); + data.append(132); + data.append(40); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_2x2/input_1.cairo b/src/tests/nodes/matmul_u32_2x2/input_1.cairo index ed84d879d..e5f03537d 100644 --- a/src/tests/nodes/matmul_u32_2x2/input_1.cairo +++ b/src/tests/nodes/matmul_u32_2x2/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(151); - data.append(68); - data.append(121); - data.append(170); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(153); + data.append(79); + data.append(80); + data.append(131); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/matmul_u32_2x2/output_0.cairo b/src/tests/nodes/matmul_u32_2x2/output_0.cairo index b65775d86..22387ec0e 100644 --- a/src/tests/nodes/matmul_u32_2x2/output_0.cairo +++ b/src/tests/nodes/matmul_u32_2x2/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(48823); - data.append(33422); - data.append(36061); - data.append(34952); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(28098); + data.append(34689); + data.append(23396); + data.append(15668); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp16x16.cairo b/src/tests/nodes/mul_fp16x16.cairo index 6a00e793e..e26469d88 100644 --- a/src/tests/nodes/mul_fp16x16.cairo +++ b/src/tests/nodes/mul_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorMul}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorMul}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_fp16x16/input_0.cairo b/src/tests/nodes/mul_fp16x16/input_0.cairo index b36222a3e..29b710982 100644 --- a/src/tests/nodes/mul_fp16x16/input_0.cairo +++ b/src/tests/nodes/mul_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 131072, 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: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + 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: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, 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: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp16x16/input_1.cairo b/src/tests/nodes/mul_fp16x16/input_1.cairo index 7d42a55c5..3acdc42ef 100644 --- a/src/tests/nodes/mul_fp16x16/input_1.cairo +++ b/src/tests/nodes/mul_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, 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 }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 65536, sign: true }); + 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: 131072, 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()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp16x16/output_0.cairo b/src/tests/nodes/mul_fp16x16/output_0.cairo index ca21b1a0c..2ec6ffe99 100644 --- a/src/tests/nodes/mul_fp16x16/output_0.cairo +++ b/src/tests/nodes/mul_fp16x16/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp16x16_broadcast.cairo b/src/tests/nodes/mul_fp16x16_broadcast.cairo index addeb33b2..d9f38748a 100644 --- a/src/tests/nodes/mul_fp16x16_broadcast.cairo +++ b/src/tests/nodes/mul_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorMul}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorMul}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/mul_fp16x16_broadcast/input_0.cairo index 7cb5681a9..93dbbd041 100644 --- a/src/tests/nodes/mul_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/mul_fp16x16_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, 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: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + 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: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/mul_fp16x16_broadcast/input_1.cairo index 74b2db63c..5b763c577 100644 --- a/src/tests/nodes/mul_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/mul_fp16x16_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/mul_fp16x16_broadcast/output_0.cairo index 8ac7788c5..b9342b356 100644 --- a/src/tests/nodes/mul_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/mul_fp16x16_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 393216, sign: false }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 589824, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 589824, sign: false }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 393216, sign: true }); - data.append(FixedType { mag: 393216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, 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: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp8x23.cairo b/src/tests/nodes/mul_fp8x23.cairo index c42b8f379..6ecda8831 100644 --- a/src/tests/nodes/mul_fp8x23.cairo +++ b/src/tests/nodes/mul_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorMul}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorMul}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_fp8x23/input_0.cairo b/src/tests/nodes/mul_fp8x23/input_0.cairo index 7685b56ed..d16f9ae2e 100644 --- a/src/tests/nodes/mul_fp8x23/input_0.cairo +++ b/src/tests/nodes/mul_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, 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: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp8x23/input_1.cairo b/src/tests/nodes/mul_fp8x23/input_1.cairo index 8fb4e887b..71a2d5dc8 100644 --- a/src/tests/nodes/mul_fp8x23/input_1.cairo +++ b/src/tests/nodes/mul_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, 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: 25165824, 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + 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: 16777216, sign: false }); + 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 }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp8x23/output_0.cairo b/src/tests/nodes/mul_fp8x23/output_0.cairo index 5205ec13a..ef187d640 100644 --- a/src/tests/nodes/mul_fp8x23/output_0.cairo +++ b/src/tests/nodes/mul_fp8x23/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 50331648, sign: true }); - data.append(FixedType { mag: 50331648, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 75497472, sign: false }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 75497472, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 50331648, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 50331648, 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: 0, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + 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: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp8x23_broadcast.cairo b/src/tests/nodes/mul_fp8x23_broadcast.cairo index 41587f986..3563976f8 100644 --- a/src/tests/nodes/mul_fp8x23_broadcast.cairo +++ b/src/tests/nodes/mul_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorMul}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorMul}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/mul_fp8x23_broadcast/input_0.cairo index 825c9b053..dfeaae98c 100644 --- a/src/tests/nodes/mul_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/mul_fp8x23_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/mul_fp8x23_broadcast/input_1.cairo index 6242b4fe0..4036513c3 100644 --- a/src/tests/nodes/mul_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/mul_fp8x23_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/mul_fp8x23_broadcast/output_0.cairo index 50ef7dfb4..4fa551de1 100644 --- a/src/tests/nodes/mul_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/mul_fp8x23_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 50331648, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 50331648, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 75497472, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i32.cairo b/src/tests/nodes/mul_i32.cairo index 4725c4837..828c656bf 100644 --- a/src/tests/nodes/mul_i32.cairo +++ b/src/tests/nodes/mul_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorMul}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorMul}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_i32/input_0.cairo b/src/tests/nodes/mul_i32/input_0.cairo index 4d7a458de..d82e4567f 100644 --- a/src/tests/nodes/mul_i32/input_0.cairo +++ b/src/tests/nodes/mul_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, 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: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: false }); + 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: 3, sign: true }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 3, sign: true }); - 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: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i32/input_1.cairo b/src/tests/nodes/mul_i32/input_1.cairo index 37052f8da..97b3e3793 100644 --- a/src/tests/nodes/mul_i32/input_1.cairo +++ b/src/tests/nodes/mul_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + 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: true }); data.append(i32 { mag: 1, 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: 0, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 3, sign: true }); 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: 1, sign: true }); - 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: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - 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: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i32/output_0.cairo b/src/tests/nodes/mul_i32/output_0.cairo index c26a2c627..a04e7dcce 100644 --- a/src/tests/nodes/mul_i32/output_0.cairo +++ b/src/tests/nodes/mul_i32/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 3, sign: false }); data.append(i32 { mag: 6, sign: true }); - 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: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: false }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 6, sign: false }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 6, sign: false }); - data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 6, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 6, sign: true }); data.append(i32 { mag: 6, sign: false }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i32_broadcast.cairo b/src/tests/nodes/mul_i32_broadcast.cairo index 8c011b7cb..35117cdaa 100644 --- a/src/tests/nodes/mul_i32_broadcast.cairo +++ b/src/tests/nodes/mul_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorMul}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorMul}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_i32_broadcast/input_0.cairo b/src/tests/nodes/mul_i32_broadcast/input_0.cairo index a10b011c9..1cce6509d 100644 --- a/src/tests/nodes/mul_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/mul_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,33 +11,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - 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: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - 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: 2, sign: false }); + 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: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); + 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: 2, sign: true }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, 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: 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: 3, sign: true }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i32_broadcast/input_1.cairo b/src/tests/nodes/mul_i32_broadcast/input_1.cairo index 23ed99e18..e7738c230 100644 --- a/src/tests/nodes/mul_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/mul_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i32_broadcast/output_0.cairo b/src/tests/nodes/mul_i32_broadcast/output_0.cairo index ca41f4940..7138bb7db 100644 --- a/src/tests/nodes/mul_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/mul_i32_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 4, sign: true }); + 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: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 6, 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: 0, sign: false }); - data.append(i32 { mag: 4, sign: true }); - data.append(i32 { mag: 6, sign: false }); - data.append(i32 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 6, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i8.cairo b/src/tests/nodes/mul_i8.cairo index d49cbf7a8..fcb1a7ffc 100644 --- a/src/tests/nodes/mul_i8.cairo +++ b/src/tests/nodes/mul_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorMul}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorMul}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_i8/input_0.cairo b/src/tests/nodes/mul_i8/input_0.cairo index 624893eff..a1f2950b1 100644 --- a/src/tests/nodes/mul_i8/input_0.cairo +++ b/src/tests/nodes/mul_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); 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: 0, 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: 2, 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: 3, sign: true }); 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: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); 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: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i8/input_1.cairo b/src/tests/nodes/mul_i8/input_1.cairo index b9bfc092a..a4e345464 100644 --- a/src/tests/nodes/mul_i8/input_1.cairo +++ b/src/tests/nodes/mul_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -12,33 +11,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); 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: 1, sign: false }); - 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: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - 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: 2, sign: true }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, 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: 3, 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: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); 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: 1, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i8/output_0.cairo b/src/tests/nodes/mul_i8/output_0.cairo index 6868e9c3b..1149304bd 100644 --- a/src/tests/nodes/mul_i8/output_0.cairo +++ b/src/tests/nodes/mul_i8/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 9, sign: false }); data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 6, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 6, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 9, sign: false }); data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 6, sign: true }); data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 6, sign: true }); data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 6, sign: true }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 6, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i8_broadcast.cairo b/src/tests/nodes/mul_i8_broadcast.cairo index 7d8f13394..e5ef399f7 100644 --- a/src/tests/nodes/mul_i8_broadcast.cairo +++ b/src/tests/nodes/mul_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorMul}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorMul}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_i8_broadcast/input_0.cairo b/src/tests/nodes/mul_i8_broadcast/input_0.cairo index 3907cbc35..17e506970 100644 --- a/src/tests/nodes/mul_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/mul_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + 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: 2, sign: false }); data.append(i8 { mag: 2, sign: true }); - 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: 3, sign: true }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); - 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: 1, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); 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: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - 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: 2, 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: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, 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: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i8_broadcast/input_1.cairo b/src/tests/nodes/mul_i8_broadcast/input_1.cairo index bcbf31651..b74cceb18 100644 --- a/src/tests/nodes/mul_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/mul_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_i8_broadcast/output_0.cairo b/src/tests/nodes/mul_i8_broadcast/output_0.cairo index 9c40824b5..e37f31db4 100644 --- a/src/tests/nodes/mul_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/mul_i8_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, 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: 6, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + 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: false }); - data.append(i8 { mag: 1, sign: true }); - 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: 4, sign: false }); - data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + 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: 4, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - 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: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_u32.cairo b/src/tests/nodes/mul_u32.cairo index 723491103..49e04c6f8 100644 --- a/src/tests/nodes/mul_u32.cairo +++ b/src/tests/nodes/mul_u32.cairo @@ -1,12 +1,12 @@ -mod input_0; -mod input_1; -mod output_0; +mod input_0; +mod input_1; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorMul}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorMul}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_mul_u32() { let y = input_0 * input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/mul_u32/input_0.cairo b/src/tests/nodes/mul_u32/input_0.cairo index fea1387c7..096393361 100644 --- a/src/tests/nodes/mul_u32/input_0.cairo +++ b/src/tests/nodes/mul_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(3); data.append(5); data.append(4); data.append(3); - data.append(5); - data.append(3); data.append(4); data.append(4); data.append(5); - data.append(5); - data.append(3); - data.append(5); - data.append(3); - data.append(5); + data.append(4); data.append(4); data.append(4); data.append(4); data.append(4); data.append(5); + data.append(4); data.append(5); + data.append(4); + data.append(4); + data.append(3); + data.append(4); data.append(5); - data.append(5); + data.append(4); + data.append(3); + data.append(3); data.append(3); data.append(3); - data.append(4); data.append(3); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_u32/input_1.cairo b/src/tests/nodes/mul_u32/input_1.cairo index 1ddde9769..96ec7e32c 100644 --- a/src/tests/nodes/mul_u32/input_1.cairo +++ b/src/tests/nodes/mul_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(1); + data.append(0); data.append(0); data.append(1); data.append(1); - data.append(0); + data.append(1); data.append(1); data.append(2); + data.append(1); data.append(2); data.append(0); - data.append(1); - data.append(1); + data.append(2); data.append(0); data.append(0); - data.append(2); data.append(0); - data.append(1); + data.append(2); data.append(1); data.append(0); - data.append(1); - data.append(2); data.append(0); data.append(1); - data.append(1); - data.append(2); data.append(2); data.append(2); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(0); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_u32/output_0.cairo b/src/tests/nodes/mul_u32/output_0.cairo index a24c0af21..f7dda0e5c 100644 --- a/src/tests/nodes/mul_u32/output_0.cairo +++ b/src/tests/nodes/mul_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); data.append(5); - data.append(4); data.append(0); + data.append(0); + data.append(4); + data.append(4); data.append(5); - data.append(6); + data.append(4); + data.append(8); + data.append(4); data.append(8); data.append(0); - data.append(5); - data.append(5); + data.append(10); data.append(0); data.append(0); - data.append(6); data.append(0); - data.append(4); - data.append(4); + data.append(8); + data.append(3); data.append(0); - data.append(4); - data.append(10); data.append(0); - data.append(5); - data.append(5); + data.append(4); data.append(6); data.append(6); - data.append(8); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + data.append(0); + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_u32_broadcast.cairo b/src/tests/nodes/mul_u32_broadcast.cairo index a954a8cbd..6dc5876ef 100644 --- a/src/tests/nodes/mul_u32_broadcast.cairo +++ b/src/tests/nodes/mul_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorMul}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorMul}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/mul_u32_broadcast/input_0.cairo b/src/tests/nodes/mul_u32_broadcast/input_0.cairo index 053d4b648..9adb47531 100644 --- a/src/tests/nodes/mul_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/mul_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(5); - data.append(5); - data.append(4); - data.append(5); data.append(3); data.append(4); data.append(3); - data.append(4); data.append(5); - data.append(3); data.append(5); data.append(3); + data.append(3); data.append(5); - data.append(5); + data.append(4); data.append(3); data.append(5); + data.append(4); data.append(5); + data.append(4); data.append(5); + data.append(3); data.append(5); data.append(3); data.append(4); - data.append(3); - data.append(3); + data.append(4); + data.append(5); + data.append(4); + data.append(5); data.append(3); data.append(3); data.append(4); - data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_u32_broadcast/input_1.cairo b/src/tests/nodes/mul_u32_broadcast/input_1.cairo index 81fe30cbc..79e305aa6 100644 --- a/src/tests/nodes/mul_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/mul_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(2); + data.append(1); data.append(0); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/mul_u32_broadcast/output_0.cairo b/src/tests/nodes/mul_u32_broadcast/output_0.cairo index 927e39b2a..18abad1e2 100644 --- a/src/tests/nodes/mul_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/mul_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(10); - data.append(10); - data.append(8); + data.append(3); + data.append(4); + data.append(3); data.append(0); data.append(0); data.append(0); - data.append(6); - data.append(8); - data.append(10); - data.append(6); - data.append(10); - data.append(6); + data.append(3); + data.append(5); + data.append(4); + data.append(3); + data.append(5); + data.append(4); data.append(0); data.append(0); data.append(0); - data.append(10); - data.append(10); - data.append(10); - data.append(10); - data.append(6); - data.append(8); + data.append(3); + data.append(5); + data.append(3); + data.append(4); + data.append(4); + data.append(5); data.append(0); data.append(0); data.append(0); - data.append(6); - data.append(8); - data.append(6); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + data.append(4); + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp16x16.cairo b/src/tests/nodes/or_fp16x16.cairo index b95871d41..1ef45573f 100644 --- a/src/tests/nodes/or_fp16x16.cairo +++ b/src/tests/nodes/or_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_fp16x16/input_0.cairo b/src/tests/nodes/or_fp16x16/input_0.cairo index 245ee929d..82efc46fe 100644 --- a/src/tests/nodes/or_fp16x16/input_0.cairo +++ b/src/tests/nodes/or_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 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: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp16x16/input_1.cairo b/src/tests/nodes/or_fp16x16/input_1.cairo index 611ec154c..5306fa505 100644 --- a/src/tests/nodes/or_fp16x16/input_1.cairo +++ b/src/tests/nodes/or_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp16x16/output_0.cairo b/src/tests/nodes/or_fp16x16/output_0.cairo index faae29d47..9488b9f2c 100644 --- a/src/tests/nodes/or_fp16x16/output_0.cairo +++ b/src/tests/nodes/or_fp16x16/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,6 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(0); data.append(1); data.append(1); data.append(1); @@ -34,10 +32,9 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); + data.append(0); data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp16x16_broadcast.cairo b/src/tests/nodes/or_fp16x16_broadcast.cairo index 5604715d2..5b4a8fa08 100644 --- a/src/tests/nodes/or_fp16x16_broadcast.cairo +++ b/src/tests/nodes/or_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/or_fp16x16_broadcast/input_0.cairo index fcab63090..d01c26c92 100644 --- a/src/tests/nodes/or_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/or_fp16x16_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/or_fp16x16_broadcast/input_1.cairo index 86361976b..de7a027d1 100644 --- a/src/tests/nodes/or_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/or_fp16x16_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/or_fp16x16_broadcast/output_0.cairo index 04e17d1f2..e7b1da4b1 100644 --- a/src/tests/nodes/or_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/or_fp16x16_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp8x23.cairo b/src/tests/nodes/or_fp8x23.cairo index 30e818fa6..72c52ab7c 100644 --- a/src/tests/nodes/or_fp8x23.cairo +++ b/src/tests/nodes/or_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_fp8x23/input_0.cairo b/src/tests/nodes/or_fp8x23/input_0.cairo index 52f0272bb..62574451b 100644 --- a/src/tests/nodes/or_fp8x23/input_0.cairo +++ b/src/tests/nodes/or_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, 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: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp8x23/input_1.cairo b/src/tests/nodes/or_fp8x23/input_1.cairo index 67e75955f..d19cd31ed 100644 --- a/src/tests/nodes/or_fp8x23/input_1.cairo +++ b/src/tests/nodes/or_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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 }); + 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: 0, 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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + 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: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp8x23/output_0.cairo b/src/tests/nodes/or_fp8x23/output_0.cairo index 581fcc840..b7502f775 100644 --- a/src/tests/nodes/or_fp8x23/output_0.cairo +++ b/src/tests/nodes/or_fp8x23/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -16,6 +15,7 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); + data.append(0); data.append(1); data.append(1); data.append(1); @@ -36,8 +36,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp8x23_broadcast.cairo b/src/tests/nodes/or_fp8x23_broadcast.cairo index e12bb7582..daac2dc16 100644 --- a/src/tests/nodes/or_fp8x23_broadcast.cairo +++ b/src/tests/nodes/or_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/or_fp8x23_broadcast/input_0.cairo index 8bdd3f1d4..1e59e0e2a 100644 --- a/src/tests/nodes/or_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/or_fp8x23_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/or_fp8x23_broadcast/input_1.cairo index b17b4f307..de3f273e4 100644 --- a/src/tests/nodes/or_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/or_fp8x23_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/or_fp8x23_broadcast/output_0.cairo index 04e17d1f2..e7b1da4b1 100644 --- a/src/tests/nodes/or_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/or_fp8x23_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i32.cairo b/src/tests/nodes/or_i32.cairo index f6fe533c4..41df5095b 100644 --- a/src/tests/nodes/or_i32.cairo +++ b/src/tests/nodes/or_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_i32/input_0.cairo b/src/tests/nodes/or_i32/input_0.cairo index c391245b4..e96fc7237 100644 --- a/src/tests/nodes/or_i32/input_0.cairo +++ b/src/tests/nodes/or_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: false }); - 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: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, 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: 1, sign: false }); data.append(i32 { mag: 2, 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: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, 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: 1, 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: 2, sign: true }); data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i32/input_1.cairo b/src/tests/nodes/or_i32/input_1.cairo index ec53b0aad..5e59ae979 100644 --- a/src/tests/nodes/or_i32/input_1.cairo +++ b/src/tests/nodes/or_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,33 +11,31 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 0, sign: false }); + 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: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); 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: 3, sign: true }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); - 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: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i32/output_0.cairo b/src/tests/nodes/or_i32/output_0.cairo index e048ead82..9d23207fe 100644 --- a/src/tests/nodes/or_i32/output_0.cairo +++ b/src/tests/nodes/or_i32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -26,7 +25,6 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(0); data.append(1); data.append(1); data.append(1); @@ -37,7 +35,6 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i32_broadcast.cairo b/src/tests/nodes/or_i32_broadcast.cairo index 38067b508..ca81beb48 100644 --- a/src/tests/nodes/or_i32_broadcast.cairo +++ b/src/tests/nodes/or_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_i32_broadcast/input_0.cairo b/src/tests/nodes/or_i32_broadcast/input_0.cairo index 41ec9571b..d5e991eb5 100644 --- a/src/tests/nodes/or_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/or_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i32_broadcast/input_1.cairo b/src/tests/nodes/or_i32_broadcast/input_1.cairo index d6d960b20..6cabdde08 100644 --- a/src/tests/nodes/or_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/or_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i32_broadcast/output_0.cairo b/src/tests/nodes/or_i32_broadcast/output_0.cairo index ec4e00878..e7b1da4b1 100644 --- a/src/tests/nodes/or_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/or_i32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(0); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i8.cairo b/src/tests/nodes/or_i8.cairo index 519b92795..3356d32bd 100644 --- a/src/tests/nodes/or_i8.cairo +++ b/src/tests/nodes/or_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_i8/input_0.cairo b/src/tests/nodes/or_i8/input_0.cairo index 2db3f81bd..54b63018a 100644 --- a/src/tests/nodes/or_i8/input_0.cairo +++ b/src/tests/nodes/or_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, 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: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, 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: 2, sign: true }); - data.append(i8 { mag: 3, sign: true }); 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: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 1, sign: false }); + 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: true }); + data.append(i8 { mag: 2, sign: false }); + 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 }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i8/input_1.cairo b/src/tests/nodes/or_i8/input_1.cairo index 6d4e1a677..cc9e3dcbd 100644 --- a/src/tests/nodes/or_i8/input_1.cairo +++ b/src/tests/nodes/or_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + 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: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: true }); 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: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); + 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: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, 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: 2, sign: true }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); - 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: 0, sign: false }); data.append(i8 { mag: 1, 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: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i8/output_0.cairo b/src/tests/nodes/or_i8/output_0.cairo index 7cda7c299..34fdfc282 100644 --- a/src/tests/nodes/or_i8/output_0.cairo +++ b/src/tests/nodes/or_i8/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,11 +12,11 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); + data.append(0); data.append(1); data.append(1); data.append(1); data.append(1); - data.append(0); data.append(1); data.append(1); data.append(1); @@ -37,7 +36,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i8_broadcast.cairo b/src/tests/nodes/or_i8_broadcast.cairo index 07805a7a7..601195f02 100644 --- a/src/tests/nodes/or_i8_broadcast.cairo +++ b/src/tests/nodes/or_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_i8_broadcast/input_0.cairo b/src/tests/nodes/or_i8_broadcast/input_0.cairo index 4aaaf98bb..cfe284cbc 100644 --- a/src/tests/nodes/or_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/or_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + 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: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i8_broadcast/input_1.cairo b/src/tests/nodes/or_i8_broadcast/input_1.cairo index 483478a6d..5ee26bf38 100644 --- a/src/tests/nodes/or_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/or_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_i8_broadcast/output_0.cairo b/src/tests/nodes/or_i8_broadcast/output_0.cairo index 04e17d1f2..e7b1da4b1 100644 --- a/src/tests/nodes/or_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/or_i8_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_u32.cairo b/src/tests/nodes/or_u32.cairo index 1ac2b242a..b0a917866 100644 --- a/src/tests/nodes/or_u32.cairo +++ b/src/tests/nodes/or_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_u32/input_0.cairo b/src/tests/nodes/or_u32/input_0.cairo index e3b4de903..3b8265911 100644 --- a/src/tests/nodes/or_u32/input_0.cairo +++ b/src/tests/nodes/or_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(1); - data.append(0); data.append(0); - data.append(5); data.append(0); data.append(2); + data.append(3); + data.append(0); + data.append(4); data.append(1); + data.append(4); data.append(2); + data.append(3); data.append(2); - data.append(0); data.append(1); data.append(3); + data.append(3); data.append(5); - data.append(2); + data.append(3); + data.append(0); data.append(4); data.append(1); + data.append(1); data.append(4); - data.append(0); data.append(1); - data.append(5); + data.append(1); data.append(4); - data.append(3); - data.append(2); - data.append(2); data.append(4); + data.append(2); data.append(3); - data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_u32/input_1.cairo b/src/tests/nodes/or_u32/input_1.cairo index 28a5de1af..186273e14 100644 --- a/src/tests/nodes/or_u32/input_1.cairo +++ b/src/tests/nodes/or_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(1); data.append(0); - data.append(4); data.append(3); data.append(5); - data.append(3); - data.append(2); + data.append(1); + data.append(0); data.append(5); - data.append(4); data.append(2); data.append(2); - data.append(5); - data.append(0); - data.append(5); + data.append(3); data.append(3); data.append(4); - data.append(4); + data.append(3); data.append(0); data.append(1); data.append(3); + data.append(1); data.append(3); data.append(2); data.append(0); - data.append(5); + data.append(4); + data.append(2); data.append(0); data.append(1); + data.append(1); data.append(2); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_u32/output_0.cairo b/src/tests/nodes/or_u32/output_0.cairo index 581fcc840..7be1706b0 100644 --- a/src/tests/nodes/or_u32/output_0.cairo +++ b/src/tests/nodes/or_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,6 +10,7 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); + data.append(0); data.append(1); data.append(1); data.append(1); @@ -36,8 +36,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_u32_broadcast.cairo b/src/tests/nodes/or_u32_broadcast.cairo index c452c76fe..3071c3b0a 100644 --- a/src/tests/nodes/or_u32_broadcast.cairo +++ b/src/tests/nodes/or_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/or_u32_broadcast/input_0.cairo b/src/tests/nodes/or_u32_broadcast/input_0.cairo index ed41aeebe..603917619 100644 --- a/src/tests/nodes/or_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/or_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(2); - data.append(3); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(4); + data.append(4); + data.append(4); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_u32_broadcast/input_1.cairo b/src/tests/nodes/or_u32_broadcast/input_1.cairo index 181d59b79..08160469e 100644 --- a/src/tests/nodes/or_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/or_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(5); - data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(2); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/or_u32_broadcast/output_0.cairo b/src/tests/nodes/or_u32_broadcast/output_0.cairo index 04e17d1f2..e7b1da4b1 100644 --- a/src/tests/nodes/or_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/or_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(1); data.append(1); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_1D.cairo b/src/tests/nodes/reduce_sum_fp16x16_1D.cairo index 5a2442291..8b9cf049b 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_1D.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_1D.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp16x16_1D/input_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_1D/input_0.cairo index 67db06586..3bb7db502 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_1D/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_1D/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_1D/output_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_1D/output_0.cairo index 9e2190ea5..aca4697cb 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_1D/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_1D/output_0.cairo @@ -1,15 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1.cairo index baacd6ce5..b490a20cd 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/input_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/input_0.cairo index 2989d0b7b..8009dcc45 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/output_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/output_0.cairo index 02f2829d7..5c1594543 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_axis_1/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_default.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_default.cairo index 01f5cd5ac..9a56b683d 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_default.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_default/input_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_default/input_0.cairo index 2989d0b7b..8009dcc45 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_default/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_default/output_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_default/output_0.cairo index 225e8383e..e7881ed14 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_default/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_default/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims.cairo index a6f4e58db..aea890952 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/input_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/input_0.cairo index 2989d0b7b..8009dcc45 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/output_0.cairo b/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/output_0.cairo index 230d83414..9dc98276a 100644 --- a/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp16x16_2D_keepdims/output_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_1D.cairo b/src/tests/nodes/reduce_sum_fp8x23_1D.cairo index b87a8b2da..9a712a803 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_1D.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_1D.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp8x23_1D/input_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_1D/input_0.cairo index f26a2c183..617c82eee 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_1D/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_1D/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_1D/output_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_1D/output_0.cairo index 36021cae1..532039c9d 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_1D/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_1D/output_0.cairo @@ -1,15 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 25165824, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1.cairo index 93a990944..4074254a8 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/input_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/input_0.cairo index d018bc3e0..738ae80d4 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/output_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/output_0.cairo index 2d4f37bf9..c2d2a02d5 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_axis_1/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 41943040, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_default.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_default.cairo index 09694f209..553a37ec7 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_default.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_default/input_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_default/input_0.cairo index d018bc3e0..738ae80d4 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_default/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_default/output_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_default/output_0.cairo index d4ec16992..d8909e9e6 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_default/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_default/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims.cairo index 3047a3fec..e1d6688eb 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/input_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/input_0.cairo index d018bc3e0..738ae80d4 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/input_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/output_0.cairo b/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/output_0.cairo index 858c4ca3e..aed0ca34e 100644 --- a/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/output_0.cairo +++ b/src/tests/nodes/reduce_sum_fp8x23_2D_keepdims/output_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_1D.cairo b/src/tests/nodes/reduce_sum_i32_1D.cairo index 5db51f6c5..90aa448df 100644 --- a/src/tests/nodes/reduce_sum_i32_1D.cairo +++ b/src/tests/nodes/reduce_sum_i32_1D.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i32_1D/input_0.cairo b/src/tests/nodes/reduce_sum_i32_1D/input_0.cairo index 839d248fb..e9ce9f192 100644 --- a/src/tests/nodes/reduce_sum_i32_1D/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_1D/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,7 +11,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_1D/output_0.cairo b/src/tests/nodes/reduce_sum_i32_1D/output_0.cairo index 73fcab685..b2096bc0f 100644 --- a/src/tests/nodes/reduce_sum_i32_1D/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_1D/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_2D_axis_1.cairo b/src/tests/nodes/reduce_sum_i32_2D_axis_1.cairo index e53d2a5c0..b7d3cbc9d 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_axis_1.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i32_2D_axis_1/input_0.cairo b/src/tests/nodes/reduce_sum_i32_2D_axis_1/input_0.cairo index a58073bdf..fb4bacc7b 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_axis_1/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_axis_1/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_2D_axis_1/output_0.cairo b/src/tests/nodes/reduce_sum_i32_2D_axis_1/output_0.cairo index 7ced920d8..2513d7cce 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_axis_1/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_axis_1/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_2D_default.cairo b/src/tests/nodes/reduce_sum_i32_2D_default.cairo index 35da05e95..f8d325b2d 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_default.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i32_2D_default/input_0.cairo b/src/tests/nodes/reduce_sum_i32_2D_default/input_0.cairo index a58073bdf..fb4bacc7b 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_default/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_default/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_2D_default/output_0.cairo b/src/tests/nodes/reduce_sum_i32_2D_default/output_0.cairo index eba6a1d0b..28240397c 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_default/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_default/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_2D_keepdims.cairo b/src/tests/nodes/reduce_sum_i32_2D_keepdims.cairo index 92b84325d..a87a7f0ab 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_keepdims.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_keepdims.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i32_2D_keepdims/input_0.cairo b/src/tests/nodes/reduce_sum_i32_2D_keepdims/input_0.cairo index a58073bdf..fb4bacc7b 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_keepdims/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_keepdims/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -14,7 +13,5 @@ fn input_0() -> Tensor { data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i32_2D_keepdims/output_0.cairo b/src/tests/nodes/reduce_sum_i32_2D_keepdims/output_0.cairo index 8e1441ae4..bf29f7645 100644 --- a/src/tests/nodes/reduce_sum_i32_2D_keepdims/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i32_2D_keepdims/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,7 +11,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_1D.cairo b/src/tests/nodes/reduce_sum_i8_1D.cairo index 99c955828..78c0f5fc6 100644 --- a/src/tests/nodes/reduce_sum_i8_1D.cairo +++ b/src/tests/nodes/reduce_sum_i8_1D.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i8_1D/input_0.cairo b/src/tests/nodes/reduce_sum_i8_1D/input_0.cairo index 61b138e63..345f34d8c 100644 --- a/src/tests/nodes/reduce_sum_i8_1D/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_1D/input_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(3); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 1, sign: false }); - data.append(FixedType { mag: 2, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_1D/output_0.cairo b/src/tests/nodes/reduce_sum_i8_1D/output_0.cairo index 4ebd65c07..b7d792408 100644 --- a/src/tests/nodes/reduce_sum_i8_1D/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_1D/output_0.cairo @@ -1,15 +1,14 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_2D_axis_1.cairo b/src/tests/nodes/reduce_sum_i8_2D_axis_1.cairo index c4b654412..090fcffdd 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_axis_1.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i8_2D_axis_1/input_0.cairo b/src/tests/nodes/reduce_sum_i8_2D_axis_1/input_0.cairo index 095672ea7..06f8f1737 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_axis_1/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_axis_1/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 1, sign: false }); - data.append(FixedType { mag: 2, sign: false }); - data.append(FixedType { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_2D_axis_1/output_0.cairo b/src/tests/nodes/reduce_sum_i8_2D_axis_1/output_0.cairo index 5f1337b2a..dce7aed06 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_axis_1/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_axis_1/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1, sign: false }); - data.append(FixedType { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 5, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_2D_default.cairo b/src/tests/nodes/reduce_sum_i8_2D_default.cairo index 8e8bde416..6fbdb3c2b 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_default.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i8_2D_default/input_0.cairo b/src/tests/nodes/reduce_sum_i8_2D_default/input_0.cairo index 095672ea7..06f8f1737 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_default/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_default/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 1, sign: false }); - data.append(FixedType { mag: 2, sign: false }); - data.append(FixedType { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_2D_default/output_0.cairo b/src/tests/nodes/reduce_sum_i8_2D_default/output_0.cairo index c3c525aed..116d100c4 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_default/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_default/output_0.cairo @@ -1,16 +1,15 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2, sign: false }); - data.append(FixedType { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_2D_keepdims.cairo b/src/tests/nodes/reduce_sum_i8_2D_keepdims.cairo index 888c11725..2f1af81bf 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_keepdims.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_keepdims.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_i8_2D_keepdims/input_0.cairo b/src/tests/nodes/reduce_sum_i8_2D_keepdims/input_0.cairo index 095672ea7..06f8f1737 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_keepdims/input_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_keepdims/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 1, sign: false }); - data.append(FixedType { mag: 2, sign: false }); - data.append(FixedType { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 1, sign: false }); + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 3, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_i8_2D_keepdims/output_0.cairo b/src/tests/nodes/reduce_sum_i8_2D_keepdims/output_0.cairo index d4ddcaca1..a40e69624 100644 --- a/src/tests/nodes/reduce_sum_i8_2D_keepdims/output_0.cairo +++ b/src/tests/nodes/reduce_sum_i8_2D_keepdims/output_0.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2, sign: false }); - data.append(FixedType { mag: 4, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 2, sign: false }); + data.append(FP8x23 { mag: 4, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_1D.cairo b/src/tests/nodes/reduce_sum_u32_1D.cairo index 86f1759ae..0db242af5 100644 --- a/src/tests/nodes/reduce_sum_u32_1D.cairo +++ b/src/tests/nodes/reduce_sum_u32_1D.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_u32_1D/input_0.cairo b/src/tests/nodes/reduce_sum_u32_1D/input_0.cairo index 4681c7596..26ecd350b 100644 --- a/src/tests/nodes/reduce_sum_u32_1D/input_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_1D/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn input_0() -> Tensor { data.append(0); data.append(1); data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_1D/output_0.cairo b/src/tests/nodes/reduce_sum_u32_1D/output_0.cairo index c30dff144..cf29a4530 100644 --- a/src/tests/nodes/reduce_sum_u32_1D/output_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_1D/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,7 +8,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_2D_axis_1.cairo b/src/tests/nodes/reduce_sum_u32_2D_axis_1.cairo index d6ae97318..99848df59 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_axis_1.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_axis_1.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_u32_2D_axis_1/input_0.cairo b/src/tests/nodes/reduce_sum_u32_2D_axis_1/input_0.cairo index 0c5fdf6d1..6c324ceb6 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_axis_1/input_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_axis_1/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn input_0() -> Tensor { data.append(1); data.append(2); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_2D_axis_1/output_0.cairo b/src/tests/nodes/reduce_sum_u32_2D_axis_1/output_0.cairo index 9ca27dafe..b15f624cd 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_axis_1/output_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_axis_1/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_2D_default.cairo b/src/tests/nodes/reduce_sum_u32_2D_default.cairo index 907bd69e7..f949deea3 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_default.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_default.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_u32_2D_default/input_0.cairo b/src/tests/nodes/reduce_sum_u32_2D_default/input_0.cairo index 0c5fdf6d1..6c324ceb6 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_default/input_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_default/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn input_0() -> Tensor { data.append(1); data.append(2); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_2D_default/output_0.cairo b/src/tests/nodes/reduce_sum_u32_2D_default/output_0.cairo index 1b1dea023..f10eb07f1 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_default/output_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_default/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,7 +9,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_2D_keepdims.cairo b/src/tests/nodes/reduce_sum_u32_2D_keepdims.cairo index 64ab96500..cfd7da1bb 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_keepdims.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_keepdims.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/reduce_sum_u32_2D_keepdims/input_0.cairo b/src/tests/nodes/reduce_sum_u32_2D_keepdims/input_0.cairo index 0c5fdf6d1..6c324ceb6 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_keepdims/input_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_keepdims/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn input_0() -> Tensor { data.append(1); data.append(2); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/reduce_sum_u32_2D_keepdims/output_0.cairo b/src/tests/nodes/reduce_sum_u32_2D_keepdims/output_0.cairo index d3938c028..7d63eb45a 100644 --- a/src/tests/nodes/reduce_sum_u32_2D_keepdims/output_0.cairo +++ b/src/tests/nodes/reduce_sum_u32_2D_keepdims/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,7 +10,5 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(2); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_fp16x16.cairo b/src/tests/nodes/relu_fp16x16.cairo index 47b9d002f..d8e439cae 100644 --- a/src/tests/nodes/relu_fp16x16.cairo +++ b/src/tests/nodes/relu_fp16x16.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/relu_fp16x16/input_0.cairo b/src/tests/nodes/relu_fp16x16/input_0.cairo index 0fe5e4a49..e196cc8c1 100644 --- a/src/tests/nodes/relu_fp16x16/input_0.cairo +++ b/src/tests/nodes/relu_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 241623, sign: false }); - data.append(FixedType { mag: 135784, sign: false }); - data.append(FixedType { mag: 91618, sign: true }); - data.append(FixedType { mag: 52199, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 6065, sign: false }); + data.append(FP16x16 { mag: 134983, sign: true }); + data.append(FP16x16 { mag: 30217, sign: false }); + data.append(FP16x16 { mag: 88950, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_fp16x16/output_0.cairo b/src/tests/nodes/relu_fp16x16/output_0.cairo index a04d917d6..be4ea0189 100644 --- a/src/tests/nodes/relu_fp16x16/output_0.cairo +++ b/src/tests/nodes/relu_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 241623, sign: false }); - data.append(FixedType { mag: 135784, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 52199, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 6065, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 30217, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_fp8x23.cairo b/src/tests/nodes/relu_fp8x23.cairo index 2fb24d946..9ceec0072 100644 --- a/src/tests/nodes/relu_fp8x23.cairo +++ b/src/tests/nodes/relu_fp8x23.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/relu_fp8x23/input_0.cairo b/src/tests/nodes/relu_fp8x23/input_0.cairo index a3dc0f555..4d1122f47 100644 --- a/src/tests/nodes/relu_fp8x23/input_0.cairo +++ b/src/tests/nodes/relu_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 23718869, sign: false }); - data.append(FixedType { mag: 34552664, sign: true }); - data.append(FixedType { mag: 34211188, sign: true }); - data.append(FixedType { mag: 16610226, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 35370496, sign: false }); + data.append(FP8x23 { mag: 51831526, sign: false }); + data.append(FP8x23 { mag: 26129513, sign: true }); + data.append(FP8x23 { mag: 10508621, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_fp8x23/output_0.cairo b/src/tests/nodes/relu_fp8x23/output_0.cairo index 6ee48bf13..cc0423858 100644 --- a/src/tests/nodes/relu_fp8x23/output_0.cairo +++ b/src/tests/nodes/relu_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 23718870, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 35370496, sign: false }); + data.append(FP8x23 { mag: 51831528, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_i32.cairo b/src/tests/nodes/relu_i32.cairo index d947fcb3d..0608a6fdd 100644 --- a/src/tests/nodes/relu_i32.cairo +++ b/src/tests/nodes/relu_i32.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::I32NN; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/relu_i32/input_0.cairo b/src/tests/nodes/relu_i32/input_0.cairo index 9ffd2dc5b..a9af2d9a5 100644 --- a/src/tests/nodes/relu_i32/input_0.cairo +++ b/src/tests/nodes/relu_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_i32/output_0.cairo b/src/tests/nodes/relu_i32/output_0.cairo index a6f599424..903239942 100644 --- a/src/tests/nodes/relu_i32/output_0.cairo +++ b/src/tests/nodes/relu_i32/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 5, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 6, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_i8.cairo b/src/tests/nodes/relu_i8.cairo index 2f535777e..85674ecd0 100644 --- a/src/tests/nodes/relu_i8.cairo +++ b/src/tests/nodes/relu_i8.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::I8NN; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/relu_i8/input_0.cairo b/src/tests/nodes/relu_i8/input_0.cairo index b9741cfc7..13d6f8f5d 100644 --- a/src/tests/nodes/relu_i8/input_0.cairo +++ b/src/tests/nodes/relu_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 6, sign: false }); data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 8, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/relu_i8/output_0.cairo b/src/tests/nodes/relu_i8/output_0.cairo index 90d7d8bfe..432b19071 100644 --- a/src/tests/nodes/relu_i8/output_0.cairo +++ b/src/tests/nodes/relu_i8/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 6, sign: false }); data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 8, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_fp16x16.cairo b/src/tests/nodes/sigmoid_fp16x16.cairo index 5d351874f..d58d99c92 100644 --- a/src/tests/nodes/sigmoid_fp16x16.cairo +++ b/src/tests/nodes/sigmoid_fp16x16.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sigmoid_fp16x16/input_0.cairo b/src/tests/nodes/sigmoid_fp16x16/input_0.cairo index 4e024e1a7..56c4e748f 100644 --- a/src/tests/nodes/sigmoid_fp16x16/input_0.cairo +++ b/src/tests/nodes/sigmoid_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 40935, sign: true }); - data.append(FixedType { mag: 33897, sign: false }); - data.append(FixedType { mag: 97672, sign: true }); - data.append(FixedType { mag: 73532, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 42997, sign: true }); + data.append(FP16x16 { mag: 108408, sign: true }); + data.append(FP16x16 { mag: 87345, sign: false }); + data.append(FP16x16 { mag: 169098, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_fp16x16/output_0.cairo b/src/tests/nodes/sigmoid_fp16x16/output_0.cairo index 73d9d5a49..f085cd671 100644 --- a/src/tests/nodes/sigmoid_fp16x16/output_0.cairo +++ b/src/tests/nodes/sigmoid_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 22854, sign: false }); - data.append(FixedType { mag: 41058, sign: false }); - data.append(FixedType { mag: 12049, sign: false }); - data.append(FixedType { mag: 49437, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 22388, sign: false }); + data.append(FP16x16 { mag: 10521, sign: false }); + data.append(FP16x16 { mag: 51858, sign: false }); + data.append(FP16x16 { mag: 60920, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_fp8x23.cairo b/src/tests/nodes/sigmoid_fp8x23.cairo index bf07b40d5..77797b92a 100644 --- a/src/tests/nodes/sigmoid_fp8x23.cairo +++ b/src/tests/nodes/sigmoid_fp8x23.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sigmoid_fp8x23/input_0.cairo b/src/tests/nodes/sigmoid_fp8x23/input_0.cairo index 4a9c5fdf8..7ae3ed063 100644 --- a/src/tests/nodes/sigmoid_fp8x23/input_0.cairo +++ b/src/tests/nodes/sigmoid_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 13876472, sign: true }); - data.append(FixedType { mag: 18112152, sign: false }); - data.append(FixedType { mag: 21105010, sign: true }); - data.append(FixedType { mag: 17882688, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 20907772, sign: true }); + data.append(FP8x23 { mag: 24683986, sign: true }); + data.append(FP8x23 { mag: 21494604, sign: true }); + data.append(FP8x23 { mag: 1609367, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_fp8x23/output_0.cairo b/src/tests/nodes/sigmoid_fp8x23/output_0.cairo index 249860881..370da14ef 100644 --- a/src/tests/nodes/sigmoid_fp8x23/output_0.cairo +++ b/src/tests/nodes/sigmoid_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 1346720, sign: false }); - data.append(FixedType { mag: 7520550, sign: false }); - data.append(FixedType { mag: 627049, sign: false }); - data.append(FixedType { mag: 889577, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 640827, sign: false }); + data.append(FP8x23 { mag: 420179, sign: false }); + data.append(FP8x23 { mag: 600630, sign: false }); + data.append(FP8x23 { mag: 4595416, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i32_fp16x16.cairo b/src/tests/nodes/sigmoid_i32_fp16x16.cairo deleted file mode 100644 index 13b922307..000000000 --- a/src/tests/nodes/sigmoid_i32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sigmoid_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::sigmoid(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i32_fp16x16/input_0.cairo b/src/tests/nodes/sigmoid_i32_fp16x16/input_0.cairo deleted file mode 100644 index 770045641..000000000 --- a/src/tests/nodes/sigmoid_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i32_fp16x16/output_0.cairo b/src/tests/nodes/sigmoid_i32_fp16x16/output_0.cairo deleted file mode 100644 index 8afafd64e..000000000 --- a/src/tests/nodes/sigmoid_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 47910, sign: false }); - data.append(FixedType { mag: 57723, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 17625, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i32_fp8x23.cairo b/src/tests/nodes/sigmoid_i32_fp8x23.cairo deleted file mode 100644 index fd508e706..000000000 --- a/src/tests/nodes/sigmoid_i32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sigmoid_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::sigmoid(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i32_fp8x23/input_0.cairo b/src/tests/nodes/sigmoid_i32_fp8x23/input_0.cairo deleted file mode 100644 index fec9a7e33..000000000 --- a/src/tests/nodes/sigmoid_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 3, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i32_fp8x23/output_0.cairo b/src/tests/nodes/sigmoid_i32_fp8x23/output_0.cairo deleted file mode 100644 index 855b4bf2c..000000000 --- a/src/tests/nodes/sigmoid_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 397837, sign: false }); - data.append(FixedType { mag: 999946, sign: false }); - data.append(FixedType { mag: 397837, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i8_fp16x16.cairo b/src/tests/nodes/sigmoid_i8_fp16x16.cairo deleted file mode 100644 index 19eee3e83..000000000 --- a/src/tests/nodes/sigmoid_i8_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sigmoid_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::sigmoid(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i8_fp16x16/input_0.cairo b/src/tests/nodes/sigmoid_i8_fp16x16/input_0.cairo deleted file mode 100644 index 4852755e2..000000000 --- a/src/tests/nodes/sigmoid_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 3, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i8_fp16x16/output_0.cairo b/src/tests/nodes/sigmoid_i8_fp16x16/output_0.cairo deleted file mode 100644 index 0593c8ff2..000000000 --- a/src/tests/nodes/sigmoid_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 3108, sign: false }); - data.append(FixedType { mag: 7812, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 47910, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i8_fp8x23.cairo b/src/tests/nodes/sigmoid_i8_fp8x23.cairo deleted file mode 100644 index f8cbda853..000000000 --- a/src/tests/nodes/sigmoid_i8_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sigmoid_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::sigmoid(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i8_fp8x23/input_0.cairo b/src/tests/nodes/sigmoid_i8_fp8x23/input_0.cairo deleted file mode 100644 index 59cc567c6..000000000 --- a/src/tests/nodes/sigmoid_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_i8_fp8x23/output_0.cairo b/src/tests/nodes/sigmoid_i8_fp8x23/output_0.cairo deleted file mode 100644 index 4f9282465..000000000 --- a/src/tests/nodes/sigmoid_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 7388661, sign: false }); - data.append(FixedType { mag: 7388661, sign: false }); - data.append(FixedType { mag: 2256044, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_u32_fp16x16.cairo b/src/tests/nodes/sigmoid_u32_fp16x16.cairo deleted file mode 100644 index 8dc1d5b09..000000000 --- a/src/tests/nodes/sigmoid_u32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sigmoid_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::sigmoid(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_u32_fp16x16/input_0.cairo b/src/tests/nodes/sigmoid_u32_fp16x16/input_0.cairo deleted file mode 100644 index 7b4ca3b97..000000000 --- a/src/tests/nodes/sigmoid_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(1); - data.append(1); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_u32_fp16x16/output_0.cairo b/src/tests/nodes/sigmoid_u32_fp16x16/output_0.cairo deleted file mode 100644 index c30c4dff3..000000000 --- a/src/tests/nodes/sigmoid_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 47910, sign: false }); - data.append(FixedType { mag: 47910, sign: false }); - data.append(FixedType { mag: 47910, sign: false }); - data.append(FixedType { mag: 47910, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_u32_fp8x23.cairo b/src/tests/nodes/sigmoid_u32_fp8x23.cairo deleted file mode 100644 index c5264b63d..000000000 --- a/src/tests/nodes/sigmoid_u32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sigmoid_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::sigmoid(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_u32_fp8x23/input_0.cairo b/src/tests/nodes/sigmoid_u32_fp8x23/input_0.cairo deleted file mode 100644 index a5a58935c..000000000 --- a/src/tests/nodes/sigmoid_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(2); - data.append(2); - data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sigmoid_u32_fp8x23/output_0.cairo b/src/tests/nodes/sigmoid_u32_fp8x23/output_0.cairo deleted file mode 100644 index 892190a98..000000000 --- a/src/tests/nodes/sigmoid_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7388661, sign: false }); - data.append(FixedType { mag: 7388661, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 6132564, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_fp16x16.cairo b/src/tests/nodes/sin_fp16x16.cairo index 57cd81276..ab1c5df2f 100644 --- a/src/tests/nodes/sin_fp16x16.cairo +++ b/src/tests/nodes/sin_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sin_fp16x16/input_0.cairo b/src/tests/nodes/sin_fp16x16/input_0.cairo index 307046012..8067cff1d 100644 --- a/src/tests/nodes/sin_fp16x16/input_0.cairo +++ b/src/tests/nodes/sin_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 187441, sign: true }); - data.append(FixedType { mag: 123153, sign: false }); - data.append(FixedType { mag: 59844, sign: true }); - data.append(FixedType { mag: 76013, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 167356, sign: false }); + data.append(FP16x16 { mag: 369339, sign: false }); + data.append(FP16x16 { mag: 308834, sign: false }); + data.append(FP16x16 { mag: 3145, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sin_fp16x16/output_0.cairo b/src/tests/nodes/sin_fp16x16/output_0.cairo index 6a13ea4b6..6513f7d26 100644 --- a/src/tests/nodes/sin_fp16x16/output_0.cairo +++ b/src/tests/nodes/sin_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 18203, sign: true }); - data.append(FixedType { mag: 62444, sign: false }); - data.append(FixedType { mag: 51867, sign: true }); - data.append(FixedType { mag: 60080, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 36348, sign: false }); + data.append(FP16x16 { mag: 39531, sign: true }); + data.append(FP16x16 { mag: 65535, sign: true }); + data.append(FP16x16 { mag: 3144, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sin_fp8x23.cairo b/src/tests/nodes/sin_fp8x23.cairo index 0b64d96d1..d9aab62d4 100644 --- a/src/tests/nodes/sin_fp8x23.cairo +++ b/src/tests/nodes/sin_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sin_fp8x23/input_0.cairo b/src/tests/nodes/sin_fp8x23/input_0.cairo index ba60998e9..4ea3887b6 100644 --- a/src/tests/nodes/sin_fp8x23/input_0.cairo +++ b/src/tests/nodes/sin_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 15411983, sign: false }); - data.append(FixedType { mag: 1403069, sign: false }); - data.append(FixedType { mag: 11223653, sign: true }); - data.append(FixedType { mag: 30290440, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 6647816, sign: true }); + data.append(FP8x23 { mag: 58073960, sign: false }); + data.append(FP8x23 { mag: 41721546, sign: false }); + data.append(FP8x23 { mag: 410451, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sin_fp8x23/output_0.cairo b/src/tests/nodes/sin_fp8x23/output_0.cairo index 4fd787668..f0d006c61 100644 --- a/src/tests/nodes/sin_fp8x23/output_0.cairo +++ b/src/tests/nodes/sin_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8092576, sign: false }); - data.append(FixedType { mag: 1396536, sign: false }); - data.append(FixedType { mag: 8162255, sign: true }); - data.append(FixedType { mag: 3793918, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 5973508, sign: true }); + data.append(FP8x23 { mag: 5008092, sign: false }); + data.append(FP8x23 { mag: 8104057, sign: true }); + data.append(FP8x23 { mag: 410287, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sin_i32_fp16x16.cairo b/src/tests/nodes/sin_i32_fp16x16.cairo deleted file mode 100644 index d2ff3de63..000000000 --- a/src/tests/nodes/sin_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sin_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sin(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i32_fp16x16/input_0.cairo b/src/tests/nodes/sin_i32_fp16x16/input_0.cairo deleted file mode 100644 index 62fdc2a14..000000000 --- a/src/tests/nodes/sin_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 116, sign: false }); - data.append(i32 { mag: 105, sign: false }); - data.append(i32 { mag: 90, sign: false }); - data.append(i32 { mag: 109, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i32_fp16x16/output_0.cairo b/src/tests/nodes/sin_i32_fp16x16/output_0.cairo deleted file mode 100644 index 5360100df..000000000 --- a/src/tests/nodes/sin_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 15509, sign: false }); - data.append(FixedType { mag: 63605, sign: true }); - data.append(FixedType { mag: 58588, sign: false }); - data.append(FixedType { mag: 53526, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i32_fp8x23.cairo b/src/tests/nodes/sin_i32_fp8x23.cairo deleted file mode 100644 index 7714ec793..000000000 --- a/src/tests/nodes/sin_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sin_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sin(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i32_fp8x23/input_0.cairo b/src/tests/nodes/sin_i32_fp8x23/input_0.cairo deleted file mode 100644 index e988582cb..000000000 --- a/src/tests/nodes/sin_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 66, sign: false }); - data.append(i32 { mag: 10, sign: false }); - data.append(i32 { mag: 111, sign: false }); - data.append(i32 { mag: 96, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i32_fp8x23/output_0.cairo b/src/tests/nodes/sin_i32_fp8x23/output_0.cairo deleted file mode 100644 index da9b2732f..000000000 --- a/src/tests/nodes/sin_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 222727, sign: true }); - data.append(FixedType { mag: 4563579, sign: true }); - data.append(FixedType { mag: 7252383, sign: true }); - data.append(FixedType { mag: 8250932, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i8_fp16x16.cairo b/src/tests/nodes/sin_i8_fp16x16.cairo deleted file mode 100644 index 88a285a5b..000000000 --- a/src/tests/nodes/sin_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sin_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sin(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i8_fp16x16/input_0.cairo b/src/tests/nodes/sin_i8_fp16x16/input_0.cairo deleted file mode 100644 index 875c201e8..000000000 --- a/src/tests/nodes/sin_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 45, sign: false }); - data.append(i8 { mag: 14, sign: false }); - data.append(i8 { mag: 64, sign: false }); - data.append(i8 { mag: 75, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i8_fp16x16/output_0.cairo b/src/tests/nodes/sin_i8_fp16x16/output_0.cairo deleted file mode 100644 index 82711df03..000000000 --- a/src/tests/nodes/sin_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 55764, sign: false }); - data.append(FixedType { mag: 64920, sign: false }); - data.append(FixedType { mag: 60294, sign: false }); - data.append(FixedType { mag: 25413, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i8_fp8x23.cairo b/src/tests/nodes/sin_i8_fp8x23.cairo deleted file mode 100644 index c3b8f65c6..000000000 --- a/src/tests/nodes/sin_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sin_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sin(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i8_fp8x23/input_0.cairo b/src/tests/nodes/sin_i8_fp8x23/input_0.cairo deleted file mode 100644 index daa3b2826..000000000 --- a/src/tests/nodes/sin_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 4, sign: true }); - data.append(i8 { mag: 6, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_i8_fp8x23/output_0.cairo b/src/tests/nodes/sin_i8_fp8x23/output_0.cairo deleted file mode 100644 index 09fce0ad4..000000000 --- a/src/tests/nodes/sin_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6348800, sign: false }); - data.append(FixedType { mag: 2342912, sign: false }); - data.append(FixedType { mag: 7626752, sign: false }); - data.append(FixedType { mag: 1183744, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_u32_fp16x16.cairo b/src/tests/nodes/sin_u32_fp16x16.cairo deleted file mode 100644 index 546293f7f..000000000 --- a/src/tests/nodes/sin_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sin_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sin(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sin_u32_fp16x16/input_0.cairo b/src/tests/nodes/sin_u32_fp16x16/input_0.cairo deleted file mode 100644 index 249e24fa1..000000000 --- a/src/tests/nodes/sin_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(84); - data.append(64); - data.append(55); - data.append(91); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_u32_fp16x16/output_0.cairo b/src/tests/nodes/sin_u32_fp16x16/output_0.cairo deleted file mode 100644 index 2db6b40ec..000000000 --- a/src/tests/nodes/sin_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 48050, sign: false }); - data.append(FixedType { mag: 60294, sign: false }); - data.append(FixedType { mag: 65519, sign: true }); - data.append(FixedType { mag: 6945, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_u32_fp8x23.cairo b/src/tests/nodes/sin_u32_fp8x23.cairo deleted file mode 100644 index e89d2cce4..000000000 --- a/src/tests/nodes/sin_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sin_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sin(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sin_u32_fp8x23/input_0.cairo b/src/tests/nodes/sin_u32_fp8x23/input_0.cairo deleted file mode 100644 index dcb471f46..000000000 --- a/src/tests/nodes/sin_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(103); - data.append(98); - data.append(86); - data.append(80); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sin_u32_fp8x23/output_0.cairo b/src/tests/nodes/sin_u32_fp8x23/output_0.cairo deleted file mode 100644 index 8c51f3392..000000000 --- a/src/tests/nodes/sin_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5226007, sign: false }); - data.append(FixedType { mag: 4809875, sign: true }); - data.append(FixedType { mag: 7746530, sign: true }); - data.append(FixedType { mag: 8337342, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_fp16x16.cairo b/src/tests/nodes/sinh_fp16x16.cairo index eb88b3fdc..704362bfc 100644 --- a/src/tests/nodes/sinh_fp16x16.cairo +++ b/src/tests/nodes/sinh_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sinh_fp16x16/input_0.cairo b/src/tests/nodes/sinh_fp16x16/input_0.cairo index aaf902e5b..e6749f4f7 100644 --- a/src/tests/nodes/sinh_fp16x16/input_0.cairo +++ b/src/tests/nodes/sinh_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 191221, sign: true }); - data.append(FixedType { mag: 176805, sign: true }); - data.append(FixedType { mag: 179634, sign: false }); - data.append(FixedType { mag: 177006, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 181084, sign: false }); + data.append(FP16x16 { mag: 85235, sign: true }); + data.append(FP16x16 { mag: 59303, sign: true }); + data.append(FP16x16 { mag: 130937, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sinh_fp16x16/output_0.cairo b/src/tests/nodes/sinh_fp16x16/output_0.cairo index 8e9b95cc8..2f7e763c3 100644 --- a/src/tests/nodes/sinh_fp16x16/output_0.cairo +++ b/src/tests/nodes/sinh_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 604463, sign: true }); - data.append(FixedType { mag: 484320, sign: true }); - data.append(FixedType { mag: 505875, sign: false }); - data.append(FixedType { mag: 485818, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 517281, sign: false }); + data.append(FP16x16 { mag: 111381, sign: true }); + data.append(FP16x16 { mag: 67734, sign: true }); + data.append(FP16x16 { mag: 237186, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sinh_fp8x23.cairo b/src/tests/nodes/sinh_fp8x23.cairo index cb496c1b9..beef97a64 100644 --- a/src/tests/nodes/sinh_fp8x23.cairo +++ b/src/tests/nodes/sinh_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sinh_fp8x23/input_0.cairo b/src/tests/nodes/sinh_fp8x23/input_0.cairo index 0f23c403b..4945e8dba 100644 --- a/src/tests/nodes/sinh_fp8x23/input_0.cairo +++ b/src/tests/nodes/sinh_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2356323, sign: true }); - data.append(FixedType { mag: 4204899, sign: false }); - data.append(FixedType { mag: 21037695, sign: false }); - data.append(FixedType { mag: 20483758, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 20711629, sign: true }); + data.append(FP8x23 { mag: 18228194, sign: false }); + data.append(FP8x23 { mag: 15655651, sign: true }); + data.append(FP8x23 { mag: 13406669, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sinh_fp8x23/output_0.cairo b/src/tests/nodes/sinh_fp8x23/output_0.cairo index 422e0f2ce..15f43bfac 100644 --- a/src/tests/nodes/sinh_fp8x23/output_0.cairo +++ b/src/tests/nodes/sinh_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2387433, sign: true }); - data.append(FixedType { mag: 4383215, sign: false }); - data.append(FixedType { mag: 51160183, sign: false }); - data.append(FixedType { mag: 47845830, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 49183175, sign: true }); + data.append(FP8x23 { mag: 36366700, sign: false }); + data.append(FP8x23 { mag: 26464518, sign: true }); + data.append(FP8x23 { mag: 19888811, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sinh_i32_fp16x16.cairo b/src/tests/nodes/sinh_i32_fp16x16.cairo deleted file mode 100644 index 6ff37deff..000000000 --- a/src/tests/nodes/sinh_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sinh_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i32_fp16x16/input_0.cairo b/src/tests/nodes/sinh_i32_fp16x16/input_0.cairo deleted file mode 100644 index 14a0e88ce..000000000 --- a/src/tests/nodes/sinh_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i32_fp16x16/output_0.cairo b/src/tests/nodes/sinh_i32_fp16x16/output_0.cairo deleted file mode 100644 index 445797d38..000000000 --- a/src/tests/nodes/sinh_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 77017, sign: true }); - data.append(FixedType { mag: 77017, sign: false }); - data.append(FixedType { mag: 237689, sign: true }); - data.append(FixedType { mag: 656531, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i32_fp8x23.cairo b/src/tests/nodes/sinh_i32_fp8x23.cairo deleted file mode 100644 index f1acb7300..000000000 --- a/src/tests/nodes/sinh_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sinh_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i32_fp8x23/input_0.cairo b/src/tests/nodes/sinh_i32_fp8x23/input_0.cairo deleted file mode 100644 index 8ea137805..000000000 --- a/src/tests/nodes/sinh_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i32_fp8x23/output_0.cairo b/src/tests/nodes/sinh_i32_fp8x23/output_0.cairo deleted file mode 100644 index 88308052f..000000000 --- a/src/tests/nodes/sinh_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 30424310, sign: false }); - data.append(FixedType { mag: 30424310, sign: false }); - data.append(FixedType { mag: 84036025, sign: true }); - data.append(FixedType { mag: 9858302, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i8_fp16x16.cairo b/src/tests/nodes/sinh_i8_fp16x16.cairo deleted file mode 100644 index 2d5d9f3f9..000000000 --- a/src/tests/nodes/sinh_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sinh_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i8_fp16x16/input_0.cairo b/src/tests/nodes/sinh_i8_fp16x16/input_0.cairo deleted file mode 100644 index c1f881701..000000000 --- a/src/tests/nodes/sinh_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i8_fp16x16/output_0.cairo b/src/tests/nodes/sinh_i8_fp16x16/output_0.cairo deleted file mode 100644 index b41da9069..000000000 --- a/src/tests/nodes/sinh_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 77017, sign: true }); - data.append(FixedType { mag: 656531, sign: true }); - data.append(FixedType { mag: 656531, sign: true }); - data.append(FixedType { mag: 77017, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i8_fp8x23.cairo b/src/tests/nodes/sinh_i8_fp8x23.cairo deleted file mode 100644 index 00e98ccf9..000000000 --- a/src/tests/nodes/sinh_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sinh_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i8_fp8x23/input_0.cairo b/src/tests/nodes/sinh_i8_fp8x23/input_0.cairo deleted file mode 100644 index 8f6e6ef04..000000000 --- a/src/tests/nodes/sinh_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 3, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_i8_fp8x23/output_0.cairo b/src/tests/nodes/sinh_i8_fp8x23/output_0.cairo deleted file mode 100644 index d8101bce7..000000000 --- a/src/tests/nodes/sinh_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 84017152, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 30425088, sign: false }); - data.append(FixedType { mag: 9854976, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_u32_fp16x16.cairo b/src/tests/nodes/sinh_u32_fp16x16.cairo deleted file mode 100644 index 69fbc15f8..000000000 --- a/src/tests/nodes/sinh_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sinh_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_u32_fp16x16/input_0.cairo b/src/tests/nodes/sinh_u32_fp16x16/input_0.cairo deleted file mode 100644 index c47ef98bd..000000000 --- a/src/tests/nodes/sinh_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(1); - data.append(1); - data.append(5); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_u32_fp16x16/output_0.cairo b/src/tests/nodes/sinh_u32_fp16x16/output_0.cairo deleted file mode 100644 index c4496f2d1..000000000 --- a/src/tests/nodes/sinh_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 77017, sign: false }); - data.append(FixedType { mag: 77017, sign: false }); - data.append(FixedType { mag: 4862981, sign: false }); - data.append(FixedType { mag: 237689, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_u32_fp8x23.cairo b/src/tests/nodes/sinh_u32_fp8x23.cairo deleted file mode 100644 index 3f3244c97..000000000 --- a/src/tests/nodes/sinh_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sinh_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sinh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_u32_fp8x23/input_0.cairo b/src/tests/nodes/sinh_u32_fp8x23/input_0.cairo deleted file mode 100644 index 975b1118c..000000000 --- a/src/tests/nodes/sinh_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(5); - data.append(0); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sinh_u32_fp8x23/output_0.cairo b/src/tests/nodes/sinh_u32_fp8x23/output_0.cairo deleted file mode 100644 index df6ac6750..000000000 --- a/src/tests/nodes/sinh_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 622461645, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 9858302, sign: false }); - data.append(FixedType { mag: 9858302, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp16x16_2d.cairo b/src/tests/nodes/slice_fp16x16_2d.cairo new file mode 100644 index 000000000..9eb2e22ef --- /dev/null +++ b/src/tests/nodes/slice_fp16x16_2d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_fp16x16_2d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp16x16_2d/input_0.cairo b/src/tests/nodes/slice_fp16x16_2d/input_0.cairo new file mode 100644 index 000000000..f4b923063 --- /dev/null +++ b/src/tests/nodes/slice_fp16x16_2d/input_0.cairo @@ -0,0 +1,22 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 5505024, sign: false }); + data.append(FP16x16 { mag: 7929856, sign: true }); + data.append(FP16x16 { mag: 720896, sign: true }); + data.append(FP16x16 { mag: 3145728, sign: true }); + data.append(FP16x16 { mag: 3407872, sign: true }); + data.append(FP16x16 { mag: 7274496, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp16x16_2d/output_0.cairo b/src/tests/nodes/slice_fp16x16_2d/output_0.cairo new file mode 100644 index 000000000..6aa02018b --- /dev/null +++ b/src/tests/nodes/slice_fp16x16_2d/output_0.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 7929856, sign: true }); + data.append(FP16x16 { mag: 720896, sign: true }); + data.append(FP16x16 { mag: 7274496, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp16x16_3d.cairo b/src/tests/nodes/slice_fp16x16_3d.cairo new file mode 100644 index 000000000..df9d57614 --- /dev/null +++ b/src/tests/nodes/slice_fp16x16_3d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_fp16x16_3d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp16x16_3d/input_0.cairo b/src/tests/nodes/slice_fp16x16_3d/input_0.cairo new file mode 100644 index 000000000..0eacc5191 --- /dev/null +++ b/src/tests/nodes/slice_fp16x16_3d/input_0.cairo @@ -0,0 +1,1015 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(20); + shape.append(10); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 6029312, sign: false }); + data.append(FP16x16 { mag: 720896, sign: true }); + data.append(FP16x16 { mag: 2621440, sign: true }); + data.append(FP16x16 { mag: 3342336, sign: true }); + data.append(FP16x16 { mag: 7143424, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 7208960, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 4063232, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: false }); + data.append(FP16x16 { mag: 6946816, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 7733248, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 7143424, sign: true }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: true }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 7405568, sign: true }); + data.append(FP16x16 { mag: 4259840, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: true }); + data.append(FP16x16 { mag: 786432, sign: true }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 5308416, sign: true }); + data.append(FP16x16 { mag: 8126464, sign: true }); + data.append(FP16x16 { mag: 2031616, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: false }); + data.append(FP16x16 { mag: 5308416, sign: false }); + data.append(FP16x16 { mag: 7274496, sign: true }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 7012352, sign: true }); + data.append(FP16x16 { mag: 7012352, sign: true }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: true }); + data.append(FP16x16 { mag: 2293760, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 5373952, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 5505024, sign: true }); + data.append(FP16x16 { mag: 6094848, sign: true }); + data.append(FP16x16 { mag: 3211264, sign: true }); + data.append(FP16x16 { mag: 1179648, sign: true }); + data.append(FP16x16 { mag: 2949120, sign: true }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: true }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: true }); + data.append(FP16x16 { mag: 4128768, sign: true }); + data.append(FP16x16 { mag: 6094848, sign: true }); + data.append(FP16x16 { mag: 3932160, sign: true }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: true }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 6946816, sign: true }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 7733248, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 327680, sign: true }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 6094848, sign: true }); + data.append(FP16x16 { mag: 1376256, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: false }); + data.append(FP16x16 { mag: 8257536, sign: true }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 7733248, sign: true }); + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 6946816, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: true }); + data.append(FP16x16 { mag: 4194304, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: true }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 6225920, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: true }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 7995392, sign: true }); + data.append(FP16x16 { mag: 2555904, sign: true }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 5832704, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: true }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 5832704, sign: true }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 2883584, sign: true }); + data.append(FP16x16 { mag: 5242880, sign: false }); + data.append(FP16x16 { mag: 5046272, sign: false }); + data.append(FP16x16 { mag: 6029312, sign: false }); + data.append(FP16x16 { mag: 4325376, sign: false }); + data.append(FP16x16 { mag: 6160384, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 5242880, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 8060928, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: true }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: true }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: true }); + data.append(FP16x16 { mag: 4718592, sign: true }); + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 8126464, sign: true }); + data.append(FP16x16 { mag: 3276800, sign: true }); + data.append(FP16x16 { mag: 1572864, sign: true }); + data.append(FP16x16 { mag: 786432, sign: true }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 6946816, sign: true }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 6029312, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 8126464, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 7208960, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: true }); + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: true }); + data.append(FP16x16 { mag: 6160384, sign: true }); + data.append(FP16x16 { mag: 8192000, sign: true }); + data.append(FP16x16 { mag: 1572864, sign: true }); + data.append(FP16x16 { mag: 7143424, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 983040, sign: true }); + data.append(FP16x16 { mag: 5046272, sign: true }); + data.append(FP16x16 { mag: 7208960, sign: true }); + data.append(FP16x16 { mag: 4521984, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: true }); + data.append(FP16x16 { mag: 6946816, sign: false }); + data.append(FP16x16 { mag: 8192000, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: true }); + data.append(FP16x16 { mag: 6946816, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 2883584, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: true }); + data.append(FP16x16 { mag: 5439488, sign: true }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: true }); + data.append(FP16x16 { mag: 7929856, sign: false }); + data.append(FP16x16 { mag: 6422528, sign: true }); + data.append(FP16x16 { mag: 4194304, sign: true }); + data.append(FP16x16 { mag: 7274496, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 589824, sign: true }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: true }); + data.append(FP16x16 { mag: 5636096, sign: false }); + data.append(FP16x16 { mag: 5373952, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: true }); + data.append(FP16x16 { mag: 6225920, sign: false }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 5046272, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: true }); + data.append(FP16x16 { mag: 7929856, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 6750208, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: true }); + data.append(FP16x16 { mag: 6553600, sign: true }); + data.append(FP16x16 { mag: 7995392, sign: true }); + data.append(FP16x16 { mag: 7405568, sign: true }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: true }); + data.append(FP16x16 { mag: 7340032, sign: true }); + data.append(FP16x16 { mag: 4980736, sign: true }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 6619136, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: true }); + data.append(FP16x16 { mag: 7864320, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: true }); + data.append(FP16x16 { mag: 5177344, sign: true }); + data.append(FP16x16 { mag: 6422528, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 5832704, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: true }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 5308416, sign: true }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 4849664, sign: true }); + data.append(FP16x16 { mag: 8060928, sign: true }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 7208960, sign: true }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 851968, sign: true }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: true }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 6946816, sign: true }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: true }); + data.append(FP16x16 { mag: 3014656, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 7733248, sign: false }); + data.append(FP16x16 { mag: 5505024, sign: false }); + data.append(FP16x16 { mag: 7602176, sign: true }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: true }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 7143424, sign: true }); + data.append(FP16x16 { mag: 6160384, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 786432, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 5636096, sign: false }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 4521984, sign: true }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 4390912, sign: true }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: true }); + data.append(FP16x16 { mag: 851968, sign: true }); + data.append(FP16x16 { mag: 524288, sign: true }); + data.append(FP16x16 { mag: 7143424, sign: true }); + data.append(FP16x16 { mag: 1638400, sign: true }); + data.append(FP16x16 { mag: 589824, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: false }); + data.append(FP16x16 { mag: 4325376, sign: true }); + data.append(FP16x16 { mag: 5046272, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: true }); + data.append(FP16x16 { mag: 3211264, sign: true }); + data.append(FP16x16 { mag: 8192000, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: true }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 5373952, sign: true }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 7208960, sign: false }); + data.append(FP16x16 { mag: 6029312, sign: true }); + data.append(FP16x16 { mag: 2949120, sign: true }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: true }); + data.append(FP16x16 { mag: 2555904, sign: true }); + data.append(FP16x16 { mag: 4128768, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: true }); + data.append(FP16x16 { mag: 5373952, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: true }); + data.append(FP16x16 { mag: 524288, sign: true }); + data.append(FP16x16 { mag: 3276800, sign: true }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: false }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: true }); + data.append(FP16x16 { mag: 1572864, sign: true }); + data.append(FP16x16 { mag: 5701632, sign: true }); + data.append(FP16x16 { mag: 4259840, sign: true }); + data.append(FP16x16 { mag: 5701632, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: false }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 4521984, sign: true }); + data.append(FP16x16 { mag: 589824, sign: true }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 8257536, sign: true }); + data.append(FP16x16 { mag: 3276800, sign: true }); + data.append(FP16x16 { mag: 2031616, sign: true }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 6750208, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 6029312, sign: true }); + data.append(FP16x16 { mag: 1179648, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 7929856, sign: true }); + data.append(FP16x16 { mag: 7208960, sign: true }); + data.append(FP16x16 { mag: 4718592, sign: true }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 1835008, sign: true }); + data.append(FP16x16 { mag: 917504, sign: true }); + data.append(FP16x16 { mag: 4259840, sign: true }); + data.append(FP16x16 { mag: 5439488, sign: true }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 6881280, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 6225920, sign: true }); + data.append(FP16x16 { mag: 589824, sign: false }); + data.append(FP16x16 { mag: 5767168, sign: true }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 917504, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: true }); + data.append(FP16x16 { mag: 7929856, sign: true }); + data.append(FP16x16 { mag: 8192000, sign: true }); + data.append(FP16x16 { mag: 4718592, sign: true }); + data.append(FP16x16 { mag: 4587520, sign: false }); + data.append(FP16x16 { mag: 7274496, sign: true }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 8060928, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: true }); + data.append(FP16x16 { mag: 4521984, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: true }); + data.append(FP16x16 { mag: 2621440, sign: true }); + data.append(FP16x16 { mag: 6094848, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 7995392, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 1769472, sign: true }); + data.append(FP16x16 { mag: 1179648, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 2228224, sign: true }); + data.append(FP16x16 { mag: 8323072, sign: true }); + data.append(FP16x16 { mag: 2031616, sign: true }); + data.append(FP16x16 { mag: 1769472, sign: true }); + data.append(FP16x16 { mag: 7995392, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: true }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: true }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 5308416, sign: true }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 1572864, sign: true }); + data.append(FP16x16 { mag: 1769472, sign: true }); + data.append(FP16x16 { mag: 7995392, sign: false }); + data.append(FP16x16 { mag: 8192000, sign: false }); + data.append(FP16x16 { mag: 6619136, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: true }); + data.append(FP16x16 { mag: 7995392, sign: true }); + data.append(FP16x16 { mag: 6422528, sign: false }); + data.append(FP16x16 { mag: 1507328, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: true }); + data.append(FP16x16 { mag: 6946816, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: true }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: true }); + data.append(FP16x16 { mag: 6881280, sign: true }); + data.append(FP16x16 { mag: 524288, sign: true }); + data.append(FP16x16 { mag: 5767168, sign: true }); + data.append(FP16x16 { mag: 6422528, sign: true }); + data.append(FP16x16 { mag: 2883584, sign: true }); + data.append(FP16x16 { mag: 7405568, sign: true }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: true }); + data.append(FP16x16 { mag: 5636096, sign: false }); + data.append(FP16x16 { mag: 7602176, sign: true }); + data.append(FP16x16 { mag: 2752512, sign: true }); + data.append(FP16x16 { mag: 2686976, sign: true }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 589824, sign: true }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 4521984, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 8323072, sign: true }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 6619136, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 1179648, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: true }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 6356992, sign: false }); + data.append(FP16x16 { mag: 5767168, sign: false }); + data.append(FP16x16 { mag: 6750208, sign: true }); + data.append(FP16x16 { mag: 7012352, sign: true }); + data.append(FP16x16 { mag: 8126464, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 4980736, sign: true }); + data.append(FP16x16 { mag: 2228224, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: true }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 7471104, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: true }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: true }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: true }); + data.append(FP16x16 { mag: 3276800, sign: true }); + data.append(FP16x16 { mag: 1966080, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 8257536, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: true }); + data.append(FP16x16 { mag: 1114112, sign: true }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 3276800, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: false }); + data.append(FP16x16 { mag: 7405568, sign: true }); + data.append(FP16x16 { mag: 4849664, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 8192000, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: true }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 6422528, sign: false }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 1376256, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 7274496, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 917504, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 4980736, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 4587520, sign: true }); + data.append(FP16x16 { mag: 2621440, sign: true }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: true }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 655360, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 2031616, sign: true }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 6225920, sign: false }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 5832704, sign: true }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 7274496, sign: false }); + data.append(FP16x16 { mag: 7471104, sign: true }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 2949120, sign: true }); + data.append(FP16x16 { mag: 327680, sign: true }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 3211264, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 4587520, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: true }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: true }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 6160384, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 6160384, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: true }); + data.append(FP16x16 { mag: 851968, sign: true }); + data.append(FP16x16 { mag: 6815744, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: true }); + data.append(FP16x16 { mag: 3997696, sign: true }); + data.append(FP16x16 { mag: 2031616, sign: false }); + data.append(FP16x16 { mag: 655360, sign: true }); + data.append(FP16x16 { mag: 6094848, sign: true }); + data.append(FP16x16 { mag: 4849664, sign: true }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: false }); + data.append(FP16x16 { mag: 7340032, sign: true }); + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 4456448, sign: true }); + data.append(FP16x16 { mag: 7340032, sign: false }); + data.append(FP16x16 { mag: 6619136, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: true }); + data.append(FP16x16 { mag: 3407872, sign: true }); + data.append(FP16x16 { mag: 6422528, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: true }); + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: true }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 7864320, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: true }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 8126464, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 6619136, sign: false }); + data.append(FP16x16 { mag: 6160384, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: true }); + data.append(FP16x16 { mag: 6160384, sign: true }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 7340032, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: true }); + data.append(FP16x16 { mag: 6160384, sign: false }); + data.append(FP16x16 { mag: 4784128, sign: true }); + data.append(FP16x16 { mag: 5505024, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: true }); + data.append(FP16x16 { mag: 6488064, sign: true }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: true }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 7667712, sign: true }); + data.append(FP16x16 { mag: 6881280, sign: true }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 7733248, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 589824, sign: true }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 7012352, sign: true }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: true }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 8126464, sign: true }); + data.append(FP16x16 { mag: 6094848, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: false }); + data.append(FP16x16 { mag: 7208960, sign: false }); + data.append(FP16x16 { mag: 7929856, sign: true }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 5373952, sign: true }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 7995392, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: true }); + data.append(FP16x16 { mag: 2686976, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: true }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: true }); + data.append(FP16x16 { mag: 6619136, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 5767168, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: false }); + data.append(FP16x16 { mag: 917504, sign: true }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 6356992, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: true }); + data.append(FP16x16 { mag: 4587520, sign: true }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 5505024, sign: true }); + data.append(FP16x16 { mag: 5505024, sign: true }); + data.append(FP16x16 { mag: 3866624, sign: true }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 3473408, sign: true }); + data.append(FP16x16 { mag: 1966080, sign: true }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 983040, sign: true }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: true }); + data.append(FP16x16 { mag: 6029312, sign: true }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 8126464, sign: false }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 7143424, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: true }); + data.append(FP16x16 { mag: 7733248, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: false }); + data.append(FP16x16 { mag: 6619136, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: true }); + data.append(FP16x16 { mag: 2949120, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 1835008, sign: true }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 2818048, sign: true }); + data.append(FP16x16 { mag: 5046272, sign: true }); + data.append(FP16x16 { mag: 4128768, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 1966080, sign: true }); + data.append(FP16x16 { mag: 6488064, sign: true }); + data.append(FP16x16 { mag: 6160384, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 7602176, sign: true }); + data.append(FP16x16 { mag: 1966080, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 7602176, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 7208960, sign: false }); + data.append(FP16x16 { mag: 6553600, sign: true }); + data.append(FP16x16 { mag: 6553600, sign: false }); + data.append(FP16x16 { mag: 5963776, sign: true }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 7405568, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 8126464, sign: false }); + data.append(FP16x16 { mag: 8192000, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 5439488, sign: true }); + data.append(FP16x16 { mag: 8192000, sign: false }); + data.append(FP16x16 { mag: 7340032, sign: true }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 3342336, sign: false }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 4980736, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: true }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 6225920, sign: true }); + data.append(FP16x16 { mag: 1310720, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 6225920, sign: true }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 5111808, sign: true }); + data.append(FP16x16 { mag: 5832704, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 7995392, sign: false }); + data.append(FP16x16 { mag: 7274496, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 7405568, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 6094848, sign: true }); + data.append(FP16x16 { mag: 7405568, sign: false }); + data.append(FP16x16 { mag: 2752512, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: true }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 655360, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 7340032, sign: false }); + data.append(FP16x16 { mag: 7405568, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: true }); + data.append(FP16x16 { mag: 5111808, sign: true }); + data.append(FP16x16 { mag: 7995392, sign: true }); + data.append(FP16x16 { mag: 8257536, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 6881280, sign: true }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 6029312, sign: false }); + data.append(FP16x16 { mag: 7929856, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: true }); + data.append(FP16x16 { mag: 4456448, sign: false }); + data.append(FP16x16 { mag: 6094848, sign: false }); + data.append(FP16x16 { mag: 7143424, sign: false }); + data.append(FP16x16 { mag: 1048576, sign: true }); + data.append(FP16x16 { mag: 5832704, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: true }); + data.append(FP16x16 { mag: 1835008, sign: false }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 8060928, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 7143424, sign: false }); + data.append(FP16x16 { mag: 8060928, sign: true }); + data.append(FP16x16 { mag: 1966080, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: false }); + data.append(FP16x16 { mag: 5373952, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: false }); + data.append(FP16x16 { mag: 5308416, sign: true }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: true }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 6356992, sign: true }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: false }); + data.append(FP16x16 { mag: 5767168, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: true }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 2293760, sign: false }); + data.append(FP16x16 { mag: 4718592, sign: true }); + data.append(FP16x16 { mag: 8257536, sign: false }); + data.append(FP16x16 { mag: 2949120, sign: true }); + data.append(FP16x16 { mag: 4128768, sign: true }); + data.append(FP16x16 { mag: 7405568, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: true }); + data.append(FP16x16 { mag: 7274496, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: true }); + data.append(FP16x16 { mag: 3866624, sign: true }); + data.append(FP16x16 { mag: 3014656, sign: false }); + data.append(FP16x16 { mag: 7274496, sign: false }); + data.append(FP16x16 { mag: 7405568, sign: true }); + data.append(FP16x16 { mag: 4915200, sign: true }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 5636096, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 6881280, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 3932160, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 7471104, sign: true }); + data.append(FP16x16 { mag: 4784128, sign: true }); + data.append(FP16x16 { mag: 2818048, sign: false }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 6422528, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 5636096, sign: true }); + data.append(FP16x16 { mag: 2097152, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: false }); + data.append(FP16x16 { mag: 2818048, sign: true }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 786432, sign: true }); + data.append(FP16x16 { mag: 1507328, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 1507328, sign: true }); + data.append(FP16x16 { mag: 7077888, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 851968, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 7667712, sign: true }); + data.append(FP16x16 { mag: 983040, sign: false }); + data.append(FP16x16 { mag: 2883584, sign: true }); + data.append(FP16x16 { mag: 2228224, sign: false }); + data.append(FP16x16 { mag: 7471104, sign: true }); + data.append(FP16x16 { mag: 7077888, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: false }); + data.append(FP16x16 { mag: 6946816, sign: true }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 7012352, sign: false }); + data.append(FP16x16 { mag: 4390912, sign: true }); + data.append(FP16x16 { mag: 6946816, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: true }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 4784128, sign: true }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 6160384, sign: true }); + data.append(FP16x16 { mag: 3801088, sign: true }); + data.append(FP16x16 { mag: 7798784, sign: false }); + data.append(FP16x16 { mag: 983040, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: true }); + data.append(FP16x16 { mag: 2818048, sign: true }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 1703936, sign: true }); + data.append(FP16x16 { mag: 4325376, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: true }); + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 4063232, sign: true }); + data.append(FP16x16 { mag: 1507328, sign: true }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: true }); + data.append(FP16x16 { mag: 3735552, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: false }); + data.append(FP16x16 { mag: 6356992, sign: true }); + data.append(FP16x16 { mag: 5308416, sign: true }); + data.append(FP16x16 { mag: 5373952, sign: true }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 4456448, sign: true }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 4259840, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: false }); + data.append(FP16x16 { mag: 6881280, sign: true }); + data.append(FP16x16 { mag: 3538944, sign: true }); + data.append(FP16x16 { mag: 5767168, sign: false }); + data.append(FP16x16 { mag: 4521984, sign: false }); + data.append(FP16x16 { mag: 2490368, sign: true }); + data.append(FP16x16 { mag: 6160384, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 7471104, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: true }); + data.append(FP16x16 { mag: 1572864, sign: true }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 5767168, sign: false }); + data.append(FP16x16 { mag: 3997696, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: false }); + data.append(FP16x16 { mag: 1769472, sign: false }); + data.append(FP16x16 { mag: 393216, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: true }); + data.append(FP16x16 { mag: 2162688, sign: true }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 1572864, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 3538944, sign: true }); + data.append(FP16x16 { mag: 8192000, sign: false }); + data.append(FP16x16 { mag: 327680, sign: false }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 4390912, sign: false }); + data.append(FP16x16 { mag: 3670016, sign: false }); + data.append(FP16x16 { mag: 1245184, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: false }); + data.append(FP16x16 { mag: 2359296, sign: true }); + data.append(FP16x16 { mag: 2752512, sign: true }); + data.append(FP16x16 { mag: 7208960, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 4653056, sign: true }); + data.append(FP16x16 { mag: 7405568, sign: false }); + data.append(FP16x16 { mag: 3080192, sign: true }); + data.append(FP16x16 { mag: 4456448, sign: true }); + data.append(FP16x16 { mag: 7077888, sign: true }); + data.append(FP16x16 { mag: 1638400, sign: false }); + data.append(FP16x16 { mag: 720896, sign: false }); + data.append(FP16x16 { mag: 6619136, sign: false }); + data.append(FP16x16 { mag: 1900544, sign: true }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 1835008, sign: true }); + data.append(FP16x16 { mag: 4587520, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: true }); + data.append(FP16x16 { mag: 5767168, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: true }); + data.append(FP16x16 { mag: 6356992, sign: true }); + data.append(FP16x16 { mag: 4194304, sign: false }); + data.append(FP16x16 { mag: 6750208, sign: true }); + data.append(FP16x16 { mag: 7929856, sign: false }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 1966080, sign: false }); + data.append(FP16x16 { mag: 7340032, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 7471104, sign: true }); + data.append(FP16x16 { mag: 4980736, sign: true }); + data.append(FP16x16 { mag: 6815744, sign: true }); + data.append(FP16x16 { mag: 3604480, sign: true }); + data.append(FP16x16 { mag: 7667712, sign: false }); + data.append(FP16x16 { mag: 6553600, sign: false }); + data.append(FP16x16 { mag: 1310720, sign: false }); + data.append(FP16x16 { mag: 4849664, sign: false }); + data.append(FP16x16 { mag: 6815744, sign: false }); + data.append(FP16x16 { mag: 524288, sign: true }); + data.append(FP16x16 { mag: 6881280, sign: false }); + data.append(FP16x16 { mag: 2621440, sign: false }); + data.append(FP16x16 { mag: 655360, sign: false }); + data.append(FP16x16 { mag: 4259840, sign: false }); + data.append(FP16x16 { mag: 851968, sign: false }); + data.append(FP16x16 { mag: 6094848, sign: false }); + data.append(FP16x16 { mag: 5111808, sign: false }); + data.append(FP16x16 { mag: 3932160, sign: false }); + data.append(FP16x16 { mag: 3604480, sign: true }); + data.append(FP16x16 { mag: 2293760, sign: true }); + data.append(FP16x16 { mag: 4980736, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp16x16_3d/output_0.cairo b/src/tests/nodes/slice_fp16x16_3d/output_0.cairo new file mode 100644 index 000000000..44a771ce3 --- /dev/null +++ b/src/tests/nodes/slice_fp16x16_3d/output_0.cairo @@ -0,0 +1,75 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP16x16 { mag: 1245184, sign: true }); + data.append(FP16x16 { mag: 6029312, sign: false }); + data.append(FP16x16 { mag: 720896, sign: true }); + data.append(FP16x16 { mag: 2621440, sign: true }); + data.append(FP16x16 { mag: 3342336, sign: true }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 3145728, sign: true }); + data.append(FP16x16 { mag: 6750208, sign: false }); + data.append(FP16x16 { mag: 6946816, sign: false }); + data.append(FP16x16 { mag: 7864320, sign: true }); + data.append(FP16x16 { mag: 4259840, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: true }); + data.append(FP16x16 { mag: 786432, sign: true }); + data.append(FP16x16 { mag: 1048576, sign: false }); + data.append(FP16x16 { mag: 524288, sign: false }); + data.append(FP16x16 { mag: 1114112, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 7012352, sign: true }); + data.append(FP16x16 { mag: 7012352, sign: true }); + data.append(FP16x16 { mag: 3407872, sign: false }); + data.append(FP16x16 { mag: 4194304, sign: true }); + data.append(FP16x16 { mag: 2293760, sign: true }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: true }); + data.append(FP16x16 { mag: 393216, sign: false }); + data.append(FP16x16 { mag: 1441792, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 2555904, sign: true }); + data.append(FP16x16 { mag: 1114112, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 6291456, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 458752, sign: true }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 4653056, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: false }); + data.append(FP16x16 { mag: 5570560, sign: false }); + data.append(FP16x16 { mag: 8257536, sign: true }); + data.append(FP16x16 { mag: 3866624, sign: false }); + data.append(FP16x16 { mag: 6488064, sign: false }); + data.append(FP16x16 { mag: 5963776, sign: false }); + data.append(FP16x16 { mag: 786432, sign: false }); + data.append(FP16x16 { mag: 5242880, sign: true }); + data.append(FP16x16 { mag: 1441792, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 2490368, sign: false }); + data.append(FP16x16 { mag: 5177344, sign: false }); + data.append(FP16x16 { mag: 6684672, sign: false }); + data.append(FP16x16 { mag: 3801088, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 5898240, sign: true }); + data.append(FP16x16 { mag: 2883584, sign: true }); + data.append(FP16x16 { mag: 5242880, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: false }); + data.append(FP16x16 { mag: 2097152, sign: false }); + data.append(FP16x16 { mag: 2686976, sign: true }); + data.append(FP16x16 { mag: 3473408, sign: false }); + data.append(FP16x16 { mag: 7536640, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp8x23_2d.cairo b/src/tests/nodes/slice_fp8x23_2d.cairo new file mode 100644 index 000000000..cd24eb21e --- /dev/null +++ b/src/tests/nodes/slice_fp8x23_2d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_fp8x23_2d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp8x23_2d/input_0.cairo b/src/tests/nodes/slice_fp8x23_2d/input_0.cairo new file mode 100644 index 000000000..c9e2ae785 --- /dev/null +++ b/src/tests/nodes/slice_fp8x23_2d/input_0.cairo @@ -0,0 +1,22 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(4); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 83886080, sign: true }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp8x23_2d/output_0.cairo b/src/tests/nodes/slice_fp8x23_2d/output_0.cairo new file mode 100644 index 000000000..a886aebd9 --- /dev/null +++ b/src/tests/nodes/slice_fp8x23_2d/output_0.cairo @@ -0,0 +1,18 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::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: 25165824, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp8x23_3d.cairo b/src/tests/nodes/slice_fp8x23_3d.cairo new file mode 100644 index 000000000..0d1dc6f49 --- /dev/null +++ b/src/tests/nodes/slice_fp8x23_3d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_fp8x23_3d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp8x23_3d/input_0.cairo b/src/tests/nodes/slice_fp8x23_3d/input_0.cairo new file mode 100644 index 000000000..3ae4fc538 --- /dev/null +++ b/src/tests/nodes/slice_fp8x23_3d/input_0.cairo @@ -0,0 +1,1015 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn input_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(20); + shape.append(10); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 754974720, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: true }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 947912704, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: true }); + data.append(FP8x23 { mag: 293601280, sign: true }); + data.append(FP8x23 { mag: 662700032, sign: true }); + data.append(FP8x23 { mag: 696254464, sign: true }); + data.append(FP8x23 { mag: 704643072, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 805306368, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: true }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: true }); + data.append(FP8x23 { mag: 1048576000, sign: true }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 1056964608, sign: false }); + data.append(FP8x23 { mag: 973078528, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 947912704, sign: false }); + data.append(FP8x23 { mag: 1048576000, sign: true }); + data.append(FP8x23 { mag: 562036736, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 260046848, sign: true }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 956301312, sign: false }); + data.append(FP8x23 { mag: 595591168, sign: true }); + data.append(FP8x23 { mag: 369098752, sign: true }); + data.append(FP8x23 { mag: 603979776, sign: true }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 889192448, sign: true }); + data.append(FP8x23 { mag: 1056964608, sign: true }); + data.append(FP8x23 { mag: 125829120, sign: true }); + data.append(FP8x23 { mag: 620756992, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 1040187392, sign: true }); + data.append(FP8x23 { mag: 830472192, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: true }); + data.append(FP8x23 { mag: 880803840, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 939524096, sign: true }); + data.append(FP8x23 { mag: 796917760, sign: true }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 1056964608, sign: true }); + data.append(FP8x23 { mag: 629145600, sign: true }); + data.append(FP8x23 { mag: 872415232, sign: true }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 478150656, sign: true }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: true }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 754974720, sign: true }); + data.append(FP8x23 { mag: 763363328, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: true }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 1015021568, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 855638016, sign: true }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 134217728, sign: true }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 872415232, sign: false }); + data.append(FP8x23 { mag: 1056964608, sign: false }); + data.append(FP8x23 { mag: 905969664, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 562036736, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 520093696, sign: false }); + data.append(FP8x23 { mag: 796917760, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 578813952, sign: true }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 922746880, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: true }); + data.append(FP8x23 { mag: 1040187392, sign: false }); + data.append(FP8x23 { mag: 679477248, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 880803840, sign: true }); + data.append(FP8x23 { mag: 914358272, sign: false }); + data.append(FP8x23 { mag: 931135488, sign: false }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 838860800, sign: true }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 905969664, sign: true }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 738197504, sign: true }); + data.append(FP8x23 { mag: 721420288, sign: true }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: true }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 947912704, sign: true }); + data.append(FP8x23 { mag: 402653184, sign: true }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 805306368, sign: true }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 780140544, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 1040187392, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 939524096, sign: true }); + data.append(FP8x23 { mag: 855638016, sign: true }); + data.append(FP8x23 { mag: 620756992, sign: true }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 721420288, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 1040187392, sign: true }); + data.append(FP8x23 { mag: 998244352, sign: true }); + data.append(FP8x23 { mag: 352321536, sign: true }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 268435456, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: true }); + data.append(FP8x23 { mag: 880803840, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: true }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 864026624, sign: true }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 713031680, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 142606336, sign: true }); + data.append(FP8x23 { mag: 578813952, sign: true }); + data.append(FP8x23 { mag: 922746880, sign: true }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 1048576000, sign: false }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 822083584, sign: true }); + data.append(FP8x23 { mag: 796917760, sign: false }); + data.append(FP8x23 { mag: 813694976, sign: true }); + data.append(FP8x23 { mag: 134217728, sign: true }); + data.append(FP8x23 { mag: 838860800, sign: true }); + data.append(FP8x23 { mag: 855638016, sign: false }); + data.append(FP8x23 { mag: 1065353216, sign: true }); + data.append(FP8x23 { mag: 662700032, sign: true }); + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 729808896, sign: true }); + data.append(FP8x23 { mag: 696254464, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 830472192, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 704643072, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 1006632960, sign: false }); + data.append(FP8x23 { mag: 478150656, sign: true }); + data.append(FP8x23 { mag: 696254464, sign: false }); + data.append(FP8x23 { mag: 847249408, sign: false }); + data.append(FP8x23 { mag: 1040187392, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: true }); + data.append(FP8x23 { mag: 452984832, sign: true }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 922746880, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: true }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 939524096, sign: true }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 1023410176, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: true }); + data.append(FP8x23 { mag: 947912704, sign: true }); + data.append(FP8x23 { mag: 226492416, sign: true }); + data.append(FP8x23 { mag: 754974720, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: true }); + data.append(FP8x23 { mag: 134217728, sign: false }); + data.append(FP8x23 { mag: 830472192, sign: true }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 603979776, sign: true }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 461373440, sign: true }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 763363328, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 855638016, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: true }); + data.append(FP8x23 { mag: 780140544, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 914358272, sign: true }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 956301312, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 880803840, sign: true }); + data.append(FP8x23 { mag: 897581056, sign: true }); + data.append(FP8x23 { mag: 528482304, sign: true }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 998244352, sign: true }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 545259520, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: true }); + data.append(FP8x23 { mag: 956301312, sign: true }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 729808896, sign: true }); + data.append(FP8x23 { mag: 1065353216, sign: true }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 713031680, sign: true }); + data.append(FP8x23 { mag: 578813952, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 696254464, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 377487360, sign: true }); + data.append(FP8x23 { mag: 671088640, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 947912704, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: true }); + data.append(FP8x23 { mag: 822083584, sign: false }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: true }); + data.append(FP8x23 { mag: 780140544, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 713031680, sign: true }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 956301312, sign: true }); + data.append(FP8x23 { mag: 973078528, sign: false }); + data.append(FP8x23 { mag: 729808896, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: true }); + data.append(FP8x23 { mag: 301989888, sign: true }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: false }); + data.append(FP8x23 { mag: 830472192, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 872415232, sign: true }); + data.append(FP8x23 { mag: 880803840, sign: true }); + data.append(FP8x23 { mag: 360710144, sign: true }); + data.append(FP8x23 { mag: 771751936, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 889192448, sign: true }); + data.append(FP8x23 { mag: 763363328, sign: true }); + data.append(FP8x23 { mag: 268435456, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 696254464, sign: true }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 864026624, sign: false }); + data.append(FP8x23 { mag: 880803840, sign: true }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 578813952, sign: true }); + data.append(FP8x23 { mag: 1056964608, sign: true }); + data.append(FP8x23 { mag: 494927872, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 771751936, sign: true }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 780140544, sign: false }); + data.append(FP8x23 { mag: 545259520, sign: true }); + data.append(FP8x23 { mag: 251658240, sign: true }); + data.append(FP8x23 { mag: 864026624, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 838860800, sign: true }); + data.append(FP8x23 { mag: 369098752, sign: true }); + data.append(FP8x23 { mag: 713031680, sign: false }); + data.append(FP8x23 { mag: 813694976, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: true }); + data.append(FP8x23 { mag: 1065353216, sign: true }); + data.append(FP8x23 { mag: 192937984, sign: true }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 981467136, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 562036736, sign: true }); + data.append(FP8x23 { mag: 201326592, sign: true }); + data.append(FP8x23 { mag: 578813952, sign: true }); + data.append(FP8x23 { mag: 947912704, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: false }); + data.append(FP8x23 { mag: 880803840, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 813694976, sign: false }); + data.append(FP8x23 { mag: 696254464, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 201326592, sign: true }); + data.append(FP8x23 { mag: 92274688, sign: true }); + data.append(FP8x23 { mag: 494927872, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: true }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 872415232, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 905969664, sign: true }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: false }); + data.append(FP8x23 { mag: 1056964608, sign: true }); + data.append(FP8x23 { mag: 402653184, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: true }); + data.append(FP8x23 { mag: 452984832, sign: true }); + data.append(FP8x23 { mag: 226492416, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 721420288, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: true }); + data.append(FP8x23 { mag: 805306368, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: true }); + data.append(FP8x23 { mag: 973078528, sign: false }); + data.append(FP8x23 { mag: 318767104, sign: true }); + data.append(FP8x23 { mag: 889192448, sign: true }); + data.append(FP8x23 { mag: 914358272, sign: true }); + data.append(FP8x23 { mag: 184549376, sign: true }); + data.append(FP8x23 { mag: 234881024, sign: true }); + data.append(FP8x23 { mag: 444596224, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 956301312, sign: true }); + data.append(FP8x23 { mag: 830472192, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: false }); + data.append(FP8x23 { mag: 939524096, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 889192448, sign: true }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: true }); + data.append(FP8x23 { mag: 729808896, sign: false }); + data.append(FP8x23 { mag: 763363328, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: true }); + data.append(FP8x23 { mag: 545259520, sign: true }); + data.append(FP8x23 { mag: 503316480, sign: true }); + data.append(FP8x23 { mag: 100663296, sign: true }); + data.append(FP8x23 { mag: 377487360, sign: true }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 813694976, sign: false }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 234881024, sign: true }); + data.append(FP8x23 { mag: 796917760, sign: false }); + data.append(FP8x23 { mag: 939524096, sign: false }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: true }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: true }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 545259520, sign: true }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: true }); + data.append(FP8x23 { mag: 847249408, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 75497472, sign: true }); + data.append(FP8x23 { mag: 327155712, sign: true }); + data.append(FP8x23 { mag: 939524096, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 478150656, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: true }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 914358272, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 956301312, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 947912704, sign: true }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 704643072, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 914358272, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: true }); + data.append(FP8x23 { mag: 603979776, sign: true }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 713031680, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: true }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 805306368, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 1056964608, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: true }); + data.append(FP8x23 { mag: 981467136, sign: false }); + data.append(FP8x23 { mag: 671088640, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 813694976, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: true }); + data.append(FP8x23 { mag: 872415232, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 545259520, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: true }); + data.append(FP8x23 { mag: 981467136, sign: false }); + data.append(FP8x23 { mag: 369098752, sign: true }); + data.append(FP8x23 { mag: 184549376, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: true }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 520093696, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: true }); + data.append(FP8x23 { mag: 201326592, sign: true }); + data.append(FP8x23 { mag: 721420288, sign: true }); + data.append(FP8x23 { mag: 511705088, sign: true }); + data.append(FP8x23 { mag: 142606336, sign: true }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 1015021568, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: true }); + data.append(FP8x23 { mag: 645922816, sign: true }); + data.append(FP8x23 { mag: 1065353216, sign: true }); + data.append(FP8x23 { mag: 394264576, sign: true }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: true }); + data.append(FP8x23 { mag: 956301312, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 822083584, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: true }); + data.append(FP8x23 { mag: 486539264, sign: true }); + data.append(FP8x23 { mag: 528482304, sign: true }); + data.append(FP8x23 { mag: 167772160, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 914358272, sign: false }); + data.append(FP8x23 { mag: 696254464, sign: true }); + data.append(FP8x23 { mag: 92274688, sign: true }); + data.append(FP8x23 { mag: 511705088, sign: false }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 939524096, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 830472192, sign: true }); + data.append(FP8x23 { mag: 301989888, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: true }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: true }); + data.append(FP8x23 { mag: 595591168, sign: true }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 1056964608, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: false }); + data.append(FP8x23 { mag: 855638016, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: true }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 822083584, sign: true }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 905969664, sign: true }); + data.append(FP8x23 { mag: 385875968, sign: true }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 545259520, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: true }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: true }); + data.append(FP8x23 { mag: 704643072, sign: true }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 796917760, sign: true }); + data.append(FP8x23 { mag: 494927872, sign: true }); + data.append(FP8x23 { mag: 813694976, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 914358272, sign: false }); + data.append(FP8x23 { mag: 998244352, sign: false }); + data.append(FP8x23 { mag: 763363328, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 780140544, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: true }); + data.append(FP8x23 { mag: 553648128, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 947912704, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: true }); + data.append(FP8x23 { mag: 771751936, sign: true }); + data.append(FP8x23 { mag: 1048576000, sign: true }); + data.append(FP8x23 { mag: 763363328, sign: false }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 1056964608, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 905969664, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: true }); + data.append(FP8x23 { mag: 192937984, sign: true }); + data.append(FP8x23 { mag: 570425344, sign: true }); + data.append(FP8x23 { mag: 83886080, sign: false }); + data.append(FP8x23 { mag: 704643072, sign: false }); + data.append(FP8x23 { mag: 771751936, sign: true }); + data.append(FP8x23 { mag: 872415232, sign: false }); + data.append(FP8x23 { mag: 704643072, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: true }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 788529152, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 486539264, sign: true }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 880803840, sign: false }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 872415232, sign: true }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: true }); + data.append(FP8x23 { mag: 545259520, sign: true }); + data.append(FP8x23 { mag: 813694976, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: true }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: true }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: true }); + data.append(FP8x23 { mag: 1048576000, sign: true }); + data.append(FP8x23 { mag: 603979776, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 612368384, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 1006632960, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 696254464, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: false }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 268435456, sign: true }); + data.append(FP8x23 { mag: 369098752, sign: false }); + data.append(FP8x23 { mag: 595591168, sign: true }); + data.append(FP8x23 { mag: 813694976, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 956301312, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: true }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 679477248, sign: true }); + data.append(FP8x23 { mag: 394264576, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: true }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 796917760, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 595591168, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 872415232, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 268435456, sign: true }); + data.append(FP8x23 { mag: 998244352, sign: false }); + data.append(FP8x23 { mag: 754974720, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 1015021568, sign: false }); + data.append(FP8x23 { mag: 813694976, sign: true }); + data.append(FP8x23 { mag: 939524096, sign: true }); + data.append(FP8x23 { mag: 301989888, sign: true }); + data.append(FP8x23 { mag: 234881024, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: true }); + data.append(FP8x23 { mag: 587202560, sign: true }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 805306368, sign: true }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 142606336, sign: false }); + data.append(FP8x23 { mag: 830472192, sign: false }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 763363328, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 301989888, sign: false }); + data.append(FP8x23 { mag: 1023410176, sign: true }); + data.append(FP8x23 { mag: 352321536, sign: true }); + data.append(FP8x23 { mag: 562036736, sign: true }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: true }); + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: false }); + data.append(FP8x23 { mag: 352321536, sign: true }); + data.append(FP8x23 { mag: 167772160, sign: true }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: true }); + data.append(FP8x23 { mag: 998244352, sign: true }); + data.append(FP8x23 { mag: 377487360, sign: true }); + data.append(FP8x23 { mag: 746586112, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 889192448, sign: false }); + data.append(FP8x23 { mag: 419430400, sign: true }); + data.append(FP8x23 { mag: 553648128, sign: true }); + data.append(FP8x23 { mag: 100663296, sign: false }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 444596224, sign: true }); + data.append(FP8x23 { mag: 520093696, sign: true }); + data.append(FP8x23 { mag: 989855744, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 134217728, sign: true }); + data.append(FP8x23 { mag: 855638016, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: true }); + data.append(FP8x23 { mag: 520093696, sign: true }); + data.append(FP8x23 { mag: 822083584, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: true }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 989855744, sign: true }); + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 956301312, sign: true }); + data.append(FP8x23 { mag: 905969664, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 570425344, sign: true }); + data.append(FP8x23 { mag: 805306368, sign: true }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 520093696, sign: true }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 167772160, sign: true }); + data.append(FP8x23 { mag: 478150656, sign: true }); + data.append(FP8x23 { mag: 922746880, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 713031680, sign: false }); + data.append(FP8x23 { mag: 922746880, sign: true }); + data.append(FP8x23 { mag: 1040187392, sign: false }); + data.append(FP8x23 { mag: 763363328, sign: true }); + data.append(FP8x23 { mag: 402653184, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: true }); + data.append(FP8x23 { mag: 989855744, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: true }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 620756992, sign: true }); + data.append(FP8x23 { mag: 301989888, sign: true }); + data.append(FP8x23 { mag: 503316480, sign: false }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 864026624, sign: true }); + data.append(FP8x23 { mag: 310378496, sign: true }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 176160768, sign: true }); + data.append(FP8x23 { mag: 864026624, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 603979776, sign: true }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 570425344, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 595591168, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 134217728, sign: true }); + data.append(FP8x23 { mag: 478150656, sign: true }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 973078528, sign: true }); + data.append(FP8x23 { mag: 788529152, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 75497472, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 914358272, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 822083584, sign: false }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 637534208, sign: true }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 939524096, sign: true }); + data.append(FP8x23 { mag: 268435456, sign: true }); + data.append(FP8x23 { mag: 595591168, sign: true }); + data.append(FP8x23 { mag: 637534208, sign: true }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: true }); + data.append(FP8x23 { mag: 964689920, sign: true }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 704643072, sign: true }); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 209715200, sign: true }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: true }); + data.append(FP8x23 { mag: 679477248, sign: true }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 100663296, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 864026624, sign: true }); + data.append(FP8x23 { mag: 167772160, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 780140544, sign: true }); + data.append(FP8x23 { mag: 763363328, sign: false }); + data.append(FP8x23 { mag: 587202560, sign: false }); + data.append(FP8x23 { mag: 478150656, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: true }); + data.append(FP8x23 { mag: 931135488, sign: true }); + data.append(FP8x23 { mag: 125829120, sign: true }); + data.append(FP8x23 { mag: 620756992, sign: true }); + data.append(FP8x23 { mag: 796917760, sign: true }); + data.append(FP8x23 { mag: 469762048, sign: false }); + data.append(FP8x23 { mag: 1015021568, sign: false }); + data.append(FP8x23 { mag: 847249408, sign: true }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 159383552, sign: true }); + data.append(FP8x23 { mag: 201326592, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 377487360, sign: false }); + data.append(FP8x23 { mag: 293601280, sign: false }); + data.append(FP8x23 { mag: 763363328, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 570425344, sign: false }); + data.append(FP8x23 { mag: 192937984, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: true }); + data.append(FP8x23 { mag: 150994944, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: true }); + data.append(FP8x23 { mag: 721420288, sign: true }); + data.append(FP8x23 { mag: 243269632, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: true }); + data.append(FP8x23 { mag: 251658240, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 763363328, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 796917760, sign: false }); + data.append(FP8x23 { mag: 989855744, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 746586112, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: true }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 754974720, sign: false }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 503316480, sign: true }); + data.append(FP8x23 { mag: 192937984, sign: true }); + data.append(FP8x23 { mag: 511705088, sign: true }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: false }); + data.append(FP8x23 { mag: 452984832, sign: false }); + data.append(FP8x23 { mag: 931135488, sign: false }); + data.append(FP8x23 { mag: 1040187392, sign: false }); + data.append(FP8x23 { mag: 738197504, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 612368384, sign: true }); + data.append(FP8x23 { mag: 511705088, sign: true }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 562036736, sign: false }); + data.append(FP8x23 { mag: 1006632960, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: false }); + data.append(FP8x23 { mag: 411041792, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: true }); + data.append(FP8x23 { mag: 662700032, sign: true }); + data.append(FP8x23 { mag: 788529152, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: true }); + data.append(FP8x23 { mag: 746586112, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 780140544, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 125829120, sign: true }); + data.append(FP8x23 { mag: 763363328, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: false }); + data.append(FP8x23 { mag: 469762048, sign: true }); + data.append(FP8x23 { mag: 922746880, sign: true }); + data.append(FP8x23 { mag: 545259520, sign: true }); + data.append(FP8x23 { mag: 981467136, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: true }); + data.append(FP8x23 { mag: 511705088, sign: true }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 503316480, sign: true }); + data.append(FP8x23 { mag: 184549376, sign: false }); + data.append(FP8x23 { mag: 394264576, sign: true }); + data.append(FP8x23 { mag: 411041792, sign: true }); + data.append(FP8x23 { mag: 620756992, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 327155712, sign: true }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 1040187392, sign: true }); + data.append(FP8x23 { mag: 134217728, sign: true }); + data.append(FP8x23 { mag: 889192448, sign: true }); + data.append(FP8x23 { mag: 352321536, sign: false }); + data.append(FP8x23 { mag: 998244352, sign: true }); + data.append(FP8x23 { mag: 838860800, sign: true }); + data.append(FP8x23 { mag: 318767104, sign: true }); + data.append(FP8x23 { mag: 318767104, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 754974720, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 419430400, sign: true }); + data.append(FP8x23 { mag: 394264576, sign: true }); + data.append(FP8x23 { mag: 75497472, sign: true }); + data.append(FP8x23 { mag: 285212672, sign: true }); + data.append(FP8x23 { mag: 931135488, sign: false }); + data.append(FP8x23 { mag: 134217728, sign: true }); + data.append(FP8x23 { mag: 301989888, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 83886080, sign: true }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 310378496, sign: true }); + data.append(FP8x23 { mag: 771751936, sign: true }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 754974720, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: true }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 880803840, sign: false }); + data.append(FP8x23 { mag: 780140544, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 922746880, sign: true }); + data.append(FP8x23 { mag: 771751936, sign: true }); + data.append(FP8x23 { mag: 796917760, sign: false }); + data.append(FP8x23 { mag: 511705088, sign: true }); + data.append(FP8x23 { mag: 947912704, sign: false }); + data.append(FP8x23 { mag: 260046848, sign: true }); + data.append(FP8x23 { mag: 536870912, sign: true }); + data.append(FP8x23 { mag: 645922816, sign: true }); + data.append(FP8x23 { mag: 1015021568, sign: false }); + data.append(FP8x23 { mag: 813694976, sign: false }); + data.append(FP8x23 { mag: 771751936, sign: true }); + data.append(FP8x23 { mag: 478150656, sign: true }); + data.append(FP8x23 { mag: 956301312, sign: true }); + data.append(FP8x23 { mag: 830472192, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: false }); + data.append(FP8x23 { mag: 444596224, sign: true }); + data.append(FP8x23 { mag: 335544320, sign: true }); + data.append(FP8x23 { mag: 654311424, sign: false }); + data.append(FP8x23 { mag: 536870912, sign: false }); + data.append(FP8x23 { mag: 704643072, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 973078528, sign: true }); + data.append(FP8x23 { mag: 486539264, sign: false }); + data.append(FP8x23 { mag: 822083584, sign: false }); + data.append(FP8x23 { mag: 436207616, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 1048576000, sign: true }); + data.append(FP8x23 { mag: 150994944, sign: false }); + data.append(FP8x23 { mag: 738197504, sign: false }); + data.append(FP8x23 { mag: 964689920, sign: false }); + data.append(FP8x23 { mag: 285212672, sign: true }); + data.append(FP8x23 { mag: 511705088, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: true }); + data.append(FP8x23 { mag: 494927872, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_fp8x23_3d/output_0.cairo b/src/tests/nodes/slice_fp8x23_3d/output_0.cairo new file mode 100644 index 000000000..89e4051c3 --- /dev/null +++ b/src/tests/nodes/slice_fp8x23_3d/output_0.cairo @@ -0,0 +1,75 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(FP8x23 { mag: 754974720, sign: true }); + data.append(FP8x23 { mag: 176160768, sign: false }); + data.append(FP8x23 { mag: 553648128, sign: true }); + data.append(FP8x23 { mag: 67108864, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: true }); + data.append(FP8x23 { mag: 461373440, sign: false }); + data.append(FP8x23 { mag: 528482304, sign: false }); + data.append(FP8x23 { mag: 805306368, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 310378496, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: false }); + data.append(FP8x23 { mag: 947912704, sign: false }); + data.append(FP8x23 { mag: 1048576000, sign: true }); + data.append(FP8x23 { mag: 562036736, sign: true }); + data.append(FP8x23 { mag: 1056964608, sign: true }); + data.append(FP8x23 { mag: 125829120, sign: true }); + data.append(FP8x23 { mag: 620756992, sign: true }); + data.append(FP8x23 { mag: 1031798784, sign: false }); + data.append(FP8x23 { mag: 109051904, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 1040187392, sign: true }); + data.append(FP8x23 { mag: 830472192, sign: false }); + data.append(FP8x23 { mag: 629145600, sign: false }); + data.append(FP8x23 { mag: 402653184, sign: true }); + data.append(FP8x23 { mag: 687865856, sign: false }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: true }); + data.append(FP8x23 { mag: 285212672, sign: false }); + data.append(FP8x23 { mag: 662700032, sign: false }); + data.append(FP8x23 { mag: 92274688, sign: false }); + data.append(FP8x23 { mag: 637534208, sign: false }); + data.append(FP8x23 { mag: 1015021568, sign: false }); + data.append(FP8x23 { mag: 494927872, sign: false }); + data.append(FP8x23 { mag: 1023410176, sign: false }); + data.append(FP8x23 { mag: 251658240, sign: false }); + data.append(FP8x23 { mag: 50331648, sign: false }); + data.append(FP8x23 { mag: 226492416, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 562036736, sign: true }); + data.append(FP8x23 { mag: 218103808, sign: false }); + data.append(FP8x23 { mag: 520093696, sign: false }); + data.append(FP8x23 { mag: 796917760, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 117440512, sign: true }); + data.append(FP8x23 { mag: 109051904, sign: false }); + data.append(FP8x23 { mag: 880803840, sign: true }); + data.append(FP8x23 { mag: 914358272, sign: false }); + data.append(FP8x23 { mag: 931135488, sign: false }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 645922816, sign: false }); + data.append(FP8x23 { mag: 687865856, sign: true }); + data.append(FP8x23 { mag: 947912704, sign: true }); + data.append(FP8x23 { mag: 402653184, sign: true }); + data.append(FP8x23 { mag: 343932928, sign: true }); + data.append(FP8x23 { mag: 578813952, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 1006632960, sign: true }); + data.append(FP8x23 { mag: 276824064, sign: true }); + data.append(FP8x23 { mag: 939524096, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i32_2d.cairo b/src/tests/nodes/slice_i32_2d.cairo new file mode 100644 index 000000000..2fa14a6ee --- /dev/null +++ b/src/tests/nodes/slice_i32_2d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_i32_2d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i32_2d/input_0.cairo b/src/tests/nodes/slice_i32_2d/input_0.cairo new file mode 100644 index 000000000..17cdb26b0 --- /dev/null +++ b/src/tests/nodes/slice_i32_2d/input_0.cairo @@ -0,0 +1,21 @@ +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(4); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 68, sign: true }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 55, sign: true }); + data.append(i32 { mag: 119, sign: true }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 73, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i32_2d/output_0.cairo b/src/tests/nodes/slice_i32_2d/output_0.cairo new file mode 100644 index 000000000..62871c4ec --- /dev/null +++ b/src/tests/nodes/slice_i32_2d/output_0.cairo @@ -0,0 +1,17 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 73, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i32_3d.cairo b/src/tests/nodes/slice_i32_3d.cairo new file mode 100644 index 000000000..13b9f712a --- /dev/null +++ b/src/tests/nodes/slice_i32_3d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_i32_3d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i32_3d/input_0.cairo b/src/tests/nodes/slice_i32_3d/input_0.cairo new file mode 100644 index 000000000..1fa19b3e6 --- /dev/null +++ b/src/tests/nodes/slice_i32_3d/input_0.cairo @@ -0,0 +1,1014 @@ +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(20); + shape.append(10); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 113, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 31, sign: true }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 69, sign: true }); + data.append(i32 { mag: 78, sign: true }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 34, sign: true }); + data.append(i32 { mag: 31, sign: true }); + data.append(i32 { mag: 78, sign: true }); + data.append(i32 { mag: 64, sign: true }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 120, sign: true }); + data.append(i32 { mag: 123, sign: true }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 118, sign: false }); + data.append(i32 { mag: 102, sign: true }); + data.append(i32 { mag: 109, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 85, sign: false }); + data.append(i32 { mag: 59, sign: true }); + data.append(i32 { mag: 49, sign: true }); + data.append(i32 { mag: 126, sign: true }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 43, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 109, sign: true }); + data.append(i32 { mag: 78, sign: true }); + data.append(i32 { mag: 56, sign: true }); + data.append(i32 { mag: 77, sign: true }); + data.append(i32 { mag: 9, sign: true }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 94, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 113, sign: true }); + data.append(i32 { mag: 127, sign: true }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 95, sign: false }); + data.append(i32 { mag: 93, sign: true }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 110, sign: false }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 52, sign: true }); + data.append(i32 { mag: 66, sign: true }); + data.append(i32 { mag: 94, sign: true }); + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 18, sign: true }); + data.append(i32 { mag: 40, sign: true }); + data.append(i32 { mag: 120, sign: true }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 118, sign: true }); + data.append(i32 { mag: 114, sign: true }); + data.append(i32 { mag: 53, sign: true }); + data.append(i32 { mag: 106, sign: true }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 38, sign: true }); + data.append(i32 { mag: 89, sign: true }); + data.append(i32 { mag: 51, sign: true }); + data.append(i32 { mag: 97, sign: false }); + data.append(i32 { mag: 13, sign: true }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 48, sign: true }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 112, sign: true }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 115, sign: true }); + data.append(i32 { mag: 72, sign: true }); + data.append(i32 { mag: 115, sign: false }); + data.append(i32 { mag: 90, sign: true }); + data.append(i32 { mag: 121, sign: false }); + data.append(i32 { mag: 46, sign: true }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 45, sign: true }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 72, sign: true }); + data.append(i32 { mag: 94, sign: true }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 126, sign: true }); + data.append(i32 { mag: 49, sign: true }); + data.append(i32 { mag: 113, sign: false }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 58, sign: false }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 58, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 15, sign: true }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 14, sign: true }); + data.append(i32 { mag: 77, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 78, sign: true }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 43, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 101, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 119, sign: false }); + data.append(i32 { mag: 108, sign: false }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 38, sign: true }); + data.append(i32 { mag: 56, sign: true }); + data.append(i32 { mag: 123, sign: false }); + data.append(i32 { mag: 81, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 53, sign: false }); + data.append(i32 { mag: 85, sign: false }); + data.append(i32 { mag: 126, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 95, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 79, sign: true }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 94, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 77, sign: true }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 102, sign: true }); + data.append(i32 { mag: 112, sign: true }); + data.append(i32 { mag: 77, sign: true }); + data.append(i32 { mag: 121, sign: true }); + data.append(i32 { mag: 106, sign: false }); + data.append(i32 { mag: 116, sign: false }); + data.append(i32 { mag: 56, sign: true }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 120, sign: false }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 13, sign: true }); + data.append(i32 { mag: 32, sign: true }); + data.append(i32 { mag: 127, sign: true }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 30, sign: true }); + data.append(i32 { mag: 72, sign: false }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 68, sign: false }); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 105, sign: true }); + data.append(i32 { mag: 93, sign: true }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 127, sign: true }); + data.append(i32 { mag: 108, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 45, sign: true }); + data.append(i32 { mag: 53, sign: false }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 19, sign: true }); + data.append(i32 { mag: 120, sign: true }); + data.append(i32 { mag: 31, sign: true }); + data.append(i32 { mag: 126, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 111, sign: false }); + data.append(i32 { mag: 98, sign: false }); + data.append(i32 { mag: 70, sign: true }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 94, sign: false }); + data.append(i32 { mag: 119, sign: false }); + data.append(i32 { mag: 57, sign: true }); + data.append(i32 { mag: 122, sign: true }); + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 123, sign: true }); + data.append(i32 { mag: 110, sign: true }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 126, sign: true }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 68, sign: true }); + data.append(i32 { mag: 99, sign: true }); + data.append(i32 { mag: 82, sign: false }); + data.append(i32 { mag: 60, sign: false }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 114, sign: true }); + data.append(i32 { mag: 88, sign: false }); + data.append(i32 { mag: 122, sign: true }); + data.append(i32 { mag: 89, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 116, sign: false }); + data.append(i32 { mag: 27, sign: false }); + data.append(i32 { mag: 104, sign: true }); + data.append(i32 { mag: 61, sign: true }); + data.append(i32 { mag: 30, sign: true }); + data.append(i32 { mag: 92, sign: false }); + data.append(i32 { mag: 15, sign: true }); + data.append(i32 { mag: 48, sign: true }); + data.append(i32 { mag: 54, sign: true }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 82, sign: false }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 62, sign: true }); + data.append(i32 { mag: 7, sign: true }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 38, sign: true }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 124, sign: true }); + data.append(i32 { mag: 43, sign: true }); + data.append(i32 { mag: 92, sign: false }); + data.append(i32 { mag: 24, sign: true }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 95, sign: false }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 93, sign: true }); + data.append(i32 { mag: 65, sign: true }); + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 58, sign: true }); + data.append(i32 { mag: 122, sign: false }); + data.append(i32 { mag: 103, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 118, sign: false }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 108, sign: true }); + data.append(i32 { mag: 103, sign: true }); + data.append(i32 { mag: 65, sign: true }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 43, sign: true }); + data.append(i32 { mag: 124, sign: true }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 41, sign: true }); + data.append(i32 { mag: 16, sign: true }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 28, sign: true }); + data.append(i32 { mag: 80, sign: false }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 84, sign: true }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 31, sign: true }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 120, sign: true }); + data.append(i32 { mag: 105, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 62, sign: true }); + data.append(i32 { mag: 85, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 93, sign: false }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 81, sign: true }); + data.append(i32 { mag: 91, sign: false }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 117, sign: true }); + data.append(i32 { mag: 44, sign: true }); + data.append(i32 { mag: 78, sign: true }); + data.append(i32 { mag: 95, sign: false }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 13, sign: true }); + data.append(i32 { mag: 101, sign: true }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 14, sign: true }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 116, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 98, sign: false }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 117, sign: false }); + data.append(i32 { mag: 93, sign: false }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 44, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 120, sign: false }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 99, sign: true }); + data.append(i32 { mag: 86, sign: true }); + data.append(i32 { mag: 109, sign: true }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 8, sign: true }); + data.append(i32 { mag: 122, sign: false }); + data.append(i32 { mag: 117, sign: true }); + data.append(i32 { mag: 110, sign: false }); + data.append(i32 { mag: 81, sign: true }); + data.append(i32 { mag: 68, sign: false }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 96, sign: true }); + data.append(i32 { mag: 115, sign: false }); + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 10, sign: true }); + data.append(i32 { mag: 85, sign: true }); + data.append(i32 { mag: 102, sign: false }); + data.append(i32 { mag: 52, sign: true }); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 40, sign: true }); + data.append(i32 { mag: 20, sign: true }); + data.append(i32 { mag: 52, sign: false }); + data.append(i32 { mag: 87, sign: false }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 118, sign: true }); + data.append(i32 { mag: 41, sign: true }); + data.append(i32 { mag: 22, sign: true }); + data.append(i32 { mag: 103, sign: false }); + data.append(i32 { mag: 98, sign: false }); + data.append(i32 { mag: 26, sign: true }); + data.append(i32 { mag: 95, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 40, sign: true }); + data.append(i32 { mag: 92, sign: false }); + data.append(i32 { mag: 108, sign: false }); + data.append(i32 { mag: 89, sign: true }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 10, sign: true }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 24, sign: true }); + data.append(i32 { mag: 39, sign: true }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 71, sign: true }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 87, sign: false }); + data.append(i32 { mag: 46, sign: true }); + data.append(i32 { mag: 28, sign: true }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 101, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 80, sign: true }); + data.append(i32 { mag: 53, sign: true }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 119, sign: true }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 27, sign: true }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 108, sign: true }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 27, sign: true }); + data.append(i32 { mag: 116, sign: false }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 80, sign: true }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 34, sign: true }); + data.append(i32 { mag: 77, sign: true }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 121, sign: true }); + data.append(i32 { mag: 122, sign: false }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 80, sign: true }); + data.append(i32 { mag: 89, sign: true }); + data.append(i32 { mag: 84, sign: false }); + data.append(i32 { mag: 86, sign: true }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 123, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 126, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 26, sign: true }); + data.append(i32 { mag: 115, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 16, sign: true }); + data.append(i32 { mag: 104, sign: true }); + data.append(i32 { mag: 57, sign: true }); + data.append(i32 { mag: 126, sign: false }); + data.append(i32 { mag: 60, sign: false }); + data.append(i32 { mag: 37, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 65, sign: true }); + data.append(i32 { mag: 109, sign: true }); + data.append(i32 { mag: 98, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 29, sign: true }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 79, sign: false }); + data.append(i32 { mag: 85, sign: false }); + data.append(i32 { mag: 69, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 81, sign: false }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 103, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 120, sign: true }); + data.append(i32 { mag: 45, sign: true }); + data.append(i32 { mag: 67, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 30, sign: true }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 80, sign: false }); + data.append(i32 { mag: 26, sign: true }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 118, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 124, sign: true }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 112, sign: true }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 65, sign: true }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 86, sign: true }); + data.append(i32 { mag: 87, sign: false }); + data.append(i32 { mag: 68, sign: false }); + data.append(i32 { mag: 112, sign: true }); + data.append(i32 { mag: 104, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 67, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 84, sign: true }); + data.append(i32 { mag: 90, sign: false }); + data.append(i32 { mag: 113, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 114, sign: true }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 99, sign: true }); + data.append(i32 { mag: 82, sign: true }); + data.append(i32 { mag: 92, sign: false }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 109, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 13, sign: true }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 102, sign: true }); + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 95, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 32, sign: true }); + data.append(i32 { mag: 62, sign: true }); + data.append(i32 { mag: 90, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 39, sign: true }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 64, sign: true }); + data.append(i32 { mag: 97, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 119, sign: true }); + data.append(i32 { mag: 68, sign: true }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 79, sign: true }); + data.append(i32 { mag: 101, sign: false }); + data.append(i32 { mag: 81, sign: true }); + data.append(i32 { mag: 73, sign: true }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 6, sign: true }); + data.append(i32 { mag: 80, sign: true }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 13, sign: true }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 43, sign: true }); + data.append(i32 { mag: 89, sign: false }); + data.append(i32 { mag: 17, sign: true }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 80, sign: false }); + data.append(i32 { mag: 83, sign: false }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 123, sign: false }); + data.append(i32 { mag: 81, sign: false }); + data.append(i32 { mag: 97, sign: false }); + data.append(i32 { mag: 73, sign: true }); + data.append(i32 { mag: 108, sign: false }); + data.append(i32 { mag: 34, sign: true }); + data.append(i32 { mag: 89, sign: true }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 42, sign: false }); + data.append(i32 { mag: 71, sign: true }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 18, sign: true }); + data.append(i32 { mag: 127, sign: true }); + data.append(i32 { mag: 11, sign: true }); + data.append(i32 { mag: 57, sign: true }); + data.append(i32 { mag: 39, sign: true }); + data.append(i32 { mag: 87, sign: true }); + data.append(i32 { mag: 126, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 104, sign: true }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 90, sign: true }); + data.append(i32 { mag: 108, sign: true }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 75, sign: true }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 96, sign: true }); + data.append(i32 { mag: 70, sign: true }); + data.append(i32 { mag: 28, sign: true }); + data.append(i32 { mag: 27, sign: false }); + data.append(i32 { mag: 19, sign: false }); + data.append(i32 { mag: 63, sign: true }); + data.append(i32 { mag: 116, sign: false }); + data.append(i32 { mag: 85, sign: true }); + data.append(i32 { mag: 59, sign: true }); + data.append(i32 { mag: 33, sign: true }); + data.append(i32 { mag: 73, sign: true }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 30, sign: true }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 90, sign: true }); + data.append(i32 { mag: 38, sign: false }); + data.append(i32 { mag: 69, sign: true }); + data.append(i32 { mag: 120, sign: true }); + data.append(i32 { mag: 84, sign: false }); + data.append(i32 { mag: 19, sign: true }); + data.append(i32 { mag: 32, sign: true }); + data.append(i32 { mag: 16, sign: true }); + data.append(i32 { mag: 116, sign: true }); + data.append(i32 { mag: 78, sign: false }); + data.append(i32 { mag: 30, sign: true }); + data.append(i32 { mag: 61, sign: true }); + data.append(i32 { mag: 122, sign: true }); + data.append(i32 { mag: 112, sign: true }); + data.append(i32 { mag: 118, sign: true }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 117, sign: true }); + data.append(i32 { mag: 29, sign: true }); + data.append(i32 { mag: 103, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 113, sign: false }); + data.append(i32 { mag: 121, sign: false }); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 117, sign: false }); + data.append(i32 { mag: 31, sign: true }); + data.append(i32 { mag: 38, sign: true }); + data.append(i32 { mag: 10, sign: true }); + data.append(i32 { mag: 16, sign: true }); + data.append(i32 { mag: 104, sign: true }); + data.append(i32 { mag: 81, sign: true }); + data.append(i32 { mag: 74, sign: true }); + data.append(i32 { mag: 36, sign: false }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 14, sign: true }); + data.append(i32 { mag: 62, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 76, sign: true }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 91, sign: false }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 59, sign: true }); + data.append(i32 { mag: 87, sign: true }); + data.append(i32 { mag: 19, sign: true }); + data.append(i32 { mag: 24, sign: true }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 90, sign: false }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 60, sign: true }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 82, sign: true }); + data.append(i32 { mag: 85, sign: false }); + data.append(i32 { mag: 98, sign: true }); + data.append(i32 { mag: 27, sign: false }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 51, sign: true }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 119, sign: true }); + data.append(i32 { mag: 53, sign: true }); + data.append(i32 { mag: 61, sign: false }); + data.append(i32 { mag: 126, sign: false }); + data.append(i32 { mag: 90, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 14, sign: true }); + data.append(i32 { mag: 122, sign: false }); + data.append(i32 { mag: 113, sign: true }); + data.append(i32 { mag: 54, sign: true }); + data.append(i32 { mag: 51, sign: true }); + data.append(i32 { mag: 37, sign: true }); + data.append(i32 { mag: 9, sign: false }); + data.append(i32 { mag: 100, sign: false }); + data.append(i32 { mag: 94, sign: true }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 79, sign: true }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 91, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 60, sign: true }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 116, sign: true }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 83, sign: true }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 45, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 98, sign: false }); + data.append(i32 { mag: 66, sign: true }); + data.append(i32 { mag: 83, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 103, sign: true }); + data.append(i32 { mag: 54, sign: false }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 95, sign: true }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 53, sign: false }); + data.append(i32 { mag: 17, sign: true }); + data.append(i32 { mag: 90, sign: false }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 72, sign: true }); + data.append(i32 { mag: 92, sign: true }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 68, sign: true }); + data.append(i32 { mag: 29, sign: true }); + data.append(i32 { mag: 17, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 80, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 94, sign: false }); + data.append(i32 { mag: 91, sign: true }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 66, sign: true }); + data.append(i32 { mag: 44, sign: true }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 57, sign: true }); + data.append(i32 { mag: 117, sign: true }); + data.append(i32 { mag: 103, sign: true }); + data.append(i32 { mag: 98, sign: true }); + data.append(i32 { mag: 102, sign: true }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 110, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 99, sign: true }); + data.append(i32 { mag: 8, sign: true }); + data.append(i32 { mag: 18, sign: true }); + data.append(i32 { mag: 21, sign: false }); + data.append(i32 { mag: 11, sign: true }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 117, sign: false }); + data.append(i32 { mag: 60, sign: false }); + data.append(i32 { mag: 101, sign: false }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 18, sign: true }); + data.append(i32 { mag: 12, sign: true }); + data.append(i32 { mag: 12, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 78, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 41, sign: true }); + data.append(i32 { mag: 51, sign: true }); + data.append(i32 { mag: 82, sign: true }); + data.append(i32 { mag: 75, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 79, sign: false }); + data.append(i32 { mag: 111, sign: false }); + data.append(i32 { mag: 5, sign: false }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 85, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 89, sign: true }); + data.append(i32 { mag: 100, sign: false }); + data.append(i32 { mag: 20, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 74, sign: true }); + data.append(i32 { mag: 95, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 41, sign: true }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 83, sign: true }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 51, sign: false }); + data.append(i32 { mag: 34, sign: false }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 82, sign: true }); + data.append(i32 { mag: 71, sign: true }); + data.append(i32 { mag: 10, sign: true }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 90, sign: false }); + data.append(i32 { mag: 111, sign: false }); + data.append(i32 { mag: 115, sign: true }); + data.append(i32 { mag: 109, sign: false }); + data.append(i32 { mag: 90, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 93, sign: true }); + data.append(i32 { mag: 67, sign: true }); + data.append(i32 { mag: 77, sign: false }); + data.append(i32 { mag: 29, sign: true }); + data.append(i32 { mag: 50, sign: true }); + data.append(i32 { mag: 75, sign: true }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 104, sign: true }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 105, sign: true }); + data.append(i32 { mag: 106, sign: false }); + data.append(i32 { mag: 20, sign: true }); + data.append(i32 { mag: 41, sign: false }); + data.append(i32 { mag: 119, sign: false }); + data.append(i32 { mag: 88, sign: false }); + data.append(i32 { mag: 73, sign: true }); + data.append(i32 { mag: 108, sign: true }); + data.append(i32 { mag: 83, sign: false }); + data.append(i32 { mag: 7, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 56, sign: true }); + data.append(i32 { mag: 72, sign: false }); + data.append(i32 { mag: 40, sign: true }); + data.append(i32 { mag: 79, sign: true }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 117, sign: false }); + data.append(i32 { mag: 13, sign: true }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 71, sign: true }); + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 93, sign: false }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 22, sign: true }); + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 59, sign: true }); + data.append(i32 { mag: 41, sign: true }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 69, sign: true }); + data.append(i32 { mag: 52, sign: true }); + data.append(i32 { mag: 98, sign: false }); + data.append(i32 { mag: 91, sign: true }); + data.append(i32 { mag: 97, sign: true }); + data.append(i32 { mag: 82, sign: true }); + data.append(i32 { mag: 125, sign: false }); + data.append(i32 { mag: 93, sign: true }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 81, sign: true }); + data.append(i32 { mag: 115, sign: false }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 29, sign: true }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 83, sign: false }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 97, sign: true }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 75, sign: true }); + data.append(i32 { mag: 44, sign: false }); + data.append(i32 { mag: 65, sign: false }); + data.append(i32 { mag: 105, sign: false }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 59, sign: false }); + data.append(i32 { mag: 26, sign: true }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 80, sign: true }); + data.append(i32 { mag: 79, sign: true }); + data.append(i32 { mag: 11, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 117, sign: true }); + data.append(i32 { mag: 25, sign: false }); + data.append(i32 { mag: 53, sign: false }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 77, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 23, sign: true }); + data.append(i32 { mag: 73, sign: true }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 102, sign: true }); + data.append(i32 { mag: 35, sign: true }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 114, sign: true }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 7, sign: true }); + data.append(i32 { mag: 69, sign: true }); + data.append(i32 { mag: 85, sign: true }); + data.append(i32 { mag: 31, sign: false }); + data.append(i32 { mag: 87, sign: false }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 28, sign: true }); + data.append(i32 { mag: 77, sign: true }); + data.append(i32 { mag: 55, sign: true }); + data.append(i32 { mag: 115, sign: false }); + data.append(i32 { mag: 17, sign: true }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 71, sign: true }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 105, sign: true }); + data.append(i32 { mag: 114, sign: true }); + data.append(i32 { mag: 86, sign: false }); + data.append(i32 { mag: 23, sign: false }); + data.append(i32 { mag: 78, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 91, sign: true }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 115, sign: true }); + data.append(i32 { mag: 28, sign: true }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 70, sign: true }); + data.append(i32 { mag: 33, sign: false }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 17, sign: false }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 29, sign: false }); + data.append(i32 { mag: 122, sign: false }); + data.append(i32 { mag: 117, sign: false }); + data.append(i32 { mag: 96, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 66, sign: false }); + data.append(i32 { mag: 40, sign: true }); + data.append(i32 { mag: 47, sign: true }); + data.append(i32 { mag: 6, sign: false }); + data.append(i32 { mag: 124, sign: false }); + data.append(i32 { mag: 71, sign: false }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 104, sign: true }); + data.append(i32 { mag: 76, sign: false }); + data.append(i32 { mag: 20, sign: true }); + data.append(i32 { mag: 16, sign: false }); + data.append(i32 { mag: 103, sign: true }); + data.append(i32 { mag: 54, sign: true }); + data.append(i32 { mag: 92, sign: true }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 44, sign: true }); + data.append(i32 { mag: 49, sign: false }); + data.append(i32 { mag: 47, sign: false }); + data.append(i32 { mag: 100, sign: false }); + data.append(i32 { mag: 89, sign: false }); + data.append(i32 { mag: 70, sign: false }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 95, sign: true }); + data.append(i32 { mag: 28, sign: false }); + data.append(i32 { mag: 63, sign: true }); + data.append(i32 { mag: 52, sign: true }); + data.append(i32 { mag: 104, sign: true }); + data.append(i32 { mag: 50, sign: false }); + data.append(i32 { mag: 64, sign: false }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 7, sign: true }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 40, sign: true }); + data.append(i32 { mag: 88, sign: true }); + data.append(i32 { mag: 127, sign: true }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 102, sign: false }); + data.append(i32 { mag: 15, sign: false }); + data.append(i32 { mag: 37, sign: true }); + data.append(i32 { mag: 84, sign: true }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 80, sign: true }); + data.append(i32 { mag: 26, sign: false }); + data.append(i32 { mag: 30, sign: false }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 115, sign: false }); + data.append(i32 { mag: 8, sign: false }); + data.append(i32 { mag: 61, sign: true }); + data.append(i32 { mag: 37, sign: true }); + data.append(i32 { mag: 20, sign: true }); + data.append(i32 { mag: 10, sign: false }); + data.append(i32 { mag: 62, sign: true }); + data.append(i32 { mag: 110, sign: false }); + data.append(i32 { mag: 116, sign: true }); + data.append(i32 { mag: 53, sign: false }); + data.append(i32 { mag: 10, sign: true }); + data.append(i32 { mag: 6, sign: true }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 17, sign: true }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 68, sign: true }); + data.append(i32 { mag: 32, sign: true }); + data.append(i32 { mag: 127, sign: true }); + data.append(i32 { mag: 40, sign: true }); + data.append(i32 { mag: 20, sign: true }); + data.append(i32 { mag: 27, sign: true }); + data.append(i32 { mag: 68, sign: true }); + data.append(i32 { mag: 84, sign: false }); + data.append(i32 { mag: 15, sign: true }); + data.append(i32 { mag: 24, sign: false }); + data.append(i32 { mag: 87, sign: false }); + data.append(i32 { mag: 54, sign: true }); + data.append(i32 { mag: 34, sign: true }); + data.append(i32 { mag: 95, sign: true }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 121, sign: false }); + data.append(i32 { mag: 83, sign: true }); + data.append(i32 { mag: 25, sign: true }); + data.append(i32 { mag: 96, sign: false }); + data.append(i32 { mag: 69, sign: true }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 14, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 32, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 83, sign: false }); + data.append(i32 { mag: 52, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i32_3d/output_0.cairo b/src/tests/nodes/slice_i32_3d/output_0.cairo new file mode 100644 index 000000000..2b2e8dc38 --- /dev/null +++ b/src/tests/nodes/slice_i32_3d/output_0.cairo @@ -0,0 +1,74 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(i32 { mag: 113, sign: false }); + data.append(i32 { mag: 43, sign: false }); + data.append(i32 { mag: 31, sign: true }); + data.append(i32 { mag: 48, sign: false }); + data.append(i32 { mag: 69, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 40, sign: false }); + data.append(i32 { mag: 39, sign: false }); + data.append(i32 { mag: 118, sign: false }); + data.append(i32 { mag: 102, sign: true }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 109, sign: true }); + data.append(i32 { mag: 78, sign: true }); + data.append(i32 { mag: 56, sign: true }); + data.append(i32 { mag: 77, sign: true }); + data.append(i32 { mag: 93, sign: true }); + data.append(i32 { mag: 107, sign: false }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 110, sign: false }); + data.append(i32 { mag: 114, sign: false }); + data.append(i32 { mag: 42, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 52, sign: true }); + data.append(i32 { mag: 66, sign: true }); + data.append(i32 { mag: 94, sign: true }); + data.append(i32 { mag: 106, sign: true }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 38, sign: true }); + data.append(i32 { mag: 89, sign: true }); + data.append(i32 { mag: 51, sign: true }); + data.append(i32 { mag: 57, sign: false }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 35, sign: false }); + data.append(i32 { mag: 112, sign: true }); + data.append(i32 { mag: 18, sign: false }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 37, sign: false }); + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 56, sign: false }); + data.append(i32 { mag: 72, sign: true }); + data.append(i32 { mag: 94, sign: true }); + data.append(i32 { mag: 74, sign: false }); + data.append(i32 { mag: 126, sign: true }); + data.append(i32 { mag: 49, sign: true }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 63, sign: false }); + data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 21, sign: true }); + data.append(i32 { mag: 107, sign: true }); + data.append(i32 { mag: 100, sign: true }); + data.append(i32 { mag: 125, sign: true }); + data.append(i32 { mag: 119, sign: false }); + data.append(i32 { mag: 108, sign: false }); + data.append(i32 { mag: 112, sign: false }); + data.append(i32 { mag: 4, sign: false }); + data.append(i32 { mag: 67, sign: false }); + data.append(i32 { mag: 79, sign: true }); + data.append(i32 { mag: 99, sign: false }); + data.append(i32 { mag: 94, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i8_2d.cairo b/src/tests/nodes/slice_i8_2d.cairo new file mode 100644 index 000000000..f79e72a97 --- /dev/null +++ b/src/tests/nodes/slice_i8_2d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_i8_2d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i8_2d/input_0.cairo b/src/tests/nodes/slice_i8_2d/input_0.cairo new file mode 100644 index 000000000..5474f3f2f --- /dev/null +++ b/src/tests/nodes/slice_i8_2d/input_0.cairo @@ -0,0 +1,21 @@ +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(4); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 40, sign: true }); + data.append(i8 { mag: 19, sign: false }); + data.append(i8 { mag: 52, sign: false }); + data.append(i8 { mag: 14, sign: true }); + data.append(i8 { mag: 15, sign: true }); + data.append(i8 { mag: 122, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i8_2d/output_0.cairo b/src/tests/nodes/slice_i8_2d/output_0.cairo new file mode 100644 index 000000000..72c92ba48 --- /dev/null +++ b/src/tests/nodes/slice_i8_2d/output_0.cairo @@ -0,0 +1,17 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 40, sign: true }); + data.append(i8 { mag: 19, sign: false }); + data.append(i8 { mag: 15, sign: true }); + data.append(i8 { mag: 122, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i8_3d.cairo b/src/tests/nodes/slice_i8_3d.cairo new file mode 100644 index 000000000..c604d84a5 --- /dev/null +++ b/src/tests/nodes/slice_i8_3d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_i8_3d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i8_3d/input_0.cairo b/src/tests/nodes/slice_i8_3d/input_0.cairo new file mode 100644 index 000000000..d1a10d4ca --- /dev/null +++ b/src/tests/nodes/slice_i8_3d/input_0.cairo @@ -0,0 +1,1014 @@ +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(20); + shape.append(10); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 86, sign: false }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 48, sign: false }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 59, sign: false }); + data.append(i8 { mag: 64, sign: false }); + data.append(i8 { mag: 119, sign: true }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 115, sign: true }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 91, sign: true }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 72, sign: false }); + data.append(i8 { mag: 120, sign: true }); + data.append(i8 { mag: 29, sign: false }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 46, sign: false }); + data.append(i8 { mag: 39, sign: false }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 12, sign: false }); + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 35, sign: false }); + data.append(i8 { mag: 38, sign: false }); + data.append(i8 { mag: 63, sign: false }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 64, sign: true }); + data.append(i8 { mag: 101, sign: true }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 37, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 72, sign: true }); + data.append(i8 { mag: 9, sign: false }); + data.append(i8 { mag: 65, sign: true }); + data.append(i8 { mag: 48, sign: true }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 33, sign: true }); + data.append(i8 { mag: 35, sign: false }); + data.append(i8 { mag: 91, sign: true }); + data.append(i8 { mag: 39, sign: false }); + data.append(i8 { mag: 16, sign: true }); + data.append(i8 { mag: 109, sign: false }); + data.append(i8 { mag: 64, sign: false }); + data.append(i8 { mag: 71, sign: true }); + data.append(i8 { mag: 53, sign: false }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 99, sign: true }); + data.append(i8 { mag: 104, sign: true }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 59, sign: true }); + data.append(i8 { mag: 121, sign: true }); + data.append(i8 { mag: 83, sign: true }); + data.append(i8 { mag: 112, sign: false }); + data.append(i8 { mag: 20, sign: false }); + data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 55, sign: true }); + data.append(i8 { mag: 70, sign: true }); + data.append(i8 { mag: 107, sign: false }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 69, sign: true }); + data.append(i8 { mag: 64, sign: false }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 82, sign: true }); + data.append(i8 { mag: 10, sign: true }); + data.append(i8 { mag: 120, sign: false }); + data.append(i8 { mag: 45, sign: false }); + data.append(i8 { mag: 12, sign: true }); + data.append(i8 { mag: 95, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 82, sign: true }); + data.append(i8 { mag: 119, sign: false }); + data.append(i8 { mag: 110, sign: false }); + data.append(i8 { mag: 53, sign: false }); + data.append(i8 { mag: 55, sign: true }); + data.append(i8 { mag: 13, sign: true }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 70, sign: true }); + data.append(i8 { mag: 101, sign: false }); + data.append(i8 { mag: 99, sign: false }); + data.append(i8 { mag: 117, sign: false }); + data.append(i8 { mag: 92, sign: false }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 21, sign: false }); + data.append(i8 { mag: 20, sign: true }); + data.append(i8 { mag: 121, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 31, sign: true }); + data.append(i8 { mag: 50, sign: false }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 110, sign: true }); + data.append(i8 { mag: 114, sign: false }); + data.append(i8 { mag: 72, sign: false }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 110, sign: false }); + data.append(i8 { mag: 116, sign: false }); + data.append(i8 { mag: 74, sign: true }); + data.append(i8 { mag: 88, sign: true }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 25, sign: true }); + data.append(i8 { mag: 54, sign: true }); + data.append(i8 { mag: 103, sign: true }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 46, sign: false }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 34, sign: true }); + data.append(i8 { mag: 76, sign: true }); + data.append(i8 { mag: 64, sign: true }); + data.append(i8 { mag: 53, sign: true }); + data.append(i8 { mag: 92, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 53, sign: true }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 124, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 13, sign: false }); + data.append(i8 { mag: 98, sign: false }); + data.append(i8 { mag: 75, sign: true }); + data.append(i8 { mag: 111, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 31, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 29, sign: false }); + data.append(i8 { mag: 109, sign: true }); + data.append(i8 { mag: 108, sign: true }); + data.append(i8 { mag: 56, sign: true }); + data.append(i8 { mag: 83, sign: false }); + data.append(i8 { mag: 45, sign: true }); + data.append(i8 { mag: 48, sign: false }); + data.append(i8 { mag: 54, sign: false }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 76, sign: false }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 40, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 32, sign: false }); + data.append(i8 { mag: 29, sign: false }); + data.append(i8 { mag: 47, sign: false }); + data.append(i8 { mag: 117, sign: false }); + data.append(i8 { mag: 95, sign: false }); + data.append(i8 { mag: 36, sign: false }); + data.append(i8 { mag: 112, sign: false }); + data.append(i8 { mag: 105, sign: false }); + data.append(i8 { mag: 97, sign: true }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 97, sign: true }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 35, sign: false }); + data.append(i8 { mag: 61, sign: false }); + data.append(i8 { mag: 114, sign: false }); + data.append(i8 { mag: 49, sign: false }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 18, sign: false }); + data.append(i8 { mag: 87, sign: false }); + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 58, sign: false }); + data.append(i8 { mag: 82, sign: true }); + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 46, sign: true }); + data.append(i8 { mag: 45, sign: true }); + data.append(i8 { mag: 111, sign: false }); + data.append(i8 { mag: 44, sign: true }); + data.append(i8 { mag: 73, sign: true }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 35, sign: true }); + data.append(i8 { mag: 94, sign: false }); + data.append(i8 { mag: 91, sign: true }); + data.append(i8 { mag: 98, sign: false }); + data.append(i8 { mag: 26, sign: false }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 88, sign: false }); + data.append(i8 { mag: 101, sign: false }); + data.append(i8 { mag: 12, sign: true }); + data.append(i8 { mag: 23, sign: false }); + data.append(i8 { mag: 88, sign: true }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 108, sign: true }); + data.append(i8 { mag: 23, sign: true }); + data.append(i8 { mag: 44, sign: false }); + data.append(i8 { mag: 96, sign: true }); + data.append(i8 { mag: 17, sign: true }); + data.append(i8 { mag: 108, sign: false }); + data.append(i8 { mag: 61, sign: true }); + data.append(i8 { mag: 65, sign: false }); + data.append(i8 { mag: 69, sign: true }); + data.append(i8 { mag: 92, sign: true }); + data.append(i8 { mag: 120, sign: false }); + data.append(i8 { mag: 93, sign: false }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 61, sign: false }); + data.append(i8 { mag: 98, sign: false }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 90, sign: true }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 126, sign: true }); + data.append(i8 { mag: 78, sign: false }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 97, sign: false }); + data.append(i8 { mag: 23, sign: true }); + data.append(i8 { mag: 64, sign: true }); + data.append(i8 { mag: 57, sign: false }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 36, sign: false }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 104, sign: true }); + data.append(i8 { mag: 23, sign: true }); + data.append(i8 { mag: 59, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 117, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 8, sign: true }); + data.append(i8 { mag: 61, sign: true }); + data.append(i8 { mag: 125, sign: false }); + data.append(i8 { mag: 82, sign: true }); + data.append(i8 { mag: 62, sign: true }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 37, sign: true }); + data.append(i8 { mag: 30, sign: false }); + data.append(i8 { mag: 88, sign: true }); + data.append(i8 { mag: 22, sign: false }); + data.append(i8 { mag: 61, sign: true }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 115, sign: false }); + data.append(i8 { mag: 54, sign: true }); + data.append(i8 { mag: 39, sign: false }); + data.append(i8 { mag: 43, sign: true }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 8, sign: false }); + data.append(i8 { mag: 30, sign: false }); + data.append(i8 { mag: 80, sign: true }); + data.append(i8 { mag: 108, sign: false }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 125, sign: false }); + data.append(i8 { mag: 87, sign: false }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 48, sign: true }); + data.append(i8 { mag: 83, sign: true }); + data.append(i8 { mag: 38, sign: false }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 98, sign: false }); + data.append(i8 { mag: 45, sign: true }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 38, sign: true }); + data.append(i8 { mag: 93, sign: false }); + data.append(i8 { mag: 89, sign: false }); + data.append(i8 { mag: 24, sign: false }); + data.append(i8 { mag: 70, sign: true }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 44, sign: false }); + data.append(i8 { mag: 23, sign: true }); + data.append(i8 { mag: 18, sign: true }); + data.append(i8 { mag: 76, sign: true }); + data.append(i8 { mag: 93, sign: false }); + data.append(i8 { mag: 99, sign: false }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 26, sign: true }); + data.append(i8 { mag: 44, sign: true }); + data.append(i8 { mag: 33, sign: true }); + data.append(i8 { mag: 94, sign: false }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 62, sign: false }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 77, sign: false }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 102, sign: true }); + data.append(i8 { mag: 81, sign: true }); + data.append(i8 { mag: 109, sign: false }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 110, sign: true }); + data.append(i8 { mag: 22, sign: true }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 97, sign: true }); + data.append(i8 { mag: 77, sign: false }); + data.append(i8 { mag: 106, sign: false }); + data.append(i8 { mag: 35, sign: true }); + data.append(i8 { mag: 82, sign: true }); + data.append(i8 { mag: 24, sign: false }); + data.append(i8 { mag: 41, sign: true }); + data.append(i8 { mag: 84, sign: false }); + data.append(i8 { mag: 69, sign: false }); + data.append(i8 { mag: 16, sign: false }); + data.append(i8 { mag: 68, sign: false }); + data.append(i8 { mag: 38, sign: true }); + data.append(i8 { mag: 117, sign: false }); + data.append(i8 { mag: 15, sign: false }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 76, sign: true }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 51, sign: true }); + data.append(i8 { mag: 13, sign: false }); + data.append(i8 { mag: 118, sign: true }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 74, sign: true }); + data.append(i8 { mag: 64, sign: false }); + data.append(i8 { mag: 49, sign: true }); + data.append(i8 { mag: 38, sign: true }); + data.append(i8 { mag: 99, sign: false }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 124, sign: false }); + data.append(i8 { mag: 63, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 122, sign: false }); + data.append(i8 { mag: 100, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 48, sign: true }); + data.append(i8 { mag: 11, sign: true }); + data.append(i8 { mag: 31, sign: true }); + data.append(i8 { mag: 33, sign: true }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 116, sign: true }); + data.append(i8 { mag: 94, sign: true }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 58, sign: true }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 90, sign: false }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 117, sign: true }); + data.append(i8 { mag: 52, sign: true }); + data.append(i8 { mag: 39, sign: true }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 52, sign: true }); + data.append(i8 { mag: 94, sign: false }); + data.append(i8 { mag: 54, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 26, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 56, sign: true }); + data.append(i8 { mag: 78, sign: false }); + data.append(i8 { mag: 117, sign: true }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 54, sign: true }); + data.append(i8 { mag: 69, sign: false }); + data.append(i8 { mag: 99, sign: true }); + data.append(i8 { mag: 106, sign: false }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 102, sign: true }); + data.append(i8 { mag: 121, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 29, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 9, sign: true }); + data.append(i8 { mag: 53, sign: false }); + data.append(i8 { mag: 72, sign: false }); + data.append(i8 { mag: 93, sign: false }); + data.append(i8 { mag: 75, sign: true }); + data.append(i8 { mag: 61, sign: false }); + data.append(i8 { mag: 121, sign: false }); + data.append(i8 { mag: 49, sign: false }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 43, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 65, sign: false }); + data.append(i8 { mag: 105, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 114, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 19, sign: true }); + data.append(i8 { mag: 95, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 98, sign: true }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 82, sign: false }); + data.append(i8 { mag: 53, sign: false }); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 121, sign: false }); + data.append(i8 { mag: 31, sign: false }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 12, sign: true }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 42, sign: true }); + data.append(i8 { mag: 122, sign: false }); + data.append(i8 { mag: 98, sign: true }); + data.append(i8 { mag: 65, sign: false }); + data.append(i8 { mag: 36, sign: true }); + data.append(i8 { mag: 119, sign: false }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 101, sign: true }); + data.append(i8 { mag: 61, sign: false }); + data.append(i8 { mag: 50, sign: false }); + data.append(i8 { mag: 86, sign: false }); + data.append(i8 { mag: 77, sign: true }); + data.append(i8 { mag: 18, sign: false }); + data.append(i8 { mag: 74, sign: false }); + data.append(i8 { mag: 90, sign: true }); + data.append(i8 { mag: 28, sign: true }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 126, sign: false }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 39, sign: true }); + data.append(i8 { mag: 78, sign: false }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 110, sign: true }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 84, sign: false }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 77, sign: true }); + data.append(i8 { mag: 106, sign: false }); + data.append(i8 { mag: 27, sign: true }); + data.append(i8 { mag: 81, sign: true }); + data.append(i8 { mag: 57, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 107, sign: false }); + data.append(i8 { mag: 57, sign: true }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 61, sign: false }); + data.append(i8 { mag: 46, sign: true }); + data.append(i8 { mag: 64, sign: true }); + data.append(i8 { mag: 29, sign: false }); + data.append(i8 { mag: 45, sign: true }); + data.append(i8 { mag: 117, sign: false }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 117, sign: true }); + data.append(i8 { mag: 29, sign: true }); + data.append(i8 { mag: 37, sign: false }); + data.append(i8 { mag: 77, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 63, sign: false }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 52, sign: true }); + data.append(i8 { mag: 21, sign: false }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 118, sign: false }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 39, sign: true }); + data.append(i8 { mag: 52, sign: false }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 46, sign: false }); + data.append(i8 { mag: 74, sign: true }); + data.append(i8 { mag: 90, sign: true }); + data.append(i8 { mag: 31, sign: true }); + data.append(i8 { mag: 11, sign: true }); + data.append(i8 { mag: 88, sign: false }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 89, sign: false }); + data.append(i8 { mag: 75, sign: false }); + data.append(i8 { mag: 104, sign: true }); + data.append(i8 { mag: 9, sign: true }); + data.append(i8 { mag: 39, sign: false }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 50, sign: true }); + data.append(i8 { mag: 103, sign: true }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 42, sign: true }); + data.append(i8 { mag: 125, sign: false }); + data.append(i8 { mag: 49, sign: false }); + data.append(i8 { mag: 98, sign: true }); + data.append(i8 { mag: 9, sign: false }); + data.append(i8 { mag: 69, sign: false }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 119, sign: true }); + data.append(i8 { mag: 61, sign: false }); + data.append(i8 { mag: 55, sign: false }); + data.append(i8 { mag: 93, sign: false }); + data.append(i8 { mag: 75, sign: true }); + data.append(i8 { mag: 50, sign: true }); + data.append(i8 { mag: 108, sign: false }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 93, sign: false }); + data.append(i8 { mag: 49, sign: false }); + data.append(i8 { mag: 30, sign: false }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 63, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 58, sign: true }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 86, sign: false }); + data.append(i8 { mag: 50, sign: false }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 123, sign: true }); + data.append(i8 { mag: 84, sign: false }); + data.append(i8 { mag: 105, sign: false }); + data.append(i8 { mag: 37, sign: false }); + data.append(i8 { mag: 91, sign: false }); + data.append(i8 { mag: 8, sign: false }); + data.append(i8 { mag: 55, sign: true }); + data.append(i8 { mag: 27, sign: false }); + data.append(i8 { mag: 94, sign: false }); + data.append(i8 { mag: 109, sign: false }); + data.append(i8 { mag: 51, sign: false }); + data.append(i8 { mag: 77, sign: false }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 110, sign: true }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 61, sign: true }); + data.append(i8 { mag: 58, sign: false }); + data.append(i8 { mag: 68, sign: true }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 58, sign: true }); + data.append(i8 { mag: 103, sign: false }); + data.append(i8 { mag: 124, sign: true }); + data.append(i8 { mag: 47, sign: true }); + data.append(i8 { mag: 26, sign: false }); + data.append(i8 { mag: 52, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 90, sign: false }); + data.append(i8 { mag: 41, sign: true }); + data.append(i8 { mag: 60, sign: true }); + data.append(i8 { mag: 67, sign: true }); + data.append(i8 { mag: 48, sign: true }); + data.append(i8 { mag: 90, sign: false }); + data.append(i8 { mag: 24, sign: false }); + data.append(i8 { mag: 94, sign: false }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 111, sign: false }); + data.append(i8 { mag: 91, sign: false }); + data.append(i8 { mag: 124, sign: true }); + data.append(i8 { mag: 77, sign: false }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 74, sign: false }); + data.append(i8 { mag: 84, sign: false }); + data.append(i8 { mag: 115, sign: false }); + data.append(i8 { mag: 26, sign: false }); + data.append(i8 { mag: 119, sign: false }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 71, sign: true }); + data.append(i8 { mag: 68, sign: false }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 8, sign: false }); + data.append(i8 { mag: 76, sign: true }); + data.append(i8 { mag: 88, sign: true }); + data.append(i8 { mag: 74, sign: false }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 20, sign: true }); + data.append(i8 { mag: 8, sign: false }); + data.append(i8 { mag: 52, sign: true }); + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 110, sign: false }); + data.append(i8 { mag: 59, sign: false }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 102, sign: true }); + data.append(i8 { mag: 49, sign: false }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 124, sign: false }); + data.append(i8 { mag: 28, sign: true }); + data.append(i8 { mag: 62, sign: true }); + data.append(i8 { mag: 34, sign: true }); + data.append(i8 { mag: 10, sign: true }); + data.append(i8 { mag: 89, sign: false }); + data.append(i8 { mag: 20, sign: false }); + data.append(i8 { mag: 48, sign: true }); + data.append(i8 { mag: 116, sign: false }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 44, sign: false }); + data.append(i8 { mag: 107, sign: false }); + data.append(i8 { mag: 72, sign: true }); + data.append(i8 { mag: 37, sign: true }); + data.append(i8 { mag: 19, sign: false }); + data.append(i8 { mag: 20, sign: false }); + data.append(i8 { mag: 39, sign: true }); + data.append(i8 { mag: 126, sign: true }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 49, sign: true }); + data.append(i8 { mag: 35, sign: false }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 28, sign: true }); + data.append(i8 { mag: 88, sign: false }); + data.append(i8 { mag: 25, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 83, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 45, sign: false }); + data.append(i8 { mag: 20, sign: false }); + data.append(i8 { mag: 50, sign: true }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 65, sign: false }); + data.append(i8 { mag: 72, sign: true }); + data.append(i8 { mag: 104, sign: true }); + data.append(i8 { mag: 119, sign: false }); + data.append(i8 { mag: 127, sign: true }); + data.append(i8 { mag: 103, sign: false }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 120, sign: true }); + data.append(i8 { mag: 33, sign: true }); + data.append(i8 { mag: 9, sign: true }); + data.append(i8 { mag: 55, sign: false }); + data.append(i8 { mag: 58, sign: true }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 49, sign: true }); + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 77, sign: true }); + data.append(i8 { mag: 45, sign: true }); + data.append(i8 { mag: 19, sign: true }); + data.append(i8 { mag: 123, sign: true }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 105, sign: false }); + data.append(i8 { mag: 81, sign: true }); + data.append(i8 { mag: 108, sign: false }); + data.append(i8 { mag: 42, sign: true }); + data.append(i8 { mag: 59, sign: false }); + data.append(i8 { mag: 112, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 32, sign: true }); + data.append(i8 { mag: 87, sign: false }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 42, sign: true }); + data.append(i8 { mag: 65, sign: true }); + data.append(i8 { mag: 35, sign: true }); + data.append(i8 { mag: 57, sign: false }); + data.append(i8 { mag: 41, sign: false }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 94, sign: false }); + data.append(i8 { mag: 81, sign: false }); + data.append(i8 { mag: 14, sign: true }); + data.append(i8 { mag: 63, sign: true }); + data.append(i8 { mag: 84, sign: false }); + data.append(i8 { mag: 65, sign: false }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 120, sign: true }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 26, sign: false }); + data.append(i8 { mag: 25, sign: false }); + data.append(i8 { mag: 63, sign: true }); + data.append(i8 { mag: 51, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 68, sign: true }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 74, sign: false }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 57, sign: false }); + data.append(i8 { mag: 23, sign: false }); + data.append(i8 { mag: 93, sign: true }); + data.append(i8 { mag: 31, sign: true }); + data.append(i8 { mag: 118, sign: true }); + data.append(i8 { mag: 97, sign: false }); + data.append(i8 { mag: 28, sign: false }); + data.append(i8 { mag: 39, sign: true }); + data.append(i8 { mag: 44, sign: false }); + data.append(i8 { mag: 16, sign: false }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 48, sign: true }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 71, sign: true }); + data.append(i8 { mag: 51, sign: true }); + data.append(i8 { mag: 84, sign: false }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 69, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 62, sign: false }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 74, sign: true }); + data.append(i8 { mag: 20, sign: false }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 35, sign: true }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 53, sign: true }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 37, sign: false }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 45, sign: false }); + data.append(i8 { mag: 48, sign: true }); + data.append(i8 { mag: 7, sign: true }); + data.append(i8 { mag: 86, sign: true }); + data.append(i8 { mag: 11, sign: false }); + data.append(i8 { mag: 68, sign: true }); + data.append(i8 { mag: 102, sign: true }); + data.append(i8 { mag: 18, sign: false }); + data.append(i8 { mag: 74, sign: true }); + data.append(i8 { mag: 68, sign: true }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 16, sign: false }); + data.append(i8 { mag: 6, sign: false }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 38, sign: false }); + data.append(i8 { mag: 51, sign: false }); + data.append(i8 { mag: 15, sign: false }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 65, sign: true }); + data.append(i8 { mag: 124, sign: true }); + data.append(i8 { mag: 60, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 12, sign: true }); + data.append(i8 { mag: 122, sign: false }); + data.append(i8 { mag: 20, sign: false }); + data.append(i8 { mag: 114, sign: true }); + data.append(i8 { mag: 86, sign: false }); + data.append(i8 { mag: 52, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 27, sign: false }); + data.append(i8 { mag: 28, sign: true }); + data.append(i8 { mag: 29, sign: false }); + data.append(i8 { mag: 20, sign: true }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 83, sign: false }); + data.append(i8 { mag: 108, sign: false }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 50, sign: true }); + data.append(i8 { mag: 77, sign: false }); + data.append(i8 { mag: 45, sign: false }); + data.append(i8 { mag: 17, sign: false }); + data.append(i8 { mag: 13, sign: true }); + data.append(i8 { mag: 116, sign: false }); + data.append(i8 { mag: 34, sign: false }); + data.append(i8 { mag: 105, sign: true }); + data.append(i8 { mag: 17, sign: true }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 68, sign: true }); + data.append(i8 { mag: 102, sign: false }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 12, sign: false }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 24, sign: false }); + data.append(i8 { mag: 64, sign: false }); + data.append(i8 { mag: 12, sign: true }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 28, sign: true }); + data.append(i8 { mag: 14, sign: true }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 39, sign: false }); + data.append(i8 { mag: 99, sign: false }); + data.append(i8 { mag: 76, sign: false }); + data.append(i8 { mag: 56, sign: true }); + data.append(i8 { mag: 47, sign: false }); + data.append(i8 { mag: 117, sign: true }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 10, sign: true }); + data.append(i8 { mag: 8, sign: false }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 90, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 25, sign: false }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 45, sign: true }); + data.append(i8 { mag: 90, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 38, sign: true }); + data.append(i8 { mag: 88, sign: false }); + data.append(i8 { mag: 18, sign: true }); + data.append(i8 { mag: 122, sign: false }); + data.append(i8 { mag: 91, sign: true }); + data.append(i8 { mag: 71, sign: true }); + data.append(i8 { mag: 25, sign: true }); + data.append(i8 { mag: 85, sign: true }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 110, sign: false }); + data.append(i8 { mag: 21, sign: false }); + data.append(i8 { mag: 53, sign: true }); + data.append(i8 { mag: 46, sign: false }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 108, sign: false }); + data.append(i8 { mag: 44, sign: true }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 14, sign: true }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 92, sign: true }); + data.append(i8 { mag: 68, sign: true }); + data.append(i8 { mag: 65, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 120, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 64, sign: true }); + data.append(i8 { mag: 6, sign: true }); + data.append(i8 { mag: 126, sign: true }); + data.append(i8 { mag: 105, sign: true }); + data.append(i8 { mag: 89, sign: false }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 41, sign: false }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 94, sign: true }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 125, sign: true }); + data.append(i8 { mag: 51, sign: false }); + data.append(i8 { mag: 33, sign: false }); + data.append(i8 { mag: 65, sign: true }); + data.append(i8 { mag: 76, sign: false }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 47, sign: false }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 38, sign: false }); + data.append(i8 { mag: 10, sign: true }); + data.append(i8 { mag: 92, sign: true }); + data.append(i8 { mag: 35, sign: false }); + data.append(i8 { mag: 33, sign: true }); + data.append(i8 { mag: 43, sign: true }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 20, sign: true }); + data.append(i8 { mag: 16, sign: true }); + data.append(i8 { mag: 123, sign: true }); + data.append(i8 { mag: 51, sign: false }); + data.append(i8 { mag: 126, sign: true }); + data.append(i8 { mag: 96, sign: true }); + data.append(i8 { mag: 43, sign: false }); + data.append(i8 { mag: 124, sign: false }); + data.append(i8 { mag: 95, sign: false }); + data.append(i8 { mag: 59, sign: true }); + data.append(i8 { mag: 18, sign: false }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 108, sign: true }); + data.append(i8 { mag: 119, sign: true }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 99, sign: false }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 91, sign: false }); + data.append(i8 { mag: 104, sign: false }); + data.append(i8 { mag: 62, sign: false }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 127, sign: true }); + data.append(i8 { mag: 37, sign: false }); + data.append(i8 { mag: 36, sign: false }); + data.append(i8 { mag: 106, sign: false }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 78, sign: true }); + data.append(i8 { mag: 49, sign: false }); + data.append(i8 { mag: 13, sign: true }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 45, sign: false }); + data.append(i8 { mag: 99, sign: true }); + data.append(i8 { mag: 71, sign: true }); + data.append(i8 { mag: 24, sign: false }); + data.append(i8 { mag: 58, sign: true }); + data.append(i8 { mag: 42, sign: true }); + data.append(i8 { mag: 95, sign: true }); + data.append(i8 { mag: 17, sign: true }); + data.append(i8 { mag: 33, sign: true }); + data.append(i8 { mag: 50, sign: false }); + data.append(i8 { mag: 87, sign: false }); + data.append(i8 { mag: 35, sign: true }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 119, sign: false }); + data.append(i8 { mag: 72, sign: false }); + data.append(i8 { mag: 37, sign: false }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 35, sign: true }); + data.append(i8 { mag: 18, sign: true }); + data.append(i8 { mag: 100, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 57, sign: true }); + data.append(i8 { mag: 87, sign: false }); + data.append(i8 { mag: 29, sign: true }); + data.append(i8 { mag: 49, sign: true }); + data.append(i8 { mag: 47, sign: false }); + data.append(i8 { mag: 71, sign: false }); + data.append(i8 { mag: 68, sign: false }); + data.append(i8 { mag: 54, sign: true }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 18, sign: true }); + data.append(i8 { mag: 94, sign: true }); + data.append(i8 { mag: 24, sign: true }); + data.append(i8 { mag: 67, sign: true }); + data.append(i8 { mag: 85, sign: true }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 65, sign: false }); + data.append(i8 { mag: 46, sign: true }); + data.append(i8 { mag: 37, sign: true }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 13, sign: false }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 111, sign: false }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 68, sign: true }); + data.append(i8 { mag: 40, sign: true }); + data.append(i8 { mag: 33, sign: false }); + data.append(i8 { mag: 21, sign: false }); + data.append(i8 { mag: 115, sign: true }); + data.append(i8 { mag: 44, sign: true }); + data.append(i8 { mag: 43, sign: false }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 122, sign: true }); + data.append(i8 { mag: 12, sign: false }); + data.append(i8 { mag: 66, sign: false }); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 16, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 53, sign: false }); + data.append(i8 { mag: 21, sign: false }); + data.append(i8 { mag: 107, sign: false }); + data.append(i8 { mag: 58, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 81, sign: false }); + data.append(i8 { mag: 68, sign: false }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 57, sign: true }); + data.append(i8 { mag: 95, sign: false }); + data.append(i8 { mag: 82, sign: true }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 91, sign: false }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 56, sign: false }); + data.append(i8 { mag: 99, sign: false }); + data.append(i8 { mag: 88, sign: true }); + data.append(i8 { mag: 16, sign: false }); + data.append(i8 { mag: 51, sign: true }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 107, sign: true }); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 107, sign: false }); + data.append(i8 { mag: 110, sign: false }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 109, sign: false }); + data.append(i8 { mag: 67, sign: false }); + data.append(i8 { mag: 8, sign: true }); + data.append(i8 { mag: 110, sign: true }); + data.append(i8 { mag: 75, sign: true }); + data.append(i8 { mag: 89, sign: false }); + data.append(i8 { mag: 98, sign: false }); + data.append(i8 { mag: 125, sign: false }); + data.append(i8 { mag: 9, sign: true }); + data.append(i8 { mag: 53, sign: true }); + data.append(i8 { mag: 62, sign: false }); + data.append(i8 { mag: 119, sign: false }); + data.append(i8 { mag: 59, sign: true }); + data.append(i8 { mag: 46, sign: true }); + data.append(i8 { mag: 42, sign: true }); + data.append(i8 { mag: 126, sign: false }); + data.append(i8 { mag: 7, sign: false }); + data.append(i8 { mag: 85, sign: false }); + data.append(i8 { mag: 69, sign: false }); + data.append(i8 { mag: 16, sign: false }); + data.append(i8 { mag: 40, sign: false }); + data.append(i8 { mag: 112, sign: false }); + data.append(i8 { mag: 73, sign: false }); + data.append(i8 { mag: 123, sign: false }); + data.append(i8 { mag: 51, sign: false }); + data.append(i8 { mag: 19, sign: false }); + data.append(i8 { mag: 94, sign: true }); + data.append(i8 { mag: 94, sign: false }); + data.append(i8 { mag: 72, sign: false }); + data.append(i8 { mag: 112, sign: false }); + data.append(i8 { mag: 60, sign: true }); + data.append(i8 { mag: 54, sign: false }); + data.append(i8 { mag: 72, sign: true }); + data.append(i8 { mag: 20, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 59, sign: false }); + data.append(i8 { mag: 105, sign: false }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 122, sign: false }); + data.append(i8 { mag: 116, sign: true }); + data.append(i8 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_i8_3d/output_0.cairo b/src/tests/nodes/slice_i8_3d/output_0.cairo new file mode 100644 index 000000000..6385f11bf --- /dev/null +++ b/src/tests/nodes/slice_i8_3d/output_0.cairo @@ -0,0 +1,74 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(i8 { mag: 86, sign: false }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 89, sign: true }); + data.append(i8 { mag: 48, sign: false }); + data.append(i8 { mag: 72, sign: false }); + data.append(i8 { mag: 120, sign: true }); + data.append(i8 { mag: 29, sign: false }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 46, sign: false }); + data.append(i8 { mag: 101, sign: true }); + data.append(i8 { mag: 87, sign: true }); + data.append(i8 { mag: 37, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 72, sign: true }); + data.append(i8 { mag: 64, sign: false }); + data.append(i8 { mag: 71, sign: true }); + data.append(i8 { mag: 53, sign: false }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 99, sign: true }); + data.append(i8 { mag: 104, sign: true }); + data.append(i8 { mag: 106, sign: true }); + data.append(i8 { mag: 59, sign: true }); + data.append(i8 { mag: 121, sign: true }); + data.append(i8 { mag: 69, sign: true }); + data.append(i8 { mag: 64, sign: false }); + data.append(i8 { mag: 42, sign: false }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 82, sign: true }); + data.append(i8 { mag: 53, sign: false }); + data.append(i8 { mag: 55, sign: true }); + data.append(i8 { mag: 13, sign: true }); + data.append(i8 { mag: 112, sign: true }); + data.append(i8 { mag: 113, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 66, sign: true }); + data.append(i8 { mag: 31, sign: true }); + data.append(i8 { mag: 50, sign: false }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 110, sign: true }); + data.append(i8 { mag: 114, sign: false }); + data.append(i8 { mag: 72, sign: false }); + data.append(i8 { mag: 21, sign: true }); + data.append(i8 { mag: 79, sign: true }); + data.append(i8 { mag: 46, sign: false }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 34, sign: true }); + data.append(i8 { mag: 76, sign: true }); + data.append(i8 { mag: 64, sign: true }); + data.append(i8 { mag: 75, sign: true }); + data.append(i8 { mag: 111, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 31, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 76, sign: false }); + data.append(i8 { mag: 60, sign: false }); + data.append(i8 { mag: 111, sign: true }); + data.append(i8 { mag: 40, sign: true }); + data.append(i8 { mag: 30, sign: true }); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_u32_2d.cairo b/src/tests/nodes/slice_u32_2d.cairo new file mode 100644 index 000000000..a4ad6e1a6 --- /dev/null +++ b/src/tests/nodes/slice_u32_2d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_u32_2d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 2].span(), array![2, 4].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 1].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_u32_2d/input_0.cairo b/src/tests/nodes/slice_u32_2d/input_0.cairo new file mode 100644 index 000000000..35b844ac3 --- /dev/null +++ b/src/tests/nodes/slice_u32_2d/input_0.cairo @@ -0,0 +1,20 @@ +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(4); + + let mut data = ArrayTrait::new(); + data.append(239); + data.append(177); + data.append(83); + data.append(88); + data.append(34); + data.append(131); + data.append(2); + data.append(11); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_u32_2d/output_0.cairo b/src/tests/nodes/slice_u32_2d/output_0.cairo new file mode 100644 index 000000000..c16ade382 --- /dev/null +++ b/src/tests/nodes/slice_u32_2d/output_0.cairo @@ -0,0 +1,16 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(2); + shape.append(2); + + let mut data = ArrayTrait::new(); + data.append(83); + data.append(88); + data.append(2); + data.append(11); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_u32_3d.cairo b/src/tests/nodes/slice_u32_3d.cairo new file mode 100644 index 000000000..36796ffbc --- /dev/null +++ b/src/tests/nodes/slice_u32_3d.cairo @@ -0,0 +1,20 @@ +mod input_0; +mod output_0; + + +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; +use orion::utils::assert_eq; + +#[test] +#[available_gas(2000000000)] +fn test_slice_u32_3d() { + let input_0 = input_0::input_0(); + let z = output_0::output_0(); + + let y = input_0.slice(array![0, 0].span(), array![3, 10].span(), Option::Some(array![0, 1].span()), Option::Some(array![1, 3].span())); + + assert_eq(y, z); +} \ No newline at end of file diff --git a/src/tests/nodes/slice_u32_3d/input_0.cairo b/src/tests/nodes/slice_u32_3d/input_0.cairo new file mode 100644 index 000000000..28b857a60 --- /dev/null +++ b/src/tests/nodes/slice_u32_3d/input_0.cairo @@ -0,0 +1,1013 @@ +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(20); + shape.append(10); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(230); + data.append(198); + data.append(114); + data.append(149); + data.append(28); + data.append(36); + data.append(139); + data.append(54); + data.append(64); + data.append(140); + data.append(248); + data.append(32); + data.append(185); + data.append(148); + data.append(7); + data.append(210); + data.append(174); + data.append(63); + data.append(232); + data.append(20); + data.append(225); + data.append(113); + data.append(79); + data.append(138); + data.append(214); + data.append(203); + data.append(40); + data.append(167); + data.append(225); + data.append(226); + data.append(217); + data.append(109); + data.append(15); + data.append(227); + data.append(223); + data.append(196); + data.append(177); + data.append(70); + data.append(197); + data.append(80); + data.append(54); + data.append(209); + data.append(125); + data.append(83); + data.append(140); + data.append(91); + data.append(8); + data.append(122); + data.append(254); + data.append(184); + data.append(250); + data.append(89); + data.append(175); + data.append(27); + data.append(67); + data.append(132); + data.append(6); + data.append(157); + data.append(171); + data.append(129); + data.append(82); + data.append(12); + data.append(12); + data.append(195); + data.append(24); + data.append(172); + data.append(220); + data.append(168); + data.append(229); + data.append(34); + data.append(78); + data.append(176); + data.append(55); + data.append(197); + data.append(32); + data.append(46); + data.append(223); + data.append(18); + data.append(178); + data.append(156); + data.append(169); + data.append(107); + data.append(123); + data.append(19); + data.append(103); + data.append(192); + data.append(121); + data.append(106); + data.append(161); + data.append(157); + data.append(114); + data.append(190); + data.append(55); + data.append(149); + data.append(84); + data.append(123); + data.append(206); + data.append(146); + data.append(12); + data.append(208); + data.append(36); + data.append(237); + data.append(192); + data.append(108); + data.append(243); + data.append(117); + data.append(144); + data.append(186); + data.append(224); + data.append(161); + data.append(218); + data.append(199); + data.append(180); + data.append(19); + data.append(211); + data.append(15); + data.append(27); + data.append(120); + data.append(67); + data.append(108); + data.append(179); + data.append(92); + data.append(66); + data.append(53); + data.append(118); + data.append(36); + data.append(217); + data.append(141); + data.append(88); + data.append(77); + data.append(31); + data.append(73); + data.append(87); + data.append(75); + data.append(227); + data.append(34); + data.append(166); + data.append(121); + data.append(111); + data.append(42); + data.append(220); + data.append(89); + data.append(79); + data.append(249); + data.append(234); + data.append(232); + data.append(164); + data.append(144); + data.append(152); + data.append(22); + data.append(20); + data.append(9); + data.append(115); + data.append(44); + data.append(129); + data.append(14); + data.append(54); + data.append(161); + data.append(167); + data.append(116); + data.append(138); + data.append(186); + data.append(156); + data.append(197); + data.append(1); + data.append(1); + data.append(193); + data.append(134); + data.append(254); + data.append(33); + data.append(132); + data.append(44); + data.append(76); + data.append(15); + data.append(221); + data.append(186); + data.append(59); + data.append(204); + data.append(93); + data.append(25); + data.append(129); + data.append(22); + data.append(101); + data.append(85); + data.append(34); + data.append(106); + data.append(70); + data.append(33); + data.append(238); + data.append(253); + data.append(62); + data.append(226); + data.append(35); + data.append(53); + data.append(123); + data.append(175); + data.append(35); + data.append(172); + data.append(68); + data.append(139); + data.append(211); + data.append(205); + data.append(216); + data.append(125); + data.append(224); + data.append(236); + data.append(62); + data.append(238); + data.append(186); + data.append(158); + data.append(222); + data.append(185); + data.append(147); + data.append(192); + data.append(28); + data.append(192); + data.append(0); + data.append(223); + data.append(239); + data.append(238); + data.append(115); + data.append(172); + data.append(188); + data.append(171); + data.append(190); + data.append(193); + data.append(98); + data.append(191); + data.append(143); + data.append(190); + data.append(117); + data.append(193); + data.append(158); + data.append(125); + data.append(131); + data.append(244); + data.append(219); + data.append(250); + data.append(219); + data.append(117); + data.append(232); + data.append(10); + data.append(16); + data.append(178); + data.append(106); + data.append(95); + data.append(215); + data.append(117); + data.append(109); + data.append(226); + data.append(105); + data.append(194); + data.append(208); + data.append(28); + data.append(36); + data.append(178); + data.append(35); + data.append(14); + data.append(69); + data.append(55); + data.append(183); + data.append(217); + data.append(191); + data.append(56); + data.append(1); + data.append(31); + data.append(211); + data.append(253); + data.append(208); + data.append(250); + data.append(76); + data.append(180); + data.append(140); + data.append(211); + data.append(249); + data.append(77); + data.append(220); + data.append(98); + data.append(21); + data.append(144); + data.append(21); + data.append(6); + data.append(160); + data.append(25); + data.append(55); + data.append(7); + data.append(13); + data.append(184); + data.append(249); + data.append(114); + data.append(248); + data.append(127); + data.append(215); + data.append(33); + data.append(86); + data.append(93); + data.append(94); + data.append(42); + data.append(175); + data.append(93); + data.append(183); + data.append(104); + data.append(33); + data.append(194); + data.append(254); + data.append(115); + data.append(26); + data.append(171); + data.append(123); + data.append(135); + data.append(44); + data.append(195); + data.append(226); + data.append(65); + data.append(175); + data.append(160); + data.append(186); + data.append(116); + data.append(95); + data.append(44); + data.append(18); + data.append(197); + data.append(192); + data.append(42); + data.append(174); + data.append(18); + data.append(65); + data.append(105); + data.append(195); + data.append(70); + data.append(141); + data.append(138); + data.append(153); + data.append(227); + data.append(27); + data.append(195); + data.append(107); + data.append(83); + data.append(153); + data.append(229); + data.append(159); + data.append(72); + data.append(25); + data.append(97); + data.append(127); + data.append(243); + data.append(52); + data.append(197); + data.append(233); + data.append(213); + data.append(153); + data.append(20); + data.append(56); + data.append(193); + data.append(250); + data.append(57); + data.append(110); + data.append(164); + data.append(92); + data.append(205); + data.append(251); + data.append(137); + data.append(0); + data.append(187); + data.append(65); + data.append(27); + data.append(188); + data.append(148); + data.append(67); + data.append(149); + data.append(47); + data.append(129); + data.append(165); + data.append(188); + data.append(84); + data.append(169); + data.append(123); + data.append(214); + data.append(36); + data.append(6); + data.append(196); + data.append(90); + data.append(100); + data.append(221); + data.append(127); + data.append(9); + data.append(186); + data.append(161); + data.append(219); + data.append(59); + data.append(247); + data.append(97); + data.append(99); + data.append(218); + data.append(215); + data.append(227); + data.append(33); + data.append(5); + data.append(223); + data.append(233); + data.append(38); + data.append(99); + data.append(124); + data.append(220); + data.append(197); + data.append(61); + data.append(135); + data.append(4); + data.append(203); + data.append(9); + data.append(30); + data.append(28); + data.append(27); + data.append(22); + data.append(240); + data.append(231); + data.append(134); + data.append(95); + data.append(107); + data.append(160); + data.append(30); + data.append(70); + data.append(50); + data.append(57); + data.append(13); + data.append(50); + data.append(35); + data.append(58); + data.append(208); + data.append(7); + data.append(1); + data.append(219); + data.append(240); + data.append(64); + data.append(135); + data.append(225); + data.append(207); + data.append(137); + data.append(6); + data.append(171); + data.append(134); + data.append(176); + data.append(98); + data.append(152); + data.append(121); + data.append(186); + data.append(122); + data.append(234); + data.append(32); + data.append(173); + data.append(104); + data.append(254); + data.append(75); + data.append(130); + data.append(66); + data.append(61); + data.append(13); + data.append(208); + data.append(152); + data.append(131); + data.append(15); + data.append(15); + data.append(77); + data.append(189); + data.append(115); + data.append(247); + data.append(200); + data.append(3); + data.append(249); + data.append(195); + data.append(165); + data.append(170); + data.append(227); + data.append(247); + data.append(199); + data.append(158); + data.append(58); + data.append(235); + data.append(111); + data.append(94); + data.append(116); + data.append(145); + data.append(179); + data.append(191); + data.append(222); + data.append(151); + data.append(177); + data.append(40); + data.append(223); + data.append(194); + data.append(161); + data.append(206); + data.append(250); + data.append(114); + data.append(70); + data.append(11); + data.append(129); + data.append(22); + data.append(213); + data.append(115); + data.append(21); + data.append(75); + data.append(169); + data.append(110); + data.append(52); + data.append(108); + data.append(173); + data.append(188); + data.append(119); + data.append(252); + data.append(22); + data.append(149); + data.append(144); + data.append(145); + data.append(106); + data.append(55); + data.append(84); + data.append(92); + data.append(198); + data.append(246); + data.append(206); + data.append(235); + data.append(118); + data.append(237); + data.append(143); + data.append(103); + data.append(155); + data.append(46); + data.append(200); + data.append(50); + data.append(126); + data.append(149); + data.append(104); + data.append(87); + data.append(238); + data.append(199); + data.append(187); + data.append(238); + data.append(112); + data.append(192); + data.append(205); + data.append(166); + data.append(108); + data.append(94); + data.append(218); + data.append(87); + data.append(178); + data.append(12); + data.append(229); + data.append(201); + data.append(247); + data.append(18); + data.append(143); + data.append(34); + data.append(53); + data.append(252); + data.append(85); + data.append(206); + data.append(115); + data.append(66); + data.append(180); + data.append(46); + data.append(65); + data.append(115); + data.append(229); + data.append(192); + data.append(245); + data.append(24); + data.append(42); + data.append(16); + data.append(164); + data.append(224); + data.append(147); + data.append(148); + data.append(193); + data.append(94); + data.append(166); + data.append(196); + data.append(13); + data.append(77); + data.append(244); + data.append(170); + data.append(113); + data.append(80); + data.append(32); + data.append(107); + data.append(180); + data.append(229); + data.append(185); + data.append(62); + data.append(27); + data.append(18); + data.append(213); + data.append(45); + data.append(76); + data.append(15); + data.append(217); + data.append(13); + data.append(217); + data.append(213); + data.append(182); + data.append(32); + data.append(28); + data.append(118); + data.append(5); + data.append(111); + data.append(230); + data.append(230); + data.append(4); + data.append(184); + data.append(123); + data.append(248); + data.append(85); + data.append(236); + data.append(66); + data.append(37); + data.append(3); + data.append(28); + data.append(181); + data.append(69); + data.append(86); + data.append(202); + data.append(104); + data.append(17); + data.append(128); + data.append(212); + data.append(224); + data.append(217); + data.append(59); + data.append(126); + data.append(94); + data.append(154); + data.append(65); + data.append(247); + data.append(152); + data.append(175); + data.append(0); + data.append(17); + data.append(101); + data.append(211); + data.append(22); + data.append(209); + data.append(149); + data.append(236); + data.append(81); + data.append(192); + data.append(155); + data.append(67); + data.append(242); + data.append(40); + data.append(123); + data.append(243); + data.append(230); + data.append(32); + data.append(122); + data.append(90); + data.append(147); + data.append(190); + data.append(52); + data.append(105); + data.append(246); + data.append(222); + data.append(119); + data.append(230); + data.append(73); + data.append(247); + data.append(93); + data.append(113); + data.append(114); + data.append(111); + data.append(220); + data.append(109); + data.append(76); + data.append(10); + data.append(129); + data.append(196); + data.append(138); + data.append(103); + data.append(105); + data.append(45); + data.append(216); + data.append(18); + data.append(19); + data.append(240); + data.append(101); + data.append(171); + data.append(110); + data.append(199); + data.append(61); + data.append(33); + data.append(14); + data.append(253); + data.append(106); + data.append(3); + data.append(147); + data.append(132); + data.append(86); + data.append(186); + data.append(236); + data.append(196); + data.append(178); + data.append(125); + data.append(168); + data.append(81); + data.append(116); + data.append(115); + data.append(140); + data.append(32); + data.append(249); + data.append(147); + data.append(72); + data.append(94); + data.append(88); + data.append(173); + data.append(177); + data.append(137); + data.append(99); + data.append(40); + data.append(35); + data.append(40); + data.append(160); + data.append(33); + data.append(214); + data.append(95); + data.append(229); + data.append(100); + data.append(101); + data.append(87); + data.append(122); + data.append(130); + data.append(170); + data.append(7); + data.append(63); + data.append(226); + data.append(187); + data.append(77); + data.append(166); + data.append(74); + data.append(111); + data.append(20); + data.append(150); + data.append(211); + data.append(8); + data.append(68); + data.append(79); + data.append(8); + data.append(49); + data.append(205); + data.append(31); + data.append(23); + data.append(148); + data.append(36); + data.append(44); + data.append(38); + data.append(178); + data.append(84); + data.append(190); + data.append(120); + data.append(204); + data.append(114); + data.append(205); + data.append(138); + data.append(201); + data.append(61); + data.append(137); + data.append(35); + data.append(139); + data.append(77); + data.append(40); + data.append(179); + data.append(56); + data.append(139); + data.append(14); + data.append(2); + data.append(254); + data.append(62); + data.append(46); + data.append(216); + data.append(163); + data.append(76); + data.append(176); + data.append(209); + data.append(11); + data.append(245); + data.append(3); + data.append(213); + data.append(146); + data.append(99); + data.append(200); + data.append(57); + data.append(174); + data.append(16); + data.append(117); + data.append(155); + data.append(216); + data.append(40); + data.append(23); + data.append(204); + data.append(158); + data.append(185); + data.append(117); + data.append(135); + data.append(13); + data.append(79); + data.append(78); + data.append(52); + data.append(42); + data.append(210); + data.append(160); + data.append(210); + data.append(83); + data.append(20); + data.append(153); + data.append(37); + data.append(148); + data.append(30); + data.append(104); + data.append(230); + data.append(66); + data.append(11); + data.append(105); + data.append(253); + data.append(221); + data.append(141); + data.append(24); + data.append(56); + data.append(104); + data.append(77); + data.append(51); + data.append(129); + data.append(147); + data.append(170); + data.append(93); + data.append(13); + data.append(92); + data.append(145); + data.append(229); + data.append(213); + data.append(22); + data.append(241); + data.append(141); + data.append(115); + data.append(25); + data.append(108); + data.append(89); + data.append(17); + data.append(11); + data.append(241); + data.append(72); + data.append(211); + data.append(199); + data.append(47); + data.append(223); + data.append(125); + data.append(163); + data.append(57); + data.append(70); + data.append(166); + data.append(243); + data.append(146); + data.append(128); + data.append(173); + data.append(115); + data.append(209); + data.append(65); + data.append(220); + data.append(111); + data.append(86); + data.append(253); + data.append(199); + data.append(115); + data.append(32); + data.append(69); + data.append(54); + data.append(231); + data.append(116); + data.append(76); + data.append(126); + data.append(97); + data.append(121); + data.append(213); + data.append(229); + data.append(152); + data.append(166); + data.append(66); + data.append(158); + data.append(138); + data.append(12); + data.append(145); + data.append(41); + data.append(95); + data.append(254); + data.append(97); + data.append(19); + data.append(229); + data.append(95); + data.append(158); + data.append(47); + data.append(194); + data.append(207); + data.append(37); + data.append(226); + data.append(177); + data.append(144); + data.append(180); + data.append(37); + data.append(218); + data.append(203); + data.append(250); + data.append(11); + data.append(149); + data.append(153); + data.append(228); + data.append(144); + data.append(31); + data.append(239); + data.append(235); + data.append(77); + data.append(144); + data.append(100); + data.append(60); + data.append(200); + data.append(136); + data.append(145); + data.append(162); + data.append(93); + data.append(42); + data.append(223); + data.append(50); + data.append(46); + data.append(121); + data.append(133); + data.append(120); + data.append(179); + data.append(87); + data.append(127); + data.append(78); + data.append(123); + data.append(10); + data.append(48); + data.append(202); + data.append(178); + data.append(167); + data.append(85); + data.append(146); + data.append(207); + data.append(128); + data.append(70); + data.append(87); + data.append(46); + data.append(56); + data.append(47); + data.append(38); + data.append(148); + data.append(147); + data.append(109); + data.append(231); + data.append(179); + data.append(40); + data.append(251); + data.append(39); + data.append(122); + data.append(15); + data.append(22); + data.append(208); + data.append(30); + data.append(225); + data.append(151); + data.append(250); + data.append(141); + data.append(27); + data.append(217); + data.append(164); + data.append(129); + data.append(160); + data.append(164); + data.append(240); + data.append(44); + data.append(121); + data.append(97); + data.append(167); + data.append(46); + data.append(134); + data.append(217); + data.append(236); + data.append(3); + data.append(73); + data.append(155); + data.append(16); + data.append(254); + data.append(62); + data.append(196); + data.append(238); + data.append(107); + data.append(104); + data.append(221); + data.append(163); + data.append(114); + data.append(235); + data.append(215); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/slice_u32_3d/output_0.cairo b/src/tests/nodes/slice_u32_3d/output_0.cairo new file mode 100644 index 000000000..4d40e1148 --- /dev/null +++ b/src/tests/nodes/slice_u32_3d/output_0.cairo @@ -0,0 +1,73 @@ +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; + +fn output_0() -> Tensor { + let mut shape = ArrayTrait::::new(); + shape.append(3); + shape.append(4); + shape.append(5); + + let mut data = ArrayTrait::new(); + data.append(230); + data.append(198); + data.append(114); + data.append(149); + data.append(28); + data.append(210); + data.append(174); + data.append(63); + data.append(232); + data.append(20); + data.append(217); + data.append(109); + data.append(15); + data.append(227); + data.append(223); + data.append(91); + data.append(8); + data.append(122); + data.append(254); + data.append(184); + data.append(250); + data.append(89); + data.append(175); + data.append(27); + data.append(67); + data.append(172); + data.append(220); + data.append(168); + data.append(229); + data.append(34); + data.append(169); + data.append(107); + data.append(123); + data.append(19); + data.append(103); + data.append(123); + data.append(206); + data.append(146); + data.append(12); + data.append(208); + data.append(36); + data.append(237); + data.append(192); + data.append(108); + data.append(243); + data.append(15); + data.append(27); + data.append(120); + data.append(67); + data.append(108); + data.append(31); + data.append(73); + data.append(87); + data.append(75); + data.append(227); + data.append(232); + data.append(164); + data.append(144); + data.append(152); + data.append(22); + TensorTrait::new(shape.span(), data.span()) +} \ No newline at end of file diff --git a/src/tests/nodes/softmax_fp16x16.cairo b/src/tests/nodes/softmax_fp16x16.cairo index 3d6666487..ea3f7f578 100644 --- a/src/tests/nodes/softmax_fp16x16.cairo +++ b/src/tests/nodes/softmax_fp16x16.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/softmax_fp16x16/input_0.cairo b/src/tests/nodes/softmax_fp16x16/input_0.cairo index 138c05607..749b61dda 100644 --- a/src/tests/nodes/softmax_fp16x16/input_0.cairo +++ b/src/tests/nodes/softmax_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 11810, sign: true }); - data.append(FixedType { mag: 193132, sign: false }); - data.append(FixedType { mag: 147644, sign: false }); - data.append(FixedType { mag: 123955, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 3889, sign: false }); + data.append(FP16x16 { mag: 89405, sign: false }); + data.append(FP16x16 { mag: 78312, sign: false }); + data.append(FP16x16 { mag: 139730, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softmax_fp16x16/output_0.cairo b/src/tests/nodes/softmax_fp16x16/output_0.cairo index b6c156a7b..b7f7bf7c5 100644 --- a/src/tests/nodes/softmax_fp16x16/output_0.cairo +++ b/src/tests/nodes/softmax_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2752, sign: false }); - data.append(FixedType { mag: 62783, sign: false }); - data.append(FixedType { mag: 64513, sign: false }); - data.append(FixedType { mag: 1022, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 13981, sign: false }); + data.append(FP16x16 { mag: 51554, sign: false }); + data.append(FP16x16 { mag: 18446, sign: false }); + data.append(FP16x16 { mag: 47089, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softmax_fp8x23.cairo b/src/tests/nodes/softmax_fp8x23.cairo index 05208c493..a658b8594 100644 --- a/src/tests/nodes/softmax_fp8x23.cairo +++ b/src/tests/nodes/softmax_fp8x23.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/softmax_fp8x23/input_0.cairo b/src/tests/nodes/softmax_fp8x23/input_0.cairo index 2eded89b0..741a9d820 100644 --- a/src/tests/nodes/softmax_fp8x23/input_0.cairo +++ b/src/tests/nodes/softmax_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 18916324, sign: false }); - data.append(FixedType { mag: 24318116, sign: false }); - data.append(FixedType { mag: 4760436, sign: true }); - data.append(FixedType { mag: 15132412, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 9804113, sign: true }); + data.append(FP8x23 { mag: 8638782, sign: true }); + data.append(FP8x23 { mag: 20159749, sign: true }); + data.append(FP8x23 { mag: 2673667, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softmax_fp8x23/output_0.cairo b/src/tests/nodes/softmax_fp8x23/output_0.cairo index a62431405..ee2fbefed 100644 --- a/src/tests/nodes/softmax_fp8x23/output_0.cairo +++ b/src/tests/nodes/softmax_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 7917831, sign: false }); - data.append(FixedType { mag: 8313213, sign: false }); - data.append(FixedType { mag: 470776, sign: false }); - data.append(FixedType { mag: 75394, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 6497841, sign: false }); + data.append(FP8x23 { mag: 2762842, sign: false }); + data.append(FP8x23 { mag: 1890766, sign: false }); + data.append(FP8x23 { mag: 5625765, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softmax_i32_fp16x16.cairo b/src/tests/nodes/softmax_i32_fp16x16.cairo deleted file mode 100644 index 1126b9ce3..000000000 --- a/src/tests/nodes/softmax_i32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softmax_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i32_fp16x16/input_0.cairo b/src/tests/nodes/softmax_i32_fp16x16/input_0.cairo deleted file mode 100644 index 86da7e4e8..000000000 --- a/src/tests/nodes/softmax_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i32_fp16x16/output_0.cairo b/src/tests/nodes/softmax_i32_fp16x16/output_0.cairo deleted file mode 100644 index 573697651..000000000 --- a/src/tests/nodes/softmax_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 62427, sign: false }); - data.append(FixedType { mag: 3108, sign: false }); - data.append(FixedType { mag: 57723, sign: false }); - data.append(FixedType { mag: 7812, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i32_fp8x23.cairo b/src/tests/nodes/softmax_i32_fp8x23.cairo deleted file mode 100644 index 127a6e410..000000000 --- a/src/tests/nodes/softmax_i32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softmax_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i32_fp8x23/input_0.cairo b/src/tests/nodes/softmax_i32_fp8x23/input_0.cairo deleted file mode 100644 index a8bdc9654..000000000 --- a/src/tests/nodes/softmax_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i32_fp8x23/output_0.cairo b/src/tests/nodes/softmax_i32_fp8x23/output_0.cairo deleted file mode 100644 index 2c8579060..000000000 --- a/src/tests/nodes/softmax_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - data.append(FixedType { mag: 4194304, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i8_fp16x16.cairo b/src/tests/nodes/softmax_i8_fp16x16.cairo deleted file mode 100644 index e5141f73c..000000000 --- a/src/tests/nodes/softmax_i8_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softmax_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i8_fp16x16/input_0.cairo b/src/tests/nodes/softmax_i8_fp16x16/input_0.cairo deleted file mode 100644 index c21e22ec2..000000000 --- a/src/tests/nodes/softmax_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i8_fp16x16/output_0.cairo b/src/tests/nodes/softmax_i8_fp16x16/output_0.cairo deleted file mode 100644 index 54dc0b2eb..000000000 --- a/src/tests/nodes/softmax_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 7812, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 57696, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i8_fp8x23.cairo b/src/tests/nodes/softmax_i8_fp8x23.cairo deleted file mode 100644 index 8adc744ea..000000000 --- a/src/tests/nodes/softmax_i8_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softmax_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i8_fp8x23/input_0.cairo b/src/tests/nodes/softmax_i8_fp8x23/input_0.cairo deleted file mode 100644 index 3ae67154f..000000000 --- a/src/tests/nodes/softmax_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_i8_fp8x23/output_0.cairo b/src/tests/nodes/softmax_i8_fp8x23/output_0.cairo deleted file mode 100644 index 64bd98a1b..000000000 --- a/src/tests/nodes/softmax_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 150784, sign: false }); - data.append(FixedType { mag: 8237056, sign: false }); - data.append(FixedType { mag: 150784, sign: false }); - data.append(FixedType { mag: 8237056, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_u32_fp16x16.cairo b/src/tests/nodes/softmax_u32_fp16x16.cairo deleted file mode 100644 index f7692123c..000000000 --- a/src/tests/nodes/softmax_u32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softmax_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softmax(@input_0, 0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_u32_fp16x16/input_0.cairo b/src/tests/nodes/softmax_u32_fp16x16/input_0.cairo deleted file mode 100644 index 20a5eef0c..000000000 --- a/src/tests/nodes/softmax_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(1); - data.append(0); - data.append(2); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_u32_fp16x16/output_0.cairo b/src/tests/nodes/softmax_u32_fp16x16/output_0.cairo deleted file mode 100644 index aae3a6576..000000000 --- a/src/tests/nodes/softmax_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 17625, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - data.append(FixedType { mag: 47910, sign: false }); - data.append(FixedType { mag: 32768, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_u32_fp8x23.cairo b/src/tests/nodes/softmax_u32_fp8x23.cairo deleted file mode 100644 index e530b12ec..000000000 --- a/src/tests/nodes/softmax_u32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softmax_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softmax(@input_0, 1); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_u32_fp8x23/input_0.cairo b/src/tests/nodes/softmax_u32_fp8x23/input_0.cairo deleted file mode 100644 index f15973209..000000000 --- a/src/tests/nodes/softmax_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -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(0); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softmax_u32_fp8x23/output_0.cairo b/src/tests/nodes/softmax_u32_fp8x23/output_0.cairo deleted file mode 100644 index f58fb562f..000000000 --- a/src/tests/nodes/softmax_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 999946, sign: false }); - data.append(FixedType { mag: 7388661, sign: false }); - data.append(FixedType { mag: 999946, sign: false }); - data.append(FixedType { mag: 7388661, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_fp16x16.cairo b/src/tests/nodes/softplus_fp16x16.cairo index 00c9b8cb9..916e1ed21 100644 --- a/src/tests/nodes/softplus_fp16x16.cairo +++ b/src/tests/nodes/softplus_fp16x16.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/softplus_fp16x16/input_0.cairo b/src/tests/nodes/softplus_fp16x16/input_0.cairo index 7d9496f13..d07486662 100644 --- a/src/tests/nodes/softplus_fp16x16/input_0.cairo +++ b/src/tests/nodes/softplus_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 38394, sign: false }); - data.append(FixedType { mag: 18964, sign: false }); - data.append(FixedType { mag: 98498, sign: false }); - data.append(FixedType { mag: 52313, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 109682, sign: true }); + data.append(FP16x16 { mag: 76425, sign: false }); + data.append(FP16x16 { mag: 182796, sign: false }); + data.append(FP16x16 { mag: 7375, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softplus_fp16x16/output_0.cairo b/src/tests/nodes/softplus_fp16x16/output_0.cairo index c4323ac39..ad5a4e5a4 100644 --- a/src/tests/nodes/softplus_fp16x16/output_0.cairo +++ b/src/tests/nodes/softplus_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 67396, sign: false }); - data.append(FixedType { mag: 55591, sign: false }); - data.append(FixedType { mag: 111662, sign: false }); - data.append(FixedType { mag: 76669, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 11266, sign: false }); + data.append(FP16x16 { mag: 94200, sign: false }); + data.append(FP16x16 { mag: 186705, sign: false }); + data.append(FP16x16 { mag: 49217, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softplus_fp8x23.cairo b/src/tests/nodes/softplus_fp8x23.cairo index 616de295f..e75490bd1 100644 --- a/src/tests/nodes/softplus_fp8x23.cairo +++ b/src/tests/nodes/softplus_fp8x23.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/softplus_fp8x23/input_0.cairo b/src/tests/nodes/softplus_fp8x23/input_0.cairo index 95f8ae895..ebd78352d 100644 --- a/src/tests/nodes/softplus_fp8x23/input_0.cairo +++ b/src/tests/nodes/softplus_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 12544105, sign: false }); - data.append(FixedType { mag: 14326838, sign: true }); - data.append(FixedType { mag: 20577317, sign: false }); - data.append(FixedType { mag: 12791075, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 3471357, sign: true }); + data.append(FP8x23 { mag: 13111113, sign: true }); + data.append(FP8x23 { mag: 21113375, sign: true }); + data.append(FP8x23 { mag: 7707092, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softplus_fp8x23/output_0.cairo b/src/tests/nodes/softplus_fp8x23/output_0.cairo index 2bab6f601..30337af60 100644 --- a/src/tests/nodes/softplus_fp8x23/output_0.cairo +++ b/src/tests/nodes/softplus_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 14240775, sign: false }); - data.append(FixedType { mag: 1397299, sign: false }); - data.append(FixedType { mag: 21269654, sign: false }); - data.append(FixedType { mag: 1651985, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 4257158, sign: false }); + data.append(FP8x23 { mag: 1595666, sign: false }); + data.append(FP8x23 { mag: 651097, sign: false }); + data.append(FP8x23 { mag: 10523719, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softplus_i32_fp16x16.cairo b/src/tests/nodes/softplus_i32_fp16x16.cairo deleted file mode 100644 index a481b52c6..000000000 --- a/src/tests/nodes/softplus_i32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softplus_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softplus(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i32_fp16x16/input_0.cairo b/src/tests/nodes/softplus_i32_fp16x16/input_0.cairo deleted file mode 100644 index 92ef6d4fa..000000000 --- a/src/tests/nodes/softplus_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i32_fp16x16/output_0.cairo b/src/tests/nodes/softplus_i32_fp16x16/output_0.cairo deleted file mode 100644 index 2cddb573a..000000000 --- a/src/tests/nodes/softplus_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 86065, sign: false }); - data.append(FixedType { mag: 8318, sign: false }); - data.append(FixedType { mag: 8318, sign: false }); - data.append(FixedType { mag: 8318, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i32_fp8x23.cairo b/src/tests/nodes/softplus_i32_fp8x23.cairo deleted file mode 100644 index 725bb1e06..000000000 --- a/src/tests/nodes/softplus_i32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softplus_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softplus(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i32_fp8x23/input_0.cairo b/src/tests/nodes/softplus_i32_fp8x23/input_0.cairo deleted file mode 100644 index 0d2a01b19..000000000 --- a/src/tests/nodes/softplus_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i32_fp8x23/output_0.cairo b/src/tests/nodes/softplus_i32_fp8x23/output_0.cairo deleted file mode 100644 index 9b39cd898..000000000 --- a/src/tests/nodes/softplus_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2627829, sign: false }); - data.append(FixedType { mag: 2627829, sign: false }); - data.append(FixedType { mag: 407580, sign: false }); - data.append(FixedType { mag: 11016437, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i8_fp16x16.cairo b/src/tests/nodes/softplus_i8_fp16x16.cairo deleted file mode 100644 index b2d17f645..000000000 --- a/src/tests/nodes/softplus_i8_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softplus_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softplus(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i8_fp16x16/input_0.cairo b/src/tests/nodes/softplus_i8_fp16x16/input_0.cairo deleted file mode 100644 index c806b62fe..000000000 --- a/src/tests/nodes/softplus_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i8_fp16x16/output_0.cairo b/src/tests/nodes/softplus_i8_fp16x16/output_0.cairo deleted file mode 100644 index e7f884222..000000000 --- a/src/tests/nodes/softplus_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 86080, sign: false }); - data.append(FixedType { mag: 45440, sign: false }); - data.append(FixedType { mag: 45440, sign: false }); - data.append(FixedType { mag: 8344, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i8_fp8x23.cairo b/src/tests/nodes/softplus_i8_fp8x23.cairo deleted file mode 100644 index 822f6aa53..000000000 --- a/src/tests/nodes/softplus_i8_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softplus_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softplus(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i8_fp8x23/input_0.cairo b/src/tests/nodes/softplus_i8_fp8x23/input_0.cairo deleted file mode 100644 index 337195c0c..000000000 --- a/src/tests/nodes/softplus_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_i8_fp8x23/output_0.cairo b/src/tests/nodes/softplus_i8_fp8x23/output_0.cairo deleted file mode 100644 index f5d29b3ce..000000000 --- a/src/tests/nodes/softplus_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5816320, sign: false }); - data.append(FixedType { mag: 17842176, sign: false }); - data.append(FixedType { mag: 407808, sign: false }); - data.append(FixedType { mag: 2629632, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_u32_fp16x16.cairo b/src/tests/nodes/softplus_u32_fp16x16.cairo deleted file mode 100644 index bd8788cb2..000000000 --- a/src/tests/nodes/softplus_u32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softplus_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softplus(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_u32_fp16x16/input_0.cairo b/src/tests/nodes/softplus_u32_fp16x16/input_0.cairo deleted file mode 100644 index f701b75a9..000000000 --- a/src/tests/nodes/softplus_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(4); - data.append(1); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_u32_fp16x16/output_0.cairo b/src/tests/nodes/softplus_u32_fp16x16/output_0.cairo deleted file mode 100644 index 4c8b44212..000000000 --- a/src/tests/nodes/softplus_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 263333, sign: false }); - data.append(FixedType { mag: 86065, sign: false }); - data.append(FixedType { mag: 86065, sign: false }); - data.append(FixedType { mag: 86065, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_u32_fp8x23.cairo b/src/tests/nodes/softplus_u32_fp8x23.cairo deleted file mode 100644 index 18bfadcfb..000000000 --- a/src/tests/nodes/softplus_u32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softplus_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softplus(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_u32_fp8x23/input_0.cairo b/src/tests/nodes/softplus_u32_fp8x23/input_0.cairo deleted file mode 100644 index ba938d4e9..000000000 --- a/src/tests/nodes/softplus_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(3); - data.append(1); - data.append(2); - data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softplus_u32_fp8x23/output_0.cairo b/src/tests/nodes/softplus_u32_fp8x23/output_0.cairo deleted file mode 100644 index 7f3b7fe19..000000000 --- a/src/tests/nodes/softplus_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 25573404, sign: false }); - data.append(FixedType { mag: 11016437, sign: false }); - data.append(FixedType { mag: 17841965, sign: false }); - data.append(FixedType { mag: 41999372, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_fp16x16.cairo b/src/tests/nodes/softsign_fp16x16.cairo index 576169a02..622ed5d59 100644 --- a/src/tests/nodes/softsign_fp16x16.cairo +++ b/src/tests/nodes/softsign_fp16x16.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP16x16NN; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/softsign_fp16x16/input_0.cairo b/src/tests/nodes/softsign_fp16x16/input_0.cairo index 780154e38..cb67eccad 100644 --- a/src/tests/nodes/softsign_fp16x16/input_0.cairo +++ b/src/tests/nodes/softsign_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 422146, sign: false }); - data.append(FixedType { mag: 240652, sign: false }); - data.append(FixedType { mag: 153455, sign: false }); - data.append(FixedType { mag: 269993, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 139604, sign: true }); + data.append(FP16x16 { mag: 91968, sign: true }); + data.append(FP16x16 { mag: 455699, sign: false }); + data.append(FP16x16 { mag: 243346, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softsign_fp16x16/output_0.cairo b/src/tests/nodes/softsign_fp16x16/output_0.cairo index 4cd6d7bfe..c42e60807 100644 --- a/src/tests/nodes/softsign_fp16x16/output_0.cairo +++ b/src/tests/nodes/softsign_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 56729, sign: false }); - data.append(FixedType { mag: 51508, sign: false }); - data.append(FixedType { mag: 45923, sign: false }); - data.append(FixedType { mag: 52735, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 44599, sign: true }); + data.append(FP16x16 { mag: 38267, sign: true }); + data.append(FP16x16 { mag: 57296, sign: false }); + data.append(FP16x16 { mag: 51631, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softsign_fp8x23.cairo b/src/tests/nodes/softsign_fp8x23.cairo index 97d2aea3e..54288f4a3 100644 --- a/src/tests/nodes/softsign_fp8x23.cairo +++ b/src/tests/nodes/softsign_fp8x23.cairo @@ -2,11 +2,10 @@ mod input_0; mod output_0; -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_fp::NN_fp; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use orion::operators::nn::NNTrait; +use orion::numbers::FixedTrait; +use orion::operators::nn::FP8x23NN; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/softsign_fp8x23/input_0.cairo b/src/tests/nodes/softsign_fp8x23/input_0.cairo index d5e04b0a2..92b80d489 100644 --- a/src/tests/nodes/softsign_fp8x23/input_0.cairo +++ b/src/tests/nodes/softsign_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 13239928, sign: false }); - data.append(FixedType { mag: 30467697, sign: true }); - data.append(FixedType { mag: 7575559, sign: false }); - data.append(FixedType { mag: 22798419, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 47253221, sign: false }); + data.append(FP8x23 { mag: 50936689, sign: false }); + data.append(FP8x23 { mag: 5714756, sign: true }); + data.append(FP8x23 { mag: 15620718, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softsign_fp8x23/output_0.cairo b/src/tests/nodes/softsign_fp8x23/output_0.cairo index 485c3c7d2..45c3cbbf3 100644 --- a/src/tests/nodes/softsign_fp8x23/output_0.cairo +++ b/src/tests/nodes/softsign_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5135094, sign: false }); - data.append(FixedType { mag: 6577608, sign: true }); - data.append(FixedType { mag: 3980689, sign: false }); - data.append(FixedType { mag: 6132261, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 7123934, sign: false }); + data.append(FP8x23 { mag: 7202457, sign: false }); + data.append(FP8x23 { mag: 3399107, sign: true }); + data.append(FP8x23 { mag: 5457715, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/softsign_i32_fp16x16.cairo b/src/tests/nodes/softsign_i32_fp16x16.cairo deleted file mode 100644 index d5df87c92..000000000 --- a/src/tests/nodes/softsign_i32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softsign_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softsign(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i32_fp16x16/input_0.cairo b/src/tests/nodes/softsign_i32_fp16x16/input_0.cairo deleted file mode 100644 index 1b6ffb598..000000000 --- a/src/tests/nodes/softsign_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 4, sign: false }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 5, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i32_fp16x16/output_0.cairo b/src/tests/nodes/softsign_i32_fp16x16/output_0.cairo deleted file mode 100644 index 9940cbee6..000000000 --- a/src/tests/nodes/softsign_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 52428, sign: false }); - data.append(FixedType { mag: 54613, sign: true }); - data.append(FixedType { mag: 54613, sign: true }); - data.append(FixedType { mag: 54613, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i32_fp8x23.cairo b/src/tests/nodes/softsign_i32_fp8x23.cairo deleted file mode 100644 index 8f39d23a7..000000000 --- a/src/tests/nodes/softsign_i32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i32::NN_i32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softsign_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softsign(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i32_fp8x23/input_0.cairo b/src/tests/nodes/softsign_i32_fp8x23/input_0.cairo deleted file mode 100644 index aace09d65..000000000 --- a/src/tests/nodes/softsign_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 5, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 4, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i32_fp8x23/output_0.cairo b/src/tests/nodes/softsign_i32_fp8x23/output_0.cairo deleted file mode 100644 index d276b1a77..000000000 --- a/src/tests/nodes/softsign_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6990506, sign: false }); - data.append(FixedType { mag: 6291456, sign: true }); - data.append(FixedType { mag: 6291456, sign: false }); - data.append(FixedType { mag: 6710886, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i8_fp16x16.cairo b/src/tests/nodes/softsign_i8_fp16x16.cairo deleted file mode 100644 index a1d9db3ba..000000000 --- a/src/tests/nodes/softsign_i8_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softsign_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softsign(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i8_fp16x16/input_0.cairo b/src/tests/nodes/softsign_i8_fp16x16/input_0.cairo deleted file mode 100644 index 25326e97b..000000000 --- a/src/tests/nodes/softsign_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 4, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i8_fp16x16/output_0.cairo b/src/tests/nodes/softsign_i8_fp16x16/output_0.cairo deleted file mode 100644 index 2cd50fd95..000000000 --- a/src/tests/nodes/softsign_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 52428, sign: false }); - data.append(FixedType { mag: 32768, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 43690, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i8_fp8x23.cairo b/src/tests/nodes/softsign_i8_fp8x23.cairo deleted file mode 100644 index cfe9e3ff0..000000000 --- a/src/tests/nodes/softsign_i8_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_i8::NN_i8; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softsign_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softsign(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i8_fp8x23/input_0.cairo b/src/tests/nodes/softsign_i8_fp8x23/input_0.cairo deleted file mode 100644 index fdbb801a5..000000000 --- a/src/tests/nodes/softsign_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 5, sign: false }); - data.append(i8 { mag: 4, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_i8_fp8x23/output_0.cairo b/src/tests/nodes/softsign_i8_fp8x23/output_0.cairo deleted file mode 100644 index 4b47a1a15..000000000 --- a/src/tests/nodes/softsign_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 5592405, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 6990506, sign: false }); - data.append(FixedType { mag: 6710886, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_u32_fp16x16.cairo b/src/tests/nodes/softsign_u32_fp16x16.cairo deleted file mode 100644 index 9f306160c..000000000 --- a/src/tests/nodes/softsign_u32_fp16x16.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softsign_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softsign(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_u32_fp16x16/input_0.cairo b/src/tests/nodes/softsign_u32_fp16x16/input_0.cairo deleted file mode 100644 index 1df7800c3..000000000 --- a/src/tests/nodes/softsign_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(6); - data.append(6); - data.append(6); - data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_u32_fp16x16/output_0.cairo b/src/tests/nodes/softsign_u32_fp16x16/output_0.cairo deleted file mode 100644 index c9fb3b0b3..000000000 --- a/src/tests/nodes/softsign_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 56173, sign: false }); - data.append(FixedType { mag: 56173, sign: false }); - data.append(FixedType { mag: 56173, sign: false }); - data.append(FixedType { mag: 49152, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_u32_fp8x23.cairo b/src/tests/nodes/softsign_u32_fp8x23.cairo deleted file mode 100644 index 3f768b0d8..000000000 --- a/src/tests/nodes/softsign_u32_fp8x23.cairo +++ /dev/null @@ -1,21 +0,0 @@ -mod input_0; -mod output_0; - - -use orion::operators::nn::core::NNTrait; -use orion::numbers::fixed_point::core::FixedTrait; -use orion::operators::nn::implementations::impl_nn_u32::NN_u32; -use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_softsign_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = NNTrait::softsign(@input_0); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_u32_fp8x23/input_0.cairo b/src/tests/nodes/softsign_u32_fp8x23/input_0.cairo deleted file mode 100644 index 6817ce562..000000000 --- a/src/tests/nodes/softsign_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(3); - data.append(5); - data.append(0); - data.append(7); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/softsign_u32_fp8x23/output_0.cairo b/src/tests/nodes/softsign_u32_fp8x23/output_0.cairo deleted file mode 100644 index a8e6933fd..000000000 --- a/src/tests/nodes/softsign_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6291456, sign: false }); - data.append(FixedType { mag: 6990506, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 7340032, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_fp16x16.cairo b/src/tests/nodes/sqrt_fp16x16.cairo index f5c00b883..39424710b 100644 --- a/src/tests/nodes/sqrt_fp16x16.cairo +++ b/src/tests/nodes/sqrt_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sqrt_fp16x16/input_0.cairo b/src/tests/nodes/sqrt_fp16x16/input_0.cairo index 17eaef85e..bc65b62d2 100644 --- a/src/tests/nodes/sqrt_fp16x16/input_0.cairo +++ b/src/tests/nodes/sqrt_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 372701, sign: false }); - data.append(FixedType { mag: 96937, sign: false }); - data.append(FixedType { mag: 172145, sign: false }); - data.append(FixedType { mag: 5219, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 317628, sign: false }); + data.append(FP16x16 { mag: 241773, sign: false }); + data.append(FP16x16 { mag: 229884, sign: false }); + data.append(FP16x16 { mag: 311367, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sqrt_fp16x16/output_0.cairo b/src/tests/nodes/sqrt_fp16x16/output_0.cairo index 0dcf21246..468899f72 100644 --- a/src/tests/nodes/sqrt_fp16x16/output_0.cairo +++ b/src/tests/nodes/sqrt_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 156286, sign: false }); - data.append(FixedType { mag: 79704, sign: false }); - data.append(FixedType { mag: 106215, sign: false }); - data.append(FixedType { mag: 18494, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 144277, sign: false }); + data.append(FP16x16 { mag: 125876, sign: false }); + data.append(FP16x16 { mag: 122742, sign: false }); + data.append(FP16x16 { mag: 142848, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sqrt_fp8x23.cairo b/src/tests/nodes/sqrt_fp8x23.cairo index 4c08c1f12..28aac23e9 100644 --- a/src/tests/nodes/sqrt_fp8x23.cairo +++ b/src/tests/nodes/sqrt_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sqrt_fp8x23/input_0.cairo b/src/tests/nodes/sqrt_fp8x23/input_0.cairo index 47c89cd5c..b46fc3377 100644 --- a/src/tests/nodes/sqrt_fp8x23/input_0.cairo +++ b/src/tests/nodes/sqrt_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 38292032, sign: false }); - data.append(FixedType { mag: 45839538, sign: false }); - data.append(FixedType { mag: 48823512, sign: false }); - data.append(FixedType { mag: 48128484, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 15040676, sign: false }); + data.append(FP8x23 { mag: 25362172, sign: false }); + data.append(FP8x23 { mag: 25487151, sign: false }); + data.append(FP8x23 { mag: 747202, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sqrt_fp8x23/output_0.cairo b/src/tests/nodes/sqrt_fp8x23/output_0.cairo index cd7e540e3..553dc52b3 100644 --- a/src/tests/nodes/sqrt_fp8x23/output_0.cairo +++ b/src/tests/nodes/sqrt_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 17922523, sign: false }); - data.append(FixedType { mag: 19609434, sign: false }); - data.append(FixedType { mag: 20237621, sign: false }); - data.append(FixedType { mag: 20093058, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 11232557, sign: false }); + data.append(FP8x23 { mag: 14586066, sign: false }); + data.append(FP8x23 { mag: 14621960, sign: false }); + data.append(FP8x23 { mag: 2503594, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i32_fp16x16.cairo b/src/tests/nodes/sqrt_i32_fp16x16.cairo deleted file mode 100644 index ba436cfa1..000000000 --- a/src/tests/nodes/sqrt_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sqrt_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sqrt(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i32_fp16x16/input_0.cairo b/src/tests/nodes/sqrt_i32_fp16x16/input_0.cairo deleted file mode 100644 index c3077f1c1..000000000 --- a/src/tests/nodes/sqrt_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 5, sign: false }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i32_fp16x16/output_0.cairo b/src/tests/nodes/sqrt_i32_fp16x16/output_0.cairo deleted file mode 100644 index b8fc3ee0e..000000000 --- a/src/tests/nodes/sqrt_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 92681, sign: false }); - data.append(FixedType { mag: 146542, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i32_fp8x23.cairo b/src/tests/nodes/sqrt_i32_fp8x23.cairo deleted file mode 100644 index 027bea1df..000000000 --- a/src/tests/nodes/sqrt_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sqrt_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sqrt(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i32_fp8x23/input_0.cairo b/src/tests/nodes/sqrt_i32_fp8x23/input_0.cairo deleted file mode 100644 index d11d6e5c6..000000000 --- a/src/tests/nodes/sqrt_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: false }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i32_fp8x23/output_0.cairo b/src/tests/nodes/sqrt_i32_fp8x23/output_0.cairo deleted file mode 100644 index ff1a20abb..000000000 --- a/src/tests/nodes/sqrt_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 14529495, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i8_fp16x16.cairo b/src/tests/nodes/sqrt_i8_fp16x16.cairo deleted file mode 100644 index abe46b8d4..000000000 --- a/src/tests/nodes/sqrt_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sqrt_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sqrt(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i8_fp16x16/input_0.cairo b/src/tests/nodes/sqrt_i8_fp16x16/input_0.cairo deleted file mode 100644 index ce8b680fb..000000000 --- a/src/tests/nodes/sqrt_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 4, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 5, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i8_fp16x16/output_0.cairo b/src/tests/nodes/sqrt_i8_fp16x16/output_0.cairo deleted file mode 100644 index f55d8d5ea..000000000 --- a/src/tests/nodes/sqrt_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 113511, sign: false }); - data.append(FixedType { mag: 146542, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i8_fp8x23.cairo b/src/tests/nodes/sqrt_i8_fp8x23.cairo deleted file mode 100644 index 05d24065d..000000000 --- a/src/tests/nodes/sqrt_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sqrt_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sqrt(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i8_fp8x23/input_0.cairo b/src/tests/nodes/sqrt_i8_fp8x23/input_0.cairo deleted file mode 100644 index 271506e0a..000000000 --- a/src/tests/nodes/sqrt_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 0, sign: false }); - data.append(i8 { mag: 5, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_i8_fp8x23/output_0.cairo b/src/tests/nodes/sqrt_i8_fp8x23/output_0.cairo deleted file mode 100644 index 6cda650be..000000000 --- a/src/tests/nodes/sqrt_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 18759680, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_u32_fp16x16.cairo b/src/tests/nodes/sqrt_u32_fp16x16.cairo deleted file mode 100644 index 4ad9159b3..000000000 --- a/src/tests/nodes/sqrt_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sqrt_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sqrt(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_u32_fp16x16/input_0.cairo b/src/tests/nodes/sqrt_u32_fp16x16/input_0.cairo deleted file mode 100644 index 3284faf22..000000000 --- a/src/tests/nodes/sqrt_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(4); - data.append(4); - data.append(3); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_u32_fp16x16/output_0.cairo b/src/tests/nodes/sqrt_u32_fp16x16/output_0.cairo deleted file mode 100644 index 10aa6b5a2..000000000 --- a/src/tests/nodes/sqrt_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 113511, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_u32_fp8x23.cairo b/src/tests/nodes/sqrt_u32_fp8x23.cairo deleted file mode 100644 index fe30153cd..000000000 --- a/src/tests/nodes/sqrt_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_sqrt_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.sqrt(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_u32_fp8x23/input_0.cairo b/src/tests/nodes/sqrt_u32_fp8x23/input_0.cairo deleted file mode 100644 index e6842fe14..000000000 --- a/src/tests/nodes/sqrt_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(1); - data.append(0); - data.append(4); - data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sqrt_u32_fp8x23/output_0.cairo b/src/tests/nodes/sqrt_u32_fp8x23/output_0.cairo deleted file mode 100644 index ecbd98231..000000000 --- a/src/tests/nodes/sqrt_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 14529495, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16.cairo b/src/tests/nodes/sub_fp16x16.cairo index 31cf9ca7e..ee3ccc2f2 100644 --- a/src/tests/nodes/sub_fp16x16.cairo +++ b/src/tests/nodes/sub_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorSub}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorSub}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_fp16x16() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16/input_0.cairo b/src/tests/nodes/sub_fp16x16/input_0.cairo index 15a5bac5c..f3afb08b1 100644 --- a/src/tests/nodes/sub_fp16x16/input_0.cairo +++ b/src/tests/nodes/sub_fp16x16/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 65536, sign: false }); + 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: 65536, sign: false }); + 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: 196608, sign: true }); + 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: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, 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: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16/input_1.cairo b/src/tests/nodes/sub_fp16x16/input_1.cairo index fe549e5be..8676d06a6 100644 --- a/src/tests/nodes/sub_fp16x16/input_1.cairo +++ b/src/tests/nodes/sub_fp16x16/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +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(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + 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: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, 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: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + 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: 131072, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + 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: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16/output_0.cairo b/src/tests/nodes/sub_fp16x16/output_0.cairo index 7768bb010..32b2d20a0 100644 --- a/src/tests/nodes/sub_fp16x16/output_0.cairo +++ b/src/tests/nodes/sub_fp16x16/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 262144, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 262144, sign: true }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 0, 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: 65536, 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: 65536, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 65536, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16_broadcast.cairo b/src/tests/nodes/sub_fp16x16_broadcast.cairo index b80a003f4..031b58802 100644 --- a/src/tests/nodes/sub_fp16x16_broadcast.cairo +++ b/src/tests/nodes/sub_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorSub}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP16x16Tensor, FP16x16TensorSub}; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_fp16x16_broadcast() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/sub_fp16x16_broadcast/input_0.cairo index a96ae8767..4b7babc68 100644 --- a/src/tests/nodes/sub_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/sub_fp16x16_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +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(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: 65536, 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: 65536, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: 131072, sign: true }); + 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: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/sub_fp16x16_broadcast/input_1.cairo index 3d4c6bb4c..5afeabf4d 100644 --- a/src/tests/nodes/sub_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/sub_fp16x16_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/sub_fp16x16_broadcast/output_0.cairo index 4c8e54d4a..08ef27d96 100644 --- a/src/tests/nodes/sub_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/sub_fp16x16_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +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(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 196608, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 327680, sign: false }); - data.append(FixedType { mag: 262144, sign: false }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 196608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 196608, 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: 262144, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 65536, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + 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: 0, sign: false }); + 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: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23.cairo b/src/tests/nodes/sub_fp8x23.cairo index ee6eaeeb9..3d2e1e402 100644 --- a/src/tests/nodes/sub_fp8x23.cairo +++ b/src/tests/nodes/sub_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorSub}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorSub}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_fp8x23() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23/input_0.cairo b/src/tests/nodes/sub_fp8x23/input_0.cairo index 8a129c069..f4ba5bb90 100644 --- a/src/tests/nodes/sub_fp8x23/input_0.cairo +++ b/src/tests/nodes/sub_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, 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: 16777216, 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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, 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: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23/input_1.cairo b/src/tests/nodes/sub_fp8x23/input_1.cairo index a6aee8a7d..c252cdbfa 100644 --- a/src/tests/nodes/sub_fp8x23/input_1.cairo +++ b/src/tests/nodes/sub_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: true }); + 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: 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: true }); + 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: 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, 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 }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23/output_0.cairo b/src/tests/nodes/sub_fp8x23/output_0.cairo index 80957ee9b..f826bfd59 100644 --- a/src/tests/nodes/sub_fp8x23/output_0.cairo +++ b/src/tests/nodes/sub_fp8x23/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 41943040, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 41943040, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 33554432, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: true }); + 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: 25165824, sign: true }); + data.append(FP8x23 { mag: 41943040, 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: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 41943040, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, 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: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23_broadcast.cairo b/src/tests/nodes/sub_fp8x23_broadcast.cairo index d74ba5415..0b43eb433 100644 --- a/src/tests/nodes/sub_fp8x23_broadcast.cairo +++ b/src/tests/nodes/sub_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::{Tensor_fp, FixedTypeTensorSub}; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{FP8x23Tensor, FP8x23TensorSub}; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_fp8x23_broadcast() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/sub_fp8x23_broadcast/input_0.cairo index af727a84f..4394feacb 100644 --- a/src/tests/nodes/sub_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/sub_fp8x23_broadcast/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + 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: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + 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: 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: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/sub_fp8x23_broadcast/input_1.cairo index 13028f229..01519e485 100644 --- a/src/tests/nodes/sub_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/sub_fp8x23_broadcast/input_1.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(3); shape.append(1); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/sub_fp8x23_broadcast/output_0.cairo index e0c546f08..51f872d37 100644 --- a/src/tests/nodes/sub_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/sub_fp8x23_broadcast/output_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +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(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 41943040, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 41943040, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 33554432, sign: true }); - data.append(FixedType { mag: 41943040, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 41943040, sign: true }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 33554432, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 41943040, 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i32.cairo b/src/tests/nodes/sub_i32.cairo index ae21e669d..a52c80cd6 100644 --- a/src/tests/nodes/sub_i32.cairo +++ b/src/tests/nodes/sub_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorSub}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorSub}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_i32() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_i32/input_0.cairo b/src/tests/nodes/sub_i32/input_0.cairo index f56b8fbb9..285b5135a 100644 --- a/src/tests/nodes/sub_i32/input_0.cairo +++ b/src/tests/nodes/sub_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: true }); - 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: 2, sign: false }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, 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: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); 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: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 1, 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: 2, sign: false }); + data.append(i32 { mag: 0, 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: 0, 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: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i32/input_1.cairo b/src/tests/nodes/sub_i32/input_1.cairo index aaee299dc..b634c93dc 100644 --- a/src/tests/nodes/sub_i32/input_1.cairo +++ b/src/tests/nodes/sub_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -13,32 +12,30 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); + 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: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - 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: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - 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: 2, sign: true }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i32/output_0.cairo b/src/tests/nodes/sub_i32/output_0.cairo index 3df6953a9..1b3de7ea6 100644 --- a/src/tests/nodes/sub_i32/output_0.cairo +++ b/src/tests/nodes/sub_i32/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 5, sign: true }); data.append(i32 { mag: 2, sign: false }); + data.append(i32 { mag: 3, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 5, sign: false }); - data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 5, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, 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: true }); data.append(i32 { mag: 3, 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: 4, sign: false }); data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i32_broadcast.cairo b/src/tests/nodes/sub_i32_broadcast.cairo index c226e74cb..2c33e07d4 100644 --- a/src/tests/nodes/sub_i32_broadcast.cairo +++ b/src/tests/nodes/sub_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::{Tensor_i32, i32TensorSub}; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I32Tensor, I32TensorSub}; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_i32_broadcast() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_i32_broadcast/input_0.cairo b/src/tests/nodes/sub_i32_broadcast/input_0.cairo index 86237a297..08a229d45 100644 --- a/src/tests/nodes/sub_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/sub_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, 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: 2, sign: false }); - data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 1, sign: false }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, 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: 3, sign: true }); + data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, 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: 2, sign: false }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 2, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i32_broadcast/input_1.cairo b/src/tests/nodes/sub_i32_broadcast/input_1.cairo index 2b552ba83..2567db422 100644 --- a/src/tests/nodes/sub_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/sub_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i32_broadcast/output_0.cairo b/src/tests/nodes/sub_i32_broadcast/output_0.cairo index b8d0dff82..deac3558b 100644 --- a/src/tests/nodes/sub_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/sub_i32_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 5, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 3, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 4, 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: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 4, sign: false }); - data.append(i32 { mag: 5, sign: false }); - data.append(i32 { mag: 5, 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: 4, sign: true }); + data.append(i32 { mag: 5, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 3, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 4, sign: true }); + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i8.cairo b/src/tests/nodes/sub_i8.cairo index 256cf2705..67ce0f788 100644 --- a/src/tests/nodes/sub_i8.cairo +++ b/src/tests/nodes/sub_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorSub}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorSub}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_i8() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_i8/input_0.cairo b/src/tests/nodes/sub_i8/input_0.cairo index 6decefd08..e3d610aeb 100644 --- a/src/tests/nodes/sub_i8/input_0.cairo +++ b/src/tests/nodes/sub_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, 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: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i8/input_1.cairo b/src/tests/nodes/sub_i8/input_1.cairo index d6da90704..796a86580 100644 --- a/src/tests/nodes/sub_i8/input_1.cairo +++ b/src/tests/nodes/sub_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); + 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: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: true }); - 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: 2, sign: true }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); 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: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i8/output_0.cairo b/src/tests/nodes/sub_i8/output_0.cairo index 2697b8e39..62debaeae 100644 --- a/src/tests/nodes/sub_i8/output_0.cairo +++ b/src/tests/nodes/sub_i8/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, 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: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 4, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 5, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 4, sign: true }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i8_broadcast.cairo b/src/tests/nodes/sub_i8_broadcast.cairo index a7f9ef56d..38b995ce1 100644 --- a/src/tests/nodes/sub_i8_broadcast.cairo +++ b/src/tests/nodes/sub_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::{Tensor_i8, i8TensorSub}; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{I8Tensor, I8TensorSub}; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_i8_broadcast() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_i8_broadcast/input_0.cairo b/src/tests/nodes/sub_i8_broadcast/input_0.cairo index 32e2271aa..b6941121d 100644 --- a/src/tests/nodes/sub_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/sub_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); + 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: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + 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: false }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i8_broadcast/input_1.cairo b/src/tests/nodes/sub_i8_broadcast/input_1.cairo index 6bcad3332..f7f01b833 100644 --- a/src/tests/nodes/sub_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/sub_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,10 +10,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_i8_broadcast/output_0.cairo b/src/tests/nodes/sub_i8_broadcast/output_0.cairo index 868fe33bd..99ba0b678 100644 --- a/src/tests/nodes/sub_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/sub_i8_broadcast/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,34 +10,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 3, sign: false }); - data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 4, sign: false }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 4, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 5, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 3, sign: false }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 5, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 4, sign: false }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 3, sign: false }); data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_u32.cairo b/src/tests/nodes/sub_u32.cairo index c1680a309..d26c7449c 100644 --- a/src/tests/nodes/sub_u32.cairo +++ b/src/tests/nodes/sub_u32.cairo @@ -1,12 +1,12 @@ -mod input_0; -mod input_1; -mod output_0; +mod input_0; +mod input_1; +mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorSub}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorSub}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/sub_u32/input_0.cairo b/src/tests/nodes/sub_u32/input_0.cairo index 1f08942a0..457bc9d0c 100644 --- a/src/tests/nodes/sub_u32/input_0.cairo +++ b/src/tests/nodes/sub_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(4); data.append(5); data.append(3); data.append(3); + data.append(3); data.append(5); - data.append(5); + data.append(3); data.append(4); + data.append(3); data.append(4); - data.append(5); + data.append(3); data.append(3); data.append(4); - data.append(5); + data.append(3); + data.append(3); data.append(4); data.append(3); data.append(5); data.append(3); - data.append(4); data.append(5); data.append(5); data.append(4); - data.append(5); data.append(3); data.append(3); - data.append(5); data.append(4); data.append(4); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_u32/input_1.cairo b/src/tests/nodes/sub_u32/input_1.cairo index 4b98bd254..e963c919d 100644 --- a/src/tests/nodes/sub_u32/input_1.cairo +++ b/src/tests/nodes/sub_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); - data.append(2); - data.append(1); data.append(2); data.append(1); - data.append(0); data.append(2); data.append(2); data.append(1); - data.append(1); data.append(0); data.append(1); - data.append(1); data.append(0); data.append(0); + data.append(2); + data.append(2); data.append(1); + data.append(0); data.append(1); data.append(2); - data.append(2); + data.append(0); data.append(0); data.append(2); data.append(1); data.append(1); data.append(0); + data.append(2); data.append(0); data.append(0); + data.append(2); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_u32/output_0.cairo b/src/tests/nodes/sub_u32/output_0.cairo index 94af33104..2c57cd25d 100644 --- a/src/tests/nodes/sub_u32/output_0.cairo +++ b/src/tests/nodes/sub_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(4); data.append(3); data.append(2); data.append(1); + data.append(1); data.append(4); - data.append(5); - data.append(2); - data.append(2); - data.append(4); - data.append(2); - data.append(4); - data.append(4); - data.append(3); - data.append(3); - data.append(5); - data.append(2); data.append(3); data.append(3); data.append(3); data.append(4); + data.append(1); + data.append(1); + data.append(3); data.append(3); data.append(2); data.append(2); + data.append(3); data.append(5); + data.append(1); data.append(4); data.append(4); data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(3); + data.append(4); + data.append(2); + data.append(5); + data.append(5); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_u32_broadcast.cairo b/src/tests/nodes/sub_u32_broadcast.cairo index ee04a19f7..74bebbf12 100644 --- a/src/tests/nodes/sub_u32_broadcast.cairo +++ b/src/tests/nodes/sub_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::{Tensor_u32, u32TensorSub}; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::{U32Tensor, U32TensorSub}; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] @@ -19,4 +19,4 @@ fn test_sub_u32_broadcast() { let y = input_0 - input_1; assert_eq(y, z); -} +} \ No newline at end of file diff --git a/src/tests/nodes/sub_u32_broadcast/input_0.cairo b/src/tests/nodes/sub_u32_broadcast/input_0.cairo index d495450a5..e90e880fc 100644 --- a/src/tests/nodes/sub_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/sub_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,33 +10,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(5); - data.append(4); - data.append(3); - data.append(4); - data.append(4); - data.append(5); - data.append(5); - data.append(4); - data.append(5); data.append(5); data.append(4); data.append(4); - data.append(4); - data.append(5); - data.append(5); data.append(3); data.append(5); + data.append(3); data.append(5); + data.append(3); data.append(5); data.append(4); + data.append(3); + data.append(3); data.append(5); + data.append(4); data.append(5); + data.append(4); + data.append(3); + data.append(3); data.append(5); data.append(3); data.append(3); + data.append(5); + data.append(4); data.append(3); data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_u32_broadcast/input_1.cairo b/src/tests/nodes/sub_u32_broadcast/input_1.cairo index fecd05f8f..b1fdd26bd 100644 --- a/src/tests/nodes/sub_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/sub_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn input_1() -> Tensor { shape.append(1); let mut data = ArrayTrait::new(); - data.append(1); data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/sub_u32_broadcast/output_0.cairo b/src/tests/nodes/sub_u32_broadcast/output_0.cairo index dae8a8ba7..192af5be9 100644 --- a/src/tests/nodes/sub_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/sub_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn output_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); + data.append(5); + data.append(5); data.append(4); data.append(3); data.append(2); data.append(4); - data.append(4); + data.append(3); + data.append(5); + data.append(3); data.append(5); data.append(4); data.append(3); + data.append(2); data.append(4); + data.append(3); + data.append(5); data.append(4); data.append(3); data.append(3); - data.append(4); - data.append(5); data.append(5); + data.append(3); data.append(2); data.append(4); - data.append(4); - data.append(4); data.append(3); - data.append(4); - data.append(5); + data.append(3); data.append(5); data.append(3); - data.append(2); - data.append(2); - data.append(4); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/tanh_fp16x16.cairo b/src/tests/nodes/tanh_fp16x16.cairo index 707d6e10d..28dc8bead 100644 --- a/src/tests/nodes/tanh_fp16x16.cairo +++ b/src/tests/nodes/tanh_fp16x16.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/tanh_fp16x16/input_0.cairo b/src/tests/nodes/tanh_fp16x16/input_0.cairo index 48342c9f4..deaf0ba70 100644 --- a/src/tests/nodes/tanh_fp16x16/input_0.cairo +++ b/src/tests/nodes/tanh_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 30249, sign: true }); - data.append(FixedType { mag: 165174, sign: true }); - data.append(FixedType { mag: 145036, sign: false }); - data.append(FixedType { mag: 81100, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 60947, sign: true }); + data.append(FP16x16 { mag: 18316, sign: true }); + data.append(FP16x16 { mag: 60057, sign: false }); + data.append(FP16x16 { mag: 56869, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/tanh_fp16x16/output_0.cairo b/src/tests/nodes/tanh_fp16x16/output_0.cairo index e0c128d08..c1712bf05 100644 --- a/src/tests/nodes/tanh_fp16x16/output_0.cairo +++ b/src/tests/nodes/tanh_fp16x16/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 28269, sign: true }); - data.append(FixedType { mag: 64693, sign: true }); - data.append(FixedType { mag: 63986, sign: false }); - data.append(FixedType { mag: 55360, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 47879, sign: true }); + data.append(FP16x16 { mag: 17853, sign: true }); + data.append(FP16x16 { mag: 47460, sign: false }); + data.append(FP16x16 { mag: 45890, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/tanh_fp8x23.cairo b/src/tests/nodes/tanh_fp8x23.cairo index d4ded21d5..049171f04 100644 --- a/src/tests/nodes/tanh_fp8x23.cairo +++ b/src/tests/nodes/tanh_fp8x23.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/tanh_fp8x23/input_0.cairo b/src/tests/nodes/tanh_fp8x23/input_0.cairo index a74f9b51b..d575e6042 100644 --- a/src/tests/nodes/tanh_fp8x23/input_0.cairo +++ b/src/tests/nodes/tanh_fp8x23/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 17641894, sign: true }); - data.append(FixedType { mag: 8395817, sign: true }); - data.append(FixedType { mag: 24711252, sign: true }); - data.append(FixedType { mag: 1922655, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 7865643, sign: false }); + data.append(FP8x23 { mag: 14710904, sign: true }); + data.append(FP8x23 { mag: 8475156, sign: true }); + data.append(FP8x23 { mag: 8392465, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/tanh_fp8x23/output_0.cairo b/src/tests/nodes/tanh_fp8x23/output_0.cairo index a1dd717ab..e638eddbe 100644 --- a/src/tests/nodes/tanh_fp8x23/output_0.cairo +++ b/src/tests/nodes/tanh_fp8x23/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8142239, sign: true }); - data.append(FixedType { mag: 6391740, sign: true }); - data.append(FixedType { mag: 8342388, sign: true }); - data.append(FixedType { mag: 1889681, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 6158448, sign: false }); + data.append(FP8x23 { mag: 7900328, sign: true }); + data.append(FP8x23 { mag: 6424778, sign: true }); + data.append(FP8x23 { mag: 6390334, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/tanh_i32_fp16x16.cairo b/src/tests/nodes/tanh_i32_fp16x16.cairo deleted file mode 100644 index 831f030f4..000000000 --- a/src/tests/nodes/tanh_i32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_tanh_i32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.tanh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i32_fp16x16/input_0.cairo b/src/tests/nodes/tanh_i32_fp16x16/input_0.cairo deleted file mode 100644 index 3f3ef4067..000000000 --- a/src/tests/nodes/tanh_i32_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i32_fp16x16/output_0.cairo b/src/tests/nodes/tanh_i32_fp16x16/output_0.cairo deleted file mode 100644 index 7910c3e23..000000000 --- a/src/tests/nodes/tanh_i32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 63178, sign: false }); - data.append(FixedType { mag: 49911, sign: true }); - data.append(FixedType { mag: 63178, sign: false }); - data.append(FixedType { mag: 49911, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i32_fp8x23.cairo b/src/tests/nodes/tanh_i32_fp8x23.cairo deleted file mode 100644 index 433e8eaf2..000000000 --- a/src/tests/nodes/tanh_i32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_tanh_i32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.tanh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i32_fp8x23/input_0.cairo b/src/tests/nodes/tanh_i32_fp8x23/input_0.cairo deleted file mode 100644 index a9f8fd5ec..000000000 --- a/src/tests/nodes/tanh_i32_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::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: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i32_fp8x23/output_0.cairo b/src/tests/nodes/tanh_i32_fp8x23/output_0.cairo deleted file mode 100644 index d554ca394..000000000 --- a/src/tests/nodes/tanh_i32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6388714, sign: true }); - data.append(FixedType { mag: 8086849, sign: false }); - data.append(FixedType { mag: 8086849, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i8_fp16x16.cairo b/src/tests/nodes/tanh_i8_fp16x16.cairo deleted file mode 100644 index dba89a2a7..000000000 --- a/src/tests/nodes/tanh_i8_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_tanh_i8_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.tanh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i8_fp16x16/input_0.cairo b/src/tests/nodes/tanh_i8_fp16x16/input_0.cairo deleted file mode 100644 index 9334c034d..000000000 --- a/src/tests/nodes/tanh_i8_fp16x16/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i8_fp16x16/output_0.cairo b/src/tests/nodes/tanh_i8_fp16x16/output_0.cairo deleted file mode 100644 index 36c5719a2..000000000 --- a/src/tests/nodes/tanh_i8_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 49911, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 49911, sign: true }); - data.append(FixedType { mag: 49911, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i8_fp8x23.cairo b/src/tests/nodes/tanh_i8_fp8x23.cairo deleted file mode 100644 index 90745c492..000000000 --- a/src/tests/nodes/tanh_i8_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_tanh_i8_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.tanh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i8_fp8x23/input_0.cairo b/src/tests/nodes/tanh_i8_fp8x23/input_0.cairo deleted file mode 100644 index 6d20083f2..000000000 --- a/src/tests/nodes/tanh_i8_fp8x23/input_0.cairo +++ /dev/null @@ -1,20 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::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: 1, sign: true }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 1, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_i8_fp8x23/output_0.cairo b/src/tests/nodes/tanh_i8_fp8x23/output_0.cairo deleted file mode 100644 index c0da54618..000000000 --- a/src/tests/nodes/tanh_i8_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6389760, sign: true }); - data.append(FixedType { mag: 6389760, sign: true }); - data.append(FixedType { mag: 6389760, sign: false }); - data.append(FixedType { mag: 6389760, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_u32_fp16x16.cairo b/src/tests/nodes/tanh_u32_fp16x16.cairo deleted file mode 100644 index aaee1faff..000000000 --- a/src/tests/nodes/tanh_u32_fp16x16.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_tanh_u32_fp16x16() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.tanh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_u32_fp16x16/input_0.cairo b/src/tests/nodes/tanh_u32_fp16x16/input_0.cairo deleted file mode 100644 index 695a993a3..000000000 --- a/src/tests/nodes/tanh_u32_fp16x16/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -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(4); - data.append(4); - data.append(2); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_u32_fp16x16/output_0.cairo b/src/tests/nodes/tanh_u32_fp16x16/output_0.cairo deleted file mode 100644 index a8d5fcf08..000000000 --- a/src/tests/nodes/tanh_u32_fp16x16/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 65492, sign: false }); - data.append(FixedType { mag: 65492, sign: false }); - data.append(FixedType { mag: 63178, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_u32_fp8x23.cairo b/src/tests/nodes/tanh_u32_fp8x23.cairo deleted file mode 100644 index 747842ba3..000000000 --- a/src/tests/nodes/tanh_u32_fp8x23.cairo +++ /dev/null @@ -1,20 +0,0 @@ -mod input_0; -mod output_0; - - -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; -use orion::utils::assert_eq; - -#[test] -#[available_gas(2000000000)] -fn test_tanh_u32_fp8x23() { - let input_0 = input_0::input_0(); - let z = output_0::output_0(); - - let y = input_0.tanh(); - - assert_eq(y, z); -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_u32_fp8x23/input_0.cairo b/src/tests/nodes/tanh_u32_fp8x23/input_0.cairo deleted file mode 100644 index 231ca3ecc..000000000 --- a/src/tests/nodes/tanh_u32_fp8x23/input_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - -fn input_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(5); - data.append(3); - data.append(4); - data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/tanh_u32_fp8x23/output_0.cairo b/src/tests/nodes/tanh_u32_fp8x23/output_0.cairo deleted file mode 100644 index e8720b550..000000000 --- a/src/tests/nodes/tanh_u32_fp8x23/output_0.cairo +++ /dev/null @@ -1,19 +0,0 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - -fn output_0() -> Tensor { - let mut shape = ArrayTrait::::new(); - shape.append(2); - shape.append(2); - - let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 8387846, sign: false }); - data.append(FixedType { mag: 8347124, sign: false }); - data.append(FixedType { mag: 8382981, sign: false }); - data.append(FixedType { mag: 8347124, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) -} \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp16x16_2d.cairo b/src/tests/nodes/transpose_fp16x16_2d.cairo index 7c8091b6e..8518391c3 100644 --- a/src/tests/nodes/transpose_fp16x16_2d.cairo +++ b/src/tests/nodes/transpose_fp16x16_2d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_fp16x16_2d/input_0.cairo b/src/tests/nodes/transpose_fp16x16_2d/input_0.cairo index 7d1f9f770..44fdf69f3 100644 --- a/src/tests/nodes/transpose_fp16x16_2d/input_0.cairo +++ b/src/tests/nodes/transpose_fp16x16_2d/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6553600, sign: true }); - data.append(FixedType { mag: 4325376, sign: true }); - data.append(FixedType { mag: 7864320, sign: true }); - data.append(FixedType { mag: 4587520, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 327680, sign: true }); + data.append(FP16x16 { mag: 4915200, sign: true }); + data.append(FP16x16 { mag: 7208960, sign: false }); + data.append(FP16x16 { mag: 458752, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp16x16_2d/output_0.cairo b/src/tests/nodes/transpose_fp16x16_2d/output_0.cairo index cd48e7193..5dfd272d6 100644 --- a/src/tests/nodes/transpose_fp16x16_2d/output_0.cairo +++ b/src/tests/nodes/transpose_fp16x16_2d/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 6553600, sign: true }); - data.append(FixedType { mag: 7864320, sign: true }); - data.append(FixedType { mag: 4325376, sign: true }); - data.append(FixedType { mag: 4587520, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 327680, sign: true }); + data.append(FP16x16 { mag: 7208960, sign: false }); + data.append(FP16x16 { mag: 4915200, sign: true }); + data.append(FP16x16 { mag: 458752, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp16x16_3d.cairo b/src/tests/nodes/transpose_fp16x16_3d.cairo index 1635c937f..45333106b 100644 --- a/src/tests/nodes/transpose_fp16x16_3d.cairo +++ b/src/tests/nodes/transpose_fp16x16_3d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP16x16Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::FP16x16TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_fp16x16_3d/input_0.cairo b/src/tests/nodes/transpose_fp16x16_3d/input_0.cairo index e7191d8ed..aaa8ef6de 100644 --- a/src/tests/nodes/transpose_fp16x16_3d/input_0.cairo +++ b/src/tests/nodes/transpose_fp16x16_3d/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2621440, sign: false }); - data.append(FixedType { mag: 7012352, sign: true }); - data.append(FixedType { mag: 3080192, sign: false }); - data.append(FixedType { mag: 5111808, sign: true }); - data.append(FixedType { mag: 6553600, sign: true }); - data.append(FixedType { mag: 3866624, sign: true }); - data.append(FixedType { mag: 1900544, sign: false }); - data.append(FixedType { mag: 2686976, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 7340032, sign: false }); + data.append(FP16x16 { mag: 5701632, sign: true }); + data.append(FP16x16 { mag: 1376256, sign: true }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: true }); + data.append(FP16x16 { mag: 589824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp16x16_3d/output_0.cairo b/src/tests/nodes/transpose_fp16x16_3d/output_0.cairo index e394702ed..291e5ff22 100644 --- a/src/tests/nodes/transpose_fp16x16_3d/output_0.cairo +++ b/src/tests/nodes/transpose_fp16x16_3d/output_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 2621440, sign: false }); - data.append(FixedType { mag: 6553600, sign: true }); - data.append(FixedType { mag: 7012352, sign: true }); - data.append(FixedType { mag: 3866624, sign: true }); - data.append(FixedType { mag: 3080192, sign: false }); - data.append(FixedType { mag: 1900544, sign: false }); - data.append(FixedType { mag: 5111808, sign: true }); - data.append(FixedType { mag: 2686976, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 262144, sign: false }); + data.append(FP16x16 { mag: 2424832, sign: false }); + data.append(FP16x16 { mag: 7340032, sign: false }); + data.append(FP16x16 { mag: 3866624, sign: true }); + data.append(FP16x16 { mag: 5701632, sign: true }); + data.append(FP16x16 { mag: 2359296, sign: true }); + data.append(FP16x16 { mag: 1376256, sign: true }); + data.append(FP16x16 { mag: 589824, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp8x23_2d.cairo b/src/tests/nodes/transpose_fp8x23_2d.cairo index 2279aff6f..93de8b029 100644 --- a/src/tests/nodes/transpose_fp8x23_2d.cairo +++ b/src/tests/nodes/transpose_fp8x23_2d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_fp8x23_2d/input_0.cairo b/src/tests/nodes/transpose_fp8x23_2d/input_0.cairo index 384951fa6..0d03b1ea9 100644 --- a/src/tests/nodes/transpose_fp8x23_2d/input_0.cairo +++ b/src/tests/nodes/transpose_fp8x23_2d/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 276824064, sign: false }); - data.append(FixedType { mag: 117440512, sign: false }); - data.append(FixedType { mag: 889192448, sign: false }); - data.append(FixedType { mag: 402653184, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 771751936, sign: false }); + data.append(FP8x23 { mag: 754974720, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp8x23_2d/output_0.cairo b/src/tests/nodes/transpose_fp8x23_2d/output_0.cairo index 5cc353282..01800798c 100644 --- a/src/tests/nodes/transpose_fp8x23_2d/output_0.cairo +++ b/src/tests/nodes/transpose_fp8x23_2d/output_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 276824064, sign: false }); - data.append(FixedType { mag: 889192448, sign: false }); - data.append(FixedType { mag: 117440512, sign: false }); - data.append(FixedType { mag: 402653184, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 595591168, sign: false }); + data.append(FP8x23 { mag: 754974720, sign: false }); + data.append(FP8x23 { mag: 771751936, sign: false }); + data.append(FP8x23 { mag: 578813952, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp8x23_3d.cairo b/src/tests/nodes/transpose_fp8x23_3d.cairo index cbf0f9bc4..7a9975363 100644 --- a/src/tests/nodes/transpose_fp8x23_3d.cairo +++ b/src/tests/nodes/transpose_fp8x23_3d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_fp::FP8x23Tensor::FPTensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::FP8x23TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_fp8x23_3d/input_0.cairo b/src/tests/nodes/transpose_fp8x23_3d/input_0.cairo index 5f1c591d1..b9fc54101 100644 --- a/src/tests/nodes/transpose_fp8x23_3d/input_0.cairo +++ b/src/tests/nodes/transpose_fp8x23_3d/input_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 905969664, sign: false }); - data.append(FixedType { mag: 838860800, sign: true }); - data.append(FixedType { mag: 142606336, sign: false }); - data.append(FixedType { mag: 159383552, sign: false }); - data.append(FixedType { mag: 721420288, sign: true }); - data.append(FixedType { mag: 276824064, sign: false }); - data.append(FixedType { mag: 226492416, sign: false }); - data.append(FixedType { mag: 629145600, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 427819008, sign: true }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 905969664, sign: true }); + data.append(FP8x23 { mag: 360710144, sign: true }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 838860800, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_fp8x23_3d/output_0.cairo b/src/tests/nodes/transpose_fp8x23_3d/output_0.cairo index 8d9b8008b..df49a1863 100644 --- a/src/tests/nodes/transpose_fp8x23_3d/output_0.cairo +++ b/src/tests/nodes/transpose_fp8x23_3d/output_0.cairo @@ -1,24 +1,23 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn output_0() -> Tensor { +fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 905969664, sign: false }); - data.append(FixedType { mag: 721420288, sign: true }); - data.append(FixedType { mag: 838860800, sign: true }); - data.append(FixedType { mag: 276824064, sign: false }); - data.append(FixedType { mag: 142606336, sign: false }); - data.append(FixedType { mag: 226492416, sign: false }); - data.append(FixedType { mag: 159383552, sign: false }); - data.append(FixedType { mag: 629145600, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 427819008, sign: false }); + data.append(FP8x23 { mag: 360710144, sign: true }); + data.append(FP8x23 { mag: 427819008, sign: true }); + data.append(FP8x23 { mag: 897581056, sign: false }); + data.append(FP8x23 { mag: 385875968, sign: false }); + data.append(FP8x23 { mag: 58720256, sign: false }); + data.append(FP8x23 { mag: 905969664, sign: true }); + data.append(FP8x23 { mag: 838860800, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i32_2d.cairo b/src/tests/nodes/transpose_i32_2d.cairo index 759ab7ff5..6c3a62908 100644 --- a/src/tests/nodes/transpose_i32_2d.cairo +++ b/src/tests/nodes/transpose_i32_2d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_i32_2d/input_0.cairo b/src/tests/nodes/transpose_i32_2d/input_0.cairo index 77090588e..89cf660d2 100644 --- a/src/tests/nodes/transpose_i32_2d/input_0.cairo +++ b/src/tests/nodes/transpose_i32_2d/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 97, sign: true }); - data.append(i32 { mag: 89, sign: true }); - data.append(i32 { mag: 104, sign: true }); - data.append(i32 { mag: 99, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 126, sign: false }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 108, sign: true }); + data.append(i32 { mag: 76, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i32_2d/output_0.cairo b/src/tests/nodes/transpose_i32_2d/output_0.cairo index 9b3ebc3ae..b944c98ba 100644 --- a/src/tests/nodes/transpose_i32_2d/output_0.cairo +++ b/src/tests/nodes/transpose_i32_2d/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 97, sign: true }); - data.append(i32 { mag: 104, sign: true }); - data.append(i32 { mag: 89, sign: true }); - data.append(i32 { mag: 99, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 126, sign: false }); + data.append(i32 { mag: 108, sign: true }); + data.append(i32 { mag: 111, sign: true }); + data.append(i32 { mag: 76, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i32_3d.cairo b/src/tests/nodes/transpose_i32_3d.cairo index 40e456281..91dd82bf9 100644 --- a/src/tests/nodes/transpose_i32_3d.cairo +++ b/src/tests/nodes/transpose_i32_3d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_i32::i32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::I32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_i32_3d/input_0.cairo b/src/tests/nodes/transpose_i32_3d/input_0.cairo index 1b7caaa6e..1db626fe7 100644 --- a/src/tests/nodes/transpose_i32_3d/input_0.cairo +++ b/src/tests/nodes/transpose_i32_3d/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 26, sign: false }); - data.append(i32 { mag: 55, sign: false }); - data.append(i32 { mag: 57, sign: false }); - data.append(i32 { mag: 89, sign: true }); - data.append(i32 { mag: 73, sign: false }); + data.append(i32 { mag: 26, sign: true }); + data.append(i32 { mag: 28, sign: true }); + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 27, sign: true }); + data.append(i32 { mag: 22, sign: false }); data.append(i32 { mag: 82, sign: false }); - data.append(i32 { mag: 92, sign: false }); - data.append(i32 { mag: 70, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 62, sign: false }); + data.append(i32 { mag: 54, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i32_3d/output_0.cairo b/src/tests/nodes/transpose_i32_3d/output_0.cairo index 1366da6bb..ac0efdce2 100644 --- a/src/tests/nodes/transpose_i32_3d/output_0.cairo +++ b/src/tests/nodes/transpose_i32_3d/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I32Tensor; +use orion::numbers::{IntegerTrait, i32}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,15 +10,13 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 26, sign: false }); - data.append(i32 { mag: 73, sign: false }); - data.append(i32 { mag: 55, sign: false }); + data.append(i32 { mag: 26, sign: true }); + data.append(i32 { mag: 22, sign: false }); + data.append(i32 { mag: 28, sign: true }); data.append(i32 { mag: 82, sign: false }); - data.append(i32 { mag: 57, sign: false }); - data.append(i32 { mag: 92, sign: false }); - data.append(i32 { mag: 89, sign: true }); - data.append(i32 { mag: 70, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 45, sign: false }); + data.append(i32 { mag: 62, sign: false }); + data.append(i32 { mag: 27, sign: true }); + data.append(i32 { mag: 54, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i8_2d.cairo b/src/tests/nodes/transpose_i8_2d.cairo index 45eda81f0..f0018ffc7 100644 --- a/src/tests/nodes/transpose_i8_2d.cairo +++ b/src/tests/nodes/transpose_i8_2d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_i8_2d/input_0.cairo b/src/tests/nodes/transpose_i8_2d/input_0.cairo index 285025d19..43baf095b 100644 --- a/src/tests/nodes/transpose_i8_2d/input_0.cairo +++ b/src/tests/nodes/transpose_i8_2d/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 39, sign: false }); - data.append(i8 { mag: 117, sign: true }); - data.append(i8 { mag: 60, sign: true }); - data.append(i8 { mag: 41, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 109, sign: false }); + data.append(i8 { mag: 54, sign: true }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 17, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i8_2d/output_0.cairo b/src/tests/nodes/transpose_i8_2d/output_0.cairo index 833fe1cd7..0ce510017 100644 --- a/src/tests/nodes/transpose_i8_2d/output_0.cairo +++ b/src/tests/nodes/transpose_i8_2d/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,11 +9,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 39, sign: false }); - data.append(i8 { mag: 60, sign: true }); - data.append(i8 { mag: 117, sign: true }); - data.append(i8 { mag: 41, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 109, sign: false }); + data.append(i8 { mag: 30, sign: true }); + data.append(i8 { mag: 54, sign: true }); + data.append(i8 { mag: 17, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i8_3d.cairo b/src/tests/nodes/transpose_i8_3d.cairo index dfd1e7a3e..e2275f9e8 100644 --- a/src/tests/nodes/transpose_i8_3d.cairo +++ b/src/tests/nodes/transpose_i8_3d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i8::i8TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I8TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_i8_3d/input_0.cairo b/src/tests/nodes/transpose_i8_3d/input_0.cairo index ffb72b427..6bc3c421f 100644 --- a/src/tests/nodes/transpose_i8_3d/input_0.cairo +++ b/src/tests/nodes/transpose_i8_3d/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,15 +10,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 8, sign: false }); - data.append(i8 { mag: 37, sign: true }); - data.append(i8 { mag: 30, sign: true }); - data.append(i8 { mag: 124, sign: false }); - data.append(i8 { mag: 117, sign: false }); - data.append(i8 { mag: 57, sign: true }); - data.append(i8 { mag: 92, sign: false }); - data.append(i8 { mag: 28, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 85, sign: true }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 14, sign: false }); + data.append(i8 { mag: 75, sign: false }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 84, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_i8_3d/output_0.cairo b/src/tests/nodes/transpose_i8_3d/output_0.cairo index 934273245..0561ce16f 100644 --- a/src/tests/nodes/transpose_i8_3d/output_0.cairo +++ b/src/tests/nodes/transpose_i8_3d/output_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::I8Tensor; +use orion::numbers::{IntegerTrait, i8}; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,15 +10,13 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 8, sign: false }); - data.append(i8 { mag: 117, sign: false }); - data.append(i8 { mag: 37, sign: true }); - data.append(i8 { mag: 57, sign: true }); - data.append(i8 { mag: 30, sign: true }); - data.append(i8 { mag: 92, sign: false }); - data.append(i8 { mag: 124, sign: false }); - data.append(i8 { mag: 28, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 85, sign: true }); + data.append(i8 { mag: 75, sign: false }); + data.append(i8 { mag: 70, sign: false }); + data.append(i8 { mag: 79, sign: false }); + data.append(i8 { mag: 113, sign: true }); + data.append(i8 { mag: 80, sign: false }); + data.append(i8 { mag: 14, sign: false }); + data.append(i8 { mag: 84, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_u32_2d.cairo b/src/tests/nodes/transpose_u32_2d.cairo index 0b57b56ed..cf85578ed 100644 --- a/src/tests/nodes/transpose_u32_2d.cairo +++ b/src/tests/nodes/transpose_u32_2d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_u32_2d/input_0.cairo b/src/tests/nodes/transpose_u32_2d/input_0.cairo index 9068f0aac..223599a73 100644 --- a/src/tests/nodes/transpose_u32_2d/input_0.cairo +++ b/src/tests/nodes/transpose_u32_2d/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(201); - data.append(13); - data.append(203); - data.append(125); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(128); + data.append(228); + data.append(50); + data.append(212); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_u32_2d/output_0.cairo b/src/tests/nodes/transpose_u32_2d/output_0.cairo index 895fc568b..d7bdc47d7 100644 --- a/src/tests/nodes/transpose_u32_2d/output_0.cairo +++ b/src/tests/nodes/transpose_u32_2d/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(201); - data.append(203); - data.append(13); - data.append(125); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(128); + data.append(50); + data.append(228); + data.append(212); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_u32_3d.cairo b/src/tests/nodes/transpose_u32_3d.cairo index 34293c5e8..e315043d7 100644 --- a/src/tests/nodes/transpose_u32_3d.cairo +++ b/src/tests/nodes/transpose_u32_3d.cairo @@ -2,10 +2,10 @@ mod input_0; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/transpose_u32_3d/input_0.cairo b/src/tests/nodes/transpose_u32_3d/input_0.cairo index be8fe4d4e..02fba471b 100644 --- a/src/tests/nodes/transpose_u32_3d/input_0.cairo +++ b/src/tests/nodes/transpose_u32_3d/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(180); - data.append(20); - data.append(198); - data.append(208); - data.append(61); - data.append(240); - data.append(165); - data.append(75); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(6); + data.append(44); + data.append(94); + data.append(97); + data.append(104); + data.append(24); + data.append(21); + data.append(83); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/transpose_u32_3d/output_0.cairo b/src/tests/nodes/transpose_u32_3d/output_0.cairo index 457192daf..12694d086 100644 --- a/src/tests/nodes/transpose_u32_3d/output_0.cairo +++ b/src/tests/nodes/transpose_u32_3d/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,15 +9,13 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(180); - data.append(61); - data.append(20); - data.append(240); - data.append(198); - data.append(165); - data.append(208); - data.append(75); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(6); + data.append(104); + data.append(44); + data.append(24); + data.append(94); + data.append(21); + data.append(97); + data.append(83); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp16x16.cairo b/src/tests/nodes/xor_fp16x16.cairo index 68f5280f2..08b6c36ae 100644 --- a/src/tests/nodes/xor_fp16x16.cairo +++ b/src/tests/nodes/xor_fp16x16.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_fp16x16/input_0.cairo b/src/tests/nodes/xor_fp16x16/input_0.cairo index 362f5a579..fff479495 100644 --- a/src/tests/nodes/xor_fp16x16/input_0.cairo +++ b/src/tests/nodes/xor_fp16x16/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 131072, sign: false }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 196608, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp16x16/input_1.cairo b/src/tests/nodes/xor_fp16x16/input_1.cairo index d5fb87471..35b36e995 100644 --- a/src/tests/nodes/xor_fp16x16/input_1.cairo +++ b/src/tests/nodes/xor_fp16x16/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 196608, sign: true }); - data.append(FixedType { mag: 196608, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp16x16/output_0.cairo b/src/tests/nodes/xor_fp16x16/output_0.cairo index 619c5c756..e7b1da4b1 100644 --- a/src/tests/nodes/xor_fp16x16/output_0.cairo +++ b/src/tests/nodes/xor_fp16x16/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp16x16_broadcast.cairo b/src/tests/nodes/xor_fp16x16_broadcast.cairo index 47b4e232f..b82315df3 100644 --- a/src/tests/nodes/xor_fp16x16_broadcast.cairo +++ b/src/tests/nodes/xor_fp16x16_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP16x16Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_fp16x16_broadcast/input_0.cairo b/src/tests/nodes/xor_fp16x16_broadcast/input_0.cairo index 84742967b..7f8ad7c16 100644 --- a/src/tests/nodes/xor_fp16x16_broadcast/input_0.cairo +++ b/src/tests/nodes/xor_fp16x16_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 65536, sign: true }); - data.append(FixedType { mag: 131072, sign: true }); - data.append(FixedType { mag: 65536, sign: false }); - data.append(FixedType { mag: 65536, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 0, sign: false }); + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 131072, sign: true }); + data.append(FP16x16 { mag: 131072, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp16x16_broadcast/input_1.cairo b/src/tests/nodes/xor_fp16x16_broadcast/input_1.cairo index f49e3c1fe..4e47e4f2c 100644 --- a/src/tests/nodes/xor_fp16x16_broadcast/input_1.cairo +++ b/src/tests/nodes/xor_fp16x16_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP16x16Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP16x16; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP16x16 { mag: 131072, sign: false }); + data.append(FP16x16 { mag: 65536, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp16x16_broadcast/output_0.cairo b/src/tests/nodes/xor_fp16x16_broadcast/output_0.cairo index 04e17d1f2..0cc7de207 100644 --- a/src/tests/nodes/xor_fp16x16_broadcast/output_0.cairo +++ b/src/tests/nodes/xor_fp16x16_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(1); - data.append(1); - data.append(1); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp8x23.cairo b/src/tests/nodes/xor_fp8x23.cairo index de2662dc9..4be36252e 100644 --- a/src/tests/nodes/xor_fp8x23.cairo +++ b/src/tests/nodes/xor_fp8x23.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_fp8x23/input_0.cairo b/src/tests/nodes/xor_fp8x23/input_0.cairo index 4e1c89565..2b77e8b23 100644 --- a/src/tests/nodes/xor_fp8x23/input_0.cairo +++ b/src/tests/nodes/xor_fp8x23/input_0.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +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(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + 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: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, 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: 8388608, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + 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: 16777216, sign: false }); + 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: 0, 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 }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp8x23/input_1.cairo b/src/tests/nodes/xor_fp8x23/input_1.cairo index 8c2476f26..e68e28e05 100644 --- a/src/tests/nodes/xor_fp8x23/input_1.cairo +++ b/src/tests/nodes/xor_fp8x23/input_1.cairo @@ -1,43 +1,42 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +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(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 0, sign: false }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 25165824, sign: true }); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: true }); - data.append(FixedType { mag: 16777216, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + 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: 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: 25165824, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 25165824, sign: true }); + 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: 0, sign: false }); + 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: 0, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + data.append(FP8x23 { mag: 0, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp8x23/output_0.cairo b/src/tests/nodes/xor_fp8x23/output_0.cairo index 656163d00..70f2eb1c0 100644 --- a/src/tests/nodes/xor_fp8x23/output_0.cairo +++ b/src/tests/nodes/xor_fp8x23/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,31 +12,29 @@ fn output_0() -> Tensor { data.append(1); data.append(0); data.append(0); - data.append(0); - data.append(1); data.append(1); data.append(0); - data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); + data.append(1); data.append(0); data.append(1); data.append(0); + data.append(0); + data.append(0); + data.append(0); + data.append(0); + data.append(0); + data.append(0); data.append(1); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp8x23_broadcast.cairo b/src/tests/nodes/xor_fp8x23_broadcast.cairo index 9358f3405..ab911da0f 100644 --- a/src/tests/nodes/xor_fp8x23_broadcast.cairo +++ b/src/tests/nodes/xor_fp8x23_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::FP8x23Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_fp8x23_broadcast/input_0.cairo b/src/tests/nodes/xor_fp8x23_broadcast/input_0.cairo index 447d7d010..4f2014dfa 100644 --- a/src/tests/nodes/xor_fp8x23_broadcast/input_0.cairo +++ b/src/tests/nodes/xor_fp8x23_broadcast/input_0.cairo @@ -1,19 +1,18 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_0() -> Tensor { +fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(2); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 16777216, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 16777216, sign: true }); + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 16777216, sign: false }); + data.append(FP8x23 { mag: 8388608, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp8x23_broadcast/input_1.cairo b/src/tests/nodes/xor_fp8x23_broadcast/input_1.cairo index 1a6f6848a..4ce45e8c2 100644 --- a/src/tests/nodes/xor_fp8x23_broadcast/input_1.cairo +++ b/src/tests/nodes/xor_fp8x23_broadcast/input_1.cairo @@ -1,17 +1,16 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::FP8x23Tensor; +use orion::numbers::FixedTrait; +use orion::numbers::FP8x23; -fn input_1() -> Tensor { +fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); shape.append(1); shape.append(2); let mut data = ArrayTrait::new(); - data.append(FixedType { mag: 16777216, sign: true }); - data.append(FixedType { mag: 8388608, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(FP8x23 { mag: 8388608, sign: false }); + data.append(FP8x23 { mag: 25165824, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_fp8x23_broadcast/output_0.cairo b/src/tests/nodes/xor_fp8x23_broadcast/output_0.cairo index 619c5c756..2101f7fc8 100644 --- a/src/tests/nodes/xor_fp8x23_broadcast/output_0.cairo +++ b/src/tests/nodes/xor_fp8x23_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i32.cairo b/src/tests/nodes/xor_i32.cairo index ebaa0f6bf..137ecc9f7 100644 --- a/src/tests/nodes/xor_i32.cairo +++ b/src/tests/nodes/xor_i32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_i32/input_0.cairo b/src/tests/nodes/xor_i32/input_0.cairo index 557bd393b..c55b2e7fd 100644 --- a/src/tests/nodes/xor_i32/input_0.cairo +++ b/src/tests/nodes/xor_i32/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -12,33 +11,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 3, sign: true }); + 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: 0, sign: false }); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 1, 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: true }); + 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: 2, sign: true }); data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 0, 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: 2, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i32/input_1.cairo b/src/tests/nodes/xor_i32/input_1.cairo index f186d2470..29e595bcf 100644 --- a/src/tests/nodes/xor_i32/input_1.cairo +++ b/src/tests/nodes/xor_i32/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - 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: false }); - data.append(i32 { mag: 1, sign: true }); 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: true }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: true }); data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 1, sign: false }); - data.append(i32 { mag: 0, sign: false }); - data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 1, 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: 2, sign: false }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 2, sign: true }); + data.append(i32 { mag: 1, sign: true }); data.append(i32 { mag: 3, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 3, sign: true }); - data.append(i32 { mag: 2, sign: false }); data.append(i32 { mag: 2, sign: true }); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 2, sign: false }); + 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: 1, sign: true }); + data.append(i32 { mag: 0, sign: false }); data.append(i32 { mag: 1, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i32/output_0.cairo b/src/tests/nodes/xor_i32/output_0.cairo index 9679e2036..496a737b9 100644 --- a/src/tests/nodes/xor_i32/output_0.cairo +++ b/src/tests/nodes/xor_i32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -15,29 +14,27 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - data.append(0); - data.append(1); - data.append(0); data.append(1); data.append(0); data.append(0); - data.append(1); - data.append(0); data.append(0); data.append(0); data.append(0); data.append(0); data.append(1); + data.append(1); + data.append(0); data.append(0); data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); + data.append(1); + data.append(1); + data.append(1); data.append(0); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i32_broadcast.cairo b/src/tests/nodes/xor_i32_broadcast.cairo index 4d582886d..9b65f7f9a 100644 --- a/src/tests/nodes/xor_i32_broadcast.cairo +++ b/src/tests/nodes/xor_i32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_i32_broadcast/input_0.cairo b/src/tests/nodes/xor_i32_broadcast/input_0.cairo index 74e772e5c..dd650e28e 100644 --- a/src/tests/nodes/xor_i32_broadcast/input_0.cairo +++ b/src/tests/nodes/xor_i32_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 1, sign: true }); - data.append(i32 { mag: 0, sign: false }); + data.append(i32 { mag: 1, sign: false }); + data.append(i32 { mag: 3, sign: true }); data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i32_broadcast/input_1.cairo b/src/tests/nodes/xor_i32_broadcast/input_1.cairo index ef02c9935..d955a58f8 100644 --- a/src/tests/nodes/xor_i32_broadcast/input_1.cairo +++ b/src/tests/nodes/xor_i32_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; +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(); @@ -10,9 +9,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i32 { mag: 2, sign: false }); - data.append(i32 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i32 { mag: 1, sign: true }); + data.append(i32 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i32_broadcast/output_0.cairo b/src/tests/nodes/xor_i32_broadcast/output_0.cairo index 619c5c756..2101f7fc8 100644 --- a/src/tests/nodes/xor_i32_broadcast/output_0.cairo +++ b/src/tests/nodes/xor_i32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -13,7 +12,5 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i8.cairo b/src/tests/nodes/xor_i8.cairo index 4e965c23f..818f8ec6e 100644 --- a/src/tests/nodes/xor_i8.cairo +++ b/src/tests/nodes/xor_i8.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_i8/input_0.cairo b/src/tests/nodes/xor_i8/input_0.cairo index 0bbeb4b5b..f0a5d8f05 100644 --- a/src/tests/nodes/xor_i8/input_0.cairo +++ b/src/tests/nodes/xor_i8/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -12,33 +11,31 @@ fn input_0() -> Tensor { let mut data = ArrayTrait::new(); 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: 2, sign: false }); - data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, 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: 0, sign: false }); + 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: 2, sign: false }); - data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 3, sign: true }); data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: true }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i8/input_1.cairo b/src/tests/nodes/xor_i8/input_1.cairo index 12cafea45..736dbe136 100644 --- a/src/tests/nodes/xor_i8/input_1.cairo +++ b/src/tests/nodes/xor_i8/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,34 +10,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 2, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 3, sign: true }); - data.append(i8 { mag: 2, 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: 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: 1, sign: true }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 0, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 1, sign: false }); + data.append(i8 { mag: 2, sign: true }); + data.append(i8 { mag: 1, sign: true }); data.append(i8 { mag: 1, sign: false }); data.append(i8 { mag: 0, sign: false }); 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: 2, sign: false }); data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + data.append(i8 { mag: 3, sign: true }); + data.append(i8 { mag: 3, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i8/output_0.cairo b/src/tests/nodes/xor_i8/output_0.cairo index 30f806126..3dfa40551 100644 --- a/src/tests/nodes/xor_i8/output_0.cairo +++ b/src/tests/nodes/xor_i8/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -12,32 +11,30 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); data.append(0); - data.append(0); data.append(1); - data.append(0); + data.append(1); data.append(0); data.append(0); data.append(1); - data.append(0); + data.append(1); + data.append(1); + data.append(1); data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(1); - data.append(0); data.append(1); data.append(0); data.append(0); data.append(0); data.append(0); - data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i8_broadcast.cairo b/src/tests/nodes/xor_i8_broadcast.cairo index 0470db225..88ecb155e 100644 --- a/src/tests/nodes/xor_i8_broadcast.cairo +++ b/src/tests/nodes/xor_i8_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_i8_broadcast/input_0.cairo b/src/tests/nodes/xor_i8_broadcast/input_0.cairo index 8ab269e83..e621a9516 100644 --- a/src/tests/nodes/xor_i8_broadcast/input_0.cairo +++ b/src/tests/nodes/xor_i8_broadcast/input_0.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -10,11 +9,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); data.append(i8 { mag: 2, sign: false }); data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 0, sign: false }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i8_broadcast/input_1.cairo b/src/tests/nodes/xor_i8_broadcast/input_1.cairo index 99e0e07e7..ed4f1bac9 100644 --- a/src/tests/nodes/xor_i8_broadcast/input_1.cairo +++ b/src/tests/nodes/xor_i8_broadcast/input_1.cairo @@ -1,8 +1,7 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; +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(); @@ -11,8 +10,6 @@ fn input_1() -> Tensor { let mut data = ArrayTrait::new(); data.append(i8 { mag: 2, sign: false }); - data.append(i8 { mag: 0, sign: false }); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(i8 { mag: 1, sign: true }); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_i8_broadcast/output_0.cairo b/src/tests/nodes/xor_i8_broadcast/output_0.cairo index 619c5c756..2094003c4 100644 --- a/src/tests/nodes/xor_i8_broadcast/output_0.cairo +++ b/src/tests/nodes/xor_i8_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn output_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(1); data.append(0); - data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(1); + data.append(1); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_u32.cairo b/src/tests/nodes/xor_u32.cairo index 7e8d41d41..bf08a5353 100644 --- a/src/tests/nodes/xor_u32.cairo +++ b/src/tests/nodes/xor_u32.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_u32/input_0.cairo b/src/tests/nodes/xor_u32/input_0.cairo index d5a74465c..0ff938795 100644 --- a/src/tests/nodes/xor_u32/input_0.cairo +++ b/src/tests/nodes/xor_u32/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_0() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); - data.append(0); - data.append(2); - data.append(1); data.append(2); - data.append(3); + data.append(4); + data.append(4); data.append(0); - data.append(5); + data.append(1); data.append(4); + data.append(1); + data.append(3); data.append(0); data.append(4); + data.append(3); data.append(4); data.append(2); data.append(5); - data.append(3); + data.append(1); + data.append(1); data.append(5); - data.append(0); - data.append(3); data.append(1); - data.append(3); + data.append(1); + data.append(1); data.append(2); data.append(5); + data.append(5); data.append(0); - data.append(1); - data.append(0); - data.append(4); data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(5); + data.append(3); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_u32/input_1.cairo b/src/tests/nodes/xor_u32/input_1.cairo index 2e9a85f2d..bd273bcdf 100644 --- a/src/tests/nodes/xor_u32/input_1.cairo +++ b/src/tests/nodes/xor_u32/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,34 +9,32 @@ fn input_1() -> Tensor { shape.append(3); let mut data = ArrayTrait::new(); - data.append(0); - data.append(1); - data.append(0); - data.append(5); + data.append(2); + data.append(4); data.append(0); data.append(2); - data.append(3); data.append(4); data.append(4); - data.append(3); - data.append(5); data.append(2); + data.append(2); + data.append(3); data.append(1); data.append(1); - data.append(1); - data.append(3); - data.append(3); - data.append(3); + data.append(2); + data.append(5); + data.append(0); data.append(3); + data.append(5); + data.append(2); + data.append(0); + data.append(0); + data.append(1); data.append(4); - data.append(3); + data.append(0); data.append(1); - data.append(3); - data.append(5); + data.append(2); + data.append(2); data.append(1); data.append(2); - data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_u32/output_0.cairo b/src/tests/nodes/xor_u32/output_0.cairo index dfcdd516a..ba056af8f 100644 --- a/src/tests/nodes/xor_u32/output_0.cairo +++ b/src/tests/nodes/xor_u32/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -11,17 +10,14 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); - data.append(1); - data.append(1); data.append(0); data.append(1); - data.append(0); data.append(1); data.append(0); data.append(0); - data.append(1); data.append(0); data.append(0); + data.append(1); data.append(0); data.append(0); data.append(0); @@ -30,14 +26,15 @@ fn output_0() -> Tensor { data.append(0); data.append(0); data.append(0); + data.append(1); + data.append(1); data.append(0); data.append(0); data.append(1); data.append(0); data.append(1); - data.append(0); data.append(1); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(0); + data.append(0); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_u32_broadcast.cairo b/src/tests/nodes/xor_u32_broadcast.cairo index ba6fd4884..350165580 100644 --- a/src/tests/nodes/xor_u32_broadcast.cairo +++ b/src/tests/nodes/xor_u32_broadcast.cairo @@ -3,10 +3,10 @@ mod input_1; mod output_0; -use array::ArrayTrait; -use orion::operators::tensor::core::TensorTrait; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; -use orion::operators::tensor::implementations::impl_tensor_u32::u32TensorPartialEq; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::TensorTrait; +use orion::operators::tensor::U32Tensor; +use orion::operators::tensor::U32TensorPartialEq; use orion::utils::assert_eq; #[test] diff --git a/src/tests/nodes/xor_u32_broadcast/input_0.cairo b/src/tests/nodes/xor_u32_broadcast/input_0.cairo index fcf798d32..ce1b965e8 100644 --- a/src/tests/nodes/xor_u32_broadcast/input_0.cairo +++ b/src/tests/nodes/xor_u32_broadcast/input_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,11 +8,9 @@ fn input_0() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); + data.append(1); + data.append(0); + data.append(0); data.append(5); - data.append(5); - data.append(3); - data.append(5); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_u32_broadcast/input_1.cairo b/src/tests/nodes/xor_u32_broadcast/input_1.cairo index ed95bfa7d..7860a60be 100644 --- a/src/tests/nodes/xor_u32_broadcast/input_1.cairo +++ b/src/tests/nodes/xor_u32_broadcast/input_1.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn input_1() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -9,9 +8,7 @@ fn input_1() -> Tensor { shape.append(2); let mut data = ArrayTrait::new(); - data.append(5); data.append(3); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + data.append(4); + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/nodes/xor_u32_broadcast/output_0.cairo b/src/tests/nodes/xor_u32_broadcast/output_0.cairo index 619c5c756..8304bcded 100644 --- a/src/tests/nodes/xor_u32_broadcast/output_0.cairo +++ b/src/tests/nodes/xor_u32_broadcast/output_0.cairo @@ -1,7 +1,6 @@ -use array::ArrayTrait; -use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; -use orion::numbers::fixed_point::core::FixedImpl; -use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; +use array::{ArrayTrait, SpanTrait}; +use orion::operators::tensor::{TensorTrait, Tensor}; +use orion::operators::tensor::U32Tensor; fn output_0() -> Tensor { let mut shape = ArrayTrait::::new(); @@ -10,10 +9,8 @@ fn output_0() -> Tensor { let mut data = ArrayTrait::new(); data.append(0); + data.append(1); + data.append(1); data.append(0); - data.append(0); - data.append(0); - - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16) }; - TensorTrait::new(shape.span(), data.span(), Option::Some(extra)) + TensorTrait::new(shape.span(), data.span()) } \ No newline at end of file diff --git a/src/tests/operators/tensor/math.cairo b/src/tests/operators/tensor/math.cairo new file mode 100644 index 000000000..be37360c1 --- /dev/null +++ b/src/tests/operators/tensor/math.cairo @@ -0,0 +1,32 @@ +mod argmax; +mod argmin; +mod max; +mod min; +mod reduce_sum; +mod exp; +mod equal; +mod greater; +mod greater_equal; +mod less; +mod less_equal; +mod abs; +mod ceil; +mod ln; +mod arithmetic; +mod sin; +mod cos; +mod asin; +mod cumsum; +mod flatten; +mod sinh; +mod tanh; +mod cosh; +mod acosh; +mod asinh; +mod atan; +mod xor; +mod or; +mod acos; +mod onehot; +mod sqrt; +mod concat; \ No newline at end of file diff --git a/src/tests/performance/dequantize_linear_test/dequantize_linear_fp_test/fp_i8_test.cairo b/src/tests/performance/dequantize_linear_test/dequantize_linear_fp_test/fp_i8_test.cairo index 68762bb8a..8bc1060bf 100644 --- a/src/tests/performance/dequantize_linear_test/dequantize_linear_fp_test/fp_i8_test.cairo +++ b/src/tests/performance/dequantize_linear_test/dequantize_linear_fp_test/fp_i8_test.cairo @@ -6,15 +6,12 @@ mod fp8x23 { use debug::PrintTrait; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; - use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; - use orion::numbers::fixed_point::implementations::fp8x23::core::{ - FP8x23Impl, FP8x23PartialEq - }; - use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams, Tensor}; - use orion::performance::core::PerfomanceTrait; - use orion::performance::implementations::impl_performance_fp::Performance_fp_i8; + use orion::numbers::fixed_point::core::{FixedTrait}; + use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23PartialEq}; + use orion::operators::tensor::I8Tensor; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::{TensorTrait, Tensor}; + use orion::numbers::FP8x23; #[test] #[available_gas(2000000)] @@ -27,112 +24,123 @@ mod fp8x23 { data.append(IntegerTrait::new(3, false)); data.append(IntegerTrait::new(125, false)); data.append(IntegerTrait::new(127, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let x = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x = TensorTrait::new(shape.span(), data.span()); // XSCALE let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(2, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let x_scale = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(0, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let x_zero_point = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x_zero_point = TensorTrait::new(shape.span(), data.span()); - let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); + let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); - assert((*y.data[0]).into() == FixedTrait::new_unscaled(0, false), '*result[0] == 0'); - assert((*y.data[1]).into() == FixedTrait::new_unscaled(6, false), '*result[1] == 6'); - assert((*y.data[2]).into() == FixedTrait::new_unscaled(250, false), '*result[2] == 250'); - assert((*y.data[3]).into() == FixedTrait::new_unscaled(254, false), '*result[3] == 254'); + assert( + (*y.data[0]).into() == FixedTrait::::new_unscaled(0, false), + '*result[0] == 0' + ); + assert( + (*y.data[1]).into() == FixedTrait::::new_unscaled(6, false), + '*result[1] == 6' + ); + assert( + (*y.data[2]).into() == FixedTrait::::new_unscaled(250, false), + '*result[2] == 250' + ); + assert( + (*y.data[3]).into() == FixedTrait::::new_unscaled(254, false), + '*result[3] == 254' + ); } +// TODO: fix it when move performance tests in nodes. +// #[test] +// #[available_gas(20000000)] +// fn per_axis() { +// // X +// let mut shape = ArrayTrait::::new(); +// shape.append(1); +// shape.append(3); +// shape.append(3); +// shape.append(2); +// let mut data = ArrayTrait::::new(); +// data.append(IntegerTrait::new(3, false)); +// data.append(IntegerTrait::new(89, false)); +// data.append(IntegerTrait::new(34, false)); +// data.append(IntegerTrait::new(127, false)); +// data.append(IntegerTrait::new(74, false)); +// data.append(IntegerTrait::new(59, false)); +// data.append(IntegerTrait::new(5, false)); +// data.append(IntegerTrait::new(24, false)); +// data.append(IntegerTrait::new(24, false)); +// data.append(IntegerTrait::new(87, false)); +// data.append(IntegerTrait::new(32, false)); +// data.append(IntegerTrait::new(13, false)); +// data.append(IntegerTrait::new(127, false)); +// data.append(IntegerTrait::new(99, false)); +// data.append(IntegerTrait::new(4, false)); +// data.append(IntegerTrait::new(127, false)); +// data.append(IntegerTrait::new(121, false)); +// data.append(IntegerTrait::new(102, false)); +// +// let x = TensorTrait::new(shape.span(), data.span()); - // TODO: fix it when move performance tests in nodes. - // #[test] - // #[available_gas(20000000)] - // fn per_axis() { - // // X - // let mut shape = ArrayTrait::::new(); - // shape.append(1); - // shape.append(3); - // shape.append(3); - // shape.append(2); - // let mut data = ArrayTrait::::new(); - // data.append(IntegerTrait::new(3, false)); - // data.append(IntegerTrait::new(89, false)); - // data.append(IntegerTrait::new(34, false)); - // data.append(IntegerTrait::new(127, false)); - // data.append(IntegerTrait::new(74, false)); - // data.append(IntegerTrait::new(59, false)); - // data.append(IntegerTrait::new(5, false)); - // data.append(IntegerTrait::new(24, false)); - // data.append(IntegerTrait::new(24, false)); - // data.append(IntegerTrait::new(87, false)); - // data.append(IntegerTrait::new(32, false)); - // data.append(IntegerTrait::new(13, false)); - // data.append(IntegerTrait::new(127, false)); - // data.append(IntegerTrait::new(99, false)); - // data.append(IntegerTrait::new(4, false)); - // data.append(IntegerTrait::new(127, false)); - // data.append(IntegerTrait::new(121, false)); - // data.append(IntegerTrait::new(102, false)); - // let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - // let x = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); - - // // XSCALE - // let mut shape = ArrayTrait::::new(); - // shape.append(1); - // shape.append(3); - // shape.append(1); - // shape.append(1); - // let mut data = ArrayTrait::::new(); - // data.append(FixedTrait::new_unscaled(2, false)); - // data.append(FixedTrait::new_unscaled(4, false)); - // data.append(FixedTrait::new_unscaled(5, false)); - // let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - // let x_scale = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); +// // XSCALE +// let mut shape = ArrayTrait::::new(); +// shape.append(1); +// shape.append(3); +// shape.append(1); +// shape.append(1); +// let mut data = ArrayTrait::::new(); +// data.append(FixedTrait::new_unscaled(2, false)); +// data.append(FixedTrait::new_unscaled(4, false)); +// data.append(FixedTrait::new_unscaled(5, false)); +// +// let x_scale = TensorTrait::new(shape.span(), data.span()); - // // ZEROPOINT - // let mut shape = ArrayTrait::::new(); - // shape.append(1); - // shape.append(3); - // shape.append(1); - // shape.append(1); - // let mut data = ArrayTrait::::new(); - // data.append(FixedTrait::new_unscaled(1, false)); - // data.append(FixedTrait::new_unscaled(2, false)); - // data.append(FixedTrait::new_unscaled(3, false)); - // let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - // let x_zero_point = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); +// // ZEROPOINT +// let mut shape = ArrayTrait::::new(); +// shape.append(1); +// shape.append(3); +// shape.append(1); +// shape.append(1); +// let mut data = ArrayTrait::::new(); +// data.append(FixedTrait::new_unscaled(1, false)); +// data.append(FixedTrait::new_unscaled(2, false)); +// data.append(FixedTrait::new_unscaled(3, false)); +// +// let x_zero_point = TensorTrait::new(shape.span(), data.span()); - // let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); +// let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); - // assert((*y.data[0]).into() == FixedTrait::new_unscaled(4, false), '*result[0] == 162'); - // assert((*y.data[1]).into() == FixedTrait::new_unscaled(176, false), '*result[1] == 10'); - // assert((*y.data[2]).into() == FixedTrait::new_unscaled(66, false), '*result[2] == 100'); - // assert((*y.data[3]).into() == FixedTrait::new_unscaled(252, false), '*result[3] == 232'); - // assert((*y.data[4]).into() == FixedTrait::new_unscaled(146, false), '*result[4] == 20'); - // assert((*y.data[5]).into() == FixedTrait::new_unscaled(116, false), '*result[5] == 50'); - // assert((*y.data[6]).into() == FixedTrait::new_unscaled(12, false), '*result[6] == 76'); - // assert((*y.data[7]).into() == FixedTrait::new_unscaled(88, false), '*result[7] == 0'); - // assert((*y.data[8]).into() == FixedTrait::new_unscaled(88, false), '*result[8] == 0'); - // assert((*y.data[9]).into() == FixedTrait::new_unscaled(340, false), '*result[9] == 252'); - // assert((*y.data[10]).into() == FixedTrait::new_unscaled(120, false), '*result[10] == 32'); - // assert((*y.data[11]).into() == FixedTrait::new_unscaled(44, false), '*result[11] == 44'); - // assert((*y.data[12]).into() == FixedTrait::new_unscaled(620, false), '*result[12] == 245'); - // assert((*y.data[13]).into() == FixedTrait::new_unscaled(480, false), '*result[13] == 485'); - // assert((*y.data[14]).into() == FixedTrait::new_unscaled(5, false), '*result[14] == 960'); - // assert((*y.data[15]).into() == FixedTrait::new_unscaled(620, false), '*result[15] == 270'); - // assert((*y.data[16]).into() == FixedTrait::new_unscaled(590, false), '*result[16] == 375'); - // assert((*y.data[17]).into() == FixedTrait::new_unscaled(495, false), '*result[17] == 470'); - // } +// assert((*y.data[0]).into() == FixedTrait::new_unscaled(4, false), '*result[0] == 162'); +// assert((*y.data[1]).into() == FixedTrait::new_unscaled(176, false), '*result[1] == 10'); +// assert((*y.data[2]).into() == FixedTrait::new_unscaled(66, false), '*result[2] == 100'); +// assert((*y.data[3]).into() == FixedTrait::new_unscaled(252, false), '*result[3] == 232'); +// assert((*y.data[4]).into() == FixedTrait::new_unscaled(146, false), '*result[4] == 20'); +// assert((*y.data[5]).into() == FixedTrait::new_unscaled(116, false), '*result[5] == 50'); +// assert((*y.data[6]).into() == FixedTrait::new_unscaled(12, false), '*result[6] == 76'); +// assert((*y.data[7]).into() == FixedTrait::new_unscaled(88, false), '*result[7] == 0'); +// assert((*y.data[8]).into() == FixedTrait::new_unscaled(88, false), '*result[8] == 0'); +// assert((*y.data[9]).into() == FixedTrait::new_unscaled(340, false), '*result[9] == 252'); +// assert((*y.data[10]).into() == FixedTrait::new_unscaled(120, false), '*result[10] == 32'); +// assert((*y.data[11]).into() == FixedTrait::new_unscaled(44, false), '*result[11] == 44'); +// assert((*y.data[12]).into() == FixedTrait::new_unscaled(620, false), '*result[12] == 245'); +// assert((*y.data[13]).into() == FixedTrait::new_unscaled(480, false), '*result[13] == 485'); +// assert((*y.data[14]).into() == FixedTrait::new_unscaled(5, false), '*result[14] == 960'); +// assert((*y.data[15]).into() == FixedTrait::new_unscaled(620, false), '*result[15] == 270'); +// assert((*y.data[16]).into() == FixedTrait::new_unscaled(590, false), '*result[16] == 375'); +// assert((*y.data[17]).into() == FixedTrait::new_unscaled(495, false), '*result[17] == 470'); +// } } #[cfg(test)] @@ -142,16 +150,16 @@ mod fp16x16 { use traits::Into; use debug::PrintTrait; + use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; - use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; + use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_point::implementations::fp16x16::core::{ FP16x16Impl, FP16x16PartialEq }; - use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams, Tensor}; - use orion::performance::core::PerfomanceTrait; - use orion::performance::implementations::impl_performance_fp::Performance_fp_i8; + use orion::operators::tensor::I8Tensor; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::{TensorTrait, Tensor}; + use orion::numbers::FP16x16; #[test] #[available_gas(2000000)] @@ -164,31 +172,43 @@ mod fp16x16 { data.append(IntegerTrait::new(3, false)); data.append(IntegerTrait::new(125, false)); data.append(IntegerTrait::new(127, false)); - let extra = Option::::None(()); - let x = TensorTrait::new(shape.span(), data.span(), extra); + + let x = TensorTrait::new(shape.span(), data.span()); // XSCALE let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(2, false)); - let extra = Option::::None(()); - let x_scale = TensorTrait::new(shape.span(), data.span(), extra); + + let x_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(0, false)); - let extra = Option::::None(()); - let x_zero_point = TensorTrait::new(shape.span(), data.span(), extra); + + let x_zero_point = TensorTrait::new(shape.span(), data.span()); - let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); + let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); - assert((*y.data[0]).into() == FixedTrait::new_unscaled(0, false), '*result[0] == 0'); - assert((*y.data[1]).into() == FixedTrait::new_unscaled(6, false), '*result[1] == 6'); - assert((*y.data[2]).into() == FixedTrait::new_unscaled(250, false), '*result[2] == 250'); - assert((*y.data[3]).into() == FixedTrait::new_unscaled(254, false), '*result[3] == 254'); + assert( + (*y.data[0]).into() == FixedTrait::::new_unscaled(0, false), + '*result[0] == 0' + ); + assert( + (*y.data[1]).into() == FixedTrait::::new_unscaled(6, false), + '*result[1] == 6' + ); + assert( + (*y.data[2]).into() == FixedTrait::::new_unscaled(250, false), + '*result[2] == 250' + ); + assert( + (*y.data[3]).into() == FixedTrait::::new_unscaled(254, false), + '*result[3] == 254' + ); } #[test] @@ -219,8 +239,8 @@ mod fp16x16 { data.append(IntegerTrait::new(127, false)); data.append(IntegerTrait::new(121, false)); data.append(IntegerTrait::new(102, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let x = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x = TensorTrait::new(shape.span(), data.span()); // XSCALE let mut shape = ArrayTrait::::new(); @@ -228,12 +248,12 @@ mod fp16x16 { shape.append(3); shape.append(1); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(4, false)); data.append(FixedTrait::new_unscaled(5, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let x_scale = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); @@ -241,32 +261,86 @@ mod fp16x16 { shape.append(3); shape.append(1); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(1, false)); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(3, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let x_zero_point = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x_zero_point = TensorTrait::new(shape.span(), data.span()); - let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); + let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); - assert((*y.data[0]).into() == FixedTrait::new_unscaled(4, false), '*result[0] == 162'); - assert((*y.data[1]).into() == FixedTrait::new_unscaled(176, false), '*result[1] == 10'); - assert((*y.data[2]).into() == FixedTrait::new_unscaled(66, false), '*result[2] == 100'); - assert((*y.data[3]).into() == FixedTrait::new_unscaled(252, false), '*result[3] == 232'); - assert((*y.data[4]).into() == FixedTrait::new_unscaled(146, false), '*result[4] == 20'); - assert((*y.data[5]).into() == FixedTrait::new_unscaled(116, false), '*result[5] == 50'); - assert((*y.data[6]).into() == FixedTrait::new_unscaled(12, false), '*result[6] == 76'); - assert((*y.data[7]).into() == FixedTrait::new_unscaled(88, false), '*result[7] == 0'); - assert((*y.data[8]).into() == FixedTrait::new_unscaled(88, false), '*result[8] == 0'); - assert((*y.data[9]).into() == FixedTrait::new_unscaled(340, false), '*result[9] == 252'); - assert((*y.data[10]).into() == FixedTrait::new_unscaled(120, false), '*result[10] == 32'); - assert((*y.data[11]).into() == FixedTrait::new_unscaled(44, false), '*result[11] == 44'); - assert((*y.data[12]).into() == FixedTrait::new_unscaled(620, false), '*result[12] == 245'); - assert((*y.data[13]).into() == FixedTrait::new_unscaled(480, false), '*result[13] == 485'); - assert((*y.data[14]).into() == FixedTrait::new_unscaled(5, false), '*result[14] == 960'); - assert((*y.data[15]).into() == FixedTrait::new_unscaled(620, false), '*result[15] == 270'); - assert((*y.data[16]).into() == FixedTrait::new_unscaled(590, false), '*result[16] == 375'); - assert((*y.data[17]).into() == FixedTrait::new_unscaled(495, false), '*result[17] == 470'); + assert( + (*y.data[0]).into() == FixedTrait::::new_unscaled(4, false), + '*result[0] == 162' + ); + assert( + (*y.data[1]).into() == FixedTrait::::new_unscaled(176, false), + '*result[1] == 10' + ); + assert( + (*y.data[2]).into() == FixedTrait::::new_unscaled(66, false), + '*result[2] == 100' + ); + assert( + (*y.data[3]).into() == FixedTrait::::new_unscaled(252, false), + '*result[3] == 232' + ); + assert( + (*y.data[4]).into() == FixedTrait::::new_unscaled(146, false), + '*result[4] == 20' + ); + assert( + (*y.data[5]).into() == FixedTrait::::new_unscaled(116, false), + '*result[5] == 50' + ); + assert( + (*y.data[6]).into() == FixedTrait::::new_unscaled(12, false), + '*result[6] == 76' + ); + assert( + (*y.data[7]).into() == FixedTrait::::new_unscaled(88, false), + '*result[7] == 0' + ); + assert( + (*y.data[8]).into() == FixedTrait::::new_unscaled(88, false), + '*result[8] == 0' + ); + assert( + (*y.data[9]).into() == FixedTrait::::new_unscaled(340, false), + '*result[9] == 252' + ); + assert( + (*y.data[10]).into() == FixedTrait::::new_unscaled(120, false), + '*result[10] == 32' + ); + assert( + (*y.data[11]).into() == FixedTrait::::new_unscaled(44, false), + '*result[11] == 44' + ); + assert( + (*y.data[12]).into() == FixedTrait::::new_unscaled(620, false), + '*result[12] == 245' + ); + assert( + (*y.data[13]).into() == FixedTrait::::new_unscaled(480, false), + '*result[13] == 485' + ); + assert( + (*y.data[14]).into() == FixedTrait::::new_unscaled(5, false), + '*result[14] == 960' + ); + assert( + (*y.data[15]).into() == FixedTrait::::new_unscaled(620, false), + '*result[15] == 270' + ); + assert( + (*y.data[16]).into() == FixedTrait::::new_unscaled(590, false), + '*result[16] == 375' + ); + assert( + (*y.data[17]).into() == FixedTrait::::new_unscaled(495, false), + '*result[17] == 470' + ); } } diff --git a/src/tests/performance/dequantize_linear_test/dequantize_linear_i32_test.cairo b/src/tests/performance/dequantize_linear_test/dequantize_linear_i32_test.cairo index 4423600bc..84efc45e7 100644 --- a/src/tests/performance/dequantize_linear_test/dequantize_linear_i32_test.cairo +++ b/src/tests/performance/dequantize_linear_test/dequantize_linear_i32_test.cairo @@ -4,12 +4,10 @@ use array::SpanTrait; use traits::Into; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32, i8::i8}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::core::{TensorTrait, ExtraParams, Tensor}; -use orion::performance::core::PerfomanceTrait; -use orion::performance::implementations::impl_performance_i32::Performance_i32_i8; +use orion::numbers::fixed_point::core::{FixedTrait}; +use orion::operators::tensor::I8Tensor; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::{TensorTrait, Tensor}; #[test] #[available_gas(2000000)] @@ -22,24 +20,24 @@ fn dequantize_linear() { data.append(IntegerTrait::new(3, false)); data.append(IntegerTrait::new(125, false)); data.append(IntegerTrait::new(127, false)); - let extra = Option::::None(()); - let x = TensorTrait::new(shape.span(), data.span(), extra); + + let x = TensorTrait::new(shape.span(), data.span()); // XSCALE let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::::new(); data.append(IntegerTrait::new(2, false)); - let extra = Option::::None(()); - let x_scale = TensorTrait::new(shape.span(), data.span(), extra); + + let x_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::::new(); data.append(IntegerTrait::new(0, false)); - let extra = Option::::None(()); - let x_zero_point = TensorTrait::new(shape.span(), data.span(), extra); + + let x_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); @@ -77,8 +75,8 @@ fn per_axis() { data.append(IntegerTrait::new(127, false)); data.append(IntegerTrait::new(121, false)); data.append(IntegerTrait::new(102, false)); - let extra = Option::::None(()); - let x = TensorTrait::new(shape.span(), data.span(), extra); + + let x = TensorTrait::new(shape.span(), data.span()); // XSCALE let mut shape = ArrayTrait::::new(); @@ -90,8 +88,8 @@ fn per_axis() { data.append(IntegerTrait::new(2, false)); data.append(IntegerTrait::new(4, false)); data.append(IntegerTrait::new(5, false)); - let extra = Option::::None(()); - let x_scale = TensorTrait::new(shape.span(), data.span(), extra); + + let x_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); @@ -103,8 +101,8 @@ fn per_axis() { data.append(IntegerTrait::new(1, false)); data.append(IntegerTrait::new(2, false)); data.append(IntegerTrait::new(3, false)); - let extra = Option::::None(()); - let x_zero_point = TensorTrait::new(shape.span(), data.span(), extra); + + let x_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.dequantize_linear(@x_scale, @x_zero_point); diff --git a/src/tests/performance/quantize_linear_test/quantize_linear_fp_test/fp_i8_test.cairo b/src/tests/performance/quantize_linear_test/quantize_linear_fp_test/fp_i8_test.cairo index 3540dad47..c586b1bcc 100644 --- a/src/tests/performance/quantize_linear_test/quantize_linear_fp_test/fp_i8_test.cairo +++ b/src/tests/performance/quantize_linear_test/quantize_linear_fp_test/fp_i8_test.cairo @@ -6,13 +6,12 @@ mod fp8x23 { use debug::PrintTrait; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32, i8::i8}; - use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; + use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams, Tensor}; - use orion::performance::core::PerfomanceTrait; - use orion::performance::implementations::impl_performance_fp::Performance_fp_i8; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::{TensorTrait, Tensor}; + use orion::numbers::FP8x23; #[test] #[available_gas(2000000)] @@ -20,31 +19,31 @@ mod fp8x23 { // X let mut shape = ArrayTrait::::new(); shape.append(6); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(0, false)); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(3, false)); data.append(FixedTrait::new_unscaled(200, false)); data.append(FixedTrait::new_unscaled(250, true)); data.append(FixedTrait::new_unscaled(100, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let x = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x = TensorTrait::new(shape.span(), data.span()); // YSCALE let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(2, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let y_scale = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(1, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let y_zero_point = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.quantize_linear(@y_scale, @y_zero_point); @@ -65,7 +64,7 @@ mod fp8x23 { shape.append(3); shape.append(3); shape.append(2); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(162, true)); data.append(FixedTrait::new_unscaled(10, false)); data.append(FixedTrait::new_unscaled(100, true)); @@ -84,8 +83,8 @@ mod fp8x23 { data.append(FixedTrait::new_unscaled(210, true)); data.append(FixedTrait::new_unscaled(200, true)); data.append(FixedTrait::new_unscaled(120, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let x = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x = TensorTrait::new(shape.span(), data.span()); // YSCALE let mut shape = ArrayTrait::::new(); @@ -93,12 +92,12 @@ mod fp8x23 { shape.append(3); shape.append(1); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(4, false)); data.append(FixedTrait::new_unscaled(5, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let y_scale = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); @@ -106,12 +105,12 @@ mod fp8x23 { shape.append(3); shape.append(1); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(84, false)); data.append(FixedTrait::new_unscaled(24, false)); data.append(FixedTrait::new_unscaled(196, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let y_zero_point = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.quantize_linear(@y_scale, @y_zero_point); @@ -145,13 +144,12 @@ mod fp16x16 { use debug::PrintTrait; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32, i8::i8}; - use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; + use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams, Tensor}; - use orion::performance::core::PerfomanceTrait; - use orion::performance::implementations::impl_performance_fp::Performance_fp_i8; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::{TensorTrait, Tensor}; + use orion::numbers::FP16x16; #[test] #[available_gas(2000000)] @@ -159,31 +157,31 @@ mod fp16x16 { // X let mut shape = ArrayTrait::::new(); shape.append(6); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(0, false)); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(3, false)); data.append(FixedTrait::new_unscaled(1000, false)); data.append(FixedTrait::new_unscaled(254, true)); data.append(FixedTrait::new_unscaled(1000, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let x = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x = TensorTrait::new(shape.span(), data.span()); // YSCALE let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(2, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let y_scale = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(1, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let y_zero_point = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.quantize_linear(@y_scale, @y_zero_point); @@ -204,7 +202,7 @@ mod fp16x16 { shape.append(3); shape.append(3); shape.append(2); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(162, true)); data.append(FixedTrait::new_unscaled(10, false)); data.append(FixedTrait::new_unscaled(100, true)); @@ -223,8 +221,8 @@ mod fp16x16 { data.append(FixedTrait::new_unscaled(270, true)); data.append(FixedTrait::new_unscaled(375, true)); data.append(FixedTrait::new_unscaled(470, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let x = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let x = TensorTrait::new(shape.span(), data.span()); // YSCALE let mut shape = ArrayTrait::::new(); @@ -232,12 +230,12 @@ mod fp16x16 { shape.append(3); shape.append(1); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(4, false)); data.append(FixedTrait::new_unscaled(5, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let y_scale = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); @@ -245,12 +243,12 @@ mod fp16x16 { shape.append(3); shape.append(1); shape.append(1); - let mut data = ArrayTrait::::new(); + let mut data = ArrayTrait::::new(); data.append(FixedTrait::new_unscaled(84, false)); data.append(FixedTrait::new_unscaled(24, false)); data.append(FixedTrait::new_unscaled(196, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP16x16(())) }; - let y_zero_point = TensorTrait::new(shape.span(), data.span(), Option::Some(extra)); + + let y_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.quantize_linear(@y_scale, @y_zero_point); diff --git a/src/tests/performance/quantize_linear_test/quantize_linear_i32_test.cairo b/src/tests/performance/quantize_linear_test/quantize_linear_i32_test.cairo index 5d555777e..089cb2a91 100644 --- a/src/tests/performance/quantize_linear_test/quantize_linear_i32_test.cairo +++ b/src/tests/performance/quantize_linear_test/quantize_linear_i32_test.cairo @@ -4,11 +4,9 @@ use array::SpanTrait; use traits::Into; use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32, i8::i8}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; -use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; -use orion::operators::tensor::core::{TensorTrait, ExtraParams, Tensor}; -use orion::performance::core::PerfomanceTrait; -use orion::performance::implementations::impl_performance_i32::Performance_i32_i8; +use orion::numbers::fixed_point::core::{FixedTrait}; +use orion::operators::tensor::I32Tensor; +use orion::operators::tensor::{TensorTrait, Tensor}; #[test] #[available_gas(2000000)] @@ -23,24 +21,24 @@ fn quantize_linear() { data.append(IntegerTrait::new(1000, false)); data.append(IntegerTrait::new(254, true)); data.append(IntegerTrait::new(1000, true)); - let extra = Option::::None(()); - let x = TensorTrait::new(shape.span(), data.span(), extra); + + let x = TensorTrait::new(shape.span(), data.span()); // YSCALE let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::::new(); data.append(IntegerTrait::new(2, false)); - let extra = Option::::None(()); - let y_scale = TensorTrait::new(shape.span(), data.span(), extra); + + let y_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); shape.append(1); let mut data = ArrayTrait::::new(); data.append(IntegerTrait::new(1, false)); - let extra = Option::::None(()); - let y_zero_point = TensorTrait::new(shape.span(), data.span(), extra); + + let y_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.quantize_linear(@y_scale, @y_zero_point); @@ -52,6 +50,7 @@ fn quantize_linear() { assert((*y.data[5]).into() == -128, '*result[5] == -128'); } + #[test] #[available_gas(20000000)] fn per_axis() { @@ -80,8 +79,8 @@ fn per_axis() { data.append(IntegerTrait::new(270, true)); data.append(IntegerTrait::new(375, true)); data.append(IntegerTrait::new(470, true)); - let extra = Option::::None(()); - let x = TensorTrait::new(shape.span(), data.span(), extra); + + let x = TensorTrait::new(shape.span(), data.span()); // YSCALE let mut shape = ArrayTrait::::new(); @@ -93,8 +92,8 @@ fn per_axis() { data.append(IntegerTrait::new(2, false)); data.append(IntegerTrait::new(4, false)); data.append(IntegerTrait::new(5, false)); - let extra = Option::::None(()); - let y_scale = TensorTrait::new(shape.span(), data.span(), extra); + + let y_scale = TensorTrait::new(shape.span(), data.span()); // ZEROPOINT let mut shape = ArrayTrait::::new(); @@ -106,8 +105,8 @@ fn per_axis() { data.append(IntegerTrait::new(84, false)); data.append(IntegerTrait::new(24, false)); data.append(IntegerTrait::new(196, false)); - let extra = Option::::None(()); - let y_zero_point = TensorTrait::new(shape.span(), data.span(), extra); + + let y_zero_point = TensorTrait::new(shape.span(), data.span()); let y: Tensor = x.quantize_linear(@y_scale, @y_zero_point); diff --git a/src/tests/tensor_core/at/at_fp_test/at_fp16x16_test.cairo b/src/tests/tensor_core/at/at_fp_test/at_fp16x16_test.cairo index 01e67d9d2..3765583e1 100644 --- a/src/tests/tensor_core/at/at_fp_test/at_fp16x16_test.cairo +++ b/src/tests/tensor_core/at/at_fp_test/at_fp16x16_test.cairo @@ -3,8 +3,8 @@ #[cfg(test)] mod tensor_1D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_1x3_helper; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16PartialEq}; @@ -27,8 +27,8 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2_helper; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16PartialEq}; @@ -54,8 +54,8 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2x2_helper; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, FP16x16PartialEq}; diff --git a/src/tests/tensor_core/at/at_fp_test/at_fp8x23_test.cairo b/src/tests/tensor_core/at/at_fp_test/at_fp8x23_test.cairo index be3afd991..36c226c01 100644 --- a/src/tests/tensor_core/at/at_fp_test/at_fp8x23_test.cairo +++ b/src/tests/tensor_core/at/at_fp_test/at_fp8x23_test.cairo @@ -3,8 +3,8 @@ #[cfg(test)] mod tensor_1D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_1x3_helper; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23PartialEq}; @@ -27,8 +27,8 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2_helper; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23PartialEq}; @@ -54,8 +54,8 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2x2_helper; use orion::numbers::fixed_point::core::FixedTrait; use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23PartialEq}; diff --git a/src/tests/tensor_core/at/at_i32_test.cairo b/src/tests/tensor_core/at/at_i32_test.cairo index 2dd2d51ee..9fb716b30 100644 --- a/src/tests/tensor_core/at/at_i32_test.cairo +++ b/src/tests/tensor_core/at/at_i32_test.cairo @@ -3,8 +3,8 @@ #[cfg(test)] mod tensor_1D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_1x3_helper; @@ -26,8 +26,8 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_2x2_helper; @@ -51,8 +51,8 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/at/at_u32_test.cairo b/src/tests/tensor_core/at/at_u32_test.cairo index 175fe1c63..22f4a804d 100644 --- a/src/tests/tensor_core/at/at_u32_test.cairo +++ b/src/tests/tensor_core/at/at_u32_test.cairo @@ -3,8 +3,8 @@ #[cfg(test)] mod tensor_1D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_1x3_helper; @@ -26,8 +26,8 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_2x2_helper; @@ -51,8 +51,8 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { use array::ArrayTrait; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp16x16_test.cairo b/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp16x16_test.cairo index f6d73b288..e8a7e5762 100644 --- a/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp16x16_test.cairo +++ b/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp16x16_test.cairo @@ -3,7 +3,7 @@ #[cfg(test)] mod tensor_1D { use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_1x3_helper; use orion::operators::tensor::core::TensorTrait; @@ -23,7 +23,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2_helper; use orion::operators::tensor::core::TensorTrait; @@ -52,7 +52,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2x2_helper; use orion::operators::tensor::core::TensorTrait; diff --git a/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp8x23_test.cairo b/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp8x23_test.cairo index b15bf7f87..be2d843fe 100644 --- a/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp8x23_test.cairo +++ b/src/tests/tensor_core/flatten/flatten_fp_test/flatten_fp8x23_test.cairo @@ -3,7 +3,7 @@ #[cfg(test)] mod tensor_1D { use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_1x3_helper; use orion::operators::tensor::core::TensorTrait; @@ -23,7 +23,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2_helper; use orion::operators::tensor::core::TensorTrait; @@ -52,7 +52,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2x2_helper; use orion::operators::tensor::core::TensorTrait; diff --git a/src/tests/tensor_core/flatten/flatten_i32_test.cairo b/src/tests/tensor_core/flatten/flatten_i32_test.cairo index 74dae1a40..e1d67fc80 100644 --- a/src/tests/tensor_core/flatten/flatten_i32_test.cairo +++ b/src/tests/tensor_core/flatten/flatten_i32_test.cairo @@ -5,8 +5,8 @@ mod tensor_1D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_1x3_helper; #[test] @@ -27,8 +27,8 @@ mod tensor_2D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_2x2_helper; #[test] @@ -58,8 +58,8 @@ mod tensor_3D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/flatten/flatten_u32_test.cairo b/src/tests/tensor_core/flatten/flatten_u32_test.cairo index 13de720ee..6e763ceee 100644 --- a/src/tests/tensor_core/flatten/flatten_u32_test.cairo +++ b/src/tests/tensor_core/flatten/flatten_u32_test.cairo @@ -5,8 +5,8 @@ mod tensor_1D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_1x3_helper; #[test] @@ -27,8 +27,8 @@ mod tensor_2D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_2x2_helper; #[test] @@ -58,8 +58,8 @@ mod tensor_3D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/max/max_fp_test/max_fp16x16_test.cairo b/src/tests/tensor_core/max/max_fp_test/max_fp16x16_test.cairo index 2e8567968..b90805c06 100644 --- a/src/tests/tensor_core/max/max_fp_test/max_fp16x16_test.cairo +++ b/src/tests/tensor_core/max/max_fp_test/max_fp16x16_test.cairo @@ -2,10 +2,10 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_1x3_helper; - use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16; use orion::numbers::fixed_point::core::{FixedTrait}; #[test] @@ -14,7 +14,7 @@ mod tensor_1D { let tensor = fp_tensor_1x3_helper(); let result = tensor.max().mag; - assert(result == FixedTrait::new_unscaled(2, false).mag, 'tensor.max = 2'); + assert(result == FixedTrait::::new_unscaled(2, false).mag, 'tensor.max = 2'); } } @@ -22,10 +22,10 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2_helper; - use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16; use orion::numbers::fixed_point::core::{FixedTrait}; @@ -35,7 +35,7 @@ mod tensor_2D { let tensor = fp_tensor_2x2_helper(); let result = tensor.max().mag; - assert(result == FixedTrait::new_unscaled(3, false).mag, 'tensor.max = 3'); + assert(result == FixedTrait::::new_unscaled(3, false).mag, 'tensor.max = 3'); } } @@ -43,10 +43,10 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2x2_helper; - use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; + use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16; use orion::numbers::fixed_point::core::{FixedTrait}; @@ -56,7 +56,7 @@ mod tensor_3D { let tensor = fp_tensor_2x2x2_helper(); let result = tensor.max().mag; - assert(result == FixedTrait::new_unscaled(7, false).mag, 'tensor.max = 7'); + assert(result == FixedTrait::::new_unscaled(7, false).mag, 'tensor.max = 7'); } } diff --git a/src/tests/tensor_core/max/max_fp_test/max_fp8x23_test.cairo b/src/tests/tensor_core/max/max_fp_test/max_fp8x23_test.cairo index a111fda94..26f5e043b 100644 --- a/src/tests/tensor_core/max/max_fp_test/max_fp8x23_test.cairo +++ b/src/tests/tensor_core/max/max_fp_test/max_fp8x23_test.cairo @@ -2,10 +2,10 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_1x3_helper; - use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23; use orion::numbers::fixed_point::core::{FixedTrait}; #[test] @@ -14,7 +14,7 @@ mod tensor_1D { let tensor = fp_tensor_1x3_helper(); let result = tensor.max().mag; - assert(result == FixedTrait::new_unscaled(2, false).mag, 'tensor.max = 2'); + assert(result == FixedTrait::::new_unscaled(2, false).mag, 'tensor.max = 2'); } } @@ -22,10 +22,10 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2_helper; - use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23; use orion::numbers::fixed_point::core::{FixedTrait}; @@ -35,7 +35,7 @@ mod tensor_2D { let tensor = fp_tensor_2x2_helper(); let result = tensor.max().mag; - assert(result == FixedTrait::new_unscaled(3, false).mag, 'tensor.max = 3'); + assert(result == FixedTrait::::new_unscaled(3, false).mag, 'tensor.max = 3'); } } @@ -43,10 +43,10 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2x2_helper; - use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; + use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23; use orion::numbers::fixed_point::core::{FixedTrait}; @@ -56,7 +56,7 @@ mod tensor_3D { let tensor = fp_tensor_2x2x2_helper(); let result = tensor.max().mag; - assert(result == FixedTrait::new_unscaled(7, false).mag, 'tensor.max = 7'); + assert(result == FixedTrait::::new_unscaled(7, false).mag, 'tensor.max = 7'); } } diff --git a/src/tests/tensor_core/max/max_i32_test.cairo b/src/tests/tensor_core/max/max_i32_test.cairo index 9d714d4c4..450b20ac1 100644 --- a/src/tests/tensor_core/max/max_i32_test.cairo +++ b/src/tests/tensor_core/max/max_i32_test.cairo @@ -2,7 +2,7 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; + use orion::operators::tensor::I32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::i32::i32_tensor_1x3_helper; @@ -20,7 +20,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; + use orion::operators::tensor::I32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::i32::i32_tensor_2x2_helper; @@ -38,7 +38,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; + use orion::operators::tensor::I32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::i32::i32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/max/max_u32_test.cairo b/src/tests/tensor_core/max/max_u32_test.cairo index 292b0773e..f53e455f4 100644 --- a/src/tests/tensor_core/max/max_u32_test.cairo +++ b/src/tests/tensor_core/max/max_u32_test.cairo @@ -2,7 +2,7 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; + use orion::operators::tensor::U32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::u32::u32_tensor_1x3_helper; @@ -20,7 +20,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; + use orion::operators::tensor::U32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::u32::u32_tensor_2x2_helper; @@ -38,7 +38,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; + use orion::operators::tensor::U32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::u32::u32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/min/min_fp_test/min_fp16x16_test.cairo b/src/tests/tensor_core/min/min_fp_test/min_fp16x16_test.cairo index b89a3d4f8..9a88d635a 100644 --- a/src/tests/tensor_core/min/min_fp_test/min_fp16x16_test.cairo +++ b/src/tests/tensor_core/min/min_fp_test/min_fp16x16_test.cairo @@ -2,7 +2,7 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_1x3_helper; use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; @@ -22,7 +22,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2_helper; use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; @@ -43,7 +43,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2x2_helper; use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; diff --git a/src/tests/tensor_core/min/min_fp_test/min_fp8x23_test.cairo b/src/tests/tensor_core/min/min_fp_test/min_fp8x23_test.cairo index 9cda89e72..d4f94818c 100644 --- a/src/tests/tensor_core/min/min_fp_test/min_fp8x23_test.cairo +++ b/src/tests/tensor_core/min/min_fp_test/min_fp8x23_test.cairo @@ -2,7 +2,7 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_1x3_helper; use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; @@ -22,7 +22,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2_helper; use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; @@ -43,7 +43,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2x2_helper; use orion::numbers::fixed_point::implementations::fp8x23::core::FP8x23Impl; diff --git a/src/tests/tensor_core/min/min_i32_test.cairo b/src/tests/tensor_core/min/min_i32_test.cairo index 59cefae7c..b7b8a1825 100644 --- a/src/tests/tensor_core/min/min_i32_test.cairo +++ b/src/tests/tensor_core/min/min_i32_test.cairo @@ -2,7 +2,7 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; + use orion::operators::tensor::I32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::i32::i32_tensor_1x3_helper; @@ -20,7 +20,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; + use orion::operators::tensor::I32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::i32::i32_tensor_2x2_helper; @@ -38,7 +38,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; + use orion::operators::tensor::I32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::i32::i32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/min/min_u32_test.cairo b/src/tests/tensor_core/min/min_u32_test.cairo index e7155a943..8fe474204 100644 --- a/src/tests/tensor_core/min/min_u32_test.cairo +++ b/src/tests/tensor_core/min/min_u32_test.cairo @@ -2,7 +2,7 @@ #[cfg(test)] mod tensor_1D { - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; + use orion::operators::tensor::U32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::u32::u32_tensor_1x3_helper; @@ -20,7 +20,7 @@ mod tensor_1D { #[cfg(test)] mod tensor_2D { - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; + use orion::operators::tensor::U32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::u32::u32_tensor_2x2_helper; @@ -38,7 +38,7 @@ mod tensor_2D { #[cfg(test)] mod tensor_3D { - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; + use orion::operators::tensor::U32Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::u32::u32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/onehot.cairo b/src/tests/tensor_core/onehot.cairo index f2de1c516..c9df02f7c 100644 --- a/src/tests/tensor_core/onehot.cairo +++ b/src/tests/tensor_core/onehot.cairo @@ -1,4 +1 @@ -mod onehot_u32_test; -mod onehot_i32_test; -mod onehot_i8_test; mod onehot_fp_test; diff --git a/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp16x16_test.cairo b/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp16x16_test.cairo index f1ba53809..070143ffd 100644 --- a/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp16x16_test.cairo +++ b/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp16x16_test.cairo @@ -2,17 +2,17 @@ use core::serde::Serde; use core::option::OptionTrait; use core::clone::Clone; // ===== 1D ===== // -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; +use orion::numbers::fixed_point::core::FixedTrait; #[cfg(test)] mod tensor_1D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; + use orion::numbers::fixed_point::core::{FixedTrait}; use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16PartialEq + FP16x16, FP16x16PartialEq }; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; use orion::tests::helpers::tensor::fixed_point::fp16x16::{ fp_tensor_1x3_helper, fp_tensor_2x2_helper, fp_tensor_3x2x2_neg_helper, fp_tensor_1x3_neg_helper, fp_tensor_2x2x2_helper @@ -25,9 +25,9 @@ mod tensor_1D { // use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; // use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{Tensor, ExtraParams}; + use orion::operators::tensor::core::{Tensor}; - fn fp_tensor_3x2x2_new() -> Tensor { + fn fp_tensor_3x2x2_new() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -47,14 +47,14 @@ mod tensor_1D { data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(3, false)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } - fn fp_tensor_2x2_pos_neg_new() -> Tensor { + fn fp_tensor_2x2_pos_neg_new() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -65,9 +65,9 @@ mod tensor_1D { data.append(FixedTrait::new_unscaled(2, true)); data.append(FixedTrait::new_unscaled(1, true)); - let extra = Option::::None(()); + - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } diff --git a/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp8x23_test.cairo b/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp8x23_test.cairo index 2bd120e79..3ccd57b90 100644 --- a/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp8x23_test.cairo +++ b/src/tests/tensor_core/onehot/onehot_fp_test/onehot_fp8x23_test.cairo @@ -2,15 +2,15 @@ use core::serde::Serde; use core::option::OptionTrait; use core::clone::Clone; // ===== 1D ===== // -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; +use orion::numbers::fixed_point::core::FixedTrait; #[cfg(test)] mod tensor_1D { use array::{ArrayTrait, SpanTrait}; use core::traits::Into; - use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; - use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, FP8x23PartialEq}; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; + use orion::numbers::fixed_point::core::{FixedTrait}; + use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23, FP8x23PartialEq}; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; use orion::operators::tensor::core::TensorTrait; use orion::tests::helpers::tensor::fixed_point::fp8x23::{ fp_tensor_1x3_helper, fp_tensor_2x2_helper, fp_tensor_3x2x2_neg_helper, @@ -21,9 +21,9 @@ mod tensor_1D { use core::option::OptionTrait; use serde::Serde; - use orion::operators::tensor::core::{Tensor, ExtraParams}; + use orion::operators::tensor::core::{Tensor}; - fn fp_tensor_3x2x2_new() -> Tensor { + fn fp_tensor_3x2x2_new() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(3); sizes.append(2); @@ -43,13 +43,13 @@ mod tensor_1D { data.append(FixedTrait::new_unscaled(2, false)); data.append(FixedTrait::new_unscaled(3, false)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } - fn fp_tensor_2x2_pos_neg_new() -> Tensor { + fn fp_tensor_2x2_pos_neg_new() -> Tensor { let mut sizes = ArrayTrait::new(); sizes.append(2); sizes.append(2); @@ -60,8 +60,8 @@ mod tensor_1D { data.append(FixedTrait::new_unscaled(2, true)); data.append(FixedTrait::new_unscaled(1, true)); - let extra = ExtraParams { fixed_point: Option::Some(FixedImpl::FP8x23(())) }; - let tensor = TensorTrait::::new(sizes.span(), data.span(), Option::Some(extra)); + + let tensor = TensorTrait::::new(sizes.span(), data.span()); return tensor; } diff --git a/src/tests/tensor_core/onehot/onehot_i32_test.cairo b/src/tests/tensor_core/onehot/onehot_i32_test.cairo deleted file mode 100644 index 6974012de..000000000 --- a/src/tests/tensor_core/onehot/onehot_i32_test.cairo +++ /dev/null @@ -1,500 +0,0 @@ -use core::serde::Serde; -use core::option::OptionTrait; -use core::clone::Clone; -// ===== 1D ===== // - -#[cfg(test)] -mod tensor_1D { - use array::{ArrayTrait, SpanTrait}; - use core::traits::Into; - use orion::numbers::fixed_point::core::{FixedTrait, FixedImpl}; - use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16PartialEq - }; - use debug::PrintTrait; - use core::clone::Clone; - use core::option::OptionTrait; - use serde::Serde; - use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, Tensor, ExtraParams}; - - use orion::tests::helpers::tensor::i32::{ - i32_tensor_1x3_helper, i32_tensor_1x3_neg_helper, i32_tensor_2x2_helper, - i32_tensor_3x2x2_helper - }; - - - fn i32_tensor_3x2x2_new() -> Tensor { - let mut sizes = ArrayTrait::new(); - sizes.append(3); - sizes.append(2); - sizes.append(2); - - let mut data = ArrayTrait::new(); - 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: 3, 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: 3, 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: 3, sign: false }); - - let extra = Option::::None(()); - - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); - - return tensor; - } - - fn i32_tensor_2x2_pos_neg_new() -> Tensor { - let mut sizes = ArrayTrait::new(); - sizes.append(2); - sizes.append(2); - - let mut data = ArrayTrait::new(); - 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: 1, sign: true }); - - let extra = Option::::None(()); - - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); - - return tensor; - } - - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_last_axis() { - let tensor = i32_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 1, 'result[4] = 1'); - assert((*result.data.at(5)).into() == 0, 'result[5] = 0'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 0, 'result[7] = 0'); - assert((*result.data.at(8)).into() == 1, 'result[8] = 1'); - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_neg_last_axis() { - let tensor = i32_tensor_1x3_neg_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 0, 'result[4] = 0'); - assert((*result.data.at(5)).into() == 1, 'result[5] = 1'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 1, 'result[7] = 1'); - assert((*result.data.at(8)).into() == 0, 'result[8] = 0'); - } - - #[test] - #[should_panic] - #[available_gas(20000000)] - fn tensor_onehot_tensor_1x3_fail() { - let tensor = i32_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::Some(3); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_Zero_axis() { - let tensor = i32_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::Some(0); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 1, 'result[4] = 1'); - assert((*result.data.at(5)).into() == 0, 'result[5] = 0'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 0, 'result[7] = 0'); - assert((*result.data.at(8)).into() == 1, 'result[8] = 1'); - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_2x2_post_neg_last_axis() { - let tensor = i32_tensor_2x2_pos_neg_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 1, 'result[4] = 1'); - assert((*result.data.at(5)).into() == 0, 'result[5] = 0'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 1, 'result[7] = 1'); - assert((*result.data.at(8)).into() == 0, 'result[8] = 0'); - assert((*result.data.at(9)).into() == 0, 'result[9] = 0'); - assert((*result.data.at(10)).into() == 0, 'result[10] = 0'); - assert((*result.data.at(11)).into() == 1, 'result[11] = 1'); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_2x2_helper_last_axis() { - let tensor = i32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 0, 'result[4] = 0'); - assert((*result.data.at(5)).into() == 1, 'result[5] = 1'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 0, 'result[7] = 0'); - assert((*result.data.at(8)).into() == 0, 'result[8] = 0'); - assert((*result.data.at(9)).into() == 0, 'result[9] = 0'); - assert((*result.data.at(10)).into() == 1, 'result[10] = 1'); - assert((*result.data.at(11)).into() == 0, 'result[11] = 0'); - assert((*result.data.at(12)).into() == 0, 'result[12] = 0'); - assert((*result.data.at(13)).into() == 0, 'result[13] = 0'); - assert((*result.data.at(14)).into() == 0, 'result[14] = 0'); - assert((*result.data.at(15)).into() == 1, 'result[15] = 1'); - - assert((*result.shape.at(0)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(1)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(2)) == 4, 'shape[0] = 4'); - } - - #[test] - #[should_panic] - #[available_gas(20000000)] - fn tensor_onehot_tensor_2x2_fail() { - let tensor = i32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(3); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_2x2_helper_first_axis() { - let tensor = i32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(0); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 0, 'result[4] = 0'); - assert((*result.data.at(5)).into() == 1, 'result[5] = 1'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 0, 'result[7] = 0'); - assert((*result.data.at(8)).into() == 0, 'result[8] = 0'); - assert((*result.data.at(9)).into() == 0, 'result[9] = 0'); - assert((*result.data.at(10)).into() == 1, 'result[10] = 1'); - assert((*result.data.at(11)).into() == 0, 'result[11] = 0'); - assert((*result.data.at(12)).into() == 0, 'result[12] = 0'); - assert((*result.data.at(13)).into() == 0, 'result[13] = 0'); - assert((*result.data.at(14)).into() == 0, 'result[14] = 0'); - assert((*result.data.at(15)).into() == 1, 'result[15] = 1'); - - assert((*result.shape.at(0)) == 4, 'shape[0] = 4'); - assert((*result.shape.at(1)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(2)) == 2, 'shape[0] = 2'); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_2x2_helper_second_axis() { - let tensor = i32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(1); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 1, 'result[3] = 1'); - assert((*result.data.at(4)).into() == 0, 'result[4] = 0'); - assert((*result.data.at(5)).into() == 0, 'result[5] = 0'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 0, 'result[7] = 0'); - assert((*result.data.at(8)).into() == 0, 'result[8] = 0'); - assert((*result.data.at(9)).into() == 0, 'result[9] = 0'); - assert((*result.data.at(10)).into() == 0, 'result[10] = 0'); - assert((*result.data.at(11)).into() == 0, 'result[11] = 0'); - assert((*result.data.at(12)).into() == 1, 'result[12] = 0'); - assert((*result.data.at(13)).into() == 0, 'result[13] = 0'); - assert((*result.data.at(14)).into() == 0, 'result[14] = 0'); - assert((*result.data.at(15)).into() == 1, 'result[15] = 1'); - - assert((*result.shape.at(0)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(1)) == 4, 'shape[0] = 4'); - assert((*result.shape.at(2)) == 2, 'shape[0] = 2'); - } - - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_last_axis() { - let tensor = i32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 0, 'result[4] = 0'); - assert((*result.data.at(5)).into() == 1, 'result[5] = 1'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 0, 'result[7] = 0'); - assert((*result.data.at(8)).into() == 0, 'result[8] = 0'); - assert((*result.data.at(9)).into() == 0, 'result[9] = 0'); - assert((*result.data.at(10)).into() == 1, 'result[10] = 1'); - assert((*result.data.at(11)).into() == 0, 'result[11] = 0'); - assert((*result.data.at(12)).into() == 0, 'result[12] = 0'); - assert((*result.data.at(13)).into() == 0, 'result[13] = 0'); - assert((*result.data.at(14)).into() == 0, 'result[14] = 0'); - assert((*result.data.at(15)).into() == 1, 'result[15] = 1'); - assert((*result.data.at(16)).into() == 1, 'result[16] = 1'); - assert((*result.data.at(21)).into() == 1, 'result[21] = 1'); - assert((*result.data.at(26)).into() == 1, 'result[26] = 1'); - assert((*result.data.at(31)).into() == 1, 'result[31] = 1'); - assert((*result.data.at(32)).into() == 1, 'result[32] = 1'); - assert((*result.data.at(37)).into() == 1, 'result[37] = 1'); - assert((*result.data.at(42)).into() == 1, 'result[42] = 1'); - assert((*result.data.at(46)).into() == 0, 'result[46] = 0'); - assert((*result.data.at(47)).into() == 1, 'result[47] = 1'); - - assert((*result.shape.at(0)) == 3, 'shape[0] = 3'); - assert((*result.shape.at(1)) == 2, 'shape[1] = 2'); - assert((*result.shape.at(2)) == 2, 'shape[2] = 2'); - assert((*result.shape.at(3)) == 4, 'shape[0] = 4'); - } - - #[test] - #[should_panic] - #[available_gas(20000000)] - fn tensor_onehot_tensor_3x2x2_fail() { - let tensor = i32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(4); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_first_axis() { - let tensor = i32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(2); - values.append(5); - let depth = 4; - let axis: Option = Option::Some(0); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 5, 'result[0] = 5'); - assert((*result.data.at(1)).into() == 2, 'result[1] = 2'); - assert((*result.data.at(2)).into() == 2, 'result[2] = 2'); - assert((*result.data.at(3)).into() == 2, 'result[3] = 2'); - assert((*result.data.at(4)).into() == 5, 'result[4] = 5'); - assert((*result.data.at(5)).into() == 2, 'result[5] = 2'); - assert((*result.data.at(6)).into() == 2, 'result[6] = 2'); - assert((*result.data.at(7)).into() == 2, 'result[7] = 2'); - assert((*result.data.at(8)).into() == 5, 'result[8] = 5'); - assert((*result.data.at(9)).into() == 2, 'result[9] = 2'); - assert((*result.data.at(10)).into() == 2, 'result[10] = 2'); - assert((*result.data.at(11)).into() == 2, 'result[11] = 2'); - assert((*result.data.at(12)).into() == 2, 'result[12] = 2'); - assert((*result.data.at(13)).into() == 5, 'result[13] = 5'); - assert((*result.data.at(14)).into() == 2, 'result[14] = 2'); - assert((*result.data.at(17)).into() == 5, 'result[17] = 5'); - assert((*result.data.at(21)).into() == 5, 'result[21] = 5'); - assert((*result.data.at(26)).into() == 5, 'result[26] = 5'); - assert((*result.data.at(30)).into() == 5, 'result[30] = 5'); - assert((*result.data.at(34)).into() == 5, 'result[34] = 5'); - assert((*result.data.at(39)).into() == 5, 'result[39] = 5'); - assert((*result.data.at(43)).into() == 5, 'result[43] = 5'); - assert((*result.data.at(46)).into() == 2, 'result[46] = 2'); - assert((*result.data.at(47)).into() == 5, 'result[47] = 5'); - - assert((*result.shape.at(0)) == 4, 'shape[0] = 4'); - assert((*result.shape.at(1)) == 3, 'shape[1] = 3'); - assert((*result.shape.at(2)) == 2, 'shape[2] = 3'); - assert((*result.shape.at(3)) == 2, 'shape[0] = 2'); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_second_axis() { - let tensor = i32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(1); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 0, 'result[3] = 0'); - assert((*result.data.at(4)).into() == 0, 'result[4] = 0'); - assert((*result.data.at(5)).into() == 1, 'result[5] = 1'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(7)).into() == 0, 'result[7] = 0'); - assert((*result.data.at(8)).into() == 0, 'result[8] = 0'); - assert((*result.data.at(9)).into() == 0, 'result[9] = 0'); - assert((*result.data.at(10)).into() == 1, 'result[10] = 1'); - assert((*result.data.at(11)).into() == 0, 'result[11] = 0'); - assert((*result.data.at(12)).into() == 0, 'result[12] = 0'); - assert((*result.data.at(13)).into() == 0, 'result[13] = 0'); - assert((*result.data.at(14)).into() == 0, 'result[14] = 0'); - assert((*result.data.at(15)).into() == 1, 'result[15] = 1'); - assert((*result.data.at(16)).into() == 1, 'result[16] = 1'); - assert((*result.data.at(21)).into() == 1, 'result[21] = 1'); - assert((*result.data.at(26)).into() == 1, 'result[26] = 1'); - assert((*result.data.at(31)).into() == 1, 'result[31] = 1'); - assert((*result.data.at(32)).into() == 1, 'result[32] = 1'); - assert((*result.data.at(37)).into() == 1, 'result[37] = 1'); - assert((*result.data.at(42)).into() == 1, 'result[42] = 1'); - assert((*result.data.at(46)).into() == 0, 'result[46] = 0'); - assert((*result.data.at(47)).into() == 1, 'result[47] = 1'); - - assert((*result.shape.at(0)) == 3, 'shape[0] = 3'); - assert((*result.shape.at(1)) == 4, 'shape[1] = 4'); - assert((*result.shape.at(2)) == 2, 'shape[2] = 3'); - assert((*result.shape.at(3)) == 2, 'shape[0] = 2'); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_third_axis() { - let tensor = i32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(2); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)).into() == 1, 'result[0] = 1'); - assert((*result.data.at(1)).into() == 0, 'result[1] = 0'); - assert((*result.data.at(2)).into() == 0, 'result[2] = 0'); - assert((*result.data.at(3)).into() == 1, 'result[3] = 1'); - assert((*result.data.at(4)).into() == 0, 'result[4] = 0'); - assert((*result.data.at(5)).into() == 0, 'result[5] = 0'); - assert((*result.data.at(6)).into() == 0, 'result[6] = 0'); - assert((*result.data.at(12)).into() == 1, 'result[12] = 1'); - assert((*result.data.at(13)).into() == 0, 'result[13] = 0'); - assert((*result.data.at(14)).into() == 0, 'result[14] = 0'); - assert((*result.data.at(15)).into() == 1, 'result[15] = 1'); - assert((*result.data.at(16)).into() == 1, 'result[16] = 1'); - assert((*result.data.at(19)).into() == 1, 'result[19] = 1'); - assert((*result.data.at(21)).into() == 0, 'result[21] = 0'); - assert((*result.data.at(26)).into() == 0, 'result[26] = 0'); - assert((*result.data.at(28)).into() == 1, 'result[28] = 1'); - assert((*result.data.at(31)).into() == 1, 'result[31] = 1'); - assert((*result.data.at(32)).into() == 1, 'result[32] = 1'); - assert((*result.data.at(35)).into() == 1, 'result[35] = 1'); - assert((*result.data.at(37)).into() == 0, 'result[37] = 0'); - assert((*result.data.at(44)).into() == 1, 'result[44] = 1'); - assert((*result.data.at(46)).into() == 0, 'result[46] = 0'); - assert((*result.data.at(47)).into() == 1, 'result[47] = 1'); - - assert((*result.shape.at(0)) == 3, 'shape[0] = 3'); - assert((*result.shape.at(1)) == 2, 'shape[1] = 2'); - assert((*result.shape.at(2)) == 4, 'shape[2] = 4'); - assert((*result.shape.at(3)) == 2, 'shape[0] = 2'); - } -} diff --git a/src/tests/tensor_core/onehot/onehot_i8_test.cairo b/src/tests/tensor_core/onehot/onehot_i8_test.cairo deleted file mode 100644 index 1a2094343..000000000 --- a/src/tests/tensor_core/onehot/onehot_i8_test.cairo +++ /dev/null @@ -1,148 +0,0 @@ -use core::serde::Serde; -use core::option::OptionTrait; -use core::clone::Clone; -// ===== 1D ===== // -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; - -#[cfg(test)] -mod tensor_1D { - use array::{ArrayTrait, SpanTrait}; - use core::traits::Into; - use orion::numbers::fixed_point::core::{FixedTrait, FixedType, FixedImpl}; - use orion::numbers::fixed_point::implementations::fp16x16::core::{ - FP16x16Impl, FP16x16PartialEq - }; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::tests::helpers::tensor::fixed_point::fp16x16::{ - fp_tensor_1x3_helper, fp_tensor_2x2_helper, fp_tensor_3x2x2_neg_helper, - fp_tensor_1x3_neg_helper, fp_tensor_2x2x2_helper - }; - use orion::operators::tensor::core::TensorTrait; - use debug::PrintTrait; - use core::clone::Clone; - use core::option::OptionTrait; - use serde::Serde; - - - use orion::operators::tensor::implementations::impl_tensor_i8::Tensor_i8; - - // use orion::numbers::fixed_point::implementations::fp16x16::core::FP16x16Impl; - // use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{Tensor, ExtraParams}; - - - use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i8::i8}; - - - // 1D - fn i8_tensor_1x3_helper() -> Tensor { - let mut sizes = ArrayTrait::new(); - sizes.append(3); - let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: false }); - data.append(i8 { mag: 2, sign: false }); - let extra = Option::::None(()); - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); - return tensor; - } - - fn i8_tensor_1x3_neg_helper() -> Tensor { - let mut sizes = ArrayTrait::new(); - sizes.append(3); - let mut data = ArrayTrait::new(); - data.append(i8 { mag: 0, sign: false }); - data.append(i8 { mag: 1, sign: true }); - data.append(i8 { mag: 2, sign: true }); - let extra = Option::::None(()); - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); - return tensor; - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_last_axis() { - let tensor = i8_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)) == IntegerTrait::new(1, false), 'result[0] = 1'); - assert((*result.data.at(1)) == IntegerTrait::new(0, false), 'result[1] = 0'); - assert((*result.data.at(2)) == IntegerTrait::new(0, false), 'result[2] = 0'); - assert((*result.data.at(3)) == IntegerTrait::new(0, false), 'result[3] = 0'); - assert((*result.data.at(4)) == IntegerTrait::new(1, false), 'result[4] = 1'); - assert((*result.data.at(5)) == IntegerTrait::new(0, false), 'result[5] = 0'); - assert((*result.data.at(6)) == IntegerTrait::new(0, false), 'result[6] = 0'); - assert((*result.data.at(7)) == IntegerTrait::new(0, false), 'result[7] = 0'); - assert((*result.data.at(8)) == IntegerTrait::new(1, false), 'result[8] = 1'); - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_neg_last_axis() { - let tensor = i8_tensor_1x3_neg_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)) == IntegerTrait::new(1, false), 'result[0] = 1'); - assert((*result.data.at(1)) == IntegerTrait::new(0, false), 'result[1] = 0'); - assert((*result.data.at(2)) == IntegerTrait::new(0, false), 'result[2] = 0'); - assert((*result.data.at(3)) == IntegerTrait::new(0, false), 'result[3] = 0'); - assert((*result.data.at(4)) == IntegerTrait::new(0, false), 'result[4] = 0'); - assert((*result.data.at(5)) == IntegerTrait::new(1, false), 'result[5] = 1'); - assert((*result.data.at(6)) == IntegerTrait::new(0, false), 'result[6] = 0'); - assert((*result.data.at(7)) == IntegerTrait::new(1, false), 'result[7] = 1'); - assert((*result.data.at(8)) == IntegerTrait::new(0, false), 'result[8] = 0'); - } - - #[test] - #[should_panic] - #[available_gas(20000000)] - fn tensor_onehot_tensor_1x3_fail() { - let tensor = i8_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::Some(3); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_Zero_axis() { - let tensor = i8_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::Some(0); - - let result = tensor.onehot(depth: depth, axis: axis, values: values.span()); - - assert((*result.data.at(0)) == IntegerTrait::new(1, false), 'result[0] = 1'); - assert((*result.data.at(1)) == IntegerTrait::new(0, false), 'result[1] = 0'); - assert((*result.data.at(2)) == IntegerTrait::new(0, false), 'result[2] = 0'); - assert((*result.data.at(3)) == IntegerTrait::new(0, false), 'result[3] = 0'); - assert((*result.data.at(4)) == IntegerTrait::new(1, false), 'result[4] = 1'); - assert((*result.data.at(5)) == IntegerTrait::new(0, false), 'result[5] = 0'); - assert((*result.data.at(6)) == IntegerTrait::new(0, false), 'result[6] = 0'); - assert((*result.data.at(7)) == IntegerTrait::new(0, false), 'result[7] = 0'); - assert((*result.data.at(8)) == IntegerTrait::new(1, false), 'result[8] = 1'); - } -} diff --git a/src/tests/tensor_core/onehot/onehot_u32_test.cairo b/src/tests/tensor_core/onehot/onehot_u32_test.cairo deleted file mode 100644 index c64945633..000000000 --- a/src/tests/tensor_core/onehot/onehot_u32_test.cairo +++ /dev/null @@ -1,451 +0,0 @@ -use core::serde::Serde; -use core::option::OptionTrait; -use core::clone::Clone; -// ===== 1D ===== // -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; - -#[cfg(test)] -mod tensor_1D { - use array::{ArrayTrait, SpanTrait}; - use core::traits::Into; - - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams, Tensor}; - use orion::tests::helpers::tensor::u32::{u32_tensor_1x3_helper, u32_tensor_2x2_helper}; - - - fn u32_tensor_3x2x2_new() -> Tensor { - let mut sizes = ArrayTrait::new(); - sizes.append(3); - sizes.append(2); - sizes.append(2); - - let mut data = ArrayTrait::new(); - data.append(0); - data.append(1); - data.append(2); - data.append(3); - data.append(0); - data.append(1); - data.append(2); - data.append(3); - data.append(0); - data.append(1); - data.append(2); - data.append(3); - - let extra = Option::::None(()); - - let tensor = TensorTrait::::new(sizes.span(), data.span(), extra); - - return tensor; -} - - - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_last_axis() { - let tensor = u32_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 0, 'result[3] = 0'); - assert((*result.data[4]) == 1, 'result[4] = 1'); - assert((*result.data[5]) == 0, 'result[5] = 0'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 1, 'result[8] = 1'); - } - - #[test] - - - #[test] - #[should_panic] - #[available_gas(20000000)] - fn tensor_onehot_tensor_1x3_fail() { - let tensor = u32_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::Some(3); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_Zero_axis() { - let tensor = u32_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::Some(0); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 0, 'result[3] = 0'); - assert((*result.data[4]) == 1, 'result[4] = 1'); - assert((*result.data[5]) == 0, 'result[5] = 0'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 1, 'result[8] = 1'); - } - - #[test] - #[available_gas(20000000)] - fn tensor_onehot_1x3_axis_one() { - let tensor = u32_tensor_1x3_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 3; - let axis: Option = Option::Some(1); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 0, 'result[3] = 0'); - assert((*result.data[4]) == 1, 'result[4] = 1'); - assert((*result.data[5]) == 0, 'result[5] = 0'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 1, 'result[8] = 1'); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_2x2_helper_last_axis() { - let tensor = u32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::None(()); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 0, 'result[3] = 0'); - assert((*result.data[4]) == 0, 'result[4] = 0'); - assert((*result.data[5]) == 1, 'result[5] = 1'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 0, 'result[8] = 0'); - assert((*result.data[9]) == 0, 'result[9] = 0'); - assert((*result.data[10]) == 1, 'result[10] = 1'); - assert((*result.data[11]) == 0, 'result[11] = 0'); - assert((*result.data[12]) == 0, 'result[12] = 0'); - assert((*result.data[13]) == 0, 'result[13] = 0'); - assert((*result.data[14]) == 0, 'result[14] = 0'); - assert((*result.data[15]) == 1, 'result[15] = 1'); - - assert((*result.shape.at(0)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(1)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(2)) == 4, 'shape[0] = 4'); - - } - - #[test] - #[should_panic] - #[available_gas(20000000)] - fn tensor_onehot_tensor_2x2_fail() { - let tensor = u32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(3); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_2x2_helper_first_axis() { - let tensor = u32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(0); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 0, 'result[3] = 0'); - assert((*result.data[4]) == 0, 'result[4] = 0'); - assert((*result.data[5]) == 1, 'result[5] = 1'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 0, 'result[8] = 0'); - assert((*result.data[9]) == 0, 'result[9] = 0'); - assert((*result.data[10]) == 1, 'result[10] = 1'); - assert((*result.data[11]) == 0, 'result[11] = 0'); - assert((*result.data[12]) == 0, 'result[12] = 0'); - assert((*result.data[13]) == 0, 'result[13] = 0'); - assert((*result.data[14]) == 0, 'result[14] = 0'); - assert((*result.data[15]) == 1, 'result[15] = 1'); - - assert((*result.shape.at(0)) == 4, 'shape[0] = 4'); - assert((*result.shape.at(1)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(2)) == 2, 'shape[0] = 2'); - - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_2x2_helper_second_axis() { - let tensor = u32_tensor_2x2_helper(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(1); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 1, 'result[3] = 1'); - assert((*result.data[4]) == 0, 'result[4] = 0'); - assert((*result.data[5]) == 0, 'result[5] = 0'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 0, 'result[8] = 0'); - assert((*result.data[9]) == 0, 'result[9] = 0'); - assert((*result.data[10]) == 0, 'result[10] = 1'); - assert((*result.data[11]) == 0, 'result[11] = 0'); - assert((*result.data[12]) == 1, 'result[12] = 1'); - assert((*result.data[13]) == 0, 'result[13] = 0'); - assert((*result.data[14]) == 0, 'result[14] = 0'); - assert((*result.data[15]) == 1, 'result[15] = 1'); - - assert((*result.shape.at(0)) == 2, 'shape[0] = 2'); - assert((*result.shape.at(1)) == 4, 'shape[0] = 4'); - assert((*result.shape.at(2)) == 2, 'shape[0] = 2'); - - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_last_axis() { - let tensor = u32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::None(()); - // let axis: Option = Option::Some(3); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 0, 'result[3] = 0'); - assert((*result.data[4]) == 0, 'result[4] = 0'); - assert((*result.data[5]) == 1, 'result[5] = 1'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 0, 'result[8] = 0'); - assert((*result.data[9]) == 0, 'result[9] = 0'); - assert((*result.data[10]) == 1, 'result[10] = 1'); - assert((*result.data[11]) == 0, 'result[11] = 0'); - assert((*result.data[12]) == 0, 'result[12] = 0'); - assert((*result.data[13]) == 0, 'result[13] = 0'); - assert((*result.data[14]) == 0, 'result[14] = 0'); - assert((*result.data[15]) == 1, 'result[15] = 1'); - assert((*result.data[16]) == 1, 'result[16] = 1'); - assert((*result.data[21]) == 1, 'result[21] = 1'); - assert((*result.data[26]) == 1, 'result[26] = 1'); - assert((*result.data[31]) == 1, 'result[31] = 1'); - assert((*result.data[32]) == 1, 'result[32] = 1'); - assert((*result.data[37]) == 1, 'result[37] = 1'); - assert((*result.data[42]) == 1, 'result[42] = 1'); - assert((*result.data[46]) == 0, 'result[46] = 0'); - assert((*result.data[47]) == 1, 'result[47] = 1'); - - assert((*result.shape.at(0)) == 3, 'shape[0] = 3'); - assert((*result.shape.at(1)) == 2, 'shape[1] = 2'); - assert((*result.shape.at(2)) == 2, 'shape[2] = 2'); - assert((*result.shape.at(3)) == 4, 'shape[0] = 4'); - } - - #[test] - #[should_panic] - #[available_gas(20000000)] - fn tensor_onehot_tensor_3x2x2_fail() { - let tensor = u32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(4); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_first_axis() { - let tensor = u32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(2); - values.append(5); - let depth = 4; - let axis: Option = Option::Some(0); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 5, 'result[0] = 5'); - assert((*result.data[1]) == 2, 'result[1] = 2'); - assert((*result.data[2]) == 2, 'result[2] = 2'); - assert((*result.data[3]) == 2, 'result[3] = 2'); - assert((*result.data[4]) == 5, 'result[4] = 5'); - assert((*result.data[5]) == 2, 'result[5] = 2'); - assert((*result.data[6]) == 2, 'result[6] = 2'); - assert((*result.data[7]) == 2, 'result[7] = 2'); - assert((*result.data[8]) == 5, 'result[8] = 5'); - assert((*result.data[9]) == 2, 'result[9] = 2'); - assert((*result.data[10]) == 2, 'result[10] = 2'); - assert((*result.data[11]) == 2, 'result[11] = 2'); - assert((*result.data[12]) == 2, 'result[12] = 2'); - assert((*result.data[13]) == 5, 'result[13] = 5'); - assert((*result.data[14]) == 2, 'result[14] = 2'); - assert((*result.data[17]) == 5, 'result[17] = 5'); - assert((*result.data[21]) == 5, 'result[21] = 5'); - assert((*result.data[26]) == 5, 'result[26] = 5'); - assert((*result.data[30]) == 5, 'result[30] = 5'); - assert((*result.data[34]) == 5, 'result[34] = 5'); - assert((*result.data[39]) == 5, 'result[39] = 5'); - assert((*result.data[43]) == 5, 'result[43] = 5'); - assert((*result.data[46]) == 2, 'result[46] = 2'); - assert((*result.data[47]) == 5, 'result[47] = 5'); - - assert((*result.shape.at(0)) == 4, 'shape[0] = 4'); - assert((*result.shape.at(1)) == 3, 'shape[1] = 3'); - assert((*result.shape.at(2)) == 2, 'shape[2] = 3'); - assert((*result.shape.at(3)) == 2, 'shape[0] = 2'); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_second_axis() { - let tensor = u32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(1); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 0, 'result[3] = 0'); - assert((*result.data[4]) == 0, 'result[4] = 0'); - assert((*result.data[5]) == 1, 'result[5] = 1'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[7]) == 0, 'result[7] = 0'); - assert((*result.data[8]) == 0, 'result[8] = 0'); - assert((*result.data[9]) == 0, 'result[9] = 0'); - assert((*result.data[10]) == 1, 'result[10] = 1'); - assert((*result.data[11]) == 0, 'result[11] = 0'); - assert((*result.data[12]) == 0, 'result[12] = 0'); - assert((*result.data[13]) == 0, 'result[13] = 0'); - assert((*result.data[14]) == 0, 'result[14] = 0'); - assert((*result.data[15]) == 1, 'result[15] = 1'); - assert((*result.data[16]) == 1, 'result[16] = 1'); - assert((*result.data[21]) == 1, 'result[21] = 1'); - assert((*result.data[26]) == 1, 'result[26] = 1'); - assert((*result.data[31]) == 1, 'result[31] = 1'); - assert((*result.data[32]) == 1, 'result[32] = 1'); - assert((*result.data[37]) == 1, 'result[37] = 1'); - assert((*result.data[42]) == 1, 'result[42] = 1'); - assert((*result.data[46]) == 0, 'result[46] = 0'); - assert((*result.data[47]) == 1, 'result[47] = 1'); - - assert((*result.shape.at(0)) == 3, 'shape[0] = 3'); - assert((*result.shape.at(1)) == 4, 'shape[1] = 4'); - assert((*result.shape.at(2)) == 2, 'shape[2] = 3'); - assert((*result.shape.at(3)) == 2, 'shape[0] = 2'); - } - - #[test] - #[available_gas(20000000)] - fn fp_tensor_onehot_3x2x2_new_third_axis() { - let tensor = u32_tensor_3x2x2_new(); - - let mut values = ArrayTrait::new(); - values.append(0); - values.append(1); - let depth = 4; - let axis: Option = Option::Some(2); - - let result = tensor.onehot(depth:depth, axis:axis, values:values.span()); - - assert((*result.data[0]) == 1, 'result[0] = 1'); - assert((*result.data[1]) == 0, 'result[1] = 0'); - assert((*result.data[2]) == 0, 'result[2] = 0'); - assert((*result.data[3]) == 1, 'result[3] = 1'); - assert((*result.data[4]) == 0, 'result[4] = 0'); - assert((*result.data[5]) == 0, 'result[5] = 0'); - assert((*result.data[6]) == 0, 'result[6] = 0'); - assert((*result.data[12]) == 1, 'result[12] = 1'); - assert((*result.data[13]) == 0, 'result[13] = 0'); - assert((*result.data[14]) == 0, 'result[14] = 0'); - assert((*result.data[15]) == 1, 'result[15] = 1'); - assert((*result.data[16]) == 1, 'result[16] = 1'); - assert((*result.data[19]) == 1, 'result[19] = 1'); - assert((*result.data[21]) == 0, 'result[21] = 0'); - assert((*result.data[26]) == 0, 'result[26] = 0'); - assert((*result.data[28]) == 1, 'result[28] = 1'); - assert((*result.data[31]) == 1, 'result[31] = 1'); - assert((*result.data[32]) == 1, 'result[32] = 1'); - assert((*result.data[35]) == 1, 'result[35] = 1'); - assert((*result.data[37]) == 0, 'result[37] = 0'); - assert((*result.data[44]) == 1, 'result[44] = 1'); - assert((*result.data[46]) == 0, 'result[46] = 0'); - assert((*result.data[47]) == 1, 'result[47] = 1'); - - assert((*result.shape.at(0)) == 3, 'shape[0] = 3'); - assert((*result.shape.at(1)) == 2, 'shape[1] = 2'); - assert((*result.shape.at(2)) == 4, 'shape[2] = 4'); - assert((*result.shape.at(3)) == 2, 'shape[0] = 2'); - } -} \ No newline at end of file diff --git a/src/tests/tensor_core/stride/stride_fp_test/stride_fp16x16_test.cairo b/src/tests/tensor_core/stride/stride_fp_test/stride_fp16x16_test.cairo index e66691132..bc6883d98 100644 --- a/src/tests/tensor_core/stride/stride_fp_test/stride_fp16x16_test.cairo +++ b/src/tests/tensor_core/stride/stride_fp_test/stride_fp16x16_test.cairo @@ -5,8 +5,8 @@ mod tensor_1D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_1x3_helper; @@ -27,8 +27,8 @@ mod tensor_2D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2_helper; @@ -50,8 +50,8 @@ mod tensor_3D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp16x16::FP16x16Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp16x16::fp_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/stride/stride_fp_test/stride_fp8x23_test.cairo b/src/tests/tensor_core/stride/stride_fp_test/stride_fp8x23_test.cairo index ad3a1fe44..627644122 100644 --- a/src/tests/tensor_core/stride/stride_fp_test/stride_fp8x23_test.cairo +++ b/src/tests/tensor_core/stride/stride_fp_test/stride_fp8x23_test.cairo @@ -5,8 +5,8 @@ mod tensor_1D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_1x3_helper; @@ -27,8 +27,8 @@ mod tensor_2D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2_helper; @@ -50,8 +50,8 @@ mod tensor_3D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_fp::Tensor_fp; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::implementations::tensor_fp8x23::FP8x23Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::fixed_point::fp8x23::fp_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/stride/stride_i32_test.cairo b/src/tests/tensor_core/stride/stride_i32_test.cairo index 62c923ebd..280dad79e 100644 --- a/src/tests/tensor_core/stride/stride_i32_test.cairo +++ b/src/tests/tensor_core/stride/stride_i32_test.cairo @@ -5,8 +5,8 @@ mod tensor_1D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_1x3_helper; @@ -27,8 +27,8 @@ mod tensor_2D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_2x2_helper; @@ -50,8 +50,8 @@ mod tensor_3D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_i32::Tensor_i32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::I32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::i32::i32_tensor_2x2x2_helper; diff --git a/src/tests/tensor_core/stride/stride_u32_test.cairo b/src/tests/tensor_core/stride/stride_u32_test.cairo index 7dffbc763..01a4d1ada 100644 --- a/src/tests/tensor_core/stride/stride_u32_test.cairo +++ b/src/tests/tensor_core/stride/stride_u32_test.cairo @@ -5,8 +5,8 @@ mod tensor_1D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_1x3_helper; @@ -27,8 +27,8 @@ mod tensor_2D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_2x2_helper; @@ -50,8 +50,8 @@ mod tensor_3D { use array::ArrayTrait; use array::SpanTrait; - use orion::operators::tensor::implementations::impl_tensor_u32::Tensor_u32; - use orion::operators::tensor::core::{TensorTrait, ExtraParams}; + use orion::operators::tensor::U32Tensor; + use orion::operators::tensor::core::{TensorTrait}; use orion::tests::helpers::tensor::u32::u32_tensor_2x2x2_helper; diff --git a/src/utils.cairo b/src/utils.cairo index fde3b88c5..b8062f733 100644 --- a/src/utils.cairo +++ b/src/utils.cairo @@ -3,11 +3,6 @@ use option::OptionTrait; use array::ArrayTrait; use array::SpanTrait; -use orion::numbers::signed_integer::{integer_trait::IntegerTrait, i32::i32}; -use orion::numbers::fixed_point::core::{FixedTrait, FixedType}; -use orion::numbers::fixed_point::implementations::fp8x23::core::{FP8x23Impl, ONE as ONE_8x23}; -use orion::numbers::fixed_point::implementations::fp16x16::core::{FP16x16Impl, ONE as ONE_16x16}; - fn u32_max(a: u32, b: u32) -> u32 { if a > b { a