Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in cairo1-run when printing the output of a Cairo program that initializes a struct from a function #1670

Closed
raphaelDkhn opened this issue Mar 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@raphaelDkhn
Copy link

raphaelDkhn commented Mar 18, 2024

Describe the bug

Hi, cairo1-run panics when I run cargo run programs/tensor_fp.sierra --layout all_cairo --print_output of the following Cairo program:

use orion::numbers::{FP16x16, FixedTrait};
use orion::operators::tensor::{Tensor, TensorTrait, FP16x16Tensor};

fn main() -> Tensor<FP16x16> {
     TensorTrait::new(
         array![1, 2].span(),
         array![
           FixedTrait::new(1, false), 
           FixedTrait::new(1, true)
         ].span()
    )
}
>>>
thread 'main' panicked at cairo1-run/src/cairo_run.rs:795:56:
called `Result::unwrap()` on an `Err` value: RelocatableSubDiffIndex((Relocatable { segment_index: 7, offset: 0 }, Relocatable { segment_index: 6, offset: 2 }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

However when I initialize Tensor and FP16x16 structs without the new function as follow it returns the correct output:

use orion::numbers::{FP16x16, FixedTrait};
use orion::operators::tensor::{Tensor, TensorTrait, FP16x16Tensor};

fn main() -> Tensor<FP16x16> {
    Tensor {
        data: array![
            FP16x16 { mag: 1, sign: false }, 
            FP16x16 { mag: 2, sign: true },
        ].span(),
        shape: array![1, 2].span()
    }
}
>>>
Program Output : [1 2] [1 false 2 true]

What version/commit are you on?
I get this issue when I'm using this PR #1665 (cc. @fmoletta)

Additional context
Here are the initialized function new of Tensor and FP16x16 on Orion lib.

@raphaelDkhn raphaelDkhn added the bug Something isn't working label Mar 18, 2024
@fmoletta
Copy link
Member

Hello! Thanks for reporting this! I just pushed a fix to #1665

@raphaelDkhn
Copy link
Author

Thank you @fmoletta for the follow up, it's perfectly working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants